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