use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesMapperTest method testFind.
@Test
public void testFind() throws Exception {
final QuizEntity quiz = this.quizzesMapper.find(1);
Assert.assertEquals((long) 1, (long) quiz.getId());
Assert.assertEquals("test_invite_code1", quiz.getInviteCode());
Assert.assertEquals(LocalDateTime.of(2003, 2, 1, 0, 0, 0), quiz.getStartedAt());
Assert.assertEquals(LocalDateTime.of(2003, 3, 1, 0, 0, 0), quiz.getFinishedAt());
Assert.assertEquals(false, quiz.getCodeExpired());
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesService method save.
@Override
public void save(QuizModelInterface quizModel) {
final QuizEntity quizEntity = this.map(quizModel);
if (quizEntity.getId() == null) {
this.quizzesMapper.insert(quizEntity);
quizModel.setId(quizEntity.getId());
return;
}
this.quizzesMapper.update(quizEntity);
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesServiceTest method createQuizEntityMock.
private QuizEntity createQuizEntityMock(Integer id, String inviteCode, Integer issueId) {
final QuizEntity quizEntity = Mockito.mock(QuizEntity.class);
Mockito.when(quizEntity.getId()).thenReturn(id);
Mockito.when(quizEntity.getInviteCode()).thenReturn(inviteCode);
Mockito.when(quizEntity.getIssueId()).thenReturn(issueId);
return quizEntity;
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesServiceTest method mapQuizEntity.
private QuizEntity mapQuizEntity(QuizModelInterface quizModel) {
final QuizEntity quizEntity = new QuizEntity();
quizEntity.map(quizModel);
return quizEntity;
}
use of easytests.core.entities.QuizEntity in project easy-tests by malinink.
the class QuizzesServiceTest method testFindByIssueWithOptions.
@Test
public void testFindByIssueWithOptions() throws Exception {
final Integer issueId = 7;
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
final QuizEntity quizEntityFirst = this.createQuizEntityMock(3, "test3", issueId);
final QuizEntity quizEntitySecond = this.createQuizEntityMock(12, "test12", issueId);
final List<QuizEntity> quizzesEntities = new ArrayList<>();
quizzesEntities.add(quizEntityFirst);
quizzesEntities.add(quizEntitySecond);
given(issueModel.getId()).willReturn(issueId);
given(this.quizzesMapper.findByIssueId(issueId)).willReturn(quizzesEntities);
final List<QuizModelInterface> quizzesModels = new ArrayList<>();
quizzesModels.add(this.mapQuizModel(quizEntityFirst));
quizzesModels.add(this.mapQuizModel(quizEntitySecond));
final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
given(quizOptions.withRelations(quizzesModels)).willReturn(quizzesModels);
final List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findByIssue(issueModel, quizOptions);
verify(this.quizzesMapper).findByIssueId(issueId);
verify(quizOptions).withRelations(quizzesModels);
Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Aggregations