Search in sources :

Example 16 with ModelExecuteOptionsType

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

the class AbstractTestForExchangeConnector method createRaw.

protected ModelExecuteOptionsType createRaw() {
    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setRaw(true);
    return options;
}
Also used : ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)

Example 17 with ModelExecuteOptionsType

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

the class AbstractTestForExchangeConnector method modifyObject.

// values: path -> value or collection of values
protected ObjectDeltaOperationType modifyObject(Class objectType, String oid, ModificationTypeType modType, Map<String, Object> values, ModelExecuteOptionsType optionsType, boolean assertSuccess) throws Exception {
    System.out.println("Modifying " + objectType.getSimpleName() + " " + oid + " (values: " + values + ")");
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(objectType));
    deltaType.setChangeType(ChangeTypeType.MODIFY);
    deltaType.setOid(oid);
    for (Map.Entry<String, Object> entry : values.entrySet()) {
        ItemDeltaType itemDelta = new ItemDeltaType();
        itemDelta.setModificationType(modType);
        itemDelta.setPath(createNonDefaultItemPathType(entry.getKey()));
        if (!(entry.getValue() instanceof Collection)) {
            itemDelta.getValue().add(entry.getValue());
        } else {
            itemDelta.getValue().addAll((Collection) (entry.getValue()));
        }
        deltaType.getItemDelta().add(itemDelta);
    }
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ObjectDeltaOperationListType odolist = modelPort.executeChanges(deltaListType, optionsType);
    return assertExecuteChangesSuccess(odolist, deltaType, assertSuccess);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) Collection(java.util.Collection) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) Map(java.util.Map) HashMap(java.util.HashMap) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 18 with ModelExecuteOptionsType

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

the class AbstractTestForExchangeConnector method createObject.

protected String createObject(Class clazz, ObjectType objectType, ModelExecuteOptionsType options, boolean assertSuccess) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(clazz));
    deltaType.setChangeType(ChangeTypeType.ADD);
    deltaType.setObjectToAdd(objectType);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ObjectDeltaOperationListType operationListType = modelPort.executeChanges(deltaListType, options);
    lastOdo = assertExecuteChangesSuccess(operationListType, null, assertSuccess);
    //        }
    return ModelClientUtil.getOidFromDeltaOperationList(operationListType, deltaType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 19 with ModelExecuteOptionsType

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

the class TestExchangeConnectorLow method test210ModifyingNonexistingPowerShellObject.

@Test
public void test210ModifyingNonexistingPowerShellObject() throws Exception {
    // create shadow with non-existing GUID
    System.out.println("Creating shadow with non-existing GUID...");
    Document doc = ModelClientUtil.getDocumnent();
    String name = "Wrong GUID shadow";
    ShadowType shadow = new ShadowType();
    shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
    shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
    shadow.setObjectClass(OC_ACCEPTED_DOMAIN);
    shadow.setKind(ShadowKindType.GENERIC);
    shadow.setIntent("custom-accepted-domain");
    ShadowAttributesType attributes = new ShadowAttributesType();
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
    attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "uid"), "wrong-GUID", doc));
    shadow.setAttributes(attributes);
    String oid = createObject(ShadowType.class, shadow, createRaw());
    System.out.println("Done, reading it back...");
    ShadowType shadowReadAgain = getObjectNoFetch(ShadowType.class, oid);
    dumpAttributes(shadowReadAgain);
    System.out.println("Now launching modifyObject operation...");
    //Class objectType, String oid, String path, ModificationTypeType modType, Object value, ModelExecuteOptionsType optionsType, boolean assertSuccess
    ObjectDeltaOperationType odo = modifyObject(ShadowType.class, oid, "attributes/DomainType", ModificationTypeType.REPLACE, "InternalRelay", null, false);
    OperationResultType r = odo.getExecutionResult();
    System.out.println("Done: " + r.getStatus() + ":" + r.getMessage());
    OperationResultType found = findOperationResult(r, new OperationResultMatcher() {

        @Override
        public boolean match(OperationResultType r) {
            return r.getDetails() != null && r.getDetails().contains("UnknownUidException");
        }
    });
    AssertJUnit.assertNotNull("UnknownUidException was not detected", found);
    System.out.println("======================================================================================================");
    System.out.println("Details: " + found.getDetails());
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 20 with ModelExecuteOptionsType

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

the class TestSanityLegacy method test005resolveConnectorRef.

@Test
public void test005resolveConnectorRef() throws Exception {
    TestUtil.displayTestTile("test005resolveConnectorRef");
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));
    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setIsImport(Boolean.TRUE);
    addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), new Holder<OperationResultType>());
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<ResourceType> uObject = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, repoResult);
    assertNotNull(uObject);
    ResourceType resourceType = uObject.asObjectable();
    assertNotNull("Reference on the connector must not be null in resource.", resourceType.getConnectorRef());
    assertNotNull("Missing oid reference on the connector", resourceType.getConnectorRef().getOid());
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) File(java.io.File) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)18 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)17 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)17 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)10 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)8 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 Test (org.testng.annotations.Test)6 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 File (java.io.File)4 QName (javax.xml.namespace.QName)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 Holder (javax.xml.ws.Holder)3 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)2 ObjectAlreadyExistsFaultType (com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType)2 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)2 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)2