Search in sources :

Example 6 with IdmContractSliceGuaranteeDto

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

the class ContractGuaranteeSaveAndDeleteProcessorTest method testCreateGuaranteeOfContractWithSlice.

@Test
public void testCreateGuaranteeOfContractWithSlice() {
    IdmIdentityDto sliceGuarantee = getHelper().createIdentity();
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmContractSliceDto slice = getHelper().createContractSlice(identity, null, LocalDate.now().minusDays(1), null, null);
    UUID contractId = slice.getParentContract();
    // guarantee can't be created directly
    try {
        getHelper().createContractGuarantee(contractId, sliceGuarantee.getId());
        fail("Contract guarantee can't be created directly when slice is applied");
    } catch (ResultCodeException ex) {
        Assert.assertTrue(CoreResultCode.CONTRACT_IS_CONTROLLED_GUARANTEE_CANNOT_BE_MODIFIED.toString().equals(ex.getError().getErrors().get(0).getStatusEnum()));
    }
    IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
    guaranteeFilter.setIdentityContractId(contractId);
    List<IdmContractGuaranteeDto> contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(0, contractGuarantees.size());
    // contract slice guarantee can be created
    getHelper().createContractSliceGuarantee(slice.getId(), sliceGuarantee.getId());
    IdmContractSliceGuaranteeFilter sliceGuaranteefilter = new IdmContractSliceGuaranteeFilter();
    sliceGuaranteefilter.setGuaranteeId(sliceGuarantee.getId());
    List<IdmContractSliceGuaranteeDto> sliceGuarantees = contractSliceGuaranteeService.find(sliceGuaranteefilter, null).getContent();
    Assert.assertEquals(1, sliceGuarantees.size());
    // applying slice with guarantee causes creating of contract guarantee which is correct
    contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(1, contractGuarantees.size());
    IdmIdentityDto sliceGuaranteeIdent = DtoUtils.getEmbedded(sliceGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
    IdmIdentityDto contractGuaranteeIdent = DtoUtils.getEmbedded(contractGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
    Assert.assertEquals(sliceGuaranteeIdent.getId(), contractGuaranteeIdent.getId());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with IdmContractSliceGuaranteeDto

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

the class ContractSliceManagerTest method testReferentialIntegrityOnIdentityDelete.

@Test
public void testReferentialIntegrityOnIdentityDelete() {
    // prepare data
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identityWithContract = helper.createIdentity();
    IdmContractSliceDto slice = helper.createContractSlice(identityWithContract);
    helper.createContractSliceGuarantee(slice.getId(), identity.getId());
    // 
    IdmContractSliceGuaranteeFilter filter = new IdmContractSliceGuaranteeFilter();
    filter.setContractSliceId(slice.getId());
    List<IdmContractSliceGuaranteeDto> guarantees = contractGuaranteeService.find(filter, null).getContent();
    assertEquals(1, guarantees.size());
    // 
    helper.deleteIdentity(identity.getId());
    // 
    guarantees = contractGuaranteeService.find(filter, null).getContent();
    assertEquals(0, guarantees.size());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) 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 8 with IdmContractSliceGuaranteeDto

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

the class ContractSliceManagerTest method testReferentialIntegrityOnContractDelete.

@Test
public void testReferentialIntegrityOnContractDelete() {
    // prepare data
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identityWithContract = helper.createIdentity();
    IdmContractSliceDto slice = helper.createContractSlice(identityWithContract);
    helper.createContractSliceGuarantee(slice.getId(), identity.getId());
    // 
    IdmContractSliceGuaranteeFilter filter = new IdmContractSliceGuaranteeFilter();
    filter.setGuaranteeId(identity.getId());
    List<IdmContractSliceGuaranteeDto> guarantees = contractGuaranteeService.find(filter, null).getContent();
    assertEquals(1, guarantees.size());
    // 
    contractSliceService.deleteById(slice.getId());
    // 
    guarantees = contractGuaranteeService.find(filter, null).getContent();
    assertEquals(0, guarantees.size());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) 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 9 with IdmContractSliceGuaranteeDto

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

the class ContractSliceGuaranteeDeleteProcessor method process.

@Override
public EventResult<IdmContractSliceGuaranteeDto> process(EntityEvent<IdmContractSliceGuaranteeDto> event) {
    IdmContractSliceGuaranteeDto dto = event.getContent();
    // 
    contractSliceGuaranteeService.deleteInternal(dto);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto)

Example 10 with IdmContractSliceGuaranteeDto

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

the class ContractSliceGuaranteeRecountProcessor method process.

@Override
public EventResult<IdmContractSliceGuaranteeDto> process(EntityEvent<IdmContractSliceGuaranteeDto> event) {
    IdmContractSliceGuaranteeDto dto = event.getContent();
    Assert.notNull(dto.getContractSlice(), "Contract slice is required.");
    IdmContractSliceDto slice = contractSliceService.get(dto.getContractSlice());
    UUID parentContract = slice.getParentContract();
    if (parentContract != null) {
        IdmIdentityContractDto contract = contractService.get(parentContract);
        // Copy guarantees to contract
        if (slice.isUsingAsContract()) {
            contractSliceManager.copyGuarantees(slice, contract);
        }
    }
    // 
    event.setContent(dto);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)

Aggregations

IdmContractSliceGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto)10 IdmContractSliceDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)8 IdmContractSliceGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter)7 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 UUID (java.util.UUID)6 ImmutableMap (com.google.common.collect.ImmutableMap)3 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)3 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)3 EntityEvent (eu.bcvsolutions.idm.core.api.event.EntityEvent)3 AutomaticRoleManager (eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager)3 ContractSliceManager (eu.bcvsolutions.idm.core.api.service.ContractSliceManager)3 IdmContractSliceGuaranteeService (eu.bcvsolutions.idm.core.api.service.IdmContractSliceGuaranteeService)3 IdmContractSliceService (eu.bcvsolutions.idm.core.api.service.IdmContractSliceService)3 IdmIdentityContractService (eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService)3 ContractSliceEvent (eu.bcvsolutions.idm.core.model.event.ContractSliceEvent)3 ContractSliceEventType (eu.bcvsolutions.idm.core.model.event.ContractSliceEvent.ContractSliceEventType)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 Serializable (java.io.Serializable)3 MessageFormat (java.text.MessageFormat)3 List (java.util.List)3