Search in sources :

Example 1 with IdentityDeleteBulkAction

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();
    }
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdentityDeleteBulkAction(eu.bcvsolutions.idm.core.bulk.action.impl.IdentityDeleteBulkAction) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Aggregations

IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)1 IdentityDeleteBulkAction (eu.bcvsolutions.idm.core.bulk.action.impl.IdentityDeleteBulkAction)1 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)1 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)1 Test (org.junit.Test)1