use of easytests.core.models.TopicModelInterface 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.TopicModelInterface 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.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testWithRelationsSubjectOnSingleModel.
@Test
public void testWithRelationsSubjectOnSingleModel() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.setTopicsService(topicsService);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.withSubject(subjectsOptions);
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelWithId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelWithId);
given(subjectsService.find(topicModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(topicModel);
Assert.assertEquals(topicModel, topicModelWithRelations);
subjectsService.find(1, subjectsOptions);
verify(topicModel).setSubject(subjectModel);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindAbsentModel.
@Test
public void testFindAbsentModel() throws Exception {
final Integer absentId = 7;
when(this.topicsMapper.find(absentId)).thenReturn(null);
final TopicModelInterface topicFoundedModel = this.topicsService.find(absentId);
Assert.assertNull(topicFoundedModel);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubjectPresentList.
@Test
public void testFindBySubjectPresentList() throws Exception {
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(topicsEntities);
final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findBySubject(subjectModel);
this.topicsSupport.assertModelsListEquals(this.getTopicsFixturesModels(), topicsFoundedModels);
}
Aggregations