Search in sources :

Example 96 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class TestBrokenResources method test359DeleteResourceWrongConnectorOid.

@Test
public void test359DeleteResourceWrongConnectorOid() throws Exception {
    final String TEST_NAME = "test359DeleteResourceWrongConnectorOid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<ResourceType> delta = ObjectDelta.createDeleteDelta(ResourceType.class, RESOURCE_DUMMY_WRONG_CONNECTOR_OID_OID, prismContext);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    display("getObject result", result);
    assertEquals("Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
    assertNoObject(ResourceType.class, RESOURCE_DUMMY_WRONG_CONNECTOR_OID_OID, task, result);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 97 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createModifyUserUnlinkAccount.

protected ObjectDelta<UserType> createModifyUserUnlinkAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    String accountOid = getLinkRefOid(userOid, resource.getOid());
    ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, userOid, prismContext);
    PrismReferenceValue accountRefVal = new PrismReferenceValue();
    accountRefVal.setOid(accountOid);
    ReferenceDelta accountDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
    userDelta.addModification(accountDelta);
    return userDelta;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 98 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createAccountShadowQuery.

protected ObjectQuery createAccountShadowQuery(String username, PrismObject<ResourceType> resource) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getPrimaryIdentifiers();
    assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
    ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
    //TODO: set matching rule instead of null
    return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(username).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 99 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createModifyUserAddAccount.

protected ObjectDelta<UserType> createModifyUserAddAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException {
    PrismObject<ShadowType> account = getAccountShadowDefinition().instantiate();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    account.asObjectable().setResourceRef(resourceRef);
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    account.asObjectable().setObjectClass(refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT).getObjectClassDefinition().getTypeName());
    ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, userOid, prismContext);
    PrismReferenceValue accountRefVal = new PrismReferenceValue();
    accountRefVal.setObject(account);
    ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
    userDelta.addModification(accountDelta);
    return userDelta;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 100 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class TestDummy method test110SeachIterative.

@Test
public void test110SeachIterative() throws Exception {
    final String TEST_NAME = "test110SeachIterative";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
    // Make sure there is an account on resource that the provisioning has
    // never seen before, so there is no shadow
    // for it yet.
    DummyAccount newAccount = new DummyAccount("meathook");
    newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Meathook");
    newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey");
    newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
    newAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 666L);
    newAccount.setEnabled(true);
    newAccount.setPassword("parrotMonster");
    dummyResource.addAccount(newAccount);
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext);
    final XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    final Holder<Boolean> seenMeathookHolder = new Holder<Boolean>(false);
    final List<PrismObject<ShadowType>> foundObjects = new ArrayList<PrismObject<ShadowType>>();
    ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {

        @Override
        public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
            foundObjects.add(object);
            display("Found", object);
            XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
            assertTrue(object.canRepresent(ShadowType.class));
            try {
                checkAccountShadow(object, parentResult, true, startTs, endTs);
            } catch (SchemaException e) {
                throw new SystemException(e.getMessage(), e);
            }
            assertCachingMetadata(object, false, startTs, endTs);
            if (object.asObjectable().getName().getOrig().equals("meathook")) {
                meathookAccountOid = object.getOid();
                seenMeathookHolder.setValue(true);
                try {
                    Long loot = ShadowUtil.getAttributeValue(object, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME));
                    assertEquals("Wrong meathook's loot", (Long) 666L, loot);
                } catch (SchemaException e) {
                    throw new SystemException(e.getMessage(), e);
                }
            }
            return true;
        }
    };
    rememberShadowFetchOperationCount();
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
    // THEN
    XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
    result.computeStatus();
    display("searchObjectsIterative result", result);
    TestUtil.assertSuccess(result);
    assertShadowFetchOperationCountIncrement(1);
    assertEquals(4, foundObjects.size());
    checkConsistency(foundObjects);
    assertProtected(foundObjects, 1);
    PrismObject<ShadowType> shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
    assertRepoShadowCachedAttributeValue(shadowWillRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman");
    checkRepoAccountShadowWill(shadowWillRepo, startTs, endTs);
    PrismObject<ShadowType> shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
    display("Meathook shadow", shadowMeathook);
    assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
    assertRepoCachingMetadata(shadowMeathook, startTs, endTs);
    // And again ...
    foundObjects.clear();
    rememberShadowFetchOperationCount();
    XMLGregorianCalendar startTs2 = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
    // THEN
    XMLGregorianCalendar endTs2 = clock.currentTimeXMLGregorianCalendar();
    assertShadowFetchOperationCountIncrement(1);
    display("Found shadows", foundObjects);
    assertEquals(4, foundObjects.size());
    checkConsistency(foundObjects);
    assertProtected(foundObjects, 1);
    shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
    checkRepoAccountShadowWill(shadowWillRepo, startTs2, endTs2);
    shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
    assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
    assertRepoCachingMetadata(shadowMeathook, startTs2, endTs2);
    assertSteadyResource();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(com.evolveum.midpoint.util.Holder) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismObject(com.evolveum.midpoint.prism.PrismObject) SystemException(com.evolveum.midpoint.util.exception.SystemException) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Aggregations

ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)252 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)199 Test (org.testng.annotations.Test)165 Task (com.evolveum.midpoint.task.api.Task)115 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)54 PrismObject (com.evolveum.midpoint.prism.PrismObject)50 QName (javax.xml.namespace.QName)45 ArrayList (java.util.ArrayList)37 Element (org.w3c.dom.Element)34 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)33 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)30 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)24 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)23 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23