use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class PointsServiceTest method testFindByQuizAbsentList.
@Test
public void testFindByQuizAbsentList() throws Exception {
final QuizModelInterface quizModel = this.quizzesSupport.getModelFixtureMock(0);
when(this.pointsMapper.findByQuizId(quizModel.getId())).thenReturn(new ArrayList<>(0));
final List<PointModelInterface> pointFoundedModels = this.pointsService.findByQuiz(quizModel);
Assert.assertEquals(0, pointFoundedModels.size());
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class PointsServiceTest method testFindByQuizPresentList.
@Test
public void testFindByQuizPresentList() throws Exception {
final QuizModelInterface quizModel = this.quizzesSupport.getModelFixtureMock(0);
final List<PointEntity> pointsEntities = this.getPointsFixturesEntities();
when(this.pointsMapper.findByQuizId(quizModel.getId())).thenReturn(pointsEntities);
final List<PointModelInterface> pointsFoundedModels = this.pointsService.findByQuiz(quizModel);
this.pointsSupport.assertModelsListEquals(this.getPointsFixturesModels(), pointsFoundedModels);
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesServiceTest method testSaveModelsListWithOptions.
@Test
public void testSaveModelsListWithOptions() throws Exception {
final ArgumentCaptor<QuizModelInterface> quizModelCaptor = ArgumentCaptor.forClass(QuizModelInterface.class);
final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
this.quizzesService.save(quizzesModels, quizzesOptions);
this.assertServicesSet(quizzesOptions, quizzesModels.size());
verify(quizzesOptions, times(quizzesModels.size())).saveWithRelations(quizModelCaptor.capture());
this.quizzesSupport.assertModelsListEquals(quizzesModels, quizModelCaptor.getAllValues());
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesServiceTest method testFindByIssuePresentList.
@Test
public void testFindByIssuePresentList() throws Exception {
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
final List<QuizEntity> quizzesEntities = this.getQuizzesFixturesEntities();
when(this.quizzesMapper.findByIssueId(issueModel.getId())).thenReturn(quizzesEntities);
final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
final List<QuizModelInterface> quizzesFoundedModels = this.quizzesService.findByIssue(issueModel);
this.quizzesSupport.assertModelsListEquals(quizzesModels, quizzesFoundedModels);
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final QuizModelInterface quizAdditionalModel = this.quizzesSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final QuizEntity quizEntity = (QuizEntity) invocation.getArguments()[0];
quizEntity.setId(5);
return null;
}).when(this.quizzesMapper).insert(Mockito.any(QuizEntity.class));
this.quizzesService.save(quizAdditionalModel);
verify(quizAdditionalModel, times(1)).setId(5);
}
Aggregations