Search in sources :

Example 11 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testSaveInsertsModel.

@Test
public void testSaveInsertsModel() throws Exception {
    final Integer id = this.topicPrioritiesService.findAll().size() + 1;
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(null, 4, true, 4);
    this.topicPrioritiesService.save(topicPriorityModel);
    final IssueStandardTopicPriorityModelInterface foundedTopicPriorityModel = this.topicPrioritiesService.find(id);
    Assert.assertEquals(topicPriorityModel, foundedTopicPriorityModel);
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testSaveUpdatesModel.

@Test
public void testSaveUpdatesModel() throws Exception {
    final Integer id = 1;
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(id, 1, false, 1);
    Assert.assertNotEquals(topicPriorityModel, this.topicPrioritiesService.find(id));
    this.topicPrioritiesService.save(topicPriorityModel);
    Assert.assertEquals(topicPriorityModel, this.topicPrioritiesService.find(id));
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    final IssueStandardTopicPriorityModelInterface foundedIopicPriorityModel = this.topicPrioritiesService.find(id);
    Assert.assertNull(foundedIopicPriorityModel);
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPriorityEntityTest method testMap.

@Test
public void testMap() {
    final Integer id = 5;
    final Integer topicId = 2;
    final Boolean isPreferable = true;
    final Integer issueStandardId = 1;
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    Mockito.when(topicPriorityModel.getId()).thenReturn(id);
    Mockito.when(topicPriorityModel.getTopic()).thenReturn(new TopicModelEmpty(topicId));
    Mockito.when(topicPriorityModel.getIsPreferable()).thenReturn(isPreferable);
    Mockito.when(topicPriorityModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardId));
    final IssueStandardTopicPriorityEntity topicPriorityEntity = new IssueStandardTopicPriorityEntity();
    topicPriorityEntity.map(topicPriorityModel);
    Assert.assertEquals(id, topicPriorityEntity.getId());
    Assert.assertEquals(topicId, topicPriorityEntity.getTopicId());
    Assert.assertEquals(isPreferable, topicPriorityEntity.getIsPreferable());
    Assert.assertEquals(issueStandardId, topicPriorityEntity.getIssueStandardId());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test)

Example 15 with IssueStandardTopicPriorityModelInterface

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

IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)33 Test (org.junit.Test)30 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)29 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)9 IssueStandardTopicPriorityEntity (easytests.core.entities.IssueStandardTopicPriorityEntity)7 IssueStandardTopicPrioritiesOptionsInterface (easytests.core.options.IssueStandardTopicPrioritiesOptionsInterface)7 ArrayList (java.util.ArrayList)7 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)5 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)4 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)3 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)3 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)2 IssueStandardTopicPriorityModel (easytests.core.models.IssueStandardTopicPriorityModel)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 TopicModelInterface (easytests.core.models.TopicModelInterface)2 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)2 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)2 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)2 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)2