use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersSupport method getModelMock.
private AnswerModelInterface getModelMock(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
Mockito.when(answerModel.getId()).thenReturn(id);
Mockito.when(answerModel.getTxt()).thenReturn(txt);
Mockito.when(answerModel.getQuestion()).thenReturn(new QuestionModelEmpty(questionId));
Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
Mockito.when(answerModel.getRight()).thenReturn(right);
return answerModel;
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final AnswerModelInterface answerModel = this.answersSupport.getModelFixtureMock(0);
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
this.answersService.save(answerModel, answersOptions);
verify(answersOptions, times(1)).saveWithRelations(answerModel);
verifyNoMoreInteractions(this.answersMapper);
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testFindByAbsentQuestion.
@Test
public void testFindByAbsentQuestion() throws Exception {
final AnswerModelInterface answerModel = this.answersSupport.getModelAdditionalMock(2);
final List<AnswerModelInterface> answerFoundedModels = this.answersService.findByQuestion(answerModel.getQuestion());
Assert.assertEquals(0, answerFoundedModels.size());
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testFindByPresentQuestion.
@Test
public void testFindByPresentQuestion() throws Exception {
final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
final List<AnswerEntity> answersEntities = getAnswersFixturesEntities();
when(this.answersMapper.findByQuestionId(answersModels.get(0).getQuestion().getId())).thenReturn(answersEntities);
final List<AnswerModelInterface> answersFoundedModels = this.answersService.findByQuestion(answersModels.get(0).getQuestion());
Integer index = 0;
for (AnswerModelInterface answerModel1 : answersFoundedModels) {
this.answersSupport.assertEquals(answerModel1, answersEntities.get(index));
index++;
}
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testDeleteModelListWithOptions.
@Test
public void testDeleteModelListWithOptions() throws Exception {
final ArgumentCaptor<AnswerModel> answerModelCaptor = ArgumentCaptor.forClass(AnswerModel.class);
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
this.answersService.delete(answersModels, answersOptions);
verify(answersOptions, times(2)).deleteWithRelations(answerModelCaptor.capture());
final List<AnswerModel> capturedModels = answerModelCaptor.getAllValues();
Integer index = 0;
for (AnswerModelInterface answerModel : answersModels) {
this.answersSupport.assertEquals(answerModel, capturedModels.get(index));
index++;
}
verifyNoMoreInteractions(this.answersMapper);
}
Aggregations