use of easytests.core.entities.AnswerEntity 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.entities.AnswerEntity 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++;
}
}
use of easytests.core.entities.AnswerEntity in project easy-tests by malinink.
the class AnswersMapperTest method testFind.
@Test
public void testFind() throws Exception {
final AnswerEntity answer = this.answersMapper.find(1);
Assert.assertEquals((Integer) 1, answer.getId());
Assert.assertEquals("Answer1", answer.getTxt());
Assert.assertEquals((Integer) 1, answer.getQuestionId());
Assert.assertEquals(true, answer.getRight());
}
use of easytests.core.entities.AnswerEntity in project easy-tests by malinink.
the class AnswersMapperTest method testFindByQuestionId.
@Test
public void testFindByQuestionId() throws Exception {
final List<AnswerEntity> answers = this.answersMapper.findByQuestionId(1);
Assert.assertEquals((Integer) 1, (Integer) answers.size());
final AnswerEntity answer = answers.get(0);
Assert.assertEquals((Integer) 1, answer.getId());
Assert.assertEquals("Answer1", answer.getTxt());
Assert.assertEquals((Integer) 1, answer.getQuestionId());
Assert.assertEquals(true, answer.getRight());
}
use of easytests.core.entities.AnswerEntity in project easy-tests by malinink.
the class AnswersService method save.
@Override
public void save(AnswerModelInterface answerModel) {
final AnswerEntity answerEntity = this.map(answerModel);
if (answerEntity.getId() == null) {
this.answersMapper.insert(answerEntity);
answerModel.setId(answerEntity.getId());
return;
}
this.answersMapper.update(answerEntity);
}
Aggregations