diff options
Diffstat (limited to 'aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java')
-rw-r--r-- | aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java index c7c1f4ca..fc2c64a1 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java @@ -19,6 +19,7 @@ */ package org.onap.aai.parsers.uri; +import org.onap.aai.schema.enums.ObjectMetadata; import org.onap.aai.setup.SchemaVersion; import org.junit.Ignore; @@ -65,7 +66,7 @@ public class URIToObjectTest extends AAISetup { currentVersion = schemaVersions.getDefaultVersion(); loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getRelatedLinkVersion()); } - + @Test public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); @@ -74,11 +75,11 @@ public class URIToObjectTest extends AAISetup { String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}"; String topEntity = "cloud-region"; String entity = "l-interface"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); } - + /** * Uri no version. * @@ -86,7 +87,7 @@ public class URIToObjectTest extends AAISetup { * @throws AAIException the AAI exception * @throws IllegalArgumentException the illegal argument exception * @throws UnsupportedEncodingException the unsupported encoding exception - * @throws AAIUnknownObjectException + * @throws AAIUnknownObjectException */ @Test public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, AAIUnknownObjectException { @@ -106,12 +107,12 @@ public class URIToObjectTest extends AAISetup { String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"tenant-name\":\"name1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"vserver-name\":\"name2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}"; String topEntity = "cloud-region"; String entity = "l-interface"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); - + } - + /** * Bad URI. @@ -124,13 +125,13 @@ public class URIToObjectTest extends AAISetup { @Test public void badURI() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build(); - + thrown.expect(AAIException.class); thrown.expect(hasProperty("code", is("AAI_3000"))); - + new URIToObject(loader, uri); } - + /** * Starts with valid namespace. * @@ -147,10 +148,10 @@ public class URIToObjectTest extends AAISetup { String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}"; String topEntity = "cloud-region"; String entity = "l-interface"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); } - + /** * Single top level. * @@ -165,14 +166,14 @@ public class URIToObjectTest extends AAISetup { URIToObject parse = new URIToObject(loader, uri); Introspector result = parse.getTopEntity(); String expected = "{\"vnf-id\":\"key1\"}"; - + String topEntity = "generic-vnf"; String entity = "generic-vnf"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); } - + /** * Naming exceptions. * @@ -190,11 +191,11 @@ public class URIToObjectTest extends AAISetup { String expected = "{\"vnf-id\":\"key1\",\"port-groups\":{\"port-group\":[{\"interface-id\":\"key2\",\"cvlan-tags\":{\"cvlan-tag-entry\":[{\"cvlan-tag\":655}]}}]}}"; String topEntity = "vce"; String entity = "cvlan-tag"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); } - + /** * No list object. * @@ -212,23 +213,23 @@ public class URIToObjectTest extends AAISetup { String entity = "l3-interface-ipv4-address-list"; String expected = "{\"equipment-name\":\"0e6189fd-9257-49b9-a3be-d7ba980ccfc9\",\"lag-interfaces\":{\"lag-interface\":[{\"interface-name\":\"8ae5aa76-d597-4382-b219-04f266fe5e37\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"9e141d03-467b-437f-b4eb-b3133ec1e205\",\"l3-interface-ipv4-address-list\":[{\"l3-interface-ipv4-address\":\"8f19f0ea-a81f-488e-8d5c-9b7b53696c11\"}]}]}}]}}"; testSet(result.marshal(false), parse, expected, topEntity, entity, version); - + } - + @Test public void relativePath() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { URI uri = UriBuilder.fromPath("./l-interfaces/l-interface/key1").build(); URIToObject parse = new URIToObject(loader, uri); Introspector result = parse.getEntity(); String expected = "{\"interface-name\":\"key1\"}"; - + String topEntity = "l-interface"; String entity = "l-interface"; - + testSet(result.marshal(false), parse, expected, topEntity, entity, version); } - + /** * Test set. * @@ -241,15 +242,15 @@ public class URIToObjectTest extends AAISetup { */ public void testSet(String json, URIToObject parse, String expected, String topEntity, String entity, SchemaVersion version) { assertEquals("blah", expected, json); - + assertEquals("top entity", topEntity, parse.getTopEntityName()); assertEquals("entity", entity, parse.getEntityName()); assertEquals("entity object", entity, parse.getEntity().getDbName()); - + assertEquals("parent list object", 1, parse.getParentList().size()); - + assertEquals("object version", version, parse.getObjectVersion()); } } |