use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testDeleteModelList.
@Test
public void testDeleteModelList() throws Exception {
final ArgumentCaptor<AnswerEntity> answerEntityCaptor = ArgumentCaptor.forClass(AnswerEntity.class);
final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
this.answersService.delete(answersModels);
verify(this.answersMapper, times(2)).delete(answerEntityCaptor.capture());
final List<AnswerEntity> capturedEntities = answerEntityCaptor.getAllValues();
Integer index = 0;
for (AnswerModelInterface answerModel : answersModels) {
this.answersSupport.assertEquals(answerModel, capturedEntities.get(index));
index++;
}
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final AnswerModelInterface answerAdditionalModel = this.answersSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final AnswerEntity answerEntity = (AnswerEntity) invocation.getArguments()[0];
answerEntity.setId(5);
return null;
}).when(this.answersMapper).insert(Mockito.any(AnswerEntity.class));
this.answersService.save(answerAdditionalModel);
verify(answerAdditionalModel, times(1)).setId(5);
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testFindByQuestionWithOptions.
@Test
public void testFindByQuestionWithOptions() throws Exception {
final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
final List<AnswerEntity> answersEntities = getAnswersFixturesEntities();
final AnswersOptionsInterface answerOptions = mock(AnswersOptionsInterface.class);
when(this.answersMapper.findByQuestionId(answersModels.get(0).getQuestion().getId())).thenReturn(answersEntities);
when(answerOptions.withRelations(listCaptor.capture())).thenReturn(answersModels);
final List<AnswerModelInterface> answersFoundedModels = this.answersService.findByQuestion(answersModels.get(0).getQuestion(), answerOptions);
this.assertEquals(answersFoundedModels, listCaptor.getValue());
Assert.assertSame(answersModels, answersFoundedModels);
verify(this.answersMapper, times(1)).findByQuestionId(answersModels.get(0).getQuestion().getId());
verifyNoMoreInteractions(this.answersMapper);
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
final List<AnswerEntity> answersEntities = getAnswersFixturesEntities();
final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
final AnswersOptionsInterface answersOptions = mock(AnswersOptionsInterface.class);
when(this.answersMapper.findAll()).thenReturn(answersEntities);
when(answersOptions.withRelations(listCaptor.capture())).thenReturn(answersModels);
final List<AnswerModelInterface> answersFoundedModels = this.answersService.findAll(answersOptions);
this.assertEquals(answersFoundedModels, listCaptor.getValue());
Assert.assertSame(answersModels, answersFoundedModels);
verify(this.answersMapper, times(1)).findAll();
verifyNoMoreInteractions(this.answersMapper);
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testSaveCreatesListEntities.
@Test
public void testSaveCreatesListEntities() throws Exception {
final ArgumentCaptor<AnswerEntity> answerEntityCaptor = ArgumentCaptor.forClass(AnswerEntity.class);
final List<AnswerModelInterface> answersModels = getAnswersAdditionalModels();
this.answersService.save(answersModels);
verify(this.answersMapper, times(2)).insert(answerEntityCaptor.capture());
final List<AnswerEntity> capturedEntities = answerEntityCaptor.getAllValues();
Integer index = 0;
for (AnswerModelInterface answerModel : answersModels) {
this.answersSupport.assertEquals(answersModels.get(index), capturedEntities.get(index));
index++;
}
}
Aggregations