Search in sources :

Example 11 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class NodeIngestorTest method testGetContextForVersion.

@Test
public void testGetContextForVersion() {
    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");
}
Also used : DynamicJAXBContext(org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext) SchemaVersion(org.onap.aai.setup.SchemaVersion) DynamicEntity(org.eclipse.persistence.dynamic.DynamicEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class NodeTypesValidationModuleTest method test.

@Test
public void test() {
    List<String> testPairs = new ArrayList<>();
    testPairs.add("bar|foo");
    testPairs.add("foo|foo");
    testPairs.add("foo|quux");
    assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11"))));
    assertTrue(// bc
    validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux"));
// no
// quux
// in
// v10
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class ConfigTranslatorForWiringTest method getNodeFiles.

@Override
public Map<SchemaVersion, List<String>> getNodeFiles() {
    String f = bean.getNodeDirectory() + "test_business_v10.xml";
    List<String> files = new ArrayList<>();
    files.add(f);
    Map<SchemaVersion, List<String>> mp = new TreeMap<>();
    mp.put(new SchemaVersion("v10"), files);
    return mp;
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Example 14 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class ConfigTranslatorForWiringTest method getEdgeFiles.

@Override
public Map<SchemaVersion, List<String>> getEdgeFiles() {
    String f = bean.getEdgeDirectory() + "test.json";
    List<String> files = new ArrayList<>();
    files.add(f);
    Map<SchemaVersion, List<String>> mp = new TreeMap<>();
    mp.put(new SchemaVersion("v10"), files);
    return mp;
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Example 15 with SchemaVersion

use of org.onap.aai.setup.SchemaVersion in project aai-aai-common by onap.

the class GoodConfigForValidationTest method getNodeFiles.

@Override
public Map<SchemaVersion, List<String>> getNodeFiles() {
    List<String> files = new ArrayList<>();
    files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml");
    Map<SchemaVersion, List<String>> input = new TreeMap<>();
    // input.put(SchemaVersion.getLatest(), files);
    for (SchemaVersion v : schemaVersions.getVersions()) {
        input.put(v, files);
    }
    return input;
}
Also used : SchemaVersion(org.onap.aai.setup.SchemaVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Aggregations

SchemaVersion (org.onap.aai.setup.SchemaVersion)78 Test (org.junit.Test)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 ArrayList (java.util.ArrayList)19 List (java.util.List)16 Loader (org.onap.aai.introspection.Loader)13 TreeMap (java.util.TreeMap)12 AAIException (org.onap.aai.exceptions.AAIException)9 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)8 Introspector (org.onap.aai.introspection.Introspector)7 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)7 URI (java.net.URI)6 DynamicJAXBContext (org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext)6 QueryParser (org.onap.aai.parsers.query.QueryParser)5 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Before (org.junit.Before)4 ModelType (org.onap.aai.introspection.ModelType)4 URIToObject (org.onap.aai.parsers.uri.URIToObject)4 DBRequest (org.onap.aai.rest.db.DBRequest)4