Made minor changes in some patterns such as removed throws clause where not needed, changed incorrect order of arguments in assertEquals

This commit is contained in:
Narendra Pathai 2018-10-17 21:11:31 +05:30
parent db33cc533b
commit 2f569d670a
39 changed files with 96 additions and 146 deletions

View File

@ -32,6 +32,7 @@ import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* AbstractDocument test class
@ -81,8 +82,8 @@ public class AbstractDocumentTest {
Map<String, Object> props = new HashMap<>();
props.put(KEY, VALUE);
DocumentImplementation document = new DocumentImplementation(props);
assertNotNull(document.toString().contains(KEY));
assertNotNull(document.toString().contains(VALUE));
assertTrue(document.toString().contains(KEY));
assertTrue(document.toString().contains(VALUE));
}
}

View File

@ -45,7 +45,7 @@ import org.junit.jupiter.api.Assertions;
*/
public class ConfigureForUnixVisitorTest {
TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
private TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
@AfterEach
public void clearLoggers() {

View File

@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
public class InventoryControllerTest {
@Test
public void testGetProductInventories() throws Exception {
public void testGetProductInventories() {
InventoryController inventoryController = new InventoryController();
int numberOfInventories = inventoryController.getProductInventories();

View File

@ -37,7 +37,7 @@ public class HammerTest extends WeaponTest {
* underlying weapon implementation.
*/
@Test
public void testHammer() throws Exception {
public void testHammer() {
final Hammer hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
testBasicWeaponActions(hammer);
}

View File

@ -37,7 +37,7 @@ public class SwordTest extends WeaponTest {
* underlying weapon implementation.
*/
@Test
public void testSword() throws Exception {
public void testSword() {
final Sword sword = spy(new Sword(mock(FlyingEnchantment.class)));
testBasicWeaponActions(sword);
}

View File

@ -41,12 +41,7 @@ public class App {
*/
public static void main(String[] args) {
Task task = new SimpleTask();
Callback callback = new Callback() {
@Override
public void call() {
LOGGER.info("I'm done now.");
}
};
Callback callback = () -> LOGGER.info("I'm done now.");
task.executeWith(callback);
}
}

View File

@ -38,29 +38,6 @@ public class CallbackTest {
@Test
public void test() {
Callback callback = new Callback() {
@Override
public void call() {
callingCount++;
}
};
Task task = new SimpleTask();
assertEquals(new Integer(0), callingCount, "Initial calling count of 0");
task.executeWith(callback);
assertEquals(new Integer(1), callingCount, "Callback called once");
task.executeWith(callback);
assertEquals(new Integer(2), callingCount, "Callback called twice");
}
@Test
public void testWithLambdasExample() {
Callback callback = () -> callingCount++;
Task task = new SimpleTask();

View File

@ -43,7 +43,7 @@ public class OrcKingTest {
};
@Test
public void testMakeRequest() throws Exception {
public void testMakeRequest() {
final OrcKing king = new OrcKing();
for (final Request request : REQUESTS) {

View File

@ -26,10 +26,10 @@ package com.iluwatar.collectionpipeline;
* A Car class that has the properties of make, model, year and category.
*/
public class Car {
private String make;
private String model;
private int year;
private Category category;
private final String make;
private final String model;
private final int year;
private final Category category;
/**
* Constructor to create an instance of car.

View File

@ -71,7 +71,7 @@ public class ConverterTest {
user.getFirstName().toLowerCase() + user.getLastName().toLowerCase() + "@whatever.com"));
User u1 = new User("John", "Doe", false, "12324");
UserDto userDto = converter.convertFromEntity(u1);
assertEquals(userDto.getEmail(), "johndoe@whatever.com");
assertEquals("johndoe@whatever.com", userDto.getEmail());
}
/**
@ -83,6 +83,6 @@ public class ConverterTest {
ArrayList<User> users = Lists.newArrayList(new User("Camile", "Tough", false, "124sad"),
new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243"));
List<User> fromDtos = userConverter.createFromDtos(userConverter.createFromEntities(users));
assertEquals(fromDtos, users);
assertEquals(users, fromDtos);
}
}

View File

@ -96,7 +96,7 @@ public class IntegrationTest {
@Test
public void testGetAuthorBooks() {
List<Book> books = queryService.getAuthorBooks("username1");
assertTrue(books.size() == 2);
assertEquals(2, books.size());
assertTrue(books.contains(new Book("title1", 10)));
assertTrue(books.contains(new Book("new_title2", 30)));
}

View File

@ -88,13 +88,7 @@ public class CustomerTest {
@Test
public void testToString() {
final StringBuffer buffer = new StringBuffer();
buffer.append("Customer{id=")
.append("" + customer.getId())
.append(", firstName='")
.append(customer.getFirstName())
.append("\', lastName='")
.append(customer.getLastName() + "\'}");
assertEquals(buffer.toString(), customer.toString());
assertEquals(String.format("Customer{id=%s, firstName='%s', lastName='%s'}",
customer.getId(), customer.getFirstName(), customer.getLastName()), customer.toString());
}
}

View File

@ -257,7 +257,7 @@ public class DbCustomerDaoTest {
private void assertCustomerCountIs(int count) throws Exception {
try (Stream<Customer> allCustomers = dao.getAll()) {
assertTrue(allCustomers.count() == count);
assertEquals(count, allCustomers.count());
}
}

View File

@ -156,7 +156,7 @@ public class InMemoryCustomerDaoTest {
private void assertCustomerCountIs(int count) throws Exception {
try (Stream<Customer> allCustomers = dao.getAll()) {
assertTrue(allCustomers.count() == count);
assertEquals(count, allCustomers.count());
}
}
}

View File

@ -21,6 +21,7 @@ package com.iluwatar.datamapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* The Data Mapper (DM) is a layer of software that separates the in-memory objects from the
@ -58,12 +59,12 @@ public class DataMapperTest {
mapper.update(student);
/* Check if student is updated in db */
assertEquals(mapper.find(student.getStudentId()).get().getName(), "AdamUpdated");
assertEquals("AdamUpdated", mapper.find(student.getStudentId()).get().getName());
/* Delete student in db */
mapper.delete(student);
/* Result should be false */
assertEquals(false, mapper.find(student.getStudentId()).isPresent());
assertFalse(mapper.find(student.getStudentId()).isPresent());
}
}

View File

@ -20,7 +20,9 @@ package com.iluwatar.datamapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@ -28,28 +30,27 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
public final class StudentTest {
@Test
/**
* This API tests the equality behaviour of Student object
* Object Equality should work as per logic defined in equals method
*
* @throws Exception if any execution error during test
*/
@Test
public void testEquality() throws Exception {
/* Create some students */
final Student firstStudent = new Student(1, "Adam", 'A');
final Student secondStudent = new Student(2, "Donald", 'B');
final Student secondSameStudent = new Student(2, "Donald", 'B');
final Student firstSameStudent = firstStudent;
/* Check equals functionality: should return 'true' */
assertTrue(firstStudent.equals(firstSameStudent));
assertEquals(firstStudent, firstStudent);
/* Check equals functionality: should return 'false' */
assertFalse(firstStudent.equals(secondStudent));
assertNotEquals(firstStudent, secondStudent);
/* Check equals functionality: should return 'true' */
assertTrue(secondStudent.equals(secondSameStudent));
assertEquals(secondStudent, secondSameStudent);
}
}

View File

@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* tests {@link CustomerResource}.
@ -45,10 +46,10 @@ public class CustomerResourceTest {
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
assertEquals(allCustomers.size(), 1);
assertEquals(allCustomers.get(0).getId(), "1");
assertEquals(allCustomers.get(0).getFirstName(), "Melody");
assertEquals(allCustomers.get(0).getLastName(), "Yates");
assertEquals(1, allCustomers.size());
assertEquals("1", allCustomers.get(0).getId());
assertEquals("Melody", allCustomers.get(0).getFirstName());
assertEquals("Yates", allCustomers.get(0).getLastName());
}
@Test
@ -59,9 +60,9 @@ public class CustomerResourceTest {
customerResource.save(customer);
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
assertEquals(allCustomers.get(0).getId(), "1");
assertEquals(allCustomers.get(0).getFirstName(), "Rita");
assertEquals(allCustomers.get(0).getLastName(), "Reynolds");
assertEquals("1", allCustomers.get(0).getId());
assertEquals("Rita", allCustomers.get(0).getFirstName());
assertEquals("Reynolds", allCustomers.get(0).getLastName());
}
@Test
@ -75,7 +76,7 @@ public class CustomerResourceTest {
customerResource.delete(customer.getId());
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
assertEquals(allCustomers.size(), 0);
assertTrue(allCustomers.isEmpty());
}
}

View File

@ -40,7 +40,7 @@ import com.iluwatar.delegation.simple.printers.HpPrinter;
*/
public class App {
public static final String MESSAGE_TO_PRINT = "hello world";
private static final String MESSAGE_TO_PRINT = "hello world";
/**
* Program entry point

View File

@ -22,6 +22,7 @@
*/
package org.dirty.flag;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
@ -41,7 +42,7 @@ public class DirtyFlagTest {
public void testIsDirty() {
DataFetcher df = new DataFetcher();
List<String> countries = df.fetch();
assertTrue(!countries.isEmpty());
assertFalse(countries.isEmpty());
}
@Test

View File

@ -51,7 +51,7 @@ public class AggregatorRoute extends RouteBuilder {
* @throws Exception in case of exception during configuration
*/
@Override
public void configure() throws Exception {
public void configure() {
// Main route
from("{{entry}}").aggregate(constant(true), aggregator)
.completionSize(3).completionInterval(2000)

View File

@ -70,7 +70,7 @@ public class App {
});
context.start();
context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString()));
context.getRoutes().forEach(r -> LOGGER.info(r.toString()));
context.stop();
}
}

View File

@ -65,7 +65,7 @@ public class App {
});
ProducerTemplate template = context.createProducerTemplate();
context.start();
context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString()));
context.getRoutes().forEach(r -> LOGGER.info(r.toString()));
template.sendBody("direct:origin", "Hello from origin");
context.stop();
}

View File

@ -76,7 +76,7 @@ public class KingJoffreyTest {
private class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>();
public InMemoryAppender(Class clazz) {
public InMemoryAppender(Class<?> clazz) {
((Logger) LoggerFactory.getLogger(clazz)).addAppender(this);
start();
}

View File

@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class WeekdayTest {
@Test
public void testToString() throws Exception {
public void testToString() {
for (final Weekday weekday : Weekday.values()) {
final String toString = weekday.toString();
assertNotNull(toString);

View File

@ -16,11 +16,12 @@
*/
package com.iluwatar.event.asynchronous;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -30,26 +31,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*
*/
public class EventAsynchronousTest {
App app;
private static final Logger LOGGER = LoggerFactory.getLogger(EventAsynchronousTest.class);
@BeforeEach
public void setUp() {
app = new App();
}
@Test
public void testAsynchronousEvent() {
EventManager eventManager = new EventManager();
try {
int aEventId = eventManager.createAsync(60);
eventManager.start(aEventId);
assertTrue(eventManager.getEventPool().size() == 1);
assertEquals(1, eventManager.getEventPool().size());
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
assertTrue(eventManager.numOfCurrentlyRunningSyncEvent() == -1);
assertEquals(-1, eventManager.numOfCurrentlyRunningSyncEvent());
eventManager.cancel(aEventId);
assertTrue(eventManager.getEventPool().size() == 0);
assertTrue(eventManager.getEventPool().isEmpty());
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
LOGGER.error(e.getMessage());
}
@ -61,11 +55,11 @@ public class EventAsynchronousTest {
try {
int sEventId = eventManager.create(60);
eventManager.start(sEventId);
assertTrue(eventManager.getEventPool().size() == 1);
assertEquals(1, eventManager.getEventPool().size());
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
assertTrue(eventManager.numOfCurrentlyRunningSyncEvent() != -1);
assertNotEquals(-1, eventManager.numOfCurrentlyRunningSyncEvent());
eventManager.cancel(sEventId);
assertTrue(eventManager.getEventPool().size() == 0);
assertTrue(eventManager.getEventPool().isEmpty());
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
| InvalidOperationException e) {
LOGGER.error(e.getMessage());
@ -73,7 +67,7 @@ public class EventAsynchronousTest {
}
@Test
public void testUnsuccessfulSynchronousEvent() throws InvalidOperationException {
public void testUnsuccessfulSynchronousEvent() {
assertThrows(InvalidOperationException.class, () -> {
EventManager eventManager = new EventManager();
try {
@ -94,7 +88,7 @@ public class EventAsynchronousTest {
int eventTime = 1;
int sEventId = eventManager.create(eventTime);
assertTrue(eventManager.getEventPool().size() == 1);
assertEquals(1, eventManager.getEventPool().size());
eventManager.start(sEventId);
long currentTime = System.currentTimeMillis();
@ -104,7 +98,7 @@ public class EventAsynchronousTest {
while (System.currentTimeMillis() < endTime) {
}
assertTrue(eventManager.getEventPool().size() == 0);
assertTrue(eventManager.getEventPool().isEmpty());
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
| InvalidOperationException e) {
@ -121,7 +115,7 @@ public class EventAsynchronousTest {
int aEventId1 = eventManager.createAsync(eventTime);
int aEventId2 = eventManager.createAsync(eventTime);
int aEventId3 = eventManager.createAsync(eventTime);
assertTrue(eventManager.getEventPool().size() == 3);
assertEquals(3, eventManager.getEventPool().size());
eventManager.start(aEventId1);
eventManager.start(aEventId2);
@ -133,7 +127,7 @@ public class EventAsynchronousTest {
while (System.currentTimeMillis() < endTime) {
}
assertTrue(eventManager.getEventPool().size() == 0);
assertTrue(eventManager.getEventPool().isEmpty());
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
LOGGER.error(e.getMessage());

View File

@ -74,7 +74,7 @@ public class App {
LOGGER.info("Running the system first time............");
eventProcessor.reset();
LOGGER.info("Creating th accounts............");
LOGGER.info("Creating the accounts............");
eventProcessor.process(new AccountCreateEvent(
0, new Date().getTime(), ACCOUNT_OF_DAENERYS, "Daenerys Targaryen"));
@ -98,7 +98,7 @@ public class App {
LOGGER.info(AccountAggregate.getAccount(ACCOUNT_OF_DAENERYS).toString());
LOGGER.info(AccountAggregate.getAccount(ACCOUNT_OF_JON).toString());
LOGGER.info("At that point system had a shot down, state in memory is cleared............");
LOGGER.info("At that point system had a shut down, state in memory is cleared............");
AccountAggregate.resetState();
LOGGER.info("Recover the system by the events in journal file............");

View File

@ -92,7 +92,7 @@ public class MoneyTransferEvent extends DomainEvent {
}
Account accountTo = AccountAggregate.getAccount(accountNoTo);
if (accountTo == null) {
throw new RuntimeException("Account not found" + accountTo);
throw new RuntimeException("Account not found " + accountNoTo);
}
accountFrom.handleTransferFromEvent(this);

View File

@ -44,26 +44,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@EnableRuleMigrationSupport
public class SimpleFileWriterTest {
/**
* Create a temporary folder, used to generate files in during this test
*/
@Rule
public final TemporaryFolder testFolder = new TemporaryFolder();
/**
* Verify if the given writer is not 'null'
*/
@Test
public void testWriterNotNull() throws Exception {
final File temporaryFile = this.testFolder.newFile();
new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
}
/**
* Test if the {@link SimpleFileWriter} creates a file if it doesn't exist
*/
@Test
public void testNonExistentFile() throws Exception {
public void testCreatesNonExistentFile() throws Exception {
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
assertFalse(nonExistingFile.exists());
@ -71,11 +62,8 @@ public class SimpleFileWriterTest {
assertTrue(nonExistingFile.exists());
}
/**
* Test if the data written to the file writer actually gets in the file
*/
@Test
public void testActualWrite() throws Exception {
public void testContentsAreWrittenToFile() throws Exception {
final String testMessage = "Test message";
final File temporaryFile = this.testFolder.newFile();
@ -85,17 +73,15 @@ public class SimpleFileWriterTest {
assertTrue(Files.lines(temporaryFile.toPath()).allMatch(testMessage::equals));
}
/**
* Verify if an {@link IOException} during the write ripples through
*/
@Test
public void testIoException() throws Exception {
public void testRipplesIoExceptionOccurredWhileWriting() {
String message = "Some error";
assertThrows(IOException.class, () -> {
final File temporaryFile = this.testFolder.newFile();
new SimpleFileWriter(temporaryFile.getPath(), writer -> {
throw new IOException("");
throw new IOException(message);
});
});
}, message);
}
}

View File

@ -32,16 +32,16 @@ import units.CommanderUnit;
*/
public class Commander implements CommanderExtension {
private static final Logger LOGGER = LoggerFactory.getLogger(Commander.class);
private CommanderUnit unit;
public Commander(CommanderUnit commanderUnit) {
this.unit = commanderUnit;
}
final Logger logger = LoggerFactory.getLogger(Commander.class);
@Override
public void commanderReady() {
logger.info("[Commander] " + unit.getName() + " is ready!");
LOGGER.info("[Commander] " + unit.getName() + " is ready!");
}
}

View File

@ -32,16 +32,16 @@ import units.SergeantUnit;
*/
public class Sergeant implements SergeantExtension {
private static final Logger LOGGER = LoggerFactory.getLogger(Sergeant.class);
private SergeantUnit unit;
public Sergeant(SergeantUnit sergeantUnit) {
this.unit = sergeantUnit;
}
final Logger logger = LoggerFactory.getLogger(Sergeant.class);
@Override
public void sergeantReady() {
logger.info("[Sergeant] " + unit.getName() + " is ready! ");
LOGGER.info("[Sergeant] " + unit.getName() + " is ready! ");
}
}

View File

@ -31,6 +31,7 @@ import units.SoldierUnit;
* Class defining Soldier
*/
public class Soldier implements SoldierExtension {
private static final Logger LOGGER = LoggerFactory.getLogger(Soldier.class);
private SoldierUnit unit;
@ -38,10 +39,8 @@ public class Soldier implements SoldierExtension {
this.unit = soldierUnit;
}
final Logger logger = LoggerFactory.getLogger(Soldier.class);
@Override
public void soldierReady() {
logger.info("[Solider] " + unit.getName() + " is ready!");
LOGGER.info("[Solider] " + unit.getName() + " is ready!");
}
}

View File

@ -30,7 +30,7 @@ import units.CommanderUnit;
*/
public class CommanderTest {
@Test
public void commanderReady() throws Exception {
public void commanderReady() {
final Commander commander = new Commander(new CommanderUnit("CommanderUnitTest"));
commander.commanderReady();

View File

@ -33,13 +33,13 @@ import static org.junit.jupiter.api.Assertions.assertNull;
*/
public class CommanderUnitTest {
@Test
public void getUnitExtension() throws Exception {
public void getUnitExtension() {
final Unit unit = new CommanderUnit("CommanderUnitName");
assertNull(unit.getUnitExtension("SoldierExtension"));
assertNull(unit.getUnitExtension("SergeantExtension"));
assertNotNull((CommanderExtension) unit.getUnitExtension("CommanderExtension"));
assertNotNull(unit.getUnitExtension("CommanderExtension"));
}
}

View File

@ -33,12 +33,12 @@ import static org.junit.jupiter.api.Assertions.assertNull;
*/
public class SergeantUnitTest {
@Test
public void getUnitExtension() throws Exception {
public void getUnitExtension() {
final Unit unit = new SergeantUnit("SergeantUnitName");
assertNull(unit.getUnitExtension("SoldierExtension"));
assertNotNull((SergeantExtension) unit.getUnitExtension("SergeantExtension"));
assertNotNull(unit.getUnitExtension("SergeantExtension"));
assertNull(unit.getUnitExtension("CommanderExtension"));
}

View File

@ -33,11 +33,11 @@ import static org.junit.jupiter.api.Assertions.assertNull;
*/
public class SoldierUnitTest {
@Test
public void getUnitExtension() throws Exception {
public void getUnitExtension() {
final Unit unit = new SoldierUnit("SoldierUnitName");
assertNotNull((SoldierExtension) unit.getUnitExtension("SoldierExtension"));
assertNotNull(unit.getUnitExtension("SoldierExtension"));
assertNull(unit.getUnitExtension("SergeantExtension"));
assertNull(unit.getUnitExtension("CommanderExtension"));

View File

@ -83,7 +83,7 @@ public class FactoryKitTest {
* @param weapon weapon object which is to be verified
* @param clazz expected class of the weapon
*/
private void verifyWeapon(Weapon weapon, Class clazz) {
private void verifyWeapon(Weapon weapon, Class<?> clazz) {
assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
}
}

View File

@ -40,14 +40,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class PropertiesFeatureToggleVersionTest {
@Test
public void testNullPropertiesPassed() throws Exception {
public void testNullPropertiesPassed() {
assertThrows(IllegalArgumentException.class, () -> {
new PropertiesFeatureToggleVersion(null);
});
}
@Test
public void testNonBooleanProperty() throws Exception {
public void testNonBooleanProperty() {
assertThrows(IllegalArgumentException.class, () -> {
final Properties properties = new Properties();
properties.setProperty("enhancedWelcome", "Something");
@ -56,7 +56,7 @@ public class PropertiesFeatureToggleVersionTest {
}
@Test
public void testFeatureTurnedOn() throws Exception {
public void testFeatureTurnedOn() {
final Properties properties = new Properties();
properties.put("enhancedWelcome", true);
Service service = new PropertiesFeatureToggleVersion(properties);
@ -66,7 +66,7 @@ public class PropertiesFeatureToggleVersionTest {
}
@Test
public void testFeatureTurnedOff() throws Exception {
public void testFeatureTurnedOff() {
final Properties properties = new Properties();
properties.put("enhancedWelcome", false);
Service service = new PropertiesFeatureToggleVersion(properties);

View File

@ -41,27 +41,27 @@ public class TieredFeatureToggleVersionTest {
final Service service = new TieredFeatureToggleVersion();
@BeforeEach
public void setUp() throws Exception {
public void setUp() {
UserGroup.addUserToPaidGroup(paidUser);
UserGroup.addUserToFreeGroup(freeUser);
}
@Test
public void testGetWelcomeMessageForPaidUser() throws Exception {
public void testGetWelcomeMessageForPaidUser() {
final String welcomeMessage = service.getWelcomeMessage(paidUser);
final String expected = "You're amazing Jamie Coder. Thanks for paying for this awesome software.";
assertEquals(expected, welcomeMessage);
}
@Test
public void testGetWelcomeMessageForFreeUser() throws Exception {
public void testGetWelcomeMessageForFreeUser() {
final String welcomeMessage = service.getWelcomeMessage(freeUser);
final String expected = "I suppose you can use this software.";
assertEquals(expected, welcomeMessage);
}
@Test
public void testIsEnhancedAlwaysTrueAsTiered() throws Exception {
public void testIsEnhancedAlwaysTrueAsTiered() {
assertTrue(service.isEnhanced());
}
}

View File

@ -179,15 +179,15 @@ public abstract class FluentIterableTest {
}
@Test
public void testForEach() throws Exception {
public void testForEach() {
final List<Integer> integers = Arrays.asList(1, 2, 3);
final Consumer<Integer> consumer = mock(Consumer.class);
createFluentIterable(integers).forEach(consumer);
verify(consumer, times(1)).accept(Integer.valueOf(1));
verify(consumer, times(1)).accept(Integer.valueOf(2));
verify(consumer, times(1)).accept(Integer.valueOf(3));
verify(consumer, times(1)).accept(1);
verify(consumer, times(1)).accept(2);
verify(consumer, times(1)).accept(3);
verifyNoMoreInteractions(consumer);
}