Search in sources :

Example 26 with IdmContractSliceDto

use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.

the class ContractSliceManagerTest method externeFilterTest.

@Test
public void externeFilterTest() {
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identity2 = helper.createIdentity();
    IdmTreeNodeDto node = helper.createTreeNode();
    IdmTreeNodeDto node2 = helper.createTreeNode();
    IdmContractSliceDto slice = helper.createContractSlice(identity, node, null, null, null);
    IdmContractSliceDto slice2 = helper.createContractSlice(identity2, node2, null, null, null);
    slice.setExterne(true);
    contractSliceService.save(slice);
    slice2.setExterne(false);
    contractSliceService.save(slice2);
    IdmContractSliceFilter filter = new IdmContractSliceFilter();
    filter.setExterne(true);
    Page<IdmContractSliceDto> result = contractSliceService.find(filter, null);
    assertTrue(result.getContent().contains(slice));
    assertFalse(result.getContent().contains(slice2));
    filter.setExterne(false);
    result = contractSliceService.find(filter, null);
    assertTrue(result.getContent().contains(slice2));
    assertFalse(result.getContent().contains(slice));
}
Also used : IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with IdmContractSliceDto

use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.

the class ContractSliceManagerTest method createSliceValidFromSameDateAsSomeExisting.

@Test
public void createSliceValidFromSameDateAsSomeExisting() {
    IdmIdentityDto identity = helper.createIdentity();
    String contractCode = "contract-three";
    LocalDate now = LocalDate.now();
    IdmContractSliceDto sliceCurrent = helper.createContractSlice(identity, contractCode, null, now, now, now.plusDays(200));
    IdmContractSliceDto sliceCurrentNew = helper.createContractSlice(identity, contractCode, null, now, now, now.plusDays(50));
    IdmContractSliceFilter filter = new IdmContractSliceFilter();
    filter.setIdentity(identity.getId());
    List<IdmContractSliceDto> results = contractSliceService.find(filter, null).getContent();
    assertEquals(2, results.size());
    UUID parentContract = results.get(0).getParentContract();
    List<IdmContractSliceDto> slices = contractSliceManager.findAllSlices(parentContract);
    assertEquals(2, slices.size());
    IdmContractSliceDto validSlice = contractSliceManager.findValidSlice(parentContract);
    // Valid slice should be currentSliceNew
    assertEquals(sliceCurrentNew, validSlice);
    IdmContractSliceDto previousSlice = contractSliceManager.findPreviousSlice(validSlice, slices);
    // Previous slice should be sliceCurrent with longer validity
    assertEquals(sliceCurrent, previousSlice);
    assertNotNull(previousSlice.getValidTill());
    // Check created contract by that slice
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setIdentity(identity.getId());
    List<IdmIdentityContractDto> resultsContract = // 
    contractService.find(filter, null).getContent().stream().filter(// 
    c -> contractService.get(c.getId()).getControlledBySlices()).collect(Collectors.toList());
    assertEquals(1, resultsContract.size());
    // Current slice should be contract
    IdmIdentityContractDto contract = resultsContract.get(0);
    assertTrue(contract.isValid());
    assertEquals(sliceCurrentNew.getContractValidFrom(), contract.getValidFrom());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) ContractSliceEventType(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent.ContractSliceEventType) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ClearDirtyStateForContractSliceTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ClearDirtyStateForContractSliceTaskExecutor) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) BigDecimal(java.math.BigDecimal) Map(java.util.Map) After(org.junit.After) ContractSliceConfiguration(eu.bcvsolutions.idm.core.api.config.domain.ContractSliceConfiguration) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) ImmutableMap(com.google.common.collect.ImmutableMap) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) SelectCurrentContractSliceTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.SelectCurrentContractSliceTaskExecutor) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractSliceService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceService) HashMap(java.util.HashMap) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) Lists(com.google.common.collect.Lists) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmContractSliceGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceGuaranteeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmLongRunningTaskService(eu.bcvsolutions.idm.core.scheduler.api.service.IdmLongRunningTaskService) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) IdmContractSlice(eu.bcvsolutions.idm.core.model.entity.IdmContractSlice) LongRunningTaskManager(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Assert.assertNull(org.junit.Assert.assertNull) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) ContractSliceManager(eu.bcvsolutions.idm.core.api.service.ContractSliceManager) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) LocalDate(java.time.LocalDate) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 28 with IdmContractSliceDto

use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.

the class ContractSliceManagerTest method createSliceValidInPastTest.

