use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityRemoveContractGuaranteeBulkActionTest method preprocessBulkActionWithGuarantees.
@Test
public void preprocessBulkActionWithGuarantees() {
List<IdmIdentityDto> guarantees = this.createIdentities(2);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
createContractGuarantees(contract1, guarantees);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRemoveContractGuaranteeBulkAction.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();
assertEquals(2, oldGuaranteeIds.size());
assertTrue(oldGuaranteeIds.contains(guarantees.get(0).getId()));
assertTrue(oldGuaranteeIds.contains(guarantees.get(1).getId()));
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityRemoveContractGuaranteeBulkActionTest method preprocessBulkActionWithoutGuarantees.
@Test
public void preprocessBulkActionWithoutGuarantees() {
IdmIdentityDto employee = getHelper().createIdentity();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRemoveContractGuaranteeBulkAction.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 IdentityRemoveContractGuaranteeBulkActionTest method ifMultipleSameGuaranteesRemoveAll.
@Test
public void ifMultipleSameGuaranteesRemoveAll() {
List<IdmIdentityDto> guarantees = this.createIdentities(4);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
createContractGuarantees(contract1, guarantees.subList(0, guarantees.size()));
// first guarantee assigned twice - possible from UI
createContractGuarantees(contract1, guarantees.subList(0, 1));
Assert.assertEquals(guarantees.size() + 1, getGuaranteesForContract(contract1.getId()).size());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRemoveContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
// selected identityDtos
List<String> uuidStrings = guarantees.subList(0, guarantees.size() - 1).stream().map(AbstractDto::getId).map(Object::toString).collect(Collectors.toList());
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE, uuidStrings);
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test that there remains only one guarantee
// both instances of the twice added guarantee were removed
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract1.getId());
Assert.assertEquals(1, assigned.size());
Assert.assertEquals(guarantees.get(guarantees.size() - 1).getId(), assigned.get(0).getGuarantee());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityRemoveContractGuaranteeBulkActionTest method processByIdsRemoveSelected.
@Test
public void processByIdsRemoveSelected() {
List<IdmIdentityDto> guarantees = this.createIdentities(4);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
IdmIdentityContractDto contract2 = getHelper().createContract(employee);
createContractGuarantees(contract1, guarantees.subList(0, guarantees.size() - 1));
createContractGuarantees(contract2, guarantees.subList(1, guarantees.size()));
Assert.assertTrue(isContractGuarantee(contract1, guarantees.subList(0, guarantees.size() - 1)).isEmpty());
Assert.assertTrue(isContractGuarantee(contract2, guarantees.subList(1, guarantees.size())).isEmpty());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityRemoveContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
// selected identityDtos
List<String> uuidStrings = guarantees.subList(1, 3).stream().map(AbstractDto::getId).map(Object::toString).collect(Collectors.toList());
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_OLD_GUARANTEE, uuidStrings);
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test that there remains on both contracts only one guarantee
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract1.getId());
Assert.assertEquals(1, assigned.size());
Assert.assertEquals(guarantees.get(0).getId(), assigned.get(0).getGuarantee());
assigned = getGuaranteesForContract(contract2.getId());
Assert.assertEquals(1, assigned.size());
Assert.assertEquals(guarantees.get(3).getId(), assigned.get(0).getGuarantee());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormDefinitionDeleteBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
String type = getHelper().createName();
// creates Main definition which won't be deleted
getHelper().createFormDefinition(type, true);
List<IdmFormDefinitionDto> defDtos = new ArrayList<IdmFormDefinitionDto>();
for (int i = 0; i < TEST_COUNT; ++i) {
getHelper().createFormDefinition(type);
}
IdmFormDefinitionFilter filter = new IdmFormDefinitionFilter();
filter.setType(type);
filter.setMain(false);
defDtos = formDefService.find(filter, null).getContent();
Set<UUID> defIds = defDtos.stream().map(IdmFormDefinitionDto::getId).collect(Collectors.toSet());
Assert.assertTrue(defIds.size() == TEST_COUNT);
IdmBulkActionDto bulkAction = findBulkAction(IdmFormDefinition.class, FormDefinitionDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, Long.valueOf(TEST_COUNT), null, null);
filter.setMain(null);
List<IdmFormDefinitionDto> defsRemain = formDefService.find(filter, null).getContent();
Assert.assertEquals(1, defsRemain.size());
Set<UUID> result = defsRemain.stream().map(IdmFormDefinitionDto::getId).collect(Collectors.toSet());
result.retainAll(defIds);
Assert.assertTrue(result.isEmpty());
}
Aggregations