Search in sources :

Example 6 with IssueStandardsServiceInterface

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

use of easytests.core.services.IssueStandardsServiceInterface 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);
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with IssueStandardsServiceInterface

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

the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() 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);
    topicPrioritiesOptions.setTopicsService(topicsService);
    topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
    topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = null;
    final IssueStandardTopicPriorityModelInterface topicPriorityModelWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModel);
    Assert.assertEquals(null, topicPriorityModelWithRelations);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with IssueStandardsServiceInterface

use of easytests.core.services.IssueStandardsServiceInterface 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 10 with IssueStandardsServiceInterface

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

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