use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest method preprocessBulkActionWithGuarantees.
@Test
public void preprocessBulkActionWithGuarantees() {
List<IdmIdentityDto> guarantees = this.createIdentities(2);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
createContractGuarantees(contract1, guarantees);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityChangeContractGuaranteeBulkAction.NAME);
bulkAction.getIdentifiers().add(employee.getId());
IdmBulkActionDto bulkActionPreprocessed = bulkActionManager.preprocessBulkAction(bulkAction);
IdmFormAttributeDto oldGuaranteeFormAttribute = bulkActionPreprocessed.getFormAttributes().stream().filter(attr -> attr.getCode().equals(AbstractContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE)).findFirst().orElse(null);
assertNotNull(oldGuaranteeFormAttribute);
List<UUID> oldGuaranteeIds = oldGuaranteeFormAttribute.getForceSearchParameters().getIds();
assertEquals(2, oldGuaranteeIds.size());
assertTrue(oldGuaranteeIds.contains(guarantees.get(0).getId()));
assertTrue(oldGuaranteeIds.contains(guarantees.get(1).getId()));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityContractDeleteBulkActionIntegrationTest method testForceDeleteAsync.
@Test
public void testForceDeleteAsync() {
// create identity
String description = getHelper().createName();
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
identity.setDescription(description);
IdmIdentityDto identityOne = identityService.save(identity);
// create role
IdmRoleDto role = getHelper().createRole();
// create automatic roles - by tree and by attribute too
IdmAutomaticRoleAttributeDto automaticRoleOne = getHelper().createAutomaticRole(role.getId());
getHelper().createAutomaticRoleRule(automaticRoleOne.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.description.getName(), null, description);
IdmTreeNodeDto treeNode = getHelper().createTreeNode();
IdmIdentityContractDto contract = getHelper().getPrimeContract(identityOne);
contract.setWorkPosition(treeNode.getId());
contractService.save(contract);
getHelper().createRoleTreeNode(role, treeNode, false);
// create manuallyAssigned roles
getHelper().createIdentityRole(identityOne, role);
//
Assert.assertEquals(3, identityRoleService.findAllByIdentity(identityOne.getId()).size());
// remove role async
try {
getHelper().setConfigurationValue(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_ENABLED, true);
//
// delete by bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentityContract.class, IdentityContractDeleteBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(contract.getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, 0l, 0l);
//
getHelper().waitForResult(res -> {
return contractService.get(contract) != null;
});
//
Assert.assertTrue(identityRoleService.findAllByIdentity(identityOne.getId()).isEmpty());
Assert.assertNull(contractService.get(contract));
} finally {
getHelper().setConfigurationValue(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_ENABLED, false);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityContractDeleteBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
List<IdmIdentityContractDto> dtos = createBulk(5);
List<IdmIdentityContractDto> otherDtos = createBulk(2);
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setIdentity(dtos.get(0).getIdentity());
List<IdmIdentityContractDto> checkDtos = contractService.find(filter, null).getContent();
// with primary
Assert.assertEquals(6, checkDtos.size());
IdmBulkActionDto bulkAction = findBulkAction(IdmIdentityContract.class, IdentityContractDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 6l, null, null);
for (IdmIdentityContractDto dto : dtos) {
Assert.assertNull(contractService.get(dto));
}
Assert.assertNotNull(contractService.get(otherDtos.get(0)));
Assert.assertNotNull(contractService.get(otherDtos.get(1)));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleBulkActionIntegrationTest method processBulkActionByIdsWithoutValidityIsGiven.
@Test
public void processBulkActionByIdsWithoutValidityIsGiven() {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identityOne);
IdmIdentityContractDto otherValidContract = getHelper().createContract(identityOne, null, LocalDate.now().plusDays(1), LocalDate.now().plusDays(2));
IdmIdentityContractDto otherInvalidContract = getHelper().createContract(identityOne, null, null, LocalDate.now().minusDays(1));
IdmRoleDto roleOne = getHelper().createRole();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(identityOne.getId()));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleBulkAction.ROLE_CODE, Lists.newArrayList(roleOne.getId().toString()));
properties.put(IdentityAddRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.FALSE);
properties.put(IdentityAddRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 2l, null, null);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identityOne.getId());
// +1 primary vithout validity is set
Assert.assertEquals(3, contracts.size());
Assert.assertTrue(identityRoleService.findAllByContract(otherInvalidContract.getId()).isEmpty());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identityOne.getId());
Assert.assertEquals(2, identityRoles.size());
Assert.assertTrue(identityRoles.stream().anyMatch(ir -> ir.getRole().equals(roleOne.getId()) && ir.getIdentityContract().equals(primeContract.getId()) && ir.getValidFrom() == null && ir.getValidTill() == null));
Assert.assertTrue(identityRoles.stream().anyMatch(ir -> ir.getRole().equals(roleOne.getId()) && ir.getIdentityContract().equals(otherValidContract.getId()) && ir.getValidFrom().equals(otherValidContract.getValidFrom()) && ir.getValidTill() == null));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
String testFirstName = "bulkActionFirstName" + System.currentTimeMillis();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmRoleDto createRole = getHelper().createRole();
for (IdmIdentityDto identity : identities) {
identity.setFirstName(testFirstName);
identity = identityService.save(identity);
// create second contract
IdmIdentityContractDto contact = getHelper().createContract(identity);
contact.setExterne(true);
contact = identityContractService.save(contact);
}
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(testFirstName);
List<IdmIdentityDto> checkIdentities = identityService.find(filter, null).getContent();
assertEquals(5, checkIdentities.size());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleBulkAction.ROLE_CODE, Lists.newArrayList(createRole.getId().toString()));
properties.put(IdentityAddRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.FALSE);
properties.put(IdentityAddRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 10l, null, null);
for (IdmIdentityDto identity : identities) {
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
assertEquals(2, contracts.size());
for (IdmIdentityContractDto contract : contracts) {
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
assertEquals(1, identityRoles.size());
IdmIdentityRoleDto identityRoleDto = identityRoles.get(0);
assertEquals(createRole.getId(), identityRoleDto.getRole());
assertNull(identityRoleDto.getValidFrom());
assertNull(identityRoleDto.getValidTill());
}
}
}
Aggregations