use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormValueDeleteBulkActionIntegrationTest method prevalidationBulkActionByIds.
@Test
public void prevalidationBulkActionByIds() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with attribute
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setMultiple(true);
attribute.setPersistentType(PersistentType.SHORTTEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// fill values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
// check value and persistent type
Assert.assertEquals(2, m.get(attributeName).size());
// Running prevalidation which is supposed to return no validation errors
// because this mapping is not used in any synchronization settings.
IdmBulkActionDto bulkAction = findBulkAction(IdmFormValue.class, FormValueDeleteBulkAction.NAME);
Set<UUID> ids = new HashSet<>();
ids.add(m.get(attributeName).stream().filter(v -> v.getValue().equals(FORM_VALUE_ONE)).findFirst().get().getId());
ids.add(m.get(attributeName).stream().filter(v -> v.getValue().equals(FORM_VALUE_TWO)).findFirst().get().getId());
bulkAction.setIdentifiers(ids);
//
ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
//
Assert.assertTrue(resultModels.getInfos().isEmpty());
//
// create attribute required
attribute.setRequired(true);
formService.saveAttribute(attribute);
//
resultModels = bulkActionManager.prevalidate(bulkAction);
Assert.assertEquals(1, resultModels.getInfos().size());
Assert.assertEquals(2L, resultModels.getInfos().get(0).getParameters().get("count"));
Assert.assertEquals(attribute.getCode(), resultModels.getInfos().get(0).getParameters().get("attribute"));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormValueDeleteBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with attribute
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setMultiple(true);
attribute.setPersistentType(PersistentType.SHORTTEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// fill values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
// check value and persistent type
Assert.assertEquals(2, m.get(attributeName).size());
Assert.assertTrue(m.get(attributeName).stream().anyMatch(v -> v.getValue().equals(FORM_VALUE_ONE)));
Assert.assertTrue(m.get(attributeName).stream().anyMatch(v -> v.getValue().equals(FORM_VALUE_TWO)));
//
IdmBulkActionDto bulkAction = findBulkAction(IdmFormValue.class, FormValueDeleteBulkAction.NAME);
IdmFormValueFilter<?> filter = new IdmFormValueFilter<>();
filter.setDefinitionId(formDefinitionOne.getId());
filter.setShortTextValue(FORM_VALUE_ONE);
filter.setAttributeId(attribute.getId());
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
Assert.assertEquals(1, m.get(attributeName).size());
Assert.assertTrue(m.get(attributeName).stream().anyMatch(v -> v.getValue().equals(FORM_VALUE_TWO)));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormValueDeleteBulkActionIntegrationTest method testDeleteBothRequiredAttributesFailed.
@Test
public void testDeleteBothRequiredAttributesFailed() throws InterruptedException {
try {
getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with attribute
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setMultiple(true);
attribute.setRequired(true);
attribute.setPersistentType(PersistentType.SHORTTEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// fill values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
// check value and persistent type
Assert.assertEquals(2, m.get(attributeName).size());
Assert.assertTrue(m.get(attributeName).stream().anyMatch(v -> v.getValue().equals(FORM_VALUE_ONE)));
Assert.assertTrue(m.get(attributeName).stream().anyMatch(v -> v.getValue().equals(FORM_VALUE_TWO)));
//
IdmBulkActionDto bulkAction = findBulkAction(IdmFormValue.class, FormValueDeleteBulkAction.NAME);
Set<UUID> ids = new HashSet<>();
ids.add(m.get(attributeName).stream().filter(v -> v.getValue().equals(FORM_VALUE_ONE)).findFirst().get().getId());
ids.add(m.get(attributeName).stream().filter(v -> v.getValue().equals(FORM_VALUE_TWO)).findFirst().get().getId());
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
ObserveLongRunningTaskEndProcessor.listenTask(processAction.getLongRunningTaskId().toString());
ObserveLongRunningTaskEndProcessor.waitForEnd(processAction.getLongRunningTaskId().toString());
checkResultLrt(processAction, 1L, 1L, null);
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
Assert.assertEquals(1, m.get(attributeName).size());
} finally {
getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ConfigurationSwitchInstanceBulkActionIntegrationTest method testNotChangeSameInstances.
@Test
public void testNotChangeSameInstances() {
String newInstanceId = getHelper().createName();
//
IdmBulkActionDto bulkAction = this.findBulkAction(IdmConfiguration.class, ConfigurationSwitchInstanceBulkAction.NAME);
Map<String, Object> properties = new HashMap<>();
properties.put(ConfigurationSwitchInstanceBulkAction.PROPERTY_PREVIOUS_INSTANCE_ID, newInstanceId);
properties.put(ConfigurationSwitchInstanceBulkAction.PROPERTY_NEW_INSTANCE_ID, newInstanceId);
bulkAction.setProperties(properties);
// prevalidate
bulkActionManager.prevalidate(bulkAction);
// change
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, null, null, 1l);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ConfigurationSwitchInstanceBulkActionIntegrationTest method testProcessWithoutAuthority.
@Test
public void testProcessWithoutAuthority() {
logout();
loginWithout(TestHelper.ADMIN_USERNAME, IdmGroupPermission.APP_ADMIN, CoreGroupPermission.SCHEDULER_ADMIN, CoreGroupPermission.SCHEDULER_UPDATE);
//
IdmBulkActionDto bulkAction = this.findBulkAction(IdmConfiguration.class, ConfigurationSwitchInstanceBulkAction.NAME);
Map<String, Object> properties = new HashMap<>();
properties.put(ConfigurationSwitchInstanceBulkAction.PROPERTY_PREVIOUS_INSTANCE_ID, getHelper().createName());
properties.put(ConfigurationSwitchInstanceBulkAction.PROPERTY_NEW_INSTANCE_ID, getHelper().createName());
bulkAction.setProperties(properties);
// prevalidate
bulkActionManager.prevalidate(bulkAction);
// change
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, null, null, 1l);
}
Aggregations