use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class VsRequestCancelBulkActionTest method testCancelRequest.
@Test
public void testCancelRequest() {
IdmIdentityDto implementer = helper.createIdentity();
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto roleForVs = helper.createRole();
SysSystemDto system = this.createVirtualSystem(implementer, null);
helper.createRoleSystem(roleForVs, system);
helper.createIdentityRole(identity, roleForVs);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(identity.getUsername());
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto request = requests.get(0);
Assert.assertEquals(identity.getUsername(), request.getUid());
Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
VsAccountDto account = accountService.findByUidSystem(identity.getUsername(), system.getId());
Assert.assertNull("Account must be null, because request was not realized yet!", account);
// We try cancel the request
IdmBulkActionDto bulkAction = this.findBulkAction(VsRequest.class, VsRequestCancelBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(request.getId()));
String reason = helper.createName();
Map<String, Object> properties = new HashMap<>();
properties.put(VsRequestCancelBulkAction.REASON, reason);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1L, null, null);
request = requestService.get(request.getId());
Assert.assertEquals(VsRequestState.CANCELED, request.getState());
Assert.assertEquals(reason, request.getReason());
account = accountService.findByUidSystem(identity.getUsername(), system.getId());
Assert.assertNull("Account must be null, because request was canceled!", account);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ProvisioningOperationCancelBulkActionTest method testCancelItemsSystem.
@Test
public void testCancelItemsSystem() {
IdmRoleDto role = getHelper().createRole();
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityDto identityTwo = getHelper().createIdentity();
SysSystemDto system = helper.createTestResourceSystem(true);
system.setDisabled(true);
system = systemService.save(system);
helper.createRoleSystem(role, system);
getHelper().createIdentityRole(identity, role);
getHelper().createIdentityRole(identityTwo, role);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identityTwo);
identityService.save(identityTwo);
identityService.save(identityTwo);
identityService.save(identityTwo);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
filter.setEntityType(SystemEntityType.IDENTITY);
List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
assertFalse(operations.isEmpty());
assertTrue(operations.size() > 1);
IdmBulkActionDto bulkAction = this.findBulkAction(SysProvisioningOperation.class, ProvisioningOperationCancelBulkAction.NAME);
int allOperations = operations.size();
// We found just one
bulkAction.setIdentifiers(getIdFromList(operations));
Map<String, Object> properties = new HashMap<>();
properties.put(ProvisioningOperationCancelBulkAction.RETRY_WHOLE_BATCH_CODE, Boolean.FALSE.toString());
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, Long.valueOf(allOperations), null, null);
List<SysProvisioningOperationDto> newOperations = provisioningOperationService.find(filter, null).getContent();
// Must be zero
assertEquals(0, newOperations.size());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ProvisioningOperationCancelBulkActionTest method testEmptyFilterWithController.
@Test
public void testEmptyFilterWithController() {
// Delete operation from before
provisioningOperationService.deleteAllOperations();
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
assertTrue(operations.isEmpty());
IdmRoleDto role = getHelper().createRole();
IdmIdentityDto identity = getHelper().createIdentity();
SysSystemDto system = helper.createTestResourceSystem(true);
system.setDisabled(true);
system = systemService.save(system);
helper.createRoleSystem(role, system);
getHelper().createIdentityRole(identity, role);
identityService.save(identity);
operations = provisioningOperationService.find(filter, null).getContent();
assertFalse(operations.isEmpty());
IdmBulkActionDto bulkAction = this.findBulkAction(SysProvisioningOperation.class, ProvisioningOperationCancelBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
// FIXME: can be multivalued (attributes) ...
bulkAction.setFilter(filter.getData().toSingleValueMap());
int allOperations = operations.size();
Map<String, Object> properties = new HashMap<>();
properties.put(ProvisioningOperationCancelBulkAction.RETRY_WHOLE_BATCH_CODE, Boolean.TRUE.toString());
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = provisioningOperationController.bulkAction(bulkAction).getBody();
checkResultLrt(processAction, Long.valueOf(allOperations), null, null);
operations = provisioningOperationService.find(filter, null).getContent();
assertTrue(operations.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ProvisioningOperationCancelBulkActionTest method testCancelBatchOneItem.
@Test
public void testCancelBatchOneItem() {
IdmRoleDto role = getHelper().createRole();
IdmIdentityDto identity = getHelper().createIdentity();
SysSystemDto system = helper.createTestResourceSystem(true);
system.setDisabled(true);
system = systemService.save(system);
helper.createRoleSystem(role, system);
getHelper().createIdentityRole(identity, role);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setEntityIdentifier(identity.getId());
filter.setEntityType(SystemEntityType.IDENTITY);
List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
assertFalse(operations.isEmpty());
assertTrue(operations.size() > 1);
IdmBulkActionDto bulkAction = this.findBulkAction(SysProvisioningOperation.class, ProvisioningOperationCancelBulkAction.NAME);
// We found just one
SysProvisioningOperationDto provisioningOperationDto = operations.stream().findAny().get();
bulkAction.setIdentifiers(Sets.newHashSet(provisioningOperationDto.getId()));
Map<String, Object> properties = new HashMap<>();
properties.put(ProvisioningOperationCancelBulkAction.RETRY_WHOLE_BATCH_CODE, Boolean.TRUE.toString());
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
List<SysProvisioningOperationDto> newOperations = provisioningOperationService.find(filter, null).getContent();
// Must be zero
assertEquals(0, newOperations.size());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ProvisioningOperationCancelBulkActionTest method testCancelBatchSystem.
@Test
public void testCancelBatchSystem() {
IdmRoleDto role = getHelper().createRole();
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityDto identityTwo = getHelper().createIdentity();
SysSystemDto system = helper.createTestResourceSystem(true);
system.setDisabled(true);
system = systemService.save(system);
helper.createRoleSystem(role, system);
getHelper().createIdentityRole(identity, role);
getHelper().createIdentityRole(identityTwo, role);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
identityService.save(identity);
// 7 Operations
identityService.save(identityTwo);
identityService.save(identityTwo);
identityService.save(identityTwo);
identityService.save(identityTwo);
// 5 Operations
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
filter.setEntityType(SystemEntityType.IDENTITY);
List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
assertFalse(operations.isEmpty());
assertTrue(operations.size() > 1);
IdmBulkActionDto bulkAction = this.findBulkAction(SysProvisioningOperation.class, ProvisioningOperationCancelBulkAction.NAME);
int allOperations = operations.size();
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
Map<String, Object> properties = new HashMap<>();
properties.put(ProvisioningOperationCancelBulkAction.RETRY_WHOLE_BATCH_CODE, Boolean.TRUE.toString());
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
// Filtering by filter = 12 operations
checkResultLrt(processAction, 12l, null, null);
checkProcessItemsCount(processAction, allOperations);
List<SysProvisioningOperationDto> newOperations = provisioningOperationService.find(filter, null).getContent();
// Must be zero
assertEquals(0, newOperations.size());
}
Aggregations