Search in sources :

Example 26 with IssueStandardModelInterface

use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.

the class IssueStandardOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() 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);
    issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
    issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    issueStandardsOptions.setSubjectsService(subjectsService);
    issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
    final IssueStandardModelInterface issueStandardModel = null;
    final IssueStandardModelInterface issueStandardModelWithRelations = issueStandardsOptions.withRelations(issueStandardModel);
    Assert.assertEquals(null, issueStandardModelWithRelations);
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with IssueStandardModelInterface

use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.

the class IssueStandardOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() 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.deleteWithRelations(issueStandardModel);
    inOrder.verify(topicPrioritiesService, times(1)).delete(issueStandardModel.getTopicPriorities(), topicPrioritiesOptions);
    inOrder.verify(questionTypeOptionsService, times(1)).delete(issueStandardModel.getQuestionTypeOptions(), questionTypeOptionsOptions);
    inOrder.verify(issueStandardsService, times(1)).delete(issueStandardModel);
    inOrder.verify(subjectsService, times(1)).delete(issueStandardModel.getSubject(), subjectsOptions);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) InOrder(org.mockito.InOrder) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with IssueStandardModelInterface

use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final Integer questionTypeId = 3;
    final Integer issueStandardId = 10;
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModel.getQuestionType()).thenReturn(new QuestionTypeModelEmpty(questionTypeId));
    Mockito.when(questionTypeOptionModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardId));
    final QuestionTypeModelInterface questionTypeModel = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionTypeModel.getId()).thenReturn(questionTypeId);
    given(questionTypesService.find(questionTypeId, questionTypesOptions)).willReturn(questionTypeModel);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    given(issueStandardsService.find(issueStandardId, issueStandardsOptions)).willReturn(issueStandardModel);
    // options не заданы
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelWithoutRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModel);
    verify(questionTypesService, times(0)).find(questionTypeId, questionTypesOptions);
    verify(issueStandardsService, times(0)).find(issueStandardId, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModel, questionTypeOptionModelWithoutRelations);
    Mockito.verify(questionTypeOptionModel, times(0)).setQuestionType(questionTypeModel);
    Mockito.verify(questionTypeOptionModel, times(0)).setIssueStandard(issueStandardModel);
    questionTypeOptionsOptions.setQuestionTypesService(questionTypesService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withQuestionType(questionTypesOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelWithRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModel);
    verify(questionTypesService, times(1)).find(questionTypeId, questionTypesOptions);
    verify(issueStandardsService, times(1)).find(issueStandardId, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModel, questionTypeOptionModelWithRelations);
    Mockito.verify(questionTypeOptionModel, times(1)).setQuestionType(questionTypeModel);
    Mockito.verify(questionTypeOptionModel, times(1)).setIssueStandard(issueStandardModel);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with IssueStandardModelInterface

use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsServiceTest method testFindByIssueStandardAbsentList.

@Test
public void testFindByIssueStandardAbsentList() throws Exception {
    final Integer issueStandardId = 10;
    given(this.questionTypeOptionsMapper.findByIssueStandardId(issueStandardId)).willReturn(new ArrayList<>(0));
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = this.questionTypeOptionsService.findByIssueStandard(issueStandardModel);
    Assert.assertNotNull(questionTypeOptionModels);
    Assert.assertEquals(0, questionTypeOptionModels.size());
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with IssueStandardModelInterface

use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final Integer issueStandardIdFirst = 10;
    final Integer issueStandardIdSecond = 20;
    final Integer questionTypeIdFirst = 2;
    final Integer questionTypeIdSecond = 3;
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelFirst = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModelFirst.getQuestionType()).thenReturn(new QuestionTypeModelEmpty(questionTypeIdFirst));
    Mockito.when(questionTypeOptionModelFirst.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdFirst));
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelSecond = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModelSecond.getQuestionType()).thenReturn(new QuestionTypeModelEmpty(questionTypeIdSecond));
    Mockito.when(questionTypeOptionModelSecond.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdSecond));
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
    questionTypeOptionModels.add(questionTypeOptionModelFirst);
    questionTypeOptionModels.add(questionTypeOptionModelSecond);
    final QuestionTypeModelInterface questionTypeModelFirst = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionTypeModelFirst.getId()).thenReturn(questionTypeIdFirst);
    given(questionTypesService.find(questionTypeIdFirst, questionTypesOptions)).willReturn(questionTypeModelFirst);
    final QuestionTypeModelInterface questionTypeModelSecond = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionTypeModelSecond.getId()).thenReturn(questionTypeIdSecond);
    given(questionTypesService.find(questionTypeIdSecond, questionTypesOptions)).willReturn(questionTypeModelSecond);
    final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelFirst.getId()).thenReturn(issueStandardIdFirst);
    given(issueStandardsService.find(issueStandardIdFirst, issueStandardsOptions)).willReturn(issueStandardModelFirst);
    final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelSecond.getId()).thenReturn(issueStandardIdSecond);
    given(issueStandardsService.find(issueStandardIdSecond, issueStandardsOptions)).willReturn(issueStandardModelSecond);
    // options не заданы
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsWithoutRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModels);
    verify(questionTypesService, times(0)).find(questionTypeIdFirst, questionTypesOptions);
    verify(questionTypesService, times(0)).find(questionTypeIdSecond, questionTypesOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModels, questionTypeOptionModelsWithoutRelations);
    Mockito.verify(questionTypeOptionModelFirst, times(0)).setQuestionType(questionTypeModelFirst);
    Mockito.verify(questionTypeOptionModelFirst, times(0)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(questionTypeOptionModelSecond, times(0)).setQuestionType(questionTypeModelSecond);
    Mockito.verify(questionTypeOptionModelSecond, times(0)).setIssueStandard(issueStandardModelSecond);
    questionTypeOptionsOptions.setQuestionTypesService(questionTypesService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withQuestionType(questionTypesOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsWithRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModels);
    verify(questionTypesService, times(1)).find(questionTypeIdFirst, questionTypesOptions);
    verify(questionTypesService, times(1)).find(questionTypeIdSecond, questionTypesOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModels, questionTypeOptionModelsWithRelations);
    Mockito.verify(questionTypeOptionModelFirst, times(1)).setQuestionType(questionTypeModelFirst);
    Mockito.verify(questionTypeOptionModelFirst, times(1)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(questionTypeOptionModelSecond, times(1)).setQuestionType(questionTypeModelSecond);
    Mockito.verify(questionTypeOptionModelSecond, times(1)).setIssueStandard(issueStandardModelSecond);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) ArrayList(java.util.ArrayList) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)30 Test (org.junit.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)24 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)10 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)9 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)9 SubjectModelInterface (easytests.core.models.SubjectModelInterface)7 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)7 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)7 ArrayList (java.util.ArrayList)6 InOrder (org.mockito.InOrder)6 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)5 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)4 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)4 IssueStandardsOptions (easytests.core.options.IssueStandardsOptions)3 IssueStandardModel (easytests.core.models.IssueStandardModel)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 SubjectModel (easytests.core.models.SubjectModel)2 TopicModelInterface (easytests.core.models.TopicModelInterface)2