Search in sources :

Example 11 with TopicsServiceInterface

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

the class TopicsOptionsTest method testSaveWithRelationsQuestions.

@Test
public void testSaveWithRelationsQuestions() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setQuestionsService(questionsService);
    topicsOptions.setTopicsService(topicsService);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    topicsOptions.withQuestions(questionsOptions);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    topicModel.setQuestions(questionsModels);
    final InOrder inOrder = Mockito.inOrder(topicsService, questionsService);
    topicsOptions.saveWithRelations(topicModel);
    inOrder.verify(topicsService).save(topicModel);
    inOrder.verify(questionsService).save(topicModel.getQuestions(), questionsOptions);
}
Also used : InOrder(org.mockito.InOrder) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with TopicsServiceInterface

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

the class TopicsOptionsTest method testSaveDeleteWithRelationsQuestion.

@Test
public void testSaveDeleteWithRelationsQuestion() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setQuestionsService(questionsService);
    topicsOptions.setTopicsService(topicsService);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    topicsOptions.withQuestions(questionsOptions);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    topicModel.setQuestions(questionsModels);
    topicsOptions.saveWithRelations((topicModel));
    verify(topicsService).save(topicModel);
    topicsOptions.deleteWithRelations(topicModel);
    verify(topicsService).delete(topicModel);
    verify(questionsService, times(2)).save(topicModel.getQuestions(), questionsOptions);
}
Also used : QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with TopicsServiceInterface

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

the class TopicsOptionsTest method testSaveDeleteWithRelationsSubject.

@Test
public void testSaveDeleteWithRelationsSubject() {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelId);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setSubjectsService(subjectsService);
    topicsOptions.setTopicsService(topicsService);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    topicsOptions.withSubject(subjectsOptions);
    final SubjectModelInterface subjectModel = new SubjectModel();
    topicModel.setSubject(subjectModel);
    topicsOptions.saveWithRelations(topicModel);
    verify(topicsService).save(topicModel);
    topicsOptions.deleteWithRelations(topicModel);
    verify(topicsService).delete(topicModel);
    verify(subjectsService, times(2)).save(topicModel.getSubject(), subjectsOptions);
}
Also used : SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with TopicsServiceInterface

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

the class TopicsOptionsTest method testSaveWithRelationsSubject.

@Test
public void testSaveWithRelationsSubject() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
    given(topicModel.getSubject()).willReturn(subjectModelId);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setSubjectsService(subjectsService);
    topicsOptions.setTopicsService(topicsService);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    topicsOptions.withSubject(subjectsOptions);
    final SubjectModelInterface subjectModel = new SubjectModel();
    topicModel.setSubject(subjectModel);
    final InOrder inOrder = Mockito.inOrder(subjectsService, topicsService);
    topicsOptions.saveWithRelations(topicModel);
    inOrder.verify(subjectsService).save(topicModel.getSubject(), subjectsOptions);
    inOrder.verify(topicsService).save(topicModel);
}
Also used : InOrder(org.mockito.InOrder) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with TopicsServiceInterface

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

Aggregations

TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)18 Test (org.junit.Test)18 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 TopicModelInterface (easytests.core.models.TopicModelInterface)16 ArrayList (java.util.ArrayList)11 QuestionModelInterface (easytests.core.models.QuestionModelInterface)10 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)7 InOrder (org.mockito.InOrder)6 SubjectModelInterface (easytests.core.models.SubjectModelInterface)5 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 AnswerModelInterface (easytests.core.models.AnswerModelInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)4 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)3 SubjectModel (easytests.core.models.SubjectModel)3 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)3 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)2