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);
}
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());
}
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);
}
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);
}
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;
}
};
}
Aggregations