Search in sources :

Example 11 with TopicModelInterface

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

the class TopicsServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
    final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
    this.topicsService.delete(topicModel, topicOptions);
    verify(topicOptions, times(1)).deleteWithRelations(topicModel);
    this.assertServicesSet(topicOptions);
    verifyNoMoreInteractions(this.topicsMapper);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with TopicModelInterface

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

the class TopicsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<TopicModelInterface> topicModelCaptor = ArgumentCaptor.forClass(TopicModelInterface.class);
    final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
    final TopicsOptionsInterface topicsOptions = mock(TopicsOptionsInterface.class);
    this.topicsService.delete(topicsModels, topicsOptions);
    this.assertServicesSet(topicsOptions, topicsModels.size());
    verify(topicsOptions, times(topicsModels.size())).deleteWithRelations(topicModelCaptor.capture());
    this.topicsSupport.assertModelsListEquals(topicsModels, topicModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.topicsMapper);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with TopicModelInterface

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

the class TopicsServiceTest method testDeleteUnidentifiedModelThrowsException.

@Test
public void testDeleteUnidentifiedModelThrowsException() throws Exception {
    final TopicModelInterface topicModel = this.topicsSupport.getModelAdditionalMock(0);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.topicsService.delete(topicModel);
}
Also used : TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with TopicModelInterface

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

the class TopicsServiceTest method testSaveWithOptions.

@Test
public void testSaveWithOptions() throws Exception {
    final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
    final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
    this.topicsService.save(topicModel, topicOptions);
    verify(topicOptions, times(1)).saveWithRelations(topicModel);
    this.assertServicesSet(topicOptions);
    verifyNoMoreInteractions(this.topicsMapper);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with TopicModelInterface

use of easytests.core.models.TopicModelInterface 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)

Aggregations

TopicModelInterface (easytests.core.models.TopicModelInterface)52 Test (org.junit.Test)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)32 SubjectModelInterface (easytests.core.models.SubjectModelInterface)18 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)16 ArrayList (java.util.ArrayList)15 QuestionModelInterface (easytests.core.models.QuestionModelInterface)14 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)9 TopicEntity (easytests.core.entities.TopicEntity)8 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)7 InOrder (org.mockito.InOrder)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 AnswerModelInterface (easytests.core.models.AnswerModelInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)4 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 QuestionEntity (easytests.core.entities.QuestionEntity)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 SubjectModel (easytests.core.models.SubjectModel)3 TopicModel (easytests.core.models.TopicModel)3