Search in sources :

Example 41 with ResourceType

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

the class TestResourceSchema method testUnmarshallResource.

@Test
public void testUnmarshallResource() throws Exception {
    System.out.println("===[ testUnmarshallResource ]===");
    // WHEN
    ResourceType resourceType = (ResourceType) PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")).asObjectable();
    // THEN
    assertCapabilities(resourceType);
}
Also used : ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) File(java.io.File) Test(org.testng.annotations.Test)

Example 42 with ResourceType

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

the class TestResourceSchema method testParseResource.

@Test
public void testParseResource() throws Exception {
    System.out.println("===[ testParseResource ]===");
    // WHEN
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml"));
    // THEN
    assertCapabilities(resource.asObjectable());
}
Also used : ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) File(java.io.File) Test(org.testng.annotations.Test)

Example 43 with ResourceType

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

the class TestResourceSchema method testResourceSchemaJaxbRoundTrip.

// The support for the xsd:any properties is missing in JAXB generator. Otherwise this test should work.
@Test(enabled = false)
public void testResourceSchemaJaxbRoundTrip() throws SchemaException, JAXBException {
    System.out.println("\n===[ testResourceSchemaJaxbRoundTrip ]=====");
    // GIVEN
    ResourceSchema schema = createResourceSchema();
    System.out.println("Resource schema before serializing to XSD: ");
    System.out.println(schema.debugDump());
    System.out.println();
    Document xsd = schema.serializeToXsd();
    ResourceType resource = new ResourceType();
    resource.setName(PrismTestUtil.createPolyStringType("JAXB With Dynamic Schemas Test"));
    ResourceTypeUtil.setResourceXsdSchema(resource, DOMUtil.getFirstChildElement(xsd));
    // WHEN
    //		JAXBElement<ResourceType> resourceElement = new JAXBElement<ResourceType>(SchemaConstants.C_RESOURCE, ResourceType.class, resource);
    //		String marshalledResource = PrismTestUtil.marshalElementToString(resourceElement);
    String marshalledResource = PrismTestUtil.serializeObjectToString(resource.asPrismObject());
    System.out.println("Marshalled resource");
    System.out.println(marshalledResource);
    ResourceType unmarshalledResource = (ResourceType) PrismTestUtil.parseObject(marshalledResource).asObjectable();
    System.out.println("unmarshalled resource");
    System.out.println(ObjectTypeUtil.dump(unmarshalledResource));
    XmlSchemaType unXmlSchemaType = unmarshalledResource.getSchema();
    Element unXsd = unXmlSchemaType.getDefinition().getAny().get(0);
    ResourceSchema unSchema = ResourceSchemaImpl.parse(unXsd, "unmarshalled resource", PrismTestUtil.getPrismContext());
    System.out.println("unmarshalled schema");
    System.out.println(unSchema.debugDump());
    // THEN
    assertResourceSchema(unSchema);
}
Also used : Element(org.w3c.dom.Element) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document) XmlSchemaType(com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType) Test(org.testng.annotations.Test)

Example 44 with ResourceType

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

the class TestResourceSchema method testResourceSchemaSerializationInResource.

@Test
public void testResourceSchemaSerializationInResource() throws SchemaException, JAXBException {
    System.out.println("\n===[ testResourceSchemaSerializationInResource ]=====");
    // GIVEN
    ResourceSchema schema = createResourceSchema();
    // WHEN
    Document xsdDocument = schema.serializeToXsd();
    Element xsdElement = DOMUtil.getFirstChildElement(xsdDocument);
    PrismObject<ResourceType> resource = wrapInResource(xsdElement);
    String resourceXmlString = PrismTestUtil.getPrismContext().serializeObjectToString(resource, PrismContext.LANG_XML);
    System.out.println("Serialized resource");
    System.out.println(resourceXmlString);
    PrismObject<ResourceType> reparsedResource = PrismTestUtil.getPrismContext().parseObject(resourceXmlString);
    System.out.println("Re-parsed resource");
    System.out.println(reparsedResource.debugDump());
    XmlSchemaType reparsedSchemaType = reparsedResource.asObjectable().getSchema();
    Element reparsedXsdElement = ObjectTypeUtil.findXsdElement(reparsedSchemaType);
    System.out.println("Reparsed XSD schema");
    System.out.println(DOMUtil.serializeDOMToString(reparsedXsdElement));
    assertDomSchema(reparsedXsdElement);
}
Also used : Element(org.w3c.dom.Element) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Document(org.w3c.dom.Document) XmlSchemaType(com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType) Test(org.testng.annotations.Test)

Example 45 with ResourceType

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

the class PageAccounts method createIntentChoices.

private IModel<List<String>> createIntentChoices() {
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> intentList = new ArrayList<>();
            ResourceItemDto dto = resourceModel.getObject();
            PrismObject<ResourceType> resourcePrism;
            if (dto == null) {
                return intentList;
            }
            String oid = dto.getOid();
            OperationResult result = new OperationResult(OPERATION_GET_INTENTS);
            try {
                resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
                ResourceType resource = resourcePrism.asObjectable();
                SchemaHandlingType schemaHandling = resource.getSchemaHandling();
                for (ResourceObjectTypeDefinitionType r : schemaHandling.getObjectType()) {
                    intentList.add(r.getIntent());
                }
            } catch (Exception e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
                error("Couldn't load intents from resource.");
                return null;
            }
            return intentList;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

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