use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testDeleteIdentifiedModel.
@Test
public void testDeleteIdentifiedModel() throws Exception {
final AnswerModelInterface answerModel = this.createAnswerModel(1, "Answer3", 1, 1, true);
this.answersService.delete(answerModel);
verify(this.answersMapper, times(1)).delete(this.mapAnswerEntity(answerModel));
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testSaveCreatesEntity.
@Test
public void testSaveCreatesEntity() throws Exception {
final AnswerModelInterface answerModel = this.createAnswerModel(null, "Answer11", 1, 1, true);
doAnswer(invocation -> {
final AnswerEntity answerEntity = (AnswerEntity) invocation.getArguments()[0];
answerEntity.setId(100);
return null;
}).when(this.answersMapper).insert(Mockito.any(AnswerEntity.class));
this.answersService.save(answerModel);
verify(this.answersMapper, times(1)).insert(this.mapAnswerEntity(answerModel));
Assert.assertEquals((Integer) 100, answerModel.getId());
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method createSolutionModel.
private SolutionModelInterface createSolutionModel(Integer id, Integer answerId, Integer pointId) {
final SolutionModelInterface solutionModel = new SolutionModel();
final AnswerModelInterface answerModel = mock(AnswerModelInterface.class);
when(answerModel.getId()).thenReturn(answerId);
final PointModelInterface pointModel = mock(PointModelInterface.class);
when(pointModel.getId()).thenReturn(pointId);
solutionModel.setId(id);
solutionModel.setAnswer(answerModel);
solutionModel.setPoint(pointModel);
return solutionModel;
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method testSaveCreatesListEntitiesWithOptions.
@Test
public void testSaveCreatesListEntitiesWithOptions() throws Exception {
final List<AnswerModelInterface> answersModels = getAnswersAdditionalModels();
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
this.answersService.save(answersModels, answersOptions);
Integer index = 0;
for (AnswerModelInterface answersModel : answersModels) {
verify(answersOptions, times(1)).saveWithRelations(answersModels.get(index));
index++;
}
verifyNoMoreInteractions(this.answersMapper);
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method assertEquals.
private void assertEquals(List<AnswerModelInterface> expected, List<AnswerModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (AnswerModelInterface answerModel : expected) {
this.answersSupport.assertEquals(answerModel, actual.get(i));
i++;
}
}
Aggregations