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:
parent
db33cc533b
commit
2f569d670a
@ -32,6 +32,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractDocument test class
|
* AbstractDocument test class
|
||||||
@ -81,8 +82,8 @@ public class AbstractDocumentTest {
|
|||||||
Map<String, Object> props = new HashMap<>();
|
Map<String, Object> props = new HashMap<>();
|
||||||
props.put(KEY, VALUE);
|
props.put(KEY, VALUE);
|
||||||
DocumentImplementation document = new DocumentImplementation(props);
|
DocumentImplementation document = new DocumentImplementation(props);
|
||||||
assertNotNull(document.toString().contains(KEY));
|
assertTrue(document.toString().contains(KEY));
|
||||||
assertNotNull(document.toString().contains(VALUE));
|
assertTrue(document.toString().contains(VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
*/
|
*/
|
||||||
public class ConfigureForUnixVisitorTest {
|
public class ConfigureForUnixVisitorTest {
|
||||||
|
|
||||||
TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
|
private TestLogger logger = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void clearLoggers() {
|
public void clearLoggers() {
|
||||||
|
@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class InventoryControllerTest {
|
public class InventoryControllerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetProductInventories() throws Exception {
|
public void testGetProductInventories() {
|
||||||
InventoryController inventoryController = new InventoryController();
|
InventoryController inventoryController = new InventoryController();
|
||||||
|
|
||||||
int numberOfInventories = inventoryController.getProductInventories();
|
int numberOfInventories = inventoryController.getProductInventories();
|
||||||
|
@ -37,7 +37,7 @@ public class HammerTest extends WeaponTest {
|
|||||||
* underlying weapon implementation.
|
* underlying weapon implementation.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHammer() throws Exception {
|
public void testHammer() {
|
||||||
final Hammer hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
|
final Hammer hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
|
||||||
testBasicWeaponActions(hammer);
|
testBasicWeaponActions(hammer);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class SwordTest extends WeaponTest {
|
|||||||
* underlying weapon implementation.
|
* underlying weapon implementation.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSword() throws Exception {
|
public void testSword() {
|
||||||
final Sword sword = spy(new Sword(mock(FlyingEnchantment.class)));
|
final Sword sword = spy(new Sword(mock(FlyingEnchantment.class)));
|
||||||
testBasicWeaponActions(sword);
|
testBasicWeaponActions(sword);
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,7 @@ public class App {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Task task = new SimpleTask();
|
Task task = new SimpleTask();
|
||||||
Callback callback = new Callback() {
|
Callback callback = () -> LOGGER.info("I'm done now.");
|
||||||
@Override
|
|
||||||
public void call() {
|
|
||||||
LOGGER.info("I'm done now.");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
task.executeWith(callback);
|
task.executeWith(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,29 +38,6 @@ public class CallbackTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void 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++;
|
Callback callback = () -> callingCount++;
|
||||||
|
|
||||||
Task task = new SimpleTask();
|
Task task = new SimpleTask();
|
||||||
|
@ -43,7 +43,7 @@ public class OrcKingTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMakeRequest() throws Exception {
|
public void testMakeRequest() {
|
||||||
final OrcKing king = new OrcKing();
|
final OrcKing king = new OrcKing();
|
||||||
|
|
||||||
for (final Request request : REQUESTS) {
|
for (final Request request : REQUESTS) {
|
||||||
|
@ -26,10 +26,10 @@ package com.iluwatar.collectionpipeline;
|
|||||||
* A Car class that has the properties of make, model, year and category.
|
* A Car class that has the properties of make, model, year and category.
|
||||||
*/
|
*/
|
||||||
public class Car {
|
public class Car {
|
||||||
private String make;
|
private final String make;
|
||||||
private String model;
|
private final String model;
|
||||||
private int year;
|
private final int year;
|
||||||
private Category category;
|
private final Category category;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to create an instance of car.
|
* Constructor to create an instance of car.
|
||||||
|
@ -71,7 +71,7 @@ public class ConverterTest {
|
|||||||
user.getFirstName().toLowerCase() + user.getLastName().toLowerCase() + "@whatever.com"));
|
user.getFirstName().toLowerCase() + user.getLastName().toLowerCase() + "@whatever.com"));
|
||||||
User u1 = new User("John", "Doe", false, "12324");
|
User u1 = new User("John", "Doe", false, "12324");
|
||||||
UserDto userDto = converter.convertFromEntity(u1);
|
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"),
|
ArrayList<User> users = Lists.newArrayList(new User("Camile", "Tough", false, "124sad"),
|
||||||
new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243"));
|
new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243"));
|
||||||
List<User> fromDtos = userConverter.createFromDtos(userConverter.createFromEntities(users));
|
List<User> fromDtos = userConverter.createFromDtos(userConverter.createFromEntities(users));
|
||||||
assertEquals(fromDtos, users);
|
assertEquals(users, fromDtos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class IntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetAuthorBooks() {
|
public void testGetAuthorBooks() {
|
||||||
List<Book> books = queryService.getAuthorBooks("username1");
|
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("title1", 10)));
|
||||||
assertTrue(books.contains(new Book("new_title2", 30)));
|
assertTrue(books.contains(new Book("new_title2", 30)));
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,7 @@ public class CustomerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
public void testToString() {
|
||||||
final StringBuffer buffer = new StringBuffer();
|
assertEquals(String.format("Customer{id=%s, firstName='%s', lastName='%s'}",
|
||||||
buffer.append("Customer{id=")
|
customer.getId(), customer.getFirstName(), customer.getLastName()), customer.toString());
|
||||||
.append("" + customer.getId())
|
|
||||||
.append(", firstName='")
|
|
||||||
.append(customer.getFirstName())
|
|
||||||
.append("\', lastName='")
|
|
||||||
.append(customer.getLastName() + "\'}");
|
|
||||||
assertEquals(buffer.toString(), customer.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public class DbCustomerDaoTest {
|
|||||||
|
|
||||||
private void assertCustomerCountIs(int count) throws Exception {
|
private void assertCustomerCountIs(int count) throws Exception {
|
||||||
try (Stream<Customer> allCustomers = dao.getAll()) {
|
try (Stream<Customer> allCustomers = dao.getAll()) {
|
||||||
assertTrue(allCustomers.count() == count);
|
assertEquals(count, allCustomers.count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public class InMemoryCustomerDaoTest {
|
|||||||
|
|
||||||
private void assertCustomerCountIs(int count) throws Exception {
|
private void assertCustomerCountIs(int count) throws Exception {
|
||||||
try (Stream<Customer> allCustomers = dao.getAll()) {
|
try (Stream<Customer> allCustomers = dao.getAll()) {
|
||||||
assertTrue(allCustomers.count() == count);
|
assertEquals(count, allCustomers.count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.iluwatar.datamapper;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
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
|
* 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);
|
mapper.update(student);
|
||||||
|
|
||||||
/* Check if student is updated in db */
|
/* 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 */
|
/* Delete student in db */
|
||||||
mapper.delete(student);
|
mapper.delete(student);
|
||||||
|
|
||||||
/* Result should be false */
|
/* Result should be false */
|
||||||
assertEquals(false, mapper.find(student.getStudentId()).isPresent());
|
assertFalse(mapper.find(student.getStudentId()).isPresent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ package com.iluwatar.datamapper;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,28 +30,27 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
*/
|
*/
|
||||||
public final class StudentTest {
|
public final class StudentTest {
|
||||||
|
|
||||||
@Test
|
|
||||||
/**
|
/**
|
||||||
* This API tests the equality behaviour of Student object
|
* This API tests the equality behaviour of Student object
|
||||||
* Object Equality should work as per logic defined in equals method
|
* Object Equality should work as per logic defined in equals method
|
||||||
*
|
*
|
||||||
* @throws Exception if any execution error during test
|
* @throws Exception if any execution error during test
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testEquality() throws Exception {
|
public void testEquality() throws Exception {
|
||||||
|
|
||||||
/* Create some students */
|
/* Create some students */
|
||||||
final Student firstStudent = new Student(1, "Adam", 'A');
|
final Student firstStudent = new Student(1, "Adam", 'A');
|
||||||
final Student secondStudent = new Student(2, "Donald", 'B');
|
final Student secondStudent = new Student(2, "Donald", 'B');
|
||||||
final Student secondSameStudent = new Student(2, "Donald", 'B');
|
final Student secondSameStudent = new Student(2, "Donald", 'B');
|
||||||
final Student firstSameStudent = firstStudent;
|
|
||||||
|
|
||||||
/* Check equals functionality: should return 'true' */
|
/* Check equals functionality: should return 'true' */
|
||||||
assertTrue(firstStudent.equals(firstSameStudent));
|
assertEquals(firstStudent, firstStudent);
|
||||||
|
|
||||||
/* Check equals functionality: should return 'false' */
|
/* Check equals functionality: should return 'false' */
|
||||||
assertFalse(firstStudent.equals(secondStudent));
|
assertNotEquals(firstStudent, secondStudent);
|
||||||
|
|
||||||
/* Check equals functionality: should return 'true' */
|
/* Check equals functionality: should return 'true' */
|
||||||
assertTrue(secondStudent.equals(secondSameStudent));
|
assertEquals(secondStudent, secondSameStudent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tests {@link CustomerResource}.
|
* tests {@link CustomerResource}.
|
||||||
@ -45,10 +46,10 @@ public class CustomerResourceTest {
|
|||||||
|
|
||||||
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
||||||
|
|
||||||
assertEquals(allCustomers.size(), 1);
|
assertEquals(1, allCustomers.size());
|
||||||
assertEquals(allCustomers.get(0).getId(), "1");
|
assertEquals("1", allCustomers.get(0).getId());
|
||||||
assertEquals(allCustomers.get(0).getFirstName(), "Melody");
|
assertEquals("Melody", allCustomers.get(0).getFirstName());
|
||||||
assertEquals(allCustomers.get(0).getLastName(), "Yates");
|
assertEquals("Yates", allCustomers.get(0).getLastName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -59,9 +60,9 @@ public class CustomerResourceTest {
|
|||||||
customerResource.save(customer);
|
customerResource.save(customer);
|
||||||
|
|
||||||
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
||||||
assertEquals(allCustomers.get(0).getId(), "1");
|
assertEquals("1", allCustomers.get(0).getId());
|
||||||
assertEquals(allCustomers.get(0).getFirstName(), "Rita");
|
assertEquals("Rita", allCustomers.get(0).getFirstName());
|
||||||
assertEquals(allCustomers.get(0).getLastName(), "Reynolds");
|
assertEquals("Reynolds", allCustomers.get(0).getLastName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -75,7 +76,7 @@ public class CustomerResourceTest {
|
|||||||
customerResource.delete(customer.getId());
|
customerResource.delete(customer.getId());
|
||||||
|
|
||||||
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
List<CustomerDto> allCustomers = customerResource.getAllCustomers();
|
||||||
assertEquals(allCustomers.size(), 0);
|
assertTrue(allCustomers.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ import com.iluwatar.delegation.simple.printers.HpPrinter;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static final String MESSAGE_TO_PRINT = "hello world";
|
private static final String MESSAGE_TO_PRINT = "hello world";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point
|
* Program entry point
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dirty.flag;
|
package org.dirty.flag;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,7 +42,7 @@ public class DirtyFlagTest {
|
|||||||
public void testIsDirty() {
|
public void testIsDirty() {
|
||||||
DataFetcher df = new DataFetcher();
|
DataFetcher df = new DataFetcher();
|
||||||
List<String> countries = df.fetch();
|
List<String> countries = df.fetch();
|
||||||
assertTrue(!countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -51,7 +51,7 @@ public class AggregatorRoute extends RouteBuilder {
|
|||||||
* @throws Exception in case of exception during configuration
|
* @throws Exception in case of exception during configuration
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void configure() throws Exception {
|
public void configure() {
|
||||||
// Main route
|
// Main route
|
||||||
from("{{entry}}").aggregate(constant(true), aggregator)
|
from("{{entry}}").aggregate(constant(true), aggregator)
|
||||||
.completionSize(3).completionInterval(2000)
|
.completionSize(3).completionInterval(2000)
|
||||||
|
@ -70,7 +70,7 @@ public class App {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context.start();
|
context.start();
|
||||||
context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString()));
|
context.getRoutes().forEach(r -> LOGGER.info(r.toString()));
|
||||||
context.stop();
|
context.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class App {
|
|||||||
});
|
});
|
||||||
ProducerTemplate template = context.createProducerTemplate();
|
ProducerTemplate template = context.createProducerTemplate();
|
||||||
context.start();
|
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");
|
template.sendBody("direct:origin", "Hello from origin");
|
||||||
context.stop();
|
context.stop();
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class KingJoffreyTest {
|
|||||||
private class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
private class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||||
private List<ILoggingEvent> log = new LinkedList<>();
|
private List<ILoggingEvent> log = new LinkedList<>();
|
||||||
|
|
||||||
public InMemoryAppender(Class clazz) {
|
public InMemoryAppender(Class<?> clazz) {
|
||||||
((Logger) LoggerFactory.getLogger(clazz)).addAppender(this);
|
((Logger) LoggerFactory.getLogger(clazz)).addAppender(this);
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||||||
public class WeekdayTest {
|
public class WeekdayTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() throws Exception {
|
public void testToString() {
|
||||||
for (final Weekday weekday : Weekday.values()) {
|
for (final Weekday weekday : Weekday.values()) {
|
||||||
final String toString = weekday.toString();
|
final String toString = weekday.toString();
|
||||||
assertNotNull(toString);
|
assertNotNull(toString);
|
||||||
|
@ -16,11 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.event.asynchronous;
|
package com.iluwatar.event.asynchronous;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@ -30,26 +31,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EventAsynchronousTest {
|
public class EventAsynchronousTest {
|
||||||
App app;
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(EventAsynchronousTest.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(EventAsynchronousTest.class);
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
app = new App();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAsynchronousEvent() {
|
public void testAsynchronousEvent() {
|
||||||
EventManager eventManager = new EventManager();
|
EventManager eventManager = new EventManager();
|
||||||
try {
|
try {
|
||||||
int aEventId = eventManager.createAsync(60);
|
int aEventId = eventManager.createAsync(60);
|
||||||
eventManager.start(aEventId);
|
eventManager.start(aEventId);
|
||||||
assertTrue(eventManager.getEventPool().size() == 1);
|
assertEquals(1, eventManager.getEventPool().size());
|
||||||
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
|
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
|
||||||
assertTrue(eventManager.numOfCurrentlyRunningSyncEvent() == -1);
|
assertEquals(-1, eventManager.numOfCurrentlyRunningSyncEvent());
|
||||||
eventManager.cancel(aEventId);
|
eventManager.cancel(aEventId);
|
||||||
assertTrue(eventManager.getEventPool().size() == 0);
|
assertTrue(eventManager.getEventPool().isEmpty());
|
||||||
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
|
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
|
||||||
LOGGER.error(e.getMessage());
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
@ -61,11 +55,11 @@ public class EventAsynchronousTest {
|
|||||||
try {
|
try {
|
||||||
int sEventId = eventManager.create(60);
|
int sEventId = eventManager.create(60);
|
||||||
eventManager.start(sEventId);
|
eventManager.start(sEventId);
|
||||||
assertTrue(eventManager.getEventPool().size() == 1);
|
assertEquals(1, eventManager.getEventPool().size());
|
||||||
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
|
assertTrue(eventManager.getEventPool().size() < EventManager.MAX_RUNNING_EVENTS);
|
||||||
assertTrue(eventManager.numOfCurrentlyRunningSyncEvent() != -1);
|
assertNotEquals(-1, eventManager.numOfCurrentlyRunningSyncEvent());
|
||||||
eventManager.cancel(sEventId);
|
eventManager.cancel(sEventId);
|
||||||
assertTrue(eventManager.getEventPool().size() == 0);
|
assertTrue(eventManager.getEventPool().isEmpty());
|
||||||
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
|
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
|
||||||
| InvalidOperationException e) {
|
| InvalidOperationException e) {
|
||||||
LOGGER.error(e.getMessage());
|
LOGGER.error(e.getMessage());
|
||||||
@ -73,7 +67,7 @@ public class EventAsynchronousTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnsuccessfulSynchronousEvent() throws InvalidOperationException {
|
public void testUnsuccessfulSynchronousEvent() {
|
||||||
assertThrows(InvalidOperationException.class, () -> {
|
assertThrows(InvalidOperationException.class, () -> {
|
||||||
EventManager eventManager = new EventManager();
|
EventManager eventManager = new EventManager();
|
||||||
try {
|
try {
|
||||||
@ -94,7 +88,7 @@ public class EventAsynchronousTest {
|
|||||||
int eventTime = 1;
|
int eventTime = 1;
|
||||||
|
|
||||||
int sEventId = eventManager.create(eventTime);
|
int sEventId = eventManager.create(eventTime);
|
||||||
assertTrue(eventManager.getEventPool().size() == 1);
|
assertEquals(1, eventManager.getEventPool().size());
|
||||||
eventManager.start(sEventId);
|
eventManager.start(sEventId);
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
@ -104,7 +98,7 @@ public class EventAsynchronousTest {
|
|||||||
while (System.currentTimeMillis() < endTime) {
|
while (System.currentTimeMillis() < endTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(eventManager.getEventPool().size() == 0);
|
assertTrue(eventManager.getEventPool().isEmpty());
|
||||||
|
|
||||||
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
|
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException
|
||||||
| InvalidOperationException e) {
|
| InvalidOperationException e) {
|
||||||
@ -121,7 +115,7 @@ public class EventAsynchronousTest {
|
|||||||
int aEventId1 = eventManager.createAsync(eventTime);
|
int aEventId1 = eventManager.createAsync(eventTime);
|
||||||
int aEventId2 = eventManager.createAsync(eventTime);
|
int aEventId2 = eventManager.createAsync(eventTime);
|
||||||
int aEventId3 = eventManager.createAsync(eventTime);
|
int aEventId3 = eventManager.createAsync(eventTime);
|
||||||
assertTrue(eventManager.getEventPool().size() == 3);
|
assertEquals(3, eventManager.getEventPool().size());
|
||||||
|
|
||||||
eventManager.start(aEventId1);
|
eventManager.start(aEventId1);
|
||||||
eventManager.start(aEventId2);
|
eventManager.start(aEventId2);
|
||||||
@ -133,7 +127,7 @@ public class EventAsynchronousTest {
|
|||||||
while (System.currentTimeMillis() < endTime) {
|
while (System.currentTimeMillis() < endTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(eventManager.getEventPool().size() == 0);
|
assertTrue(eventManager.getEventPool().isEmpty());
|
||||||
|
|
||||||
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
|
} catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
|
||||||
LOGGER.error(e.getMessage());
|
LOGGER.error(e.getMessage());
|
||||||
|
@ -74,7 +74,7 @@ public class App {
|
|||||||
LOGGER.info("Running the system first time............");
|
LOGGER.info("Running the system first time............");
|
||||||
eventProcessor.reset();
|
eventProcessor.reset();
|
||||||
|
|
||||||
LOGGER.info("Creating th accounts............");
|
LOGGER.info("Creating the accounts............");
|
||||||
|
|
||||||
eventProcessor.process(new AccountCreateEvent(
|
eventProcessor.process(new AccountCreateEvent(
|
||||||
0, new Date().getTime(), ACCOUNT_OF_DAENERYS, "Daenerys Targaryen"));
|
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_DAENERYS).toString());
|
||||||
LOGGER.info(AccountAggregate.getAccount(ACCOUNT_OF_JON).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();
|
AccountAggregate.resetState();
|
||||||
|
|
||||||
LOGGER.info("Recover the system by the events in journal file............");
|
LOGGER.info("Recover the system by the events in journal file............");
|
||||||
|
@ -92,7 +92,7 @@ public class MoneyTransferEvent extends DomainEvent {
|
|||||||
}
|
}
|
||||||
Account accountTo = AccountAggregate.getAccount(accountNoTo);
|
Account accountTo = AccountAggregate.getAccount(accountNoTo);
|
||||||
if (accountTo == null) {
|
if (accountTo == null) {
|
||||||
throw new RuntimeException("Account not found" + accountTo);
|
throw new RuntimeException("Account not found " + accountNoTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
accountFrom.handleTransferFromEvent(this);
|
accountFrom.handleTransferFromEvent(this);
|
||||||
|
@ -44,26 +44,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
@EnableRuleMigrationSupport
|
@EnableRuleMigrationSupport
|
||||||
public class SimpleFileWriterTest {
|
public class SimpleFileWriterTest {
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a temporary folder, used to generate files in during this test
|
|
||||||
*/
|
|
||||||
@Rule
|
@Rule
|
||||||
public final TemporaryFolder testFolder = new TemporaryFolder();
|
public final TemporaryFolder testFolder = new TemporaryFolder();
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify if the given writer is not 'null'
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriterNotNull() throws Exception {
|
public void testWriterNotNull() throws Exception {
|
||||||
final File temporaryFile = this.testFolder.newFile();
|
final File temporaryFile = this.testFolder.newFile();
|
||||||
new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
|
new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if the {@link SimpleFileWriter} creates a file if it doesn't exist
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonExistentFile() throws Exception {
|
public void testCreatesNonExistentFile() throws Exception {
|
||||||
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
|
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
|
||||||
assertFalse(nonExistingFile.exists());
|
assertFalse(nonExistingFile.exists());
|
||||||
|
|
||||||
@ -71,11 +62,8 @@ public class SimpleFileWriterTest {
|
|||||||
assertTrue(nonExistingFile.exists());
|
assertTrue(nonExistingFile.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if the data written to the file writer actually gets in the file
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testActualWrite() throws Exception {
|
public void testContentsAreWrittenToFile() throws Exception {
|
||||||
final String testMessage = "Test message";
|
final String testMessage = "Test message";
|
||||||
|
|
||||||
final File temporaryFile = this.testFolder.newFile();
|
final File temporaryFile = this.testFolder.newFile();
|
||||||
@ -85,17 +73,15 @@ public class SimpleFileWriterTest {
|
|||||||
assertTrue(Files.lines(temporaryFile.toPath()).allMatch(testMessage::equals));
|
assertTrue(Files.lines(temporaryFile.toPath()).allMatch(testMessage::equals));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify if an {@link IOException} during the write ripples through
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testIoException() throws Exception {
|
public void testRipplesIoExceptionOccurredWhileWriting() {
|
||||||
|
String message = "Some error";
|
||||||
assertThrows(IOException.class, () -> {
|
assertThrows(IOException.class, () -> {
|
||||||
final File temporaryFile = this.testFolder.newFile();
|
final File temporaryFile = this.testFolder.newFile();
|
||||||
new SimpleFileWriter(temporaryFile.getPath(), writer -> {
|
new SimpleFileWriter(temporaryFile.getPath(), writer -> {
|
||||||
throw new IOException("");
|
throw new IOException(message);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,16 +32,16 @@ import units.CommanderUnit;
|
|||||||
*/
|
*/
|
||||||
public class Commander implements CommanderExtension {
|
public class Commander implements CommanderExtension {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Commander.class);
|
||||||
|
|
||||||
private CommanderUnit unit;
|
private CommanderUnit unit;
|
||||||
|
|
||||||
public Commander(CommanderUnit commanderUnit) {
|
public Commander(CommanderUnit commanderUnit) {
|
||||||
this.unit = commanderUnit;
|
this.unit = commanderUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Logger logger = LoggerFactory.getLogger(Commander.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commanderReady() {
|
public void commanderReady() {
|
||||||
logger.info("[Commander] " + unit.getName() + " is ready!");
|
LOGGER.info("[Commander] " + unit.getName() + " is ready!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,16 +32,16 @@ import units.SergeantUnit;
|
|||||||
*/
|
*/
|
||||||
public class Sergeant implements SergeantExtension {
|
public class Sergeant implements SergeantExtension {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Sergeant.class);
|
||||||
|
|
||||||
private SergeantUnit unit;
|
private SergeantUnit unit;
|
||||||
|
|
||||||
public Sergeant(SergeantUnit sergeantUnit) {
|
public Sergeant(SergeantUnit sergeantUnit) {
|
||||||
this.unit = sergeantUnit;
|
this.unit = sergeantUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Logger logger = LoggerFactory.getLogger(Sergeant.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sergeantReady() {
|
public void sergeantReady() {
|
||||||
logger.info("[Sergeant] " + unit.getName() + " is ready! ");
|
LOGGER.info("[Sergeant] " + unit.getName() + " is ready! ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import units.SoldierUnit;
|
|||||||
* Class defining Soldier
|
* Class defining Soldier
|
||||||
*/
|
*/
|
||||||
public class Soldier implements SoldierExtension {
|
public class Soldier implements SoldierExtension {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Soldier.class);
|
||||||
|
|
||||||
private SoldierUnit unit;
|
private SoldierUnit unit;
|
||||||
|
|
||||||
@ -38,10 +39,8 @@ public class Soldier implements SoldierExtension {
|
|||||||
this.unit = soldierUnit;
|
this.unit = soldierUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Logger logger = LoggerFactory.getLogger(Soldier.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void soldierReady() {
|
public void soldierReady() {
|
||||||
logger.info("[Solider] " + unit.getName() + " is ready!");
|
LOGGER.info("[Solider] " + unit.getName() + " is ready!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import units.CommanderUnit;
|
|||||||
*/
|
*/
|
||||||
public class CommanderTest {
|
public class CommanderTest {
|
||||||
@Test
|
@Test
|
||||||
public void commanderReady() throws Exception {
|
public void commanderReady() {
|
||||||
final Commander commander = new Commander(new CommanderUnit("CommanderUnitTest"));
|
final Commander commander = new Commander(new CommanderUnit("CommanderUnitTest"));
|
||||||
|
|
||||||
commander.commanderReady();
|
commander.commanderReady();
|
||||||
|
@ -33,13 +33,13 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||||||
*/
|
*/
|
||||||
public class CommanderUnitTest {
|
public class CommanderUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void getUnitExtension() throws Exception {
|
public void getUnitExtension() {
|
||||||
|
|
||||||
final Unit unit = new CommanderUnit("CommanderUnitName");
|
final Unit unit = new CommanderUnit("CommanderUnitName");
|
||||||
|
|
||||||
assertNull(unit.getUnitExtension("SoldierExtension"));
|
assertNull(unit.getUnitExtension("SoldierExtension"));
|
||||||
assertNull(unit.getUnitExtension("SergeantExtension"));
|
assertNull(unit.getUnitExtension("SergeantExtension"));
|
||||||
assertNotNull((CommanderExtension) unit.getUnitExtension("CommanderExtension"));
|
assertNotNull(unit.getUnitExtension("CommanderExtension"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -33,12 +33,12 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||||||
*/
|
*/
|
||||||
public class SergeantUnitTest {
|
public class SergeantUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void getUnitExtension() throws Exception {
|
public void getUnitExtension() {
|
||||||
|
|
||||||
final Unit unit = new SergeantUnit("SergeantUnitName");
|
final Unit unit = new SergeantUnit("SergeantUnitName");
|
||||||
|
|
||||||
assertNull(unit.getUnitExtension("SoldierExtension"));
|
assertNull(unit.getUnitExtension("SoldierExtension"));
|
||||||
assertNotNull((SergeantExtension) unit.getUnitExtension("SergeantExtension"));
|
assertNotNull(unit.getUnitExtension("SergeantExtension"));
|
||||||
assertNull(unit.getUnitExtension("CommanderExtension"));
|
assertNull(unit.getUnitExtension("CommanderExtension"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||||||
*/
|
*/
|
||||||
public class SoldierUnitTest {
|
public class SoldierUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void getUnitExtension() throws Exception {
|
public void getUnitExtension() {
|
||||||
|
|
||||||
final Unit unit = new SoldierUnit("SoldierUnitName");
|
final Unit unit = new SoldierUnit("SoldierUnitName");
|
||||||
|
|
||||||
assertNotNull((SoldierExtension) unit.getUnitExtension("SoldierExtension"));
|
assertNotNull(unit.getUnitExtension("SoldierExtension"));
|
||||||
assertNull(unit.getUnitExtension("SergeantExtension"));
|
assertNull(unit.getUnitExtension("SergeantExtension"));
|
||||||
assertNull(unit.getUnitExtension("CommanderExtension"));
|
assertNull(unit.getUnitExtension("CommanderExtension"));
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class FactoryKitTest {
|
|||||||
* @param weapon weapon object which is to be verified
|
* @param weapon weapon object which is to be verified
|
||||||
* @param clazz expected class of the weapon
|
* @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());
|
assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
public class PropertiesFeatureToggleVersionTest {
|
public class PropertiesFeatureToggleVersionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullPropertiesPassed() throws Exception {
|
public void testNullPropertiesPassed() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new PropertiesFeatureToggleVersion(null);
|
new PropertiesFeatureToggleVersion(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonBooleanProperty() throws Exception {
|
public void testNonBooleanProperty() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
properties.setProperty("enhancedWelcome", "Something");
|
properties.setProperty("enhancedWelcome", "Something");
|
||||||
@ -56,7 +56,7 @@ public class PropertiesFeatureToggleVersionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFeatureTurnedOn() throws Exception {
|
public void testFeatureTurnedOn() {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
properties.put("enhancedWelcome", true);
|
properties.put("enhancedWelcome", true);
|
||||||
Service service = new PropertiesFeatureToggleVersion(properties);
|
Service service = new PropertiesFeatureToggleVersion(properties);
|
||||||
@ -66,7 +66,7 @@ public class PropertiesFeatureToggleVersionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFeatureTurnedOff() throws Exception {
|
public void testFeatureTurnedOff() {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
properties.put("enhancedWelcome", false);
|
properties.put("enhancedWelcome", false);
|
||||||
Service service = new PropertiesFeatureToggleVersion(properties);
|
Service service = new PropertiesFeatureToggleVersion(properties);
|
||||||
|
@ -41,27 +41,27 @@ public class TieredFeatureToggleVersionTest {
|
|||||||
final Service service = new TieredFeatureToggleVersion();
|
final Service service = new TieredFeatureToggleVersion();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
UserGroup.addUserToPaidGroup(paidUser);
|
UserGroup.addUserToPaidGroup(paidUser);
|
||||||
UserGroup.addUserToFreeGroup(freeUser);
|
UserGroup.addUserToFreeGroup(freeUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWelcomeMessageForPaidUser() throws Exception {
|
public void testGetWelcomeMessageForPaidUser() {
|
||||||
final String welcomeMessage = service.getWelcomeMessage(paidUser);
|
final String welcomeMessage = service.getWelcomeMessage(paidUser);
|
||||||
final String expected = "You're amazing Jamie Coder. Thanks for paying for this awesome software.";
|
final String expected = "You're amazing Jamie Coder. Thanks for paying for this awesome software.";
|
||||||
assertEquals(expected, welcomeMessage);
|
assertEquals(expected, welcomeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWelcomeMessageForFreeUser() throws Exception {
|
public void testGetWelcomeMessageForFreeUser() {
|
||||||
final String welcomeMessage = service.getWelcomeMessage(freeUser);
|
final String welcomeMessage = service.getWelcomeMessage(freeUser);
|
||||||
final String expected = "I suppose you can use this software.";
|
final String expected = "I suppose you can use this software.";
|
||||||
assertEquals(expected, welcomeMessage);
|
assertEquals(expected, welcomeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsEnhancedAlwaysTrueAsTiered() throws Exception {
|
public void testIsEnhancedAlwaysTrueAsTiered() {
|
||||||
assertTrue(service.isEnhanced());
|
assertTrue(service.isEnhanced());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,15 +179,15 @@ public abstract class FluentIterableTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForEach() throws Exception {
|
public void testForEach() {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
||||||
|
|
||||||
final Consumer<Integer> consumer = mock(Consumer.class);
|
final Consumer<Integer> consumer = mock(Consumer.class);
|
||||||
createFluentIterable(integers).forEach(consumer);
|
createFluentIterable(integers).forEach(consumer);
|
||||||
|
|
||||||
verify(consumer, times(1)).accept(Integer.valueOf(1));
|
verify(consumer, times(1)).accept(1);
|
||||||
verify(consumer, times(1)).accept(Integer.valueOf(2));
|
verify(consumer, times(1)).accept(2);
|
||||||
verify(consumer, times(1)).accept(Integer.valueOf(3));
|
verify(consumer, times(1)).accept(3);
|
||||||
verifyNoMoreInteractions(consumer);
|
verifyNoMoreInteractions(consumer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user