use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class IdentityAddContractGuaranteeBulkActionTest method isContractGuarantee.
/**
* Tests if there are all identities contract guarantees
* If some of them are not contract guarantees, they are returned
* Empty returned List means that there are all identities contract guarantees
*
* @param contract
* @param guarantees
* @return
*/
private List<IdmIdentityDto> isContractGuarantee(IdmIdentityContractDto contract, List<IdmIdentityDto> guarantees) {
IdmContractGuaranteeFilter filt = new IdmContractGuaranteeFilter();
filt.setIdentityContractId(contract.getId());
Set<UUID> cgUUIDs = contractGuaranteeService.find(filt, null).getContent().stream().map(IdmContractGuaranteeDto::getGuarantee).collect(Collectors.toSet());
return guarantees.stream().filter(ident -> !cgUUIDs.contains(ident.getId())).collect(Collectors.toList());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class IdentityRemoveContractGuaranteeBulkActionTest method getGuaranteesForContract.
/**
* Gets all contractGuarantees for contract
* @param contract
* @return
*/
private List<IdmContractGuaranteeDto> getGuaranteesForContract(UUID contract) {
IdmContractGuaranteeFilter filt = new IdmContractGuaranteeFilter();
filt.setIdentityContractId(contract);
return contractGuaranteeService.find(filt, null).getContent();
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter 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.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class AbstractContractGuaranteeBulkAction method findGuarantees.
/**
* Get all guarantees for identity
*
* @param identity
* @param permissions
* @return
*/
protected List<IdmContractGuaranteeDto> findGuarantees(UUID identity, BasePermission... permissions) {
IdmContractGuaranteeFilter filter = new IdmContractGuaranteeFilter();
filter.setIdentity(identity);
return contractGuaranteeService.find(filter, null, permissions).getContent();
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class IdmContractGuaranteeController method toFilter.
@Override
protected IdmContractGuaranteeFilter toFilter(MultiValueMap<String, Object> parameters) {
IdmContractGuaranteeFilter filter = super.toFilter(parameters);
// codeable decorator
filter.setIdentity(getParameterConverter().toEntityUuid(parameters, IdmContractGuaranteeFilter.PARAMETER_IDENTITY, IdmIdentityDto.class));
//
return filter;
}
Aggregations