use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class SubjectsOptions method withRelations.
public SubjectModelInterface withRelations(SubjectModelInterface subjectModel) {
if (subjectModel == null) {
return subjectModel;
}
if (this.usersOptions != null) {
subjectModel.setUser(this.usersService.find(subjectModel.getUser().getId(), this.usersOptions));
}
if (this.topicsOptions != null) {
subjectModel.setTopics(this.topicsService.findBySubject(subjectModel, this.topicsOptions));
}
if (this.issueStandardsOptions != null) {
final IssueStandardModelInterface issueStandard = this.issueStandardsService.findBySubject(subjectModel, this.issueStandardsOptions);
subjectModel.setIssueStandard(issueStandard);
}
if (this.issuesOptions != null) {
subjectModel.setIssues(this.issuesService.findBySubject(subjectModel, this.issuesOptions));
}
return subjectModel;
}
use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = new IssueStandardTopicPrioritiesOptions();
final IssueStandardTopicPrioritiesServiceInterface topicPrioritiesService = Mockito.mock(IssueStandardTopicPrioritiesServiceInterface.class);
final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
final Integer issueStandardId = 10;
final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
final IssueStandardTopicPriorityModelInterface topicPriorityModel = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
Mockito.when(topicPriorityModel.getIssueStandard()).thenReturn(issueStandardModel);
topicPrioritiesOptions.setTopicPrioritiesService(topicPrioritiesService);
topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
topicPrioritiesOptions.withIssueStandard(issueStandardsOptions);
final InOrder inOrder = Mockito.inOrder(issueStandardsService, topicPrioritiesService);
topicPrioritiesOptions.deleteWithRelations(topicPriorityModel);
inOrder.verify(topicPrioritiesService).delete(topicPriorityModel);
inOrder.verify(issueStandardsService).delete(topicPriorityModel.getIssueStandard(), issueStandardsOptions);
}
use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = new IssueStandardTopicPrioritiesOptions();
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
final Integer topicId = 3;
final Integer issueStandardId = 10;
final IssueStandardTopicPriorityModelInterface topicPriorityModel = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
Mockito.when(topicPriorityModel.getTopic()).thenReturn(new TopicModelEmpty(topicId));
Mockito.when(topicPriorityModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardId));
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
Mockito.when(topicModel.getId()).thenReturn(topicId);
given(topicsService.find(topicId, topicsOptions)).willReturn(topicModel);
final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
given(issueStandardsService.find(issueStandardId, issueStandardsOptions)).willReturn(issueStandardModel);
// options не заданы
final IssueStandardTopicPriorityModelInterface topicPriorityModelWithoutRelations = topicPrioritiesOptions.withRelations(topicPriorityModel);
verify(topicsService, times(0)).find(topicId, topicsOptions);
verify(issueStandardsService, times(0)).find(issueStandardId, issueStandardsOptions);
Assert.assertEquals(topicPriorityModel, topicPriorityModelWithoutRelations);
Mockito.verify(topicPriorityModel, times(0)).setTopic(topicModel);
Mockito.verify(topicPriorityModel, times(0)).setIssueStandard(issueStandardModel);
topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
topicPrioritiesOptions.setTopicsService(topicsService);
topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
// теперь options заданы
final IssueStandardTopicPriorityModelInterface topicPriorityModelWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModel);
verify(topicsService, times(1)).find(topicId, topicsOptions);
verify(issueStandardsService, times(1)).find(issueStandardId, issueStandardsOptions);
Assert.assertEquals(topicPriorityModel, topicPriorityModelWithRelations);
Mockito.verify(topicPriorityModel, times(1)).setTopic(topicModel);
Mockito.verify(topicPriorityModel, times(1)).setIssueStandard(issueStandardModel);
}
use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
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 IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getTopicPriorities()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModel.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModel.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
// возвращаемые сервисами
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(1);
topicPriorityModels.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(1);
questionTypeOptionModels.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
given(topicPrioritiesService.findByIssueStandard(issueStandardModel, topicPrioritiesOptions)).willReturn(topicPriorityModels);
given(questionTypeOptionsService.findByIssueStandard(issueStandardModel, questionTypeOptionsOptions)).willReturn(questionTypeOptionModels);
given(subjectsService.find(subjectId, subjectsOptions)).willReturn(subjectModel);
// options не заданы
final IssueStandardModelInterface issueStandardModelWithoutRelations = issueStandardsOptions.withRelations(issueStandardModel);
verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModel, topicPrioritiesOptions);
verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModel, questionTypeOptionsOptions);
verify(subjectsService, times(0)).find(subjectId, subjectsOptions);
Assert.assertEquals(issueStandardModel, issueStandardModelWithoutRelations);
verify(issueStandardModel, times(0)).setTopicPriorities(topicPriorityModels);
verify(issueStandardModel, times(0)).setQuestionTypeOptions(questionTypeOptionModels);
verify(issueStandardModel, times(0)).setSubject(subjectModel);
issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
issueStandardsOptions.setSubjectsService(subjectsService);
issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
// теперь options заданы
final IssueStandardModelInterface issueStandardModelWithRelations = issueStandardsOptions.withRelations(issueStandardModel);
verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModel, topicPrioritiesOptions);
verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModel, questionTypeOptionsOptions);
verify(subjectsService, times(1)).find(subjectId, subjectsOptions);
Assert.assertEquals(issueStandardModel, issueStandardModelWithRelations);
verify(issueStandardModel, times(1)).setTopicPriorities(topicPriorityModels);
verify(issueStandardModel, times(1)).setQuestionTypeOptions(questionTypeOptionModels);
verify(issueStandardModel, times(1)).setSubject(subjectModel);
}
use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
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 subjectIdFirst = 3;
final Integer subjectIdSecond = 5;
// модели в начале
final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModelFirst.getTopicPriorities()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModelFirst.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModelFirst.getSubject()).thenReturn(new SubjectModelEmpty(subjectIdFirst));
final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModelSecond.getTopicPriorities()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModelSecond.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
Mockito.when(issueStandardModelSecond.getSubject()).thenReturn(new SubjectModelEmpty(subjectIdSecond));
final List<IssueStandardModelInterface> issueStandardModels = new ArrayList<>(2);
issueStandardModels.add(issueStandardModelFirst);
issueStandardModels.add(issueStandardModelSecond);
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsFirst = new ArrayList<>(1);
topicPriorityModelsFirst.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsSecond = new ArrayList<>(1);
topicPriorityModelsSecond.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
given(topicPrioritiesService.findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions)).willReturn(topicPriorityModelsFirst);
given(topicPrioritiesService.findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions)).willReturn(topicPriorityModelsSecond);
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsFirst = new ArrayList<>(1);
questionTypeOptionModelsFirst.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsSecond = new ArrayList<>(1);
questionTypeOptionModelsSecond.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
given(questionTypeOptionsService.findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions)).willReturn(questionTypeOptionModelsFirst);
given(questionTypeOptionsService.findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions)).willReturn(questionTypeOptionModelsSecond);
final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
Mockito.when(subjectModelFirst.getId()).thenReturn(subjectIdFirst);
final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
Mockito.when(subjectModelSecond.getId()).thenReturn(subjectIdSecond);
given(subjectsService.find(subjectIdFirst, subjectsOptions)).willReturn(subjectModelFirst);
given(subjectsService.find(subjectIdSecond, subjectsOptions)).willReturn(subjectModelSecond);
// options не заданы
List<IssueStandardModelInterface> issueStandardModelsWithoutRelations = issueStandardsOptions.withRelations(issueStandardModels);
verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions);
verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions);
verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions);
verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions);
verify(subjectsService, times(0)).find(subjectIdFirst, subjectsOptions);
verify(subjectsService, times(0)).find(subjectIdSecond, subjectsOptions);
Assert.assertEquals(issueStandardModels, issueStandardModelsWithoutRelations);
verify(issueStandardModelFirst, times(0)).setTopicPriorities(topicPriorityModelsFirst);
verify(issueStandardModelFirst, times(0)).setQuestionTypeOptions(questionTypeOptionModelsFirst);
verify(issueStandardModelFirst, times(0)).setSubject(subjectModelFirst);
verify(issueStandardModelSecond, times(0)).setTopicPriorities(topicPriorityModelsSecond);
verify(issueStandardModelSecond, times(0)).setQuestionTypeOptions(questionTypeOptionModelsSecond);
verify(issueStandardModelSecond, times(0)).setSubject(subjectModelSecond);
issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
issueStandardsOptions.setSubjectsService(subjectsService);
issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
// теперь options заданы
List<IssueStandardModelInterface> issueStandardModelsWithRelations = issueStandardsOptions.withRelations(issueStandardModels);
verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions);
verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions);
verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions);
verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions);
verify(subjectsService, times(1)).find(subjectIdFirst, subjectsOptions);
verify(subjectsService, times(1)).find(subjectIdSecond, subjectsOptions);
Assert.assertEquals(issueStandardModels, issueStandardModelsWithRelations);
verify(issueStandardModelFirst, times(1)).setTopicPriorities(topicPriorityModelsFirst);
verify(issueStandardModelFirst, times(1)).setQuestionTypeOptions(questionTypeOptionModelsFirst);
verify(issueStandardModelFirst, times(1)).setSubject(subjectModelFirst);
verify(issueStandardModelSecond, times(1)).setTopicPriorities(topicPriorityModelsSecond);
verify(issueStandardModelSecond, times(1)).setQuestionTypeOptions(questionTypeOptionModelsSecond);
verify(issueStandardModelSecond, times(1)).setSubject(subjectModelSecond);
}
Aggregations