use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testDeleteIdentifiedModel.
@Test
public void testDeleteIdentifiedModel() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
this.questionsService.delete(questionModel);
verify(this.questionsMapper, times(1)).delete(this.mapQuestionEntity(questionModel));
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testFindByTopicWithOptions.
@Test
public void testFindByTopicWithOptions() throws Exception {
final Integer topicId = 7;
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionEntity questionEntityFirst = Entities.createQuestionEntityMock(3, "test3", 1, topicId);
final QuestionEntity questionEntitySecond = Entities.createQuestionEntityMock(12, "test12", 1, topicId);
final List<QuestionEntity> questionsEntities = new ArrayList<>();
questionsEntities.add(questionEntityFirst);
questionsEntities.add(questionEntitySecond);
given(topicModel.getId()).willReturn(topicId);
given(this.questionsMapper.findByTopicId(topicId)).willReturn(questionsEntities);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
questionsModels.add(this.mapQuestionModel(questionEntityFirst));
questionsModels.add(this.mapQuestionModel(questionEntitySecond));
final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(questionOptions.withRelations(questionsModels)).willReturn(questionsModels);
final List<QuestionModelInterface> foundedQuestionsModels = this.questionsService.findByTopic(topicModel, questionOptions);
verify(this.questionsMapper).findByTopicId(topicId);
verify(questionOptions).withRelations(questionsModels);
Assert.assertEquals(questionsModels, foundedQuestionsModels);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<QuestionEntity> questionsEntities = this.getQuestionsEntities();
final List<QuestionModelInterface> questionsModels = this.getQuestionsModels();
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(this.questionsMapper.findAll()).willReturn(questionsEntities);
given(questionsOptions.withRelations(Mockito.anyList())).willReturn(questionsModels);
final List<QuestionModelInterface> foundedQuestionsModels = this.questionsService.findAll(questionsOptions);
verify(questionsOptions).withRelations(questionsModels);
Assert.assertEquals(questionsModels, foundedQuestionsModels);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveEntitiesList.
@Test
public void testSaveEntitiesList() throws Exception {
final QuestionModelInterface questionModelFirst = Models.createQuestionModel(null, "Text1", 1, 1);
final QuestionModelInterface questionModelSecond = Models.createQuestionModel(null, "Text2", 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.save(questionsModels);
verify(questionsServiceSpy, times(1)).save(questionModelFirst);
verify(questionsServiceSpy, times(1)).save(questionModelSecond);
questionsServiceSpy.save(questionsModels, questionsOptions);
verify(questionsServiceSpy, times(1)).save(questionModelFirst, questionsOptions);
verify(questionsServiceSpy, times(1)).save(questionModelSecond, questionsOptions);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method mapQuestionModel.
private QuestionModelInterface mapQuestionModel(QuestionEntity questionEntity) {
final QuestionModelInterface questionModel = new QuestionModel();
questionModel.map(questionEntity);
return questionModel;
}
Aggregations