Search in sources :

Example 1 with GenericObjectType

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

the class TestParseGenericObject method testPrismParseJaxbElement.

/**
	 * Parsing in form of JAXBELement
	 * @throws DatatypeConfigurationException 
	 */
@Deprecated
@Test(enabled = false)
public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException {
    System.out.println("===[ testPrismParseJaxbElement ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance();
    // WHEN
    JAXBElement<GenericObjectType> jaxbElement = jaxbProcessor.unmarshalElement(GENERIC_FILE, GenericObjectType.class);
    GenericObjectType genericType = jaxbElement.getValue();
    // THEN
    assertGenericObject(genericType.asPrismObject());
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) JaxbTestUtil(com.evolveum.midpoint.prism.util.JaxbTestUtil) Test(org.testng.annotations.Test)

Example 2 with GenericObjectType

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

the class TestJaxbConstruction method testExtensionTypeConstruction.

@Test
public void testExtensionTypeConstruction() throws Exception {
    System.out.println("\n\n ===[ testExtensionTypeConstruction ]===\n");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    GenericObjectType object = new GenericObjectType();
    prismContext.adopt(object.asPrismObject(), GenericObjectType.class);
    ExtensionType extension = new ExtensionType();
    object.setExtension(extension);
    PrismContainerValue extValue = extension.asPrismContainerValue();
    assertNotNull("No extension definition", extValue.getParent().getDefinition());
    // WHEN
    Item item = extValue.findOrCreateItem(SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT);
    // THEN
    assertNotNull(item);
    object.asPrismObject().checkConsistence();
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) ExtensionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType) Test(org.testng.annotations.Test)

Example 3 with GenericObjectType

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

the class TestParseGenericObject method assertGenericObject.

private void assertGenericObject(PrismObject<GenericObjectType> generic) throws DatatypeConfigurationException {
    generic.checkConsistence();
    assertEquals("Wrong oid", "c0c010c0-d34d-b33f-f00d-999111111111", generic.getOid());
    //		assertEquals("Wrong version", "42", resource.getVersion());
    PrismObjectDefinition<GenericObjectType> resourceDefinition = generic.getDefinition();
    assertNotNull("No resource definition", resourceDefinition);
    PrismAsserts.assertObjectDefinition(resourceDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "genericObject"), GenericObjectType.COMPLEX_TYPE, GenericObjectType.class);
    assertEquals("Wrong class in resource", GenericObjectType.class, generic.getCompileTimeClass());
    GenericObjectType genericType = generic.asObjectable();
    assertNotNull("asObjectable resulted in null", genericType);
    assertPropertyValue(generic, "name", PrismTestUtil.createPolyString("My Sample Config Object"));
    assertPropertyDefinition(generic, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
    assertPropertyValue(generic, "objectType", QNameUtil.qNameToUri(new QName(SchemaTestConstants.NS_EXTENSION, "SampleConfigType")));
    assertPropertyDefinition(generic, "objectType", DOMUtil.XSD_ANYURI, 1, 1);
    PrismContainer<?> extensionContainer = generic.findContainer(GenericObjectType.F_EXTENSION);
    assertContainerDefinition(extensionContainer, "extension", ExtensionType.COMPLEX_TYPE, 0, 1);
    PrismContainerDefinition<?> extensionContainerDefinition = extensionContainer.getDefinition();
    assertTrue("Extension container definition is NOT dynamic", extensionContainerDefinition.isDynamic());
    PrismContainerValue<?> extensionContainerValue = extensionContainer.getValue();
    List<Item<?, ?>> extensionItems = extensionContainerValue.getItems();
    assertEquals("Wrong number of extension items", 5, extensionItems.size());
    // COMPLEX RUN TIME PROPERTIES...NOT SUPPORTED WITH NEW PARSERS..
    //		Item<?> locationsItem = extensionContainerValue.findItem(SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT);
    //		if (!(locationsItem instanceof PrismProperty)) {
    //			AssertJUnit.fail("Expected the extension item to be of type "+PrismProperty.class+
    //					"but it was of type "+locationsItem.getClass());
    //		}
    //		PrismProperty<?> locationsProperty = (PrismProperty<?>)locationsItem;
    //		assertEquals("Wrong name of <locations>", SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, locationsProperty.getElementName());
    //		PrismPropertyDefinition locationsDefinition = locationsProperty.getDefinition();
    //		assertNotNull("No definition for <locations>", locationsDefinition);
    //		PrismAsserts.assertDefinition(locationsDefinition, SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, 
    //				SchemaTestConstants.EXTENSION_LOCATIONS_TYPE, 0, -1);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT, "X marks the spot");
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_LONG_TYPE_ELEMENT, 567890L);
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2002-05-30T09:10:11");
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DATE_TYPE_ELEMENT, calendar);
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) QName(javax.xml.namespace.QName)

Example 4 with GenericObjectType

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

the class RGenericObject method toJAXB.

@Override
public GenericObjectType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    GenericObjectType object = new GenericObjectType();
    RUtil.revive(object, prismContext);
    RGenericObject.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)

Example 5 with GenericObjectType

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

the class TestJaxbConstruction method testGenericConstruction.

@Test
public void testGenericConstruction() throws JAXBException, SchemaException {
    System.out.println("\n\n ===[ testGenericConstruction ]===\n");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    GenericObjectType genericType = new GenericObjectType();
    prismContext.adopt(genericType);
    PrismObject<GenericObjectType> generic = genericType.asPrismObject();
    assertNotNull("No object definition after adopt", generic.getDefinition());
    // WHEN
    ExtensionType extension = new ExtensionType();
    genericType.setExtension(extension);
    // THEN
    generic.checkConsistence();
    PrismContainer<Containerable> extensionContainer = generic.findContainer(GenericObjectType.F_EXTENSION);
    checkExtension(extensionContainer, "user extension after setExtension");
    checkExtension(extension, "user extension after setExtension");
    generic.checkConsistence();
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) ExtensionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType) Test(org.testng.annotations.Test)

Aggregations

GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)9 Test (org.testng.annotations.Test)7 JaxbTestUtil (com.evolveum.midpoint.prism.util.JaxbTestUtil)4 ExtensionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType)2 JAXBElement (javax.xml.bind.JAXBElement)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 QName (javax.xml.namespace.QName)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1