Search in sources :

Example 31 with IcObjectClassImpl

use of eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method testRunningOperationInQueue.

@Test
public void testRunningOperationInQueue() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    system.setQueue(true);
    system = systemService.save(system);
    // 
    // create test provisioning context
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // is necessary to get again operation from service
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    SysProvisioningOperationDto operation = provisioningOperationService.find(filter, null).getContent().get(0);
    assertEquals(OperationState.CREATED, operation.getResultState());
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertTrue(systemEntity.isWish());
    assertNull(getHelper().findResource(uid));
    SysProvisioningBatchDto batch = DtoUtils.getEmbedded(operation, SysProvisioningOperation_.batch);
    Assert.assertNull(batch.getNextAttempt());
    // 
    // set operation state to running manually
    operation.getResult().setState(OperationState.RUNNING);
    operation = provisioningOperationService.save(operation);
    // 
    // created the second operation
    ProvisioningContext context = new ProvisioningContext();
    String firstname = "firstname2";
    accoutObject = createAccountObject(systemEntity, firstname);
    context.setAccountObject(accoutObject);
    // 
    // prepare provisioning operation
    SysSystemMappingDto systemMapping = getHelper().getDefaultMapping(system);
    IcObjectClass objectClass = new IcObjectClassImpl(schemaObjectClassService.get(systemMapping.getObjectClass()).getObjectClassName());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(null, objectClass, null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningOperationType.CREATE).setSystemEntity(systemEntity).setProvisioningContext(new ProvisioningContext(accoutObject, connectorObject));
    SysProvisioningOperationDto secondOperation = operationBuilder.build();
    // for quick search
    secondOperation.setId(UUID.randomUUID());
    // 
    // publish event
    provisioningExecutor.execute(secondOperation);
    // 
    secondOperation = provisioningOperationService.get(secondOperation);
    batch = provisioningBatchService.get(batch);
    Assert.assertNotNull(batch.getNextAttempt());
    // 
    // retry - the operation is still running
    RetryProvisioningTaskExecutor retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
    Boolean result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
    Assert.assertTrue(result);
    operation = provisioningOperationService.get(operation);
    secondOperation = provisioningOperationService.get(secondOperation);
    // 
    Assert.assertEquals(OperationState.RUNNING, operation.getResultState());
    Assert.assertEquals(OperationState.NOT_EXECUTED, secondOperation.getResultState());
    // 
    operation.getResult().setState(OperationState.EXECUTED);
    operation = provisioningOperationService.save(operation);
    // Account cannot exist now
    TestResource resource = getHelper().findResource(uid);
    Assert.assertNull(resource);
    // 
    // retry - expected success now
    retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
    result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
    Assert.assertTrue(result);
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    Assert.assertFalse(systemEntity.isWish());
    resource = getHelper().findResource(uid);
    Assert.assertNotNull(resource);
    Assert.assertEquals(firstname, resource.getFirstname());
    batch = provisioningBatchService.get(batch.getId());
    Assert.assertNull(batch.getNextAttempt());
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) RetryProvisioningTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.RetryProvisioningTaskExecutor) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 32 with IcObjectClassImpl

use of eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningArchiveServiceIntegrationTest method testOperationArchivateWithSingleRemovedAttributeWithNullValue.

@Test
public void testOperationArchivateWithSingleRemovedAttributeWithNullValue() {
    SysSystemDto system = getHelper().createTestResourceSystem(false);
    // 
    IcAttribute icAttributeOne = new IcAttributeImpl(getHelper().createName(), null);
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
    // 
    SysProvisioningOperationDto operation = prepareProvisioningOperation(system);
    operation.getProvisioningContext().setConnectorObject(connectorObject);
    // 
    SysProvisioningArchiveDto archive = service.archive(operation);
    // 
    List<SysProvisioningAttribute> attributes = provisioningAttributeRepository.findAllByProvisioningId(archive.getId());
    // 
    Assert.assertEquals(1, attributes.size());
    Assert.assertEquals(icAttributeOne.getName(), attributes.get(0).getName());
    Assert.assertTrue(attributes.get(0).isRemoved());
}
Also used : SysProvisioningAttribute(eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 33 with IcObjectClassImpl

use of eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningArchiveServiceIntegrationTest method testOperationArchivateWithMultiRemovedAttributeWithEmptyValue.

@Test
public void testOperationArchivateWithMultiRemovedAttributeWithEmptyValue() {
    SysSystemDto system = getHelper().createTestResourceSystem(false);
    // 
    IcAttribute icAttributeOne = new IcAttributeImpl(getHelper().createName(), Lists.newArrayList(""));
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
    // 
    SysProvisioningOperationDto operation = prepareProvisioningOperation(system);
    operation.getProvisioningContext().setConnectorObject(connectorObject);
    // 
    SysProvisioningArchiveDto archive = service.archive(operation);
    // 
    List<SysProvisioningAttribute> attributes = provisioningAttributeRepository.findAllByProvisioningId(archive.getId());
    // 
    Assert.assertEquals(1, attributes.size());
    Assert.assertEquals(icAttributeOne.getName(), attributes.get(0).getName());
    Assert.assertTrue(attributes.get(0).isRemoved());
}
Also used : SysProvisioningAttribute(eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 34 with IcObjectClassImpl

use of eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectUpdateSingleTest.

@Test
public void differenceObjectUpdateSingleTest() {
    String attrName = getHelper().createName();
    IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, "TEST1");
    IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
    IcAttributeImpl icAttributeTwo = new IcAttributeImpl(attrName, "TEST2");
    IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeTwo));
    List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
    Assert.assertEquals(1, diffs.size());
    Assert.assertFalse(diffs.get(0).isMultivalue());
    Assert.assertEquals(SysValueChangeType.UPDATED, diffs.get(0).getValue().getChange());
    Assert.assertEquals("TEST1", diffs.get(0).getValue().getOldValue());
    Assert.assertEquals("TEST2", diffs.get(0).getValue().getValue());
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 35 with IcObjectClassImpl

use of eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectAddSingleTest.

@Test
public void differenceObjectAddSingleTest() {
    String attrName = getHelper().createName();
    IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, "TEST1");
    IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
    IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of());
    List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
    Assert.assertEquals(1, diffs.size());
    Assert.assertFalse(diffs.get(0).isMultivalue());
    Assert.assertEquals(SysValueChangeType.ADDED, diffs.get(0).getValue().getChange());
    Assert.assertEquals(null, diffs.get(0).getValue().getOldValue());
    Assert.assertEquals("TEST1", diffs.get(0).getValue().getValue());
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)35 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)26 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)19 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)19 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 Test (org.junit.Test)16 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)14 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)12 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)12 IcAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcAttributeImpl)12 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)10 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)9 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)7 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)7 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)7 SysProvisioningAttribute (eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute)7 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)6 ArrayList (java.util.ArrayList)6