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());
}
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;
}
Aggregations