Search in sources :

Example 21 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testDeleteIdentifiedModel.

@Test
public void testDeleteIdentifiedModel() throws Exception {
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(1, 3, true, 1);
    this.topicPrioritiesService.delete(topicPriorityModel);
    verify(this.topicPrioritiesMapper, times(1)).delete(this.mapTopicPriorityEntity(topicPriorityModel));
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testFindByIssueStandardPresentList.

@Test
public void testFindByIssueStandardPresentList() throws Exception {
    final Integer issueStandardId = 5;
    final List<IssueStandardTopicPriorityEntity> topicPriorityEntities = new ArrayList<>(2);
    topicPriorityEntities.add(Entities.createTopicPriorityEntityMock(1, 2, true, issueStandardId));
    topicPriorityEntities.add(Entities.createTopicPriorityEntityMock(2, 4, false, issueStandardId));
    given(this.topicPrioritiesMapper.findByIssueStandardId(issueStandardId)).willReturn(topicPriorityEntities);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = this.topicPrioritiesService.findByIssueStandard(issueStandardModel);
    Assert.assertNotNull(topicPriorityModels);
    Assert.assertEquals(topicPriorityEntities.size(), topicPriorityModels.size());
    for (int i = 0; i < topicPriorityModels.size(); i++) {
        Assert.assertEquals(topicPriorityModels.get(i), this.mapTopicPriorityModel(topicPriorityEntities.get(i)));
    }
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardTopicPriorityEntity(easytests.core.entities.IssueStandardTopicPriorityEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 23 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testSaveList.

@Test
public void testSaveList() throws Exception {
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(2);
    topicPriorityModels.add(Models.createTopicPriorityModel(1, 2, true, 3));
    topicPriorityModels.add(Models.createTopicPriorityModel(null, 3, false, 3));
    final Integer id = 10;
    doAnswer(invocations -> {
        final IssueStandardTopicPriorityEntity topicPriorityEntity = (IssueStandardTopicPriorityEntity) invocations.getArguments()[0];
        topicPriorityEntity.setId(id);
        return null;
    }).when(this.topicPrioritiesMapper).insert(Mockito.any(IssueStandardTopicPriorityEntity.class));
    this.topicPrioritiesService.save(topicPriorityModels);
    verify(this.topicPrioritiesMapper, times(1)).update(this.mapTopicPriorityEntity(topicPriorityModels.get(0)));
    verify(this.topicPrioritiesMapper, times(1)).insert(this.mapTopicPriorityEntity(topicPriorityModels.get(1)));
    Assert.assertEquals(id, topicPriorityModels.get(1).getId());
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardTopicPriorityEntity(easytests.core.entities.IssueStandardTopicPriorityEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testFindByIssueStandardAbsentList.

@Test
public void testFindByIssueStandardAbsentList() throws Exception {
    final Integer issueStandardId = 10;
    given(this.topicPrioritiesMapper.findByIssueStandardId(issueStandardId)).willReturn(new ArrayList<>(0));
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = this.topicPrioritiesService.findByIssueStandard(issueStandardModel);
    Assert.assertNotNull(topicPriorityModels);
    Assert.assertEquals(0, topicPriorityModels.size());
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testDeleteList.

@Test
public void testDeleteList() throws Exception {
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = this.getTopicPriorityModels();
    this.topicPrioritiesService.delete(topicPriorityModels);
    for (IssueStandardTopicPriorityModelInterface topicPriorityModel : topicPriorityModels) {
        verify(this.topicPrioritiesMapper, times(1)).delete(this.mapTopicPriorityEntity(topicPriorityModel));
    }
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) 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