use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubjectAbsentList.
@Test
public void testFindBySubjectAbsentList() throws Exception {
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(new ArrayList<>(0));
final List<TopicModelInterface> topicFoundedModels = this.topicsService.findBySubject(subjectModel);
Assert.assertNotNull(topicFoundedModels);
Assert.assertEquals(0, topicFoundedModels.size());
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubjectWithOptions.
@Test
public void testFindBySubjectWithOptions() throws Exception {
final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(topicsEntities);
when(topicOptions.withRelations(listCaptor.capture())).thenReturn(topicsModels);
final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findBySubject(subjectModel, topicOptions);
this.topicsSupport.assertModelsListEquals(topicsModels, listCaptor.getValue());
Assert.assertSame(topicsModels, topicsFoundedModels);
this.assertServicesSet(topicOptions);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class IssueStandardOptionsTest method testSaveWithRelations.
@Test
public void testSaveWithRelations() throws Exception {
final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
final IssueStandardTopicPrioritiesServiceInterface topicPrioritiesService = Mockito.mock(IssueStandardTopicPrioritiesServiceInterface.class);
final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = Mockito.mock(IssueStandardTopicPrioritiesOptionsInterface.class);
final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.class);
final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getTopicPriorities()).thenReturn(new ArrayList<>());
Mockito.when(issueStandardModel.getQuestionTypeOptions()).thenReturn(new ArrayList<>());
Mockito.when(issueStandardModel.getSubject()).thenReturn(subjectModel);
issueStandardsOptions.setIssueStandardsService(issueStandardsService);
issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
issueStandardsOptions.setSubjectsService(subjectsService);
issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
final InOrder inOrder = Mockito.inOrder(subjectsService, issueStandardsService, topicPrioritiesService, questionTypeOptionsService);
issueStandardsOptions.saveWithRelations(issueStandardModel);
inOrder.verify(subjectsService, times(1)).save(issueStandardModel.getSubject(), subjectsOptions);
inOrder.verify(issueStandardsService, times(1)).save(issueStandardModel);
inOrder.verify(topicPrioritiesService, times(1)).save(issueStandardModel.getTopicPriorities(), topicPrioritiesOptions);
inOrder.verify(questionTypeOptionsService, times(1)).save(issueStandardModel.getQuestionTypeOptions(), questionTypeOptionsOptions);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class IssuesOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final IssueModelInterface issueModelFirst = Mockito.mock(IssueModelInterface.class);
issueModelFirst.setId(1);
given(issueModelFirst.getSubject()).willReturn(new SubjectModelEmpty(1));
final IssueModelInterface issueModelSecond = Mockito.mock(IssueModelInterface.class);
issueModelSecond.setId(2);
given(issueModelSecond.getSubject()).willReturn(new SubjectModelEmpty(2));
final List<IssueModelInterface> issuesModels = new ArrayList<>(2);
issuesModels.add(issueModelFirst);
issuesModels.add(issueModelSecond);
final IssuesOptionsInterface issuesOptions = new IssuesOptions();
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
issuesOptions.setSubjectsService(subjectsService);
issuesOptions.setQuizzesService(quizzesService);
issuesOptions.withSubject(subjectsOptions);
issuesOptions.withQuizzes(quizzesOptions);
final List<QuizModelInterface> quizzesModelsFirst = new ArrayList<>();
quizzesModelsFirst.add(Mockito.mock(QuizModelInterface.class));
final List<QuizModelInterface> quizzesModelsSecond = new ArrayList<>();
quizzesModelsSecond.add(Mockito.mock(QuizModelInterface.class));
quizzesModelsSecond.add(Mockito.mock(QuizModelInterface.class));
given(quizzesService.findByIssue(issueModelFirst, quizzesOptions)).willReturn(quizzesModelsFirst);
given(quizzesService.findByIssue(issueModelSecond, quizzesOptions)).willReturn(quizzesModelsSecond);
final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
given(subjectsService.find(1, subjectsOptions)).willReturn(subjectModelFirst);
given(subjectsService.find(2, subjectsOptions)).willReturn(subjectModelSecond);
final List<IssueModelInterface> issuesModelsWithRelations = issuesOptions.withRelations(issuesModels);
Assert.assertEquals(issuesModelsWithRelations, issuesModels);
verify(quizzesService).findByIssue(issueModelFirst, quizzesOptions);
verify(subjectsService).find(1, subjectsOptions);
verify(issuesModels.get(0)).setQuizzes(quizzesModelsFirst);
verify(issuesModels.get(0)).setQuizzes(Mockito.anyList());
verify(issuesModels.get(0)).setSubject(subjectModelFirst);
verify(quizzesService).findByIssue(issueModelSecond, quizzesOptions);
verify(subjectsService).find(2, subjectsOptions);
verify(issuesModels.get(1)).setQuizzes(quizzesModelsSecond);
verify(issuesModels.get(1)).setQuizzes(Mockito.anyList());
verify(issuesModels.get(1)).setSubject(subjectModelSecond);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class IssuesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
issueModel.setId(1);
given(issueModel.getSubject()).willReturn(new SubjectModelEmpty(1));
final IssuesOptionsInterface issuesOptions = new IssuesOptions();
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
issuesOptions.setSubjectsService(subjectsService);
issuesOptions.setQuizzesService(quizzesService);
issuesOptions.withSubject(subjectsOptions);
issuesOptions.withQuizzes(quizzesOptions);
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<QuizModelInterface> quizzesModels = new ArrayList<>();
quizzesModels.add(Mockito.mock(QuizModelInterface.class));
given(subjectsService.find(issueModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
given(quizzesService.findByIssue(issueModel, quizzesOptions)).willReturn(quizzesModels);
final IssueModelInterface issueModelWithRelations = issuesOptions.withRelations(issueModel);
Assert.assertEquals(issueModel, issueModelWithRelations);
verify(subjectsService).find(1, subjectsOptions);
verify(quizzesService).findByIssue(issueModel, quizzesOptions);
verify(issueModel).setQuizzes(quizzesModels);
verify(issueModel).setQuizzes(Mockito.anyList());
}
Aggregations