use of easytests.core.entities.AnswerEntity in project easy-tests by malinink.
the class AnswersMapperTest method testInsert.
@Test
public void testInsert() throws Exception {
final Integer id = this.answersMapper.findAll().size() + 1;
final String txt = "Text";
final Integer questionId = 1;
final Boolean right = true;
AnswerEntity answerEntity = Mockito.mock(AnswerEntity.class);
Mockito.when(answerEntity.getTxt()).thenReturn(txt);
Mockito.when(answerEntity.getQuestionId()).thenReturn(questionId);
Mockito.when(answerEntity.getRight()).thenReturn(right);
this.answersMapper.insert(answerEntity);
verify(answerEntity, times(1)).setId(id);
answerEntity = this.answersMapper.find(id);
Assert.assertEquals(id, answerEntity.getId());
Assert.assertEquals(txt, answerEntity.getTxt());
Assert.assertEquals(questionId, answerEntity.getQuestionId());
Assert.assertEquals(right, answerEntity.getRight());
}
use of easytests.core.entities.AnswerEntity in project easy-tests by malinink.
the class AnswersSupport method getEntityMock.
private AnswerEntity getEntityMock(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
final AnswerEntity answerEntity = Mockito.mock(AnswerEntity.class);
Mockito.when(answerEntity.getId()).thenReturn(id);
Mockito.when(answerEntity.getTxt()).thenReturn(txt);
Mockito.when(answerEntity.getQuestionId()).thenReturn(questionId);
Mockito.when(answerEntity.getSerialNumber()).thenReturn(serialNumber);
Mockito.when(answerEntity.getRight()).thenReturn(right);
return answerEntity;
}
use of easytests.core.entities.AnswerEntity 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.entities.AnswerEntity 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.entities.AnswerEntity 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);
}
Aggregations