Search in sources :

Example 1 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface in project easy-tests by malinink.

the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() 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 topicIdFirst = 3;
    final Integer topicIdSecond = 5;
    final Integer issueStandardIdFirst = 10;
    final Integer issueStandardIdSecond = 20;
    IssueStandardTopicPriorityModelInterface topicPriorityModelFirst = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    IssueStandardTopicPriorityModelInterface topicPriorityModelSecond = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    Mockito.when(topicPriorityModelFirst.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdFirst));
    Mockito.when(topicPriorityModelFirst.getTopic()).thenReturn(new TopicModelEmpty(topicIdFirst));
    Mockito.when(topicPriorityModelSecond.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdSecond));
    Mockito.when(topicPriorityModelSecond.getTopic()).thenReturn(new TopicModelEmpty(topicIdSecond));
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(2);
    topicPriorityModels.add(topicPriorityModelFirst);
    topicPriorityModels.add(topicPriorityModelSecond);
    final TopicModelInterface topicModelFirst = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelFirst.getId()).thenReturn(topicIdFirst);
    given(topicsService.find(topicIdFirst, topicsOptions)).willReturn(topicModelFirst);
    final TopicModelInterface topicModelSecond = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelSecond.getId()).thenReturn(topicIdSecond);
    given(topicsService.find(topicIdSecond, topicsOptions)).willReturn(topicModelSecond);
    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<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithoutRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
    verify(topicsService, times(0)).find(topicIdFirst, topicsOptions);
    verify(topicsService, times(0)).find(topicIdSecond, topicsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithoutRelations);
    Mockito.verify(topicPriorityModelFirst, times(0)).setTopic(topicModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(0)).setTopic(topicModelSecond);
    Mockito.verify(topicPriorityModelFirst, times(0)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(0)).setIssueStandard(issueStandardModelSecond);
    topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
    topicPrioritiesOptions.setTopicsService(topicsService);
    topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
    verify(topicsService, times(1)).find(topicIdFirst, topicsOptions);
    verify(topicsService, times(1)).find(topicIdSecond, topicsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithRelations);
    Mockito.verify(topicPriorityModelFirst, times(1)).setTopic(topicModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(1)).setTopic(topicModelSecond);
    Mockito.verify(topicPriorityModelFirst, times(1)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(1)).setIssueStandard(issueStandardModelSecond);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface in project easy-tests by malinink.

the class IssueStandardTopicPrioritiesOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() 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.saveWithRelations(topicPriorityModel);
    inOrder.verify(issueStandardsService).save(topicPriorityModel.getIssueStandard(), issueStandardsOptions);
    inOrder.verify(topicPrioritiesService).save(topicPriorityModel);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) InOrder(org.mockito.InOrder) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.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 IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModel.getIssueStandard()).thenReturn(issueStandardModel);
    questionTypeOptionsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withIssueStandard(issueStandardsOptions);
    final InOrder inOrder = Mockito.inOrder(issueStandardsService, questionTypeOptionsService);
    questionTypeOptionsOptions.saveWithRelations(questionTypeOptionModel);
    inOrder.verify(issueStandardsService).save(questionTypeOptionModel.getIssueStandard(), issueStandardsOptions);
    inOrder.verify(questionTypeOptionsService).save(questionTypeOptionModel);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) InOrder(org.mockito.InOrder) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.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 IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModel.getIssueStandard()).thenReturn(issueStandardModel);
    questionTypeOptionsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withIssueStandard(issueStandardsOptions);
    final InOrder inOrder = Mockito.inOrder(issueStandardsService, questionTypeOptionsService);
    questionTypeOptionsOptions.deleteWithRelations(questionTypeOptionModel);
    inOrder.verify(questionTypeOptionsService).delete(questionTypeOptionModel);
    inOrder.verify(issueStandardsService).delete(questionTypeOptionModel.getIssueStandard(), issueStandardsOptions);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) InOrder(org.mockito.InOrder) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface 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);
}
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)

Aggregations

IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)12 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)10 InOrder (org.mockito.InOrder)6 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)5 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)5 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)4 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)4 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)4 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 TopicModelInterface (easytests.core.models.TopicModelInterface)2 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)2 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)2 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)2 ArrayList (java.util.ArrayList)2