use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesMapperTest method testDelete.
@Test
public void testDelete() throws Exception {
QuizEntity quiz = this.quizzesMapper.find(1);
Assert.assertNotNull(quiz);
this.quizzesMapper.delete(quiz);
quiz = this.quizzesMapper.find(1);
Assert.assertNull(quiz);
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesMapperTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Integer id = 2;
final String inviteCode = "updated";
final LocalDateTime testStartedAt = LocalDateTime.of(2017, 5, 18, 12, 1, 0);
final LocalDateTime testFinishedAt = LocalDateTime.of(2017, 5, 18, 13, 0, 0);
final boolean testCodeExpired = false;
QuizEntity quiz = this.quizzesMapper.find(id);
Assert.assertNotEquals(inviteCode, quiz.getInviteCode());
quiz = Mockito.mock(QuizEntity.class);
Mockito.when(quiz.getId()).thenReturn(id);
Mockito.when(quiz.getInviteCode()).thenReturn(inviteCode);
Mockito.when(quiz.getStartedAt()).thenReturn(testStartedAt);
Mockito.when(quiz.getFinishedAt()).thenReturn(testFinishedAt);
Mockito.when(quiz.getCodeExpired()).thenReturn(testCodeExpired);
this.quizzesMapper.update(quiz);
final QuizEntity readQuiz = quizzesMapper.find(id);
Assert.assertEquals(inviteCode, readQuiz.getInviteCode());
Assert.assertEquals(testStartedAt, readQuiz.getStartedAt());
Assert.assertEquals(testFinishedAt, readQuiz.getFinishedAt());
Assert.assertEquals(testCodeExpired, readQuiz.getCodeExpired());
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesMapperTest method testInsert.
@Test
public void testInsert() throws Exception {
final Integer id = this.quizzesMapper.findAll().size() + 1;
final Integer testIssueId = 1;
final String testInviteCode = "test";
final LocalDateTime testStartedAt = LocalDateTime.of(2017, 5, 18, 12, 1, 0);
final LocalDateTime testFinishedAt = LocalDateTime.of(2017, 5, 18, 13, 0, 0);
final boolean testCodeExpired = false;
final QuizEntity testQuiz = Mockito.mock(QuizEntity.class);
Mockito.when(testQuiz.getId()).thenReturn(id);
Mockito.when(testQuiz.getInviteCode()).thenReturn(testInviteCode);
Mockito.when(testQuiz.getIssueId()).thenReturn(testIssueId);
Mockito.when(testQuiz.getStartedAt()).thenReturn(testStartedAt);
Mockito.when(testQuiz.getFinishedAt()).thenReturn(testFinishedAt);
Mockito.when(testQuiz.getCodeExpired()).thenReturn(testCodeExpired);
quizzesMapper.insert(testQuiz);
verify(testQuiz, times(1)).setId(id);
final QuizEntity readQuiz = quizzesMapper.find(testQuiz.getId());
Assert.assertNotNull(readQuiz);
Assert.assertEquals(testIssueId, readQuiz.getIssueId());
Assert.assertEquals(testInviteCode, readQuiz.getInviteCode());
Assert.assertEquals(testStartedAt, readQuiz.getStartedAt());
Assert.assertEquals(testFinishedAt, readQuiz.getFinishedAt());
Assert.assertEquals(testCodeExpired, readQuiz.getCodeExpired());
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesService method delete.
@Override
public void delete(QuizModelInterface quizModel) {
final QuizEntity quizEntity = this.map(quizModel);
if (quizEntity.getId() == null) {
throw new DeleteUnidentifiedModelException();
}
this.quizzesMapper.delete(quizEntity);
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<QuizEntity> quizzesEntities = this.getQuizzesEntities();
final List<QuizModelInterface> quizzesModels = this.getIssuesModels();
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
given(this.quizzesMapper.findAll()).willReturn(quizzesEntities);
given(quizzesOptions.withRelations(Mockito.anyList())).willReturn(quizzesModels);
final List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findAll(quizzesOptions);
verify(quizzesOptions).withRelations(foundedQuizzesModels);
Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Aggregations