use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class OxmSchemaProvider method getVertexSchema.
@Override
public VertexSchema getVertexSchema(String vertexName, String schemaVersion) throws SchemaProviderException {
DynamicJAXBContext jaxbContext = OxmSchemaLoader.getContextForVersion(schemaVersion);
FromOxmVertexSchema vs = new FromOxmVertexSchema();
try {
vs.fromOxm(vertexName, jaxbContext, OxmSchemaLoader.getXmlLookupMap(schemaVersion));
} catch (SchemaProviderException ex) {
// Node doesn't exist in schema. Return null.
return null;
}
return vs;
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class StoreNotificationEventTest method testStoreDynamicEventNullObj.
@Test(expected = AAIException.class)
public void testStoreDynamicEventNullObj() throws AAIException {
DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
DynamicJAXBContext notificationJaxbContext = nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion());
sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, null);
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class NodeIngestorLocalTest method testGetContextForVersion11.
@Test
public void testGetContextForVersion11() {
DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
// should work bc Foo is valid in test_network_v10 schema
DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
foo10.set("fooId", "bar");
assertEquals("bar", foo10.get("fooId"));
// should work bc Bar is valid in test_business_v10 schema
DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
bar10.set("barId", "bar2");
assertEquals("bar2", bar10.get("barId"));
XSDOutputResolver outputResolver10 = new XSDOutputResolver();
ctx10.generateSchema(outputResolver10);
DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
// should work bc Foo.quantity is valid in test_network_v11 schema
DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
foo11.set("quantity", "12");
assertEquals("12", foo11.get("quantity"));
DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
quux11.set("qManagerName", "some guy");
assertEquals("some guy", quux11.get("qManagerName"));
XSDOutputResolver outputResolver11 = new XSDOutputResolver();
ctx11.generateSchema(outputResolver11);
thrown.expect(IllegalArgumentException.class);
// should fail bc Quux not in v10 test schema
ctx10.newDynamicEntity("Quux");
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class NodeIngestorLocalTest method testCombinedSchema.
@Test
public void testCombinedSchema() throws TransformerException, IOException {
DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13"));
XSDOutputResolver outputResolver13 = new XSDOutputResolver();
ctx13.generateSchema(outputResolver13);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer);
String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml")));
content = content.replaceAll("\\s+", "");
String expected = buffer.toString().replaceAll("\\s+", "");
assertThat("OXM:\n" + expected, expected, is(content));
}
use of org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext in project aai-aai-common by onap.
the class NodeIngestorTest method testCombinedSchema.
@Test
public void testCombinedSchema() throws TransformerException, IOException {
DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13"));
XSDOutputResolver outputResolver13 = new XSDOutputResolver();
ctx13.generateSchema(outputResolver13);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer);
String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml")));
content = content.replaceAll("\\s+", "");
String expected = buffer.toString().replaceAll("\\s+", "");
assertThat("OXM:\n" + expected, expected, is(content));
}
Aggregations