use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormAttributeDeleteBulkActionIntegrationTest method testProcessBulkActionByFilter.
@Test
public void testProcessBulkActionByFilter() {
List<IdmFormAttributeDto> attributes = createAttributes(5);
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setId(attributes.get(2).getId());
List<IdmFormAttributeDto> checkAttributes = service.find(filter, null).getContent();
Assert.assertEquals(1, checkAttributes.size());
IdmBulkActionDto bulkAction = findBulkAction(IdmFormAttribute.class, FormAttributeDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
Assert.assertNull(service.get(attributes.get(2)));
Assert.assertNotNull(service.get(attributes.get(1)));
Assert.assertNotNull(service.get(attributes.get(3)));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleWithoutSelectionBulkActionIntegrationTest method processBulkActionWithoutPermission.
@Test
public void processBulkActionWithoutPermission() {
// user hasn't permission for change permission identity
IdmIdentityDto identityForLogin = getHelper().createIdentity();
IdmRoleDto permissionRole = getHelper().createRole();
getHelper().createBasePolicy(permissionRole.getId(), CoreGroupPermission.IDENTITY, IdmIdentity.class, IdmBasePermission.READ);
getHelper().createBasePolicy(permissionRole.getId(), CoreGroupPermission.IDENTITYCONTRACT, IdmIdentityContract.class, IdmBasePermission.AUTOCOMPLETE);
getHelper().createIdentityRole(identityForLogin, permissionRole);
loginAsNoAdmin(identityForLogin.getUsername());
IdmRoleDto createRole = getHelper().createRole();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleWithoutSelectionBulkAction.NAME);
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_ROLE, Lists.newArrayList(createRole.getId().toString()));
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_IDENTITY, identities.stream().map(IdmIdentityDto::getId).collect(Collectors.toList()));
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_PRIME_CONTRACT, Boolean.TRUE);
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_APPROVE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, 0l, 5l);
for (IdmIdentityDto identity : identities) {
identity = identityService.get(identity);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, contracts.size());
IdmIdentityContractDto contract = contracts.get(0);
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
Assert.assertTrue(identityRoles.isEmpty());
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleWithoutSelectionBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmRoleDto createRole = getHelper().createRole();
IdmRoleDto createRole2 = getHelper().createRole();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleWithoutSelectionBulkAction.NAME);
LocalDate validTill = LocalDate.now().minusDays(5);
LocalDate validFrom = LocalDate.now().plusDays(60);
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_ROLE, Lists.newArrayList(createRole.getId().toString(), createRole2.getId().toString()));
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_IDENTITY, identities.stream().map(IdmIdentityDto::getId).collect(Collectors.toList()));
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_VALID_FROM, validFrom);
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_VALID_TILL, validTill);
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_PRIME_CONTRACT, Boolean.TRUE);
properties.put(IdentityAddRoleWithoutSelectionBulkAction.PROPERTY_APPROVE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 10l, null, null);
for (IdmIdentityDto identity : identities) {
identity = identityService.get(identity);
Assert.assertNotNull(identity);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, contracts.size());
IdmIdentityContractDto contract = contracts.get(0);
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
Assert.assertEquals(2, identityRoles.size());
for (IdmIdentityRoleDto identityRole : identityRoles) {
Assert.assertEquals(identityRole.getValidFrom(), validFrom);
Assert.assertEquals(identityRole.getValidTill(), validTill);
boolean existsRole = false;
if (identityRole.getRole().equals(createRole.getId()) || identityRole.getRole().equals(createRole2.getId())) {
existsRole = true;
}
Assert.assertTrue(existsRole);
}
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityEvaluateStateBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
List<IdmIdentityDto> identities = this.createIdentities(3);
IdmIdentityDto identityOne = identities.get(0);
identityOne.setState(IdentityState.DISABLED);
identityOne = identityService.save(identityOne);
Assert.assertTrue(identityOne.isDisabled());
Assert.assertEquals(IdentityState.DISABLED, identityOne.getState());
IdmIdentityDto identityTwo = identities.get(1);
identityTwo.setState(IdentityState.DISABLED_MANUALLY);
identityTwo = identityService.save(identityTwo);
Assert.assertTrue(identityTwo.isDisabled());
Assert.assertEquals(IdentityState.DISABLED_MANUALLY, identityTwo.getState());
IdmIdentityDto identityThree = identities.get(2);
Assert.assertFalse(identityThree.isDisabled());
Assert.assertEquals(IdentityState.CREATED, identityThree.getState());
//
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityEvaluateStateBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(ids);
//
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 3l, null, null);
identityOne = identityService.get(identityOne);
identityTwo = identityService.get(identityTwo);
identityThree = identityService.get(identityThree);
Assert.assertEquals(IdentityState.VALID, identityOne.getState());
Assert.assertEquals(IdentityState.DISABLED_MANUALLY, identityTwo.getState());
Assert.assertEquals(IdentityState.VALID, identityThree.getState());
//
processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 3l, null, null);
identityOne = identityService.get(identityOne);
identityTwo = identityService.get(identityTwo);
identityThree = identityService.get(identityThree);
Assert.assertEquals(IdentityState.VALID, identityOne.getState());
Assert.assertEquals(IdentityState.DISABLED_MANUALLY, identityTwo.getState());
Assert.assertEquals(IdentityState.VALID, identityThree.getState());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class NotificationTemplateDeleteBulkActionIntegrationTest method prevalidationBulkActionByIds.
@Test
public void prevalidationBulkActionByIds() {
templateService.init();
IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
IdmNotificationTemplateDto template2 = templateService.getByCode(TEST_TEMPLATE_TWO);
template1.setUnmodifiable(true);
template2.setUnmodifiable(false);
template1 = templateService.save(template1);
template2 = templateService.save(template2);
Set<UUID> templates = new HashSet<UUID>();
templates.add(template1.getId());
templates.add(template2.getId());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateDeleteBulkAction.NAME);
bulkAction.setIdentifiers(templates);
ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
List<ResultModel> results = resultModels.getInfos();
assertEquals(1, results.size());
assertEquals(results.get(0).getStatusEnum(), CoreResultCode.NOTIFICATION_SYSTEM_TEMPLATE_DELETE_FAILED.toString());
String code = (String) results.get(0).getParameters().get("template");
assertEquals(code, template1.getCode());
}
Aggregations