use of eu.bcvsolutions.idm.core.bulk.action.impl.IdentityDeleteBulkAction in project CzechIdMng by bcvsolutions.
the class DefaultLongRunningTaskManagerIntegrationTest method testExecutePersistedBulkAction.
@Test
public void testExecutePersistedBulkAction() {
getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
try {
getHelper().loginAdmin();
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityOther = getHelper().createIdentity((GuardedString) null);
// filter setting
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setUsername(identityOne.getUsername());
// test before
List<IdmIdentityDto> identities = identityService.find(filter, null).getContent();
Assert.assertEquals(1, identities.size());
// prepare bulk action
IdmBulkActionDto bulkAction = findBulkAction(IdmIdentity.class, IdentityDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
// prepare and persist LRT
IdentityDeleteBulkAction identityDeleteBulkAction = new IdentityDeleteBulkAction();
identityDeleteBulkAction.setAction(bulkAction);
IdmLongRunningTaskDto task = manager.resolveLongRunningTask(identityDeleteBulkAction, null, OperationState.CREATED);
manager.processCreated(task.getId());
//
identities = identityService.find(filter, null).getContent();
Assert.assertTrue(identities.isEmpty());
Assert.assertNull(identityService.get(identityOne));
Assert.assertNotNull(identityService.get(identityOther));
} finally {
getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
getHelper().logout();
}
}
Aggregations