Nawet w książce jest given when then.
Poprawiłem może teraz to lepiej wygląda chyba, że znowu przekombinowałem.
@Test
public void usersQuizzesWithPublicStatusCanBeFindInGlobalQuizList_test() {
User user = newUser("test@example.com");
User otherUser = newUser("test1@example.com");
newQuizWithStatus("test", Status.PUBLIC, user.getEmail());
newQuizWithStatus("test1", Status.PRIVATE, user.getEmail());
newQuizWithStatus("test2", Status.PRIVATE, otherUser.getEmail());
newQuizWithStatus("test3", Status.PUBLIC, otherUser.getEmail());
List<QuizDTO> publicQuizzes = quizService.findAllPublicQuizzes();
Assertions.assertEquals(publicQuizzes.size(), 2);
Assertions.assertEquals(publicQuizzes.get(0).title(), "test");
Assertions.assertEquals(publicQuizzes.get(1).title(), "test3");
}
@Test
public void userShouldFindOnlyOwnQuizzes_test() {
User user = newUser("test@example.com");
User otherUser = newUser("test1@example.com");
newQuizWithStatus("test", Status.PRIVATE, user.getEmail());
newQuizWithStatus("test2", Status.PUBLIC, otherUser.getEmail());
List<QuizDTO> userQuizzes = quizService.findYourQuizzes(new TestPrincipal(user.getEmail()));
Assertions.assertEquals(userQuizzes.size(), 1);
Assertions.assertEquals(userQuizzes.get(0).title(), "test");
}