@Test
public void createSliceValidInPastTest() {
    IdmIdentityDto identity = helper.createIdentity();
    String contractCode = "contract-one";
    IdmContractSliceDto slice = helper.createContractSlice(identity, null, LocalDate.now().minusDays(10), null, LocalDate.now().minusDays(5));
    slice.setContractCode(contractCode);
    contractSliceService.save(slice);
    IdmContractSliceFilter filter = new IdmContractSliceFilter();
    filter.setIdentity(identity.getId());
    List<IdmContractSliceDto> results = contractSliceService.find(filter, null).getContent();
    assertEquals(1, results.size());
    IdmContractSliceDto createdSlice = results.get(0);
    assertTrue(createdSlice.isValid());
    assertEquals(null, createdSlice.getValidTill());
    // Check created contract by that slice
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setIdentity(identity.getId());
    List<IdmIdentityContractDto> resultsContract = // 
    contractService.find(filter, null).getContent().stream().filter(// 
    c -> contractService.get(c.getId()).getControlledBySlices()).collect(Collectors.toList());
    // 
    assertEquals(1, resultsContract.size());
    IdmIdentityContractDto contract = resultsContract.get(0);
    assertEquals(slice.getContractValidFrom(), contract.getValidFrom());
    assertEquals(slice.getContractValidTill(), contract.getValidTill());
    assertFalse(contract.isValidNowOrInFuture());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) ContractSliceEventType(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent.ContractSliceEventType) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ClearDirtyStateForContractSliceTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ClearDirtyStateForContractSliceTaskExecutor) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) BigDecimal(java.math.BigDecimal) Map(java.util.Map) After(org.junit.After) ContractSliceConfiguration(eu.bcvsolutions.idm.core.api.config.domain.ContractSliceConfiguration) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) ImmutableMap(com.google.common.collect.ImmutableMap) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) SelectCurrentContractSliceTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.SelectCurrentContractSliceTaskExecutor) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractSliceService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceService) HashMap(java.util.HashMap) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) Lists(com.google.common.collect.Lists) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmContractSliceGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceGuaranteeService) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmLongRunningTaskService(eu.bcvsolutions.idm.core.scheduler.api.service.IdmLongRunningTaskService) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) IdmContractSlice(eu.bcvsolutions.idm.core.model.entity.IdmContractSlice) LongRunningTaskManager(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Assert.assertNull(org.junit.Assert.assertNull) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) ContractSliceManager(eu.bcvsolutions.idm.core.api.service.ContractSliceManager) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmContractSliceDto

use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.

the class ContractSliceManagerTest method contractValidityProtectionModeEnabledTest.

@Test
public void contractValidityProtectionModeEnabledTest() {
    // Enable protection mode (5 days, gap is 5 days)
    configurationService.setValue(ContractSliceConfiguration.PROPERTY_PROTECTION_INTERVAL, "5");
    IdmIdentityDto identity = helper.createIdentity();
    IdmContractSliceDto sliceOne = helper.createContractSlice(identity, "11", null, LocalDate.now().minusDays(100), LocalDate.now().minusDays(100), LocalDate.now().plusDays(5));
    IdmContractSliceDto sliceTwo = helper.createContractSlice(identity, "11", null, LocalDate.now().plusDays(10), LocalDate.now().plusDays(10), LocalDate.now().plusDays(100));
    assertNotNull(sliceOne.getParentContract());
    assertNotNull(sliceTwo.getParentContract());
    assertEquals(sliceOne.getParentContract(), sliceTwo.getParentContract());
    assertTrue(sliceOne.isUsingAsContract());
    assertFalse(sliceTwo.isUsingAsContract());
    IdmIdentityContractDto contract = contractService.get(sliceOne.getParentContract());
    // Protection mode is enabled
    assertEquals(sliceOne.getContractValidFrom(), contract.getValidFrom());
    assertEquals(sliceTwo.getContractValidFrom(), contract.getValidTill());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with IdmContractSliceDto

use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.

the class ContractSliceManagerTest method contractValidityProtectionModeEnabledInfinityTest.

@Test
public void contractValidityProtectionModeEnabledInfinityTest() {
    // Enable protection mode (1 days)
    configurationService.setValue(ContractSliceConfiguration.PROPERTY_PROTECTION_INTERVAL, "1");
    IdmIdentityDto identity = helper.createIdentity();
    IdmContractSliceDto sliceOne = helper.createContractSlice(identity, "11", null, LocalDate.now().minusDays(100), LocalDate.now().minusDays(100), LocalDate.now().plusDays(5));
    IdmContractSliceDto sliceTwo = helper.createContractSlice(identity, "11", null, LocalDate.now().plusDays(10), null, LocalDate.now().plusDays(100));
    assertNotNull(sliceOne.getParentContract());
    assertNotNull(sliceTwo.getParentContract());
    assertEquals(sliceOne.getParentContract(), sliceTwo.getParentContract());
    assertTrue(sliceOne.isUsingAsContract());
    assertFalse(sliceTwo.isUsingAsContract());
    IdmIdentityContractDto contract = contractService.get(sliceOne.getParentContract());
    // Protection mode is enabled, next slice has contract valid from sets to null
    assertEquals(null, contract.getValidTill());
    assertEquals(sliceOne.getContractValidFrom(), contract.getValidFrom());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmContractSliceDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)72 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 Test (org.junit.Test)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)42 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)36 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)35 ContractSliceEvent (eu.bcvsolutions.idm.core.model.event.ContractSliceEvent)26 UUID (java.util.UUID)22 IdmContractSliceGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto)21 IdmContractSliceGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter)21 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)20 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)19 HashMap (java.util.HashMap)19 ImmutableMap (com.google.common.collect.ImmutableMap)17 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)17 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)17 ContractSliceManager (eu.bcvsolutions.idm.core.api.service.ContractSliceManager)17 List (java.util.List)17 Autowired (org.springframework.beans.factory.annotation.Autowired)17 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)16