use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ConfigurationSwitchInstanceBulkActionIntegrationTest method testReuseAsynchronousEventInstanceId.
@Test
public void testReuseAsynchronousEventInstanceId() {
String eventInstanceId = getHelper().createName();
IdmConfigurationDto instanceId = configurationService.getByCode(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_INSTANCE_ID);
if (instanceId == null) {
configurationService.setValue(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_INSTANCE_ID, eventInstanceId);
instanceId = configurationService.getByCode(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_INSTANCE_ID);
} else {
eventInstanceId = instanceId.getValue();
}
//
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);
//
IdmConfigurationDto afterActionInstanceId = configurationService.getByCode(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_INSTANCE_ID);
Assert.assertNotNull(afterActionInstanceId);
Assert.assertEquals(instanceId.getId(), afterActionInstanceId.getId());
Assert.assertEquals(eventInstanceId, afterActionInstanceId.getValue());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest method preprocessBulkActionWithoutGuarantees.
@Test
public void preprocessBulkActionWithoutGuarantees() {
IdmIdentityDto employee = getHelper().createIdentity();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityChangeContractGuaranteeBulkAction.NAME);
bulkAction.getIdentifiers().add(employee.getId());
IdmBulkActionDto bulkActionPreprocessed = bulkActionManager.preprocessBulkAction(bulkAction);
IdmFormAttributeDto oldGuaranteeFormAttribute = bulkActionPreprocessed.getFormAttributes().stream().filter(attr -> attr.getCode().equals(AbstractContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE)).findFirst().orElse(null);
assertNotNull(oldGuaranteeFormAttribute);
List<UUID> oldGuaranteeIds = oldGuaranteeFormAttribute.getForceSearchParameters().getIds();
// it will always be 1 which is a random id not corresponding to an actual identity
assertEquals(1, oldGuaranteeIds.size());
assertNull(identityService.get(oldGuaranteeIds.get(0)));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest method changeWhereContractContainsOldGuarantee.
// Test that there are changed only contracts which contained at least one old guarantee.
@Test
public void changeWhereContractContainsOldGuarantee() {
List<IdmIdentityDto> oldGuarantees = this.createIdentities(2);
List<IdmIdentityDto> newGuarantees = this.createIdentities(1);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
IdmIdentityContractDto contract2 = getHelper().createContract(employee);
createContractGuarantees(contract1, oldGuarantees.subList(0, 1));
createContractGuarantees(contract2, oldGuarantees.subList(1, oldGuarantees.size()));
Assert.assertTrue(isContractGuarantee(contract1, oldGuarantees.subList(0, 1)).isEmpty());
Assert.assertTrue(isContractGuarantee(contract2, oldGuarantees.subList(1, oldGuarantees.size())).isEmpty());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityChangeContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE, oldGuarantees.get(0).getId().toString());
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_NEW_GUARANTEE, newGuarantees.get(0).getId().toString());
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test that there remains on both contracts only one guarantee
// CONTRACT1
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract1.getId());
Assert.assertEquals(1, assigned.size());
List<IdmIdentityDto> expectedDto = new ArrayList<IdmIdentityDto>(newGuarantees);
Assert.assertTrue(isContractGuarantee(contract1, expectedDto).isEmpty());
// CONTRACT2
assigned = getGuaranteesForContract(contract2.getId());
Assert.assertEquals(1, assigned.size());
// old guarantee stayed added
expectedDto = new ArrayList<IdmIdentityDto>(oldGuarantees.subList(1, 2));
Assert.assertTrue(isContractGuarantee(contract2, expectedDto).isEmpty());
// newly set guarantee is not applied
expectedDto = new ArrayList<IdmIdentityDto>(newGuarantees);
Assert.assertEquals(1, isContractGuarantee(contract2, expectedDto).size());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest method prevalidateBulkActionWithoutGuarantees.
@Test
public void prevalidateBulkActionWithoutGuarantees() {
IdmIdentityDto employee = getHelper().createIdentity();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityChangeContractGuaranteeBulkAction.NAME);
bulkAction.getIdentifiers().add(employee.getId());
// 1 result model, info, warning that no contract guarantee exists
ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
assertEquals(1, resultModels.getInfos().size());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityChangeContractGuaranteeBulkActionTest method processByIdsChangeSelected.
@Test
public void processByIdsChangeSelected() {
List<IdmIdentityDto> oldGuarantees = this.createIdentities(2);
List<IdmIdentityDto> newGuarantees = this.createIdentities(1);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
IdmIdentityContractDto contract2 = getHelper().createContract(employee);
createContractGuarantees(contract1, oldGuarantees);
createContractGuarantees(contract2, oldGuarantees);
Assert.assertTrue(isContractGuarantee(contract1, oldGuarantees).isEmpty());
Assert.assertTrue(isContractGuarantee(contract2, oldGuarantees).isEmpty());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityChangeContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE, oldGuarantees.get(0).getId().toString());
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_NEW_GUARANTEE, newGuarantees.get(0).getId().toString());
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test that there remains on both contracts only one guarantee
// CONTRACT1
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract1.getId());
Assert.assertEquals(2, assigned.size());
List<IdmIdentityDto> expectedDto = new ArrayList<IdmIdentityDto>(oldGuarantees.subList(1, 2));
expectedDto.addAll(newGuarantees);
Assert.assertTrue(isContractGuarantee(contract1, expectedDto).isEmpty());
// CONTRACT2
assigned = getGuaranteesForContract(contract2.getId());
Assert.assertEquals(2, assigned.size());
expectedDto = new ArrayList<IdmIdentityDto>(oldGuarantees.subList(1, 2));
expectedDto.addAll(newGuarantees);
Assert.assertTrue(isContractGuarantee(contract2, expectedDto).isEmpty());
}
Aggregations