Search in sources :

Example 16 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() 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.saveWithRelations(topicPriorityModel);
    inOrder.verify(issueStandardsService).save(topicPriorityModel.getIssueStandard(), issueStandardsOptions);
    inOrder.verify(topicPrioritiesService).save(topicPriorityModel);
}
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 17 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesService method map.

private IssueStandardTopicPriorityModelInterface map(IssueStandardTopicPriorityEntity topicPriorityEntity) {
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = new IssueStandardTopicPriorityModel();
    topicPriorityModel.map(topicPriorityEntity);
    return topicPriorityModel;
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardTopicPriorityModel(easytests.core.models.IssueStandardTopicPriorityModel)

Example 18 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardDtoValidator method validateTopicPriorityDtoIdBelongsToIssueStandard.

private void validateTopicPriorityDtoIdBelongsToIssueStandard(Errors errors, IssueStandardDto issueStandardDto) {
    final List<IssueStandardTopicPriorityModelInterface> tpModels = this.topicPrioritiesService.findByIssueStandard(new IssueStandardModelEmpty(issueStandardDto.getId()));
    final List<Integer> tpModelIds = new ArrayList<>(tpModels.size());
    tpModelIds.addAll(tpModels.stream().map(IdentityInterface::getId).collect(Collectors.toList()));
    int index = 0;
    for (IssueStandardTopicPriorityDto tpDto : issueStandardDto.getTopicPriorities()) {
        if (tpDto.getId() != null && !tpModelIds.contains(tpDto.getId())) {
            reject(errors, tpField(index, "id"), "Foreign topicPriority id for IssueStandard entity");
        }
        index++;
    }
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) ArrayList(java.util.ArrayList) IdentityInterface(easytests.core.models.IdentityInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) IssueStandardTopicPriorityDto(easytests.personal.dto.IssueStandardTopicPriorityDto)

Example 19 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer issueStandardId = 1;
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Models.createTopicPriorityModel(id, 1, true, issueStandardId);
    final IssueStandardModelInterface issueStandardModel = Models.createIssueStandardModel(issueStandardId, 300, 30, 1);
    topicPriorityModel.setIssueStandard(issueStandardModel);
    final IssueStandardTopicPriorityModelInterface foundedTopicPriorityModel = this.topicPrioritiesService.find(id, new IssueStandardTopicPrioritiesOptions().withIssueStandard(new IssueStandardsOptions()));
    Assert.assertEquals(topicPriorityModel, foundedTopicPriorityModel);
    Assert.assertEquals(issueStandardModel, foundedTopicPriorityModel.getIssueStandard());
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardTopicPrioritiesOptions(easytests.core.options.IssueStandardTopicPrioritiesOptions) IssueStandardsOptions(easytests.core.options.IssueStandardsOptions) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with IssueStandardTopicPriorityModelInterface

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

the class IssueStandardTopicPrioritiesServiceTest method testDeleteListWithOptions.

@Test
public void testDeleteListWithOptions() throws Exception {
    final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = Mockito.mock(IssueStandardTopicPrioritiesOptionsInterface.class);
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = this.getTopicPriorityModels();
    this.topicPrioritiesService.delete(topicPriorityModels, topicPrioritiesOptions);
    for (IssueStandardTopicPriorityModelInterface topicPriorityModel : topicPriorityModels) {
        verify(topicPrioritiesOptions).deleteWithRelations(topicPriorityModel);
    }
}
Also used : IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardTopicPrioritiesOptionsInterface(easytests.core.options.IssueStandardTopicPrioritiesOptionsInterface) 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