use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityEnableBulkActionTest method processBulkActionByFilterWithRemove.
@Test
public void processBulkActionByFilterWithRemove() {
String testLastName = "bulkActionLastName" + System.currentTimeMillis();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmIdentityDto removedIdentity = identities.get(0);
IdmIdentityDto removedIdentity2 = identities.get(1);
for (IdmIdentityDto identity : identities) {
identity.setLastName(testLastName);
identity = identityService.save(identity);
identity = identityService.disable(identity.getId());
assertTrue(identity.getState() == IdentityState.DISABLED_MANUALLY);
}
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setLastName(testLastName);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityEnableBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
bulkAction.setRemoveIdentifiers(Sets.newHashSet(removedIdentity.getId(), removedIdentity2.getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 3l, null, null);
for (IdmIdentityDto identity : identities) {
IdmIdentityDto dto = identityService.get(identity.getId());
assertNotNull(dto);
if (dto.getId().equals(removedIdentity.getId()) || dto.getId().equals(removedIdentity2.getId())) {
assertTrue(dto.getState() == IdentityState.DISABLED_MANUALLY);
continue;
}
assertTrue(dto.getState() == IdentityState.VALID);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class EntityStateDeleteBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
List<OperationState> states = getStates();
List<IdmEntityStateDto> operationStates = createOperationStates(states);
IdmBulkActionDto bulkAction = findBulkAction(IdmEntityState.class, EntityStateDeleteBulkAction.NAME);
Set<UUID> ids = getIdFromList(operationStates);
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, (long) states.size(), null, null);
for (UUID id : ids) {
Assert.assertNull(service.get(id));
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityDisableBulkActionTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
List<IdmIdentityDto> identities = this.createIdentities(5);
for (IdmIdentityDto identity : identities) {
assertTrue(identity.getState() != IdentityState.DISABLED_MANUALLY);
}
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityDisableBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 5l, null, null);
for (UUID id : ids) {
IdmIdentityDto identityDto = identityService.get(id);
assertNotNull(identityDto);
assertTrue(identityDto.getState() == IdentityState.DISABLED_MANUALLY);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityRemoveRoleBulkActionTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
String testFirstName = "bulkActionFirstName" + System.currentTimeMillis();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmRoleDto createRole = getHelper().createRole();
IdmRoleDto createRole2 = getHelper().createRole();
for (IdmIdentityDto identity : identities) {
identity.setFirstName(testFirstName);
identity = identityService.save(identity);
// create second contract
IdmIdentityContractDto contact = getHelper().createContract(identity);
contact.setValidTill(LocalDate.now().plusDays(5));
contact.setExterne(true);
contact = identityContractService.save(contact);
getHelper().createIdentityRole(contact, createRole);
getHelper().createIdentityRole(contact, createRole2);
getHelper().createIdentityRole(identity, createRole);
getHelper().createIdentityRole(identity, createRole2);
}
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, IdentityRemoveRoleBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityRemoveRoleBulkAction.ROLE_CODE, Lists.newArrayList(createRole.getId().toString(), createRole2.getId().toString()));
properties.put(IdentityRemoveRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.FALSE);
properties.put(IdentityRemoveRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 5l, 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(0, identityRoles.size());
}
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityRemoveRoleBulkActionTest method processBulkActionWithoutContracts.
@Test
public void processBulkActionWithoutContracts() {
IdmRoleDto createRole = getHelper().createRole();
List<IdmIdentityDto> identities = this.createIdentities(5);
for (IdmIdentityDto identity : identities) {
for (IdmIdentityContractDto contract : identityContractService.findAllByIdentity(identity.getId())) {
identityContractService.delete(contract);
}
}
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRemoveRoleBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(this.getIdFromList(identities));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityRemoveRoleBulkAction.ROLE_CODE, Lists.newArrayList(createRole.getId().toString()));
properties.put(IdentityRemoveRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.FALSE);
properties.put(IdentityRemoveRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, 0l, 5l);
for (UUID id : ids) {
IdmIdentityDto identity = identityService.get(id);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
assertEquals(0, contracts.size());
}
}
Aggregations