use of eu.bcvsolutions.idm.core.api.dto.AbstractDto 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.dto.AbstractDto 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.dto.AbstractDto in project CzechIdMng by bcvsolutions.
the class IdentityAddContractGuaranteeBulkActionTest method processByIdsNoGuaranteesMoreContracts.
@Test
public void processByIdsNoGuaranteesMoreContracts() {
List<IdmIdentityDto> guarantees = this.createIdentities(3);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
IdmIdentityContractDto contract2 = getHelper().createContract(employee);
List<IdmIdentityContractDto> contracts = Arrays.asList(contract1, contract2);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
Map<String, Object> properties = new HashMap<>();
List<String> uuidStrings = guarantees.stream().map(AbstractDto::getId).map(Object::toString).collect(Collectors.toList());
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_NEW_GUARANTEE, uuidStrings);
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test guarantes on all contracts
for (IdmIdentityContractDto contract : contracts) {
// expected number of guarantees
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract.getId());
Assert.assertEquals(guarantees.size(), assigned.size());
// none of expected guarantees are missing in created cintractGuarantee bindings
Assert.assertTrue(isContractGuarantee(contract, guarantees).isEmpty());
}
}
use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.
the class IdentityAddContractGuaranteeBulkActionTest method processByIdsGuaranteeNotSetTwice.
@Test
public void processByIdsGuaranteeNotSetTwice() {
List<IdmIdentityDto> guarantees = this.createIdentities(1);
IdmIdentityDto employee = getHelper().createIdentity();
IdmIdentityContractDto contract1 = getHelper().getPrimeContract(employee);
// set guarantee before reassigned by BA
createContractGuarantees(contract1, guarantees);
Assert.assertTrue(isContractGuarantee(contract1, guarantees).isEmpty());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddContractGuaranteeBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(Arrays.asList(employee));
bulkAction.setIdentifiers(ids);
Map<String, Object> properties = new HashMap<>();
List<String> uuidStrings = guarantees.stream().map(AbstractDto::getId).map(Object::toString).collect(Collectors.toList());
properties.put(IdentityAddContractGuaranteeBulkAction.PROPERTY_NEW_GUARANTEE, uuidStrings);
bulkAction.setProperties(properties);
bulkActionManager.processAction(bulkAction);
// test guarantees on all contracts
List<IdmContractGuaranteeDto> assigned = getGuaranteesForContract(contract1.getId());
// same guarantee is assigned only once
Assert.assertEquals(guarantees.size(), assigned.size());
Set<UUID> assignedGuarUUID = assigned.stream().map(IdmContractGuaranteeDto::getGuarantee).collect(Collectors.toSet());
guarantees.forEach(guarantee -> {
Assert.assertTrue(assignedGuarUUID.contains(guarantee.getId()));
});
}
use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.
the class DefaultValueGeneratorManagerTest method testCreateGenerator.
@Test
public void testCreateGenerator() {
Set<Class<? extends AbstractDto>> supportedTypes = valueGeneratorManager.getSupportedTypes();
//
supportedTypes.forEach(supportedType -> {
List<ValueGeneratorDto> availableGenerators = valueGeneratorManager.getAvailableGenerators(supportedType);
availableGenerators.forEach(generator -> {
IdmFormDefinitionDto formDefinition = generator.getFormDefinition();
//
createGenerator(supportedType, generator.getGeneratorType(), createConfiguration(formDefinition, ImmutableMap.of()), null, null);
});
});
}
Aggregations