use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testFindAbsentModel.
@Test
public void testFindAbsentModel() throws Exception {
final Integer id = 10;
given(this.questionsMapper.find(id)).willReturn(null);
final QuestionModelInterface questionModel = this.questionsService.find(id);
Assert.assertEquals(null, questionModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testDeleteWithOptions.
@Test
public void testDeleteWithOptions() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
this.questionsService.delete(questionModel, questionsOptions);
verify(questionsOptions).deleteWithRelations(questionModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testDeleteModelsList.
@Test
public void testDeleteModelsList() throws Exception {
final QuestionModelInterface questionModelFirst = Models.createQuestionModel(1, "test1", 1, 1);
final QuestionModelInterface questionModelSecond = Models.createQuestionModel(2, "test2", 2, 1);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
questionsModels.add(questionModelFirst);
questionsModels.add(questionModelSecond);
final QuestionsServiceInterface questionsServiceSpy = Mockito.spy(questionsService);
questionsServiceSpy.delete(questionsModels);
verify(questionsServiceSpy, times(1)).delete(questionModelFirst);
verify(questionsServiceSpy, times(1)).delete(questionModelSecond);
questionsServiceSpy.delete(questionsModels, questionsOptions);
verify(questionsServiceSpy, times(1)).delete(questionModelFirst, questionsOptions);
verify(questionsServiceSpy, times(1)).delete(questionModelSecond, questionsOptions);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
this.questionsService.save(questionModel);
verify(this.questionsMapper, times(1)).update(this.mapQuestionEntity(questionModel));
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveCreatesEntity.
@Test
public void testSaveCreatesEntity() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
doAnswer(invocation -> {
final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
questionEntity.setId(5);
return null;
}).when(this.questionsMapper).insert(Mockito.any(QuestionEntity.class));
this.questionsService.save(questionModel);
verify(this.questionsMapper, times(1)).insert(this.mapQuestionEntity(questionModel));
Assert.assertEquals((Integer) 5, questionModel.getId());
}
Aggregations