Search in sources :

Example 6 with DummyResourceContoller

use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.

the class TestIteration method test820SubtypeSetByInbound.

/**
 * MID-5618: When subtype is set by inbound, wrong iterator is used.
 */
@Test
public void test820SubtypeSetByInbound() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    setDefaultObjectTemplate(UserType.COMPLEX_TYPE, null);
    setDefaultObjectTemplate(UserType.COMPLEX_TYPE, "associate", USER_TEMPLATE_ITERATION_ASSOCIATE_OID, result);
    DummyResourceContoller associateCtl = dummyResourceCollection.get("associate");
    // should be imported as jim-0
    associateCtl.addAccount("u1", "jim");
    // should be imported as jim-1
    associateCtl.addAccount("u2", "jim");
    ObjectQuery query = prismContext.queryFor(ShadowType.class).item(ShadowType.F_RESOURCE_REF).ref(RESOURCE_DUMMY_ASSOCIATE_OID).and().item(ShadowType.F_OBJECT_CLASS).eq(SchemaConstants.RI_ACCOUNT_OBJECT_CLASS).build();
    SearchResultList<PrismObject<ShadowType>> shadows = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    display("shadows", shadows);
    assertEquals("Wrong # of shadows", 2, shadows.size());
    // WHEN
    when();
    importFromResourceLauncher.importSingleShadow(shadows.get(0).getOid(), task, result);
    importFromResourceLauncher.importSingleShadow(shadows.get(1).getOid(), task, result);
    // THEN
    then();
    assertSuccess(result);
    ObjectQuery userQuery = prismContext.queryFor(UserType.class).item(UserType.F_SUBTYPE).eq("associate").asc(UserType.F_NAME).build();
    SearchResultList<PrismObject<UserType>> usersAfter = repositoryService.searchObjects(UserType.class, userQuery, null, result);
    display("users", usersAfter);
    assertEquals("Wrong # of created users", 2, usersAfter.size());
    assertEquals("Wrong name of user 1", "jim-0", usersAfter.get(0).getName().getOrig());
    assertEquals("Wrong name of user 2", "jim-1", usersAfter.get(1).getName().getOrig());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 7 with DummyResourceContoller

use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.

the class TestWriter method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    DummyResourceContoller writerDummyController = DummyResourceContoller.create(RESOURCE_WRITER_DUMMY_NAME);
    writerDummyController.extendSchemaPirate();
    dummyResourceCollection.initDummyResource(RESOURCE_WRITER_DUMMY_NAME, writerDummyController);
    PrismObject<ResourceType> resourceWriter = importAndGetObjectFromFile(ResourceType.class, RESOURCE_WRITER_FILE, RESOURCE_WRITER_OID, initTask, initResult);
    writerDummyController.setResource(resourceWriter);
}
Also used : ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller)

Example 8 with DummyResourceContoller

use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.

the class AbstractProvisioningIntegrationTest method initDummyResource.

protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, FailableProcessor<DummyResourceContoller> controllerInitLambda, OperationResult result) throws Exception {
    DummyResourceContoller controller = DummyResourceContoller.create(name);
    if (controllerInitLambda != null) {
        controllerInitLambda.process(controller);
    } else {
        controller.populateWithDefaultSchema();
    }
    if (resourceFile != null) {
        addResourceFromFile(resourceFile, IntegrationTestTools.DUMMY_CONNECTOR_TYPE, result);
    }
    if (resourceOid != null) {
        PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, resourceOid, null, result);
        controller.setResource(resource);
    }
    return controller;
}
Also used : DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller)

Example 9 with DummyResourceContoller

use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.

the class DummyResourceCollection method initDummyResource.

public DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, FailableProcessor<DummyResourceContoller> controllerInitLambda, Task task, OperationResult result) throws Exception {
    if (map.containsKey(name)) {
        throw new IllegalArgumentException("Dummy resource " + name + " already initialized");
    }
    DummyResourceContoller controller = DummyResourceContoller.create(name);
    if (controllerInitLambda != null) {
        controllerInitLambda.process(controller);
    } else {
        controller.populateWithDefaultSchema();
    }
    if (resourceFile != null) {
        LOGGER.info("Importing {}", resourceFile);
        modelService.importObjectsFromFile(resourceFile, null, task, result);
        OperationResult importResult = result.getLastSubresult();
        if (importResult.isError()) {
            throw new RuntimeException("Error importing " + resourceFile + ": " + importResult.getMessage());
        }
        LOGGER.debug("File {} imported: {}", resourceFile, importResult);
    }
    if (resourceOid != null) {
        PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, resourceOid, null, task, result);
        controller.setResource(resource);
    }
    map.put(name, controller);
    return controller;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller)

Example 10 with DummyResourceContoller

use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.

the class AbstractProvisioningIntegrationTest method initDummyResource.

protected DummyResourceContoller initDummyResource(DummyTestResource resource, OperationResult result) throws Exception {
    DummyResourceContoller controller = initDummyResource(resource.name, resource.file, resource.oid, resource.controllerInitLambda, result);
    resource.controller = controller;
    return controller;
}
Also used : DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller)

Aggregations

DummyResourceContoller (com.evolveum.midpoint.test.DummyResourceContoller)12 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 Task (com.evolveum.midpoint.task.api.Task)2 Test (org.testng.annotations.Test)2 DummyResource (com.evolveum.icf.dummy.resource.DummyResource)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 FileNotFoundException (java.io.FileNotFoundException)1 ConnectException (java.net.ConnectException)1