Search in sources :

Example 71 with IdmContractSliceDto

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

the class IdentityContractSaveProcessorIntegrationTest method contractUpdateUnderSliceControl.

@Test
public void contractUpdateUnderSliceControl() {
    IdmIdentityDto identity = getHelper().createIdentity();
    List<IdmIdentityContractDto> contracts = contractService.findAllByIdentity(identity.getId());
    Assert.assertEquals(1, contracts.size());
    // contract without slices successfully saved
    IdmIdentityContractDto contractWithoutSlice = contracts.get(0);
    contractWithoutSlice.setValidFrom(LocalDate.now().minusDays(1));
    contractWithoutSlice = contractService.save(contractWithoutSlice);
    Assert.assertEquals(LocalDate.now().minusDays(1), contractWithoutSlice.getValidFrom());
    IdmContractSliceDto slice = getHelper().createContractSlice(identity, null, LocalDate.now().minusDays(1), null, null);
    IdmIdentityContractDto contractWithSlice = getLookupService().lookupEmbeddedDto(slice, IdmContractSlice_.parentContract);
    // modification of a contract controlled by slice has to throw
    contractWithSlice.setValidFrom(LocalDate.now().minusDays(1));
    try {
        contractService.save(contractWithSlice);
        fail();
    } catch (ResultCodeException ex) {
        Assert.assertTrue(CoreResultCode.CONTRACT_IS_CONTROLLED_CANNOT_BE_MODIFIED.toString().equals(ex.getError().getErrors().get(0).getStatusEnum()));
    }
    // updated slice
    slice.setContractValidFrom(LocalDate.now().minusDays(2));
    slice = sliceService.save(slice);
    Assert.assertEquals(LocalDate.now().minusDays(2), slice.getContractValidFrom());
    // slice controlled contract is supposed to be also updated
    contractWithSlice = contractService.get(contractWithSlice);
    Assert.assertEquals(LocalDate.now().minusDays(2), contractWithSlice.getValidFrom());
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 72 with IdmContractSliceDto

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

the class IdmContractSliceControllerRestTest method prepareDto.

@Override
protected IdmContractSliceDto prepareDto() {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmContractSliceDto slice = new IdmContractSliceDto();
    slice.setIdentity(identity.getId());
    slice.setPosition(getHelper().createName());
    slice.setContractCode(getHelper().createName());
    slice.setValidFrom(LocalDate.now());
    slice.setContractValidFrom(LocalDate.now());
    // 
    return slice;
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)

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