use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto 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.dto.IdmContractGuaranteeDto 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());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto 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.IdmContractGuaranteeDto 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.IdmContractGuaranteeDto in project CzechIdMng by bcvsolutions.
the class DefaultAuditServiceIntegrationTest method testContractGuaranteeOwner.
@Test
public void testContractGuaranteeOwner() {
IdmIdentityDto subordinate = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto manager = getHelper().createIdentity((GuardedString) null);
IdmContractGuaranteeDto contractGuarantee = getHelper().createContractGuarantee(getHelper().getPrimeContract(subordinate), manager);
//
IdmAuditFilter filter = new IdmAuditFilter();
filter.setOwnerId(subordinate.getId().toString());
filter.setType(IdmContractGuarantee.class.getCanonicalName());
//
List<IdmAuditDto> revisions = auditService.find(filter, null).getContent();
Assert.assertEquals(1, revisions.size());
Assert.assertEquals(RevisionType.ADD.name(), revisions.get(0).getModification());
Assert.assertEquals(contractGuarantee.getId(), revisions.get(0).getEntityId());
Assert.assertEquals(subordinate.getId().toString(), revisions.get(0).getOwnerId());
Assert.assertEquals(manager.getId().toString(), revisions.get(0).getSubOwnerId());
//
// non transactional test => cleanup
identityService.delete(subordinate);
identityService.delete(manager);
}
Aggregations