use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testWithRelationsQuestionsOnSingleModel.
@Test
public void testWithRelationsQuestionsOnSingleModel() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setQuestionsService(questionsService);
topicsOptions.setTopicsService(topicsService);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
topicsOptions.withQuestions(questionsOptions);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
questionsModels.add(Mockito.mock(QuestionModelInterface.class));
given(questionsService.findByTopic(topicModel, questionsOptions)).willReturn(questionsModels);
final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(topicModel);
Assert.assertEquals(topicModel, topicModelWithRelations);
verify(questionsService).findByTopic(topicModel, questionsOptions);
verify(topicModel).setQuestions(questionsModels);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testDeleteWithRelationsQuestion.
@Test
public void testDeleteWithRelationsQuestion() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setQuestionsService(questionsService);
topicsOptions.setTopicsService(topicsService);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
topicsOptions.withQuestions(questionsOptions);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
topicModel.setQuestions(questionsModels);
final InOrder inOrder = Mockito.inOrder(questionsService, topicsService);
topicsOptions.deleteWithRelations(topicModel);
inOrder.verify(questionsService).save(topicModel.getQuestions(), questionsOptions);
inOrder.verify(topicsService).delete(topicModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testDeleteModelsListWithOptions.
@Test
public void testDeleteModelsListWithOptions() throws Exception {
final ArgumentCaptor<QuestionModelInterface> questionModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
this.questionsService.delete(questionsModels, questionsOptions);
this.assertServicesSet(questionsOptions, questionsModels.size());
verify(questionsOptions, times(questionsModels.size())).deleteWithRelations(questionModelCaptor.capture());
this.questionsSupport.assertModelsListEquals(questionsModels, questionModelCaptor.getAllValues());
verifyNoMoreInteractions(this.questionsMapper);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveModelsListWithOptions.
@Test
public void testSaveModelsListWithOptions() throws Exception {
final ArgumentCaptor<QuestionModelInterface> questionsModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
this.questionsService.save(questionsModels, questionsOptions);
this.assertServicesSet(questionsOptions, questionsModels.size());
verify(questionsOptions, times(questionsModels.size())).saveWithRelations(questionsModelCaptor.capture());
this.questionsSupport.assertModelsListEquals(questionsModels, questionsModelCaptor.getAllValues());
verifyNoMoreInteractions(this.questionsMapper);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsSupport method assertModelsListEquals.
public void assertModelsListEquals(List<QuestionModelInterface> expected, List<QuestionModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (QuestionModelInterface questionModel : expected) {
this.assertEquals(questionModel, actual.get(i));
i++;
}
}
Aggregations