use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class ContractGuaranteeSaveAndDeleteProcessorTest method testProvisioningAfterUpdateContractGuarantee.
@Test
public void testProvisioningAfterUpdateContractGuarantee() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
//
IdmIdentityDto identity = testHelper.createIdentity();
testHelper.createIdentityAccount(system, identity);
//
// save identity with account, invoke provisioning = create
identity = identityService.save(identity);
//
IdmIdentityDto guarantee = testHelper.createIdentity();
IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
IdmContractGuaranteeDto contractGuarantee = testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
//
IdmIdentityDto newGuarantee = testHelper.createIdentity();
contractGuarantee.setGuarantee(newGuarantee.getId());
// save/update
contractGuarantee = contractGuaranteeService.save(contractGuarantee);
//
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
// create, add contract guarantee and update = 3 operation
assertEquals(3, content.size());
// sort by created and found last
SysProvisioningArchiveDto last = content.stream().max(Comparator.comparing(SysProvisioningArchiveDto::getCreated)).orElse(null);
;
assertNotNull(last);
assertEquals(ProvisioningEventType.UPDATE, last.getOperationType());
assertEquals(SystemEntityType.IDENTITY, last.getEntityType());
assertEquals(identity.getId(), last.getEntityIdentifier());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class ContractGuaranteeSaveAndDeleteProcessorTest method testUpdateContractGuaranteeWithoutProvisioning.
@Test
public void testUpdateContractGuaranteeWithoutProvisioning() {
IdmIdentityDto identity = testHelper.createIdentity();
//
IdmIdentityDto guarantee = testHelper.createIdentity();
IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
IdmContractGuaranteeDto contractGuarantee = testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
//
IdmIdentityDto newGuarantee = testHelper.createIdentity();
contractGuarantee.setGuarantee(newGuarantee.getId());
// save/update
contractGuarantee = contractGuaranteeService.save(contractGuarantee);
//
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setEntityIdentifier(identity.getId());
List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
assertEquals(0, content.size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class IdentityAddContractGuaranteeBulkAction method processDto.
@Override
protected OperationResult processDto(IdmIdentityDto identity) {
Set<UUID> newGuarantees = getSelectedGuaranteeUuids(PROPERTY_NEW_GUARANTEE);
Map<UUID, List<IdmContractGuaranteeDto>> currentGuarantees = getIdentityGuaranteesOrderedByContract(identity.getId());
for (Map.Entry<UUID, List<IdmContractGuaranteeDto>> entry : currentGuarantees.entrySet()) {
UUID contractId = entry.getKey();
List<IdmContractGuaranteeDto> contractGuarantees = entry.getValue();
Set<UUID> currentGuaranteesUuidSet = contractGuarantees.stream().map(IdmContractGuaranteeDto::getGuarantee).collect(Collectors.toSet());
Set<UUID> guaranteesToAdd = Sets.difference(newGuarantees, currentGuaranteesUuidSet);
// add all new contract guarantees
for (UUID guaranteeId : guaranteesToAdd) {
try {
IdmContractGuaranteeDto guaranteeDto = createContractGuarantee(guaranteeId, contractId, IdmBasePermission.CREATE);
logItemProcessed(guaranteeDto, new OperationResult.Builder(OperationState.EXECUTED).build());
} catch (ForbiddenEntityException ex) {
LOG.warn("Not authorized to set contract guarantee [{}] of contract [{}].", guaranteeId, contractId, ex);
IdmIdentityContractDto dto = identityContractService.get(contractId);
logContractGuaranteePermissionError(dto, guaranteeId, contractId, IdmBasePermission.CREATE, ex);
} catch (ResultCodeException ex) {
IdmIdentityContractDto dto = identityContractService.get(contractId);
logResultCodeException(dto, ex);
}
}
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class InitTestDataProcessor method process.
@Override
public EventResult<ModuleDescriptorDto> process(EntityEvent<ModuleDescriptorDto> event) {
IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
IdmTreeNodeDto rootOrganization = treeNodeService.findRoots(treeType.getId(), PageRequest.of(0, 1)).getContent().get(0);
//
if (!configurationService.getBooleanValue(PARAMETER_TEST_DATA_CREATED, false)) {
LOG.info("Creating test data ...");
//
IdmRoleDto role1 = new IdmRoleDto();
role1.setCode(TEST_USER_ROLE);
role1 = this.roleService.save(role1);
LOG.info("Test role created [id: {}]", role1.getId());
//
IdmRoleDto role2 = new IdmRoleDto();
role2.setCode(TEST_CUSTOM_ROLE);
role2 = this.roleService.save(role2);
LOG.info("Test role created [id: {}]", role2.getId());
//
// Users for JUnit testing
IdmIdentityDto testUser1 = new IdmIdentityDto();
testUser1.setUsername(TEST_USER_1);
testUser1.setPassword(new GuardedString("heslo"));
testUser1.setFirstName("Test");
testUser1.setLastName("First User");
testUser1.setEmail("test1@bscsolutions.eu");
testUser1 = this.identityService.save(testUser1);
LOG.info("Identity created [id: {}]", testUser1.getId());
IdmIdentityDto testUser2 = new IdmIdentityDto();
testUser2.setUsername(TEST_USER_2);
testUser2.setPassword(new GuardedString("heslo"));
testUser2.setFirstName("Test");
testUser2.setLastName("Second User");
testUser2.setEmail("test2@bscsolutions.eu");
testUser2 = this.identityService.save(testUser2);
LOG.info("Identity created [id: {}]", testUser2.getId());
IdmTreeTypeDto type = this.treeTypeService.get(rootOrganization.getTreeType());
IdmTreeNodeDto organization = new IdmTreeNodeDto();
organization.setCode("test");
organization.setName("Organization Test");
organization.setCreator("ja");
organization.setParent(rootOrganization.getId());
organization.setTreeType(type.getId());
organization = this.treeNodeService.save(organization);
IdmIdentityContractDto identityWorkPosition2 = new IdmIdentityContractDto();
identityWorkPosition2.setIdentity(testUser1.getId());
identityWorkPosition2.setWorkPosition(organization.getId());
identityWorkPosition2 = identityContractService.save(identityWorkPosition2);
IdmContractGuaranteeDto contractGuarantee = new IdmContractGuaranteeDto();
contractGuarantee.setIdentityContract(identityWorkPosition2.getId());
contractGuarantee.setGuarantee(testUser2.getId());
contractGuaranteeService.save(contractGuarantee);
//
LOG.info("Test data was created.");
//
configurationService.setBooleanValue(PARAMETER_TEST_DATA_CREATED, true);
}
// create default password policy for validate (We need to set min length of password ot 0 in tests.)
createValidatePolicy();
// create default password policy for generate (Must be here, because default init password processor is skipped for test profile.)
createGeneratePolicy();
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest 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());
}
Aggregations