Search in sources :

Example 66 with IdmBulkActionDto

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());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) HashMap(java.util.HashMap) IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 67 with IdmBulkActionDto

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)));
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 68 with IdmBulkActionDto

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());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 69 with IdmBulkActionDto

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());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 70 with IdmBulkActionDto

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());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Aggregations

IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)262 Test (org.junit.Test)238 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)220 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)142 UUID (java.util.UUID)129 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)98 HashMap (java.util.HashMap)72 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)64 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)52 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)41 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)38 ResultModels (eu.bcvsolutions.idm.core.api.dto.ResultModels)35 HashSet (java.util.HashSet)33 List (java.util.List)29 Autowired (org.springframework.beans.factory.annotation.Autowired)26 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)24 After (org.junit.After)21 Assert (org.junit.Assert)21 Before (org.junit.Before)21 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)20