Search in sources :

Example 1 with UserDAO

use of com.stackify.daos.UserDAO in project tutorials by eugenp.

the class DynamicTests method dynamicUserTestCollection.

@TestFactory
public Stream<DynamicTest> dynamicUserTestCollection() {
    List<User> inputList = Arrays.asList(new User("john@yahoo.com", "John"), new User("ana@yahoo.com", "Ana"));
    Function<User, String> displayNameGenerator = (input) -> "Saving user: " + input;
    UserDAO userDAO = new UserDAO();
    ThrowingConsumer<User> testExecutor = (input) -> {
        userDAO.add(input);
        assertNotNull(userDAO.findOne(input.getEmail()));
    };
    return DynamicTest.stream(inputList.iterator(), displayNameGenerator, testExecutor);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) Stream(java.util.stream.Stream) TestFactory(org.junit.jupiter.api.TestFactory) Collection(java.util.Collection) UserDAO(com.stackify.daos.UserDAO) Assertions(org.junit.jupiter.api.Assertions) DynamicTest(org.junit.jupiter.api.DynamicTest) User(com.stackify.models.User) Function(java.util.function.Function) ThrowingConsumer(org.junit.jupiter.api.function.ThrowingConsumer) User(com.stackify.models.User) UserDAO(com.stackify.daos.UserDAO) TestFactory(org.junit.jupiter.api.TestFactory)

Aggregations

UserDAO (com.stackify.daos.UserDAO)1 User (com.stackify.models.User)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 Assertions (org.junit.jupiter.api.Assertions)1 DynamicTest (org.junit.jupiter.api.DynamicTest)1 TestFactory (org.junit.jupiter.api.TestFactory)1 ThrowingConsumer (org.junit.jupiter.api.function.ThrowingConsumer)1