diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2019-01-11 14:13:38 -0500 |
---|---|---|
committer | Kajur, Harish (vk250x) <vk250x@att.com> | 2019-01-13 20:30:47 -0500 |
commit | 5a4ff0ea07e8f5b5dde84c9ef171f188dd8a134c (patch) | |
tree | 8440af5a79557c99f42a29eb07b0f519d6c4a1a6 /aai-core/src/test/java | |
parent | 1dd67efcaf40c5b4278ad8594b78f63a838514ca (diff) |
Sync up the changes for v15
Issue-ID: AAI-1811
Change-Id: I307731ee35d8a644ae995c4b372345a7ebeca0a1
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Signed-off-by: Harish Venkata Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core/src/test/java')
31 files changed, 620 insertions, 453 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/AAISetup.java b/aai-core/src/test/java/org/onap/aai/AAISetup.java index ce8dfe20..fb914f01 100644 --- a/aai-core/src/test/java/org/onap/aai/AAISetup.java +++ b/aai-core/src/test/java/org/onap/aai/AAISetup.java @@ -56,10 +56,11 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule; EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, - IntrospectionConfig.class, + IntrospectionConfig.class, RestBeanConfig.class }) -@TestPropertySource(properties = { "schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000" , "schema.translator.list=config"}) +@TestPropertySource(properties = { "schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000" , "schema.translator.list=config", + "schema.nodes.location=src/test/resources/onap/oxm", "schema.edges.location=src/test/resources/onap/dbedgerules"}) public abstract class AAISetup { @ClassRule @@ -70,16 +71,16 @@ public abstract class AAISetup { @Autowired protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance; - + @Autowired protected HttpEntry traversalHttpEntry; - + @Autowired protected HttpEntry traversalUriHttpEntry; - + @Autowired protected NodeIngestor nodeIngestor; - + @Autowired protected LoaderFactory loaderFactory; @@ -90,8 +91,8 @@ public abstract class AAISetup { protected String basePath; @Value("${schema.xsd.maxoccurs}") - protected String maxOccurs; - + protected String maxOccurs; + protected static final String SERVICE_NAME = "JUNIT"; @BeforeClass @@ -101,7 +102,7 @@ public abstract class AAISetup { System.setProperty("aai.service.name", SERVICE_NAME); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/"); } - - - + + + } diff --git a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java new file mode 100644 index 00000000..0138f329 --- /dev/null +++ b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java @@ -0,0 +1,120 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.onap.aai.config.IntrospectionConfig; +import org.onap.aai.config.RestBeanConfig; +import org.onap.aai.config.SpringContextAware; +import org.onap.aai.edges.EdgeIngestor; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.MoxyLoader; +import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.rest.db.HttpEntry; +import org.onap.aai.serialization.db.EdgeSerializer; +import org.onap.aai.serialization.queryformats.QueryFormatTestHelper; +import org.onap.aai.setup.AAIConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.testutils.TestUtilConfigTranslatorforDataLink; +import org.onap.aai.util.AAIConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.rules.SpringClassRule; +import org.springframework.test.context.junit4.rules.SpringMethodRule; + +import java.util.Map; + + +@ContextConfiguration(classes = { + SchemaLocationsBean.class, + SchemaVersions.class, + TestUtilConfigTranslatorforDataLink.class, + EdgeIngestor.class, + EdgeSerializer.class, + NodeIngestor.class, + SpringContextAware.class, + IntrospectionConfig.class, + RestBeanConfig.class +}) +@TestPropertySource(properties = { + "schema.uri.base.path = /aai", + "schema.xsd.maxoccurs = 5000", + "schema.version.api.default = v4", + "schema.version.edge.label.start = v4", + "schema.version.depth.start = v3", + "schema.version.app.root.start = v4", + "schema.version.related.link.start = v4", + "schema.version.namespace.change.start = v4", + "schema.version.list = v1,v2,v3,v4", + "schema.translator.list = config" +}) +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) +public abstract class DataLinkSetup { + + @ClassRule + public static final SpringClassRule springClassRule = new SpringClassRule(); + + @Rule + public final SpringMethodRule springMethodRule = new SpringMethodRule(); + + @Autowired + protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance; + + @Autowired + protected HttpEntry traversalHttpEntry; + + @Autowired + protected HttpEntry traversalUriHttpEntry; + + @Autowired + protected NodeIngestor nodeIngestor; + + @Autowired + protected LoaderFactory loaderFactory; + + @Autowired + protected SchemaVersions schemaVersions; + + @Value("${schema.uri.base.path}") + protected String basePath; + + @Value("${schema.xsd.maxoccurs}") + protected String maxOccurs; + + protected static final String SERVICE_NAME = "JUNIT"; + + @BeforeClass + public static void setupBundleconfig() throws Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); + System.setProperty("aai.service.name", SERVICE_NAME); + QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/"); + } + + + +} diff --git a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java index c8d8caf4..e5ecaee6 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java @@ -21,8 +21,10 @@ package org.onap.aai.introspection; import org.junit.Test; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class MoxyEngineTest extends IntrospectorTestSpec { /** diff --git a/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java b/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java index 72b5d318..882b67e9 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java @@ -24,6 +24,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import java.util.Set; @@ -31,6 +32,7 @@ import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class PropertyPredicatesTest extends AAISetup { private Loader loader; diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java index f0165466..c94afd29 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java @@ -151,33 +151,6 @@ public class DataCopyTest extends AAISetup{ } @Test - public void runPopulateModelVersionId() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException { - - final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion()); - final Introspector obj = loader.introspectorFromName("generic-vnf"); - obj.setValue("vnf-id", "myId"); - obj.setValue("persona-model-id", "key1"); - obj.setValue("persona-model-version", "testValue"); - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - Graph g = graph.newTransaction(); - GraphTraversalSource traversal = g.traversal(); - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop); - when(prop.orElse(null)).thenReturn(obj.getURI()); - DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST"); - SideEffectRunner runner = new SideEffectRunner - .Builder(spy, serializer).addSideEffect(DataCopy.class).build(); - - runner.execute(obj, self); - - assertEquals("value populated", "key2", obj.getValue("model-version-id")); - - g.tx().rollback(); - } - - @Test public void verifyNestedSideEffect() throws URISyntaxException, AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, IOException { final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()); diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java index aed7bd59..c1218298 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java @@ -36,6 +36,7 @@ import org.junit.runners.Parameterized; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.onap.aai.AAISetup; +import org.onap.aai.DataLinkSetup; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.dbmap.DBConnectionType; import org.onap.aai.exceptions.AAIException; @@ -61,7 +62,7 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @RunWith(value = Parameterized.class) -public class DataLinkTest extends AAISetup { +public class DataLinkTest extends DataLinkSetup { private static JanusGraph graph; private final static ModelType introspectorFactoryType = ModelType.MOXY; diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/CreateUUIDTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/CreateUUIDTest.java index b6f15e47..e44fdd52 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/tools/CreateUUIDTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/CreateUUIDTest.java @@ -24,10 +24,12 @@ import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class CreateUUIDTest extends AAISetup { private CreateUUID createUUID; diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java index 8047342d..5fd185d5 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java @@ -24,12 +24,14 @@ import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import static junit.framework.TestCase.assertNotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class DefaultFieldsTest extends AAISetup { private Loader loader; @@ -76,4 +78,4 @@ public class DefaultFieldsTest extends AAISetup { assertFalse("It shouldn't be resolving this issue as hostname is required key", isResolved); } -}
\ No newline at end of file +} diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java index fa457922..713a8ae0 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import java.net.URI; @@ -33,6 +34,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class InjectKeysFromURITest extends AAISetup { private Loader loader; @@ -91,4 +93,4 @@ public class InjectKeysFromURITest extends AAISetup { pserver.getValue("hostname")); } -}
\ No newline at end of file +} diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java index f71aa2aa..68a03b3b 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import static junit.framework.TestCase.assertNotNull; import static org.eclipse.persistence.jpa.jpql.Assert.fail; @@ -31,6 +32,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class IntrospectorValidatorTest extends AAISetup { private Loader loader; @@ -122,4 +124,4 @@ public class IntrospectorValidatorTest extends AAISetup { assertNotNull("Get resolvers should not be null", b.getResolvers()); } -}
\ No newline at end of file +} diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java index 2e99e3e0..cf1b7782 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java @@ -24,11 +24,13 @@ import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNull; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class RemoveNonVisiblePropertyTest extends AAISetup { private Loader loader; @@ -65,4 +67,4 @@ public class RemoveNonVisiblePropertyTest extends AAISetup { } -}
\ No newline at end of file +} diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java index d452b00c..c2f8055b 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java @@ -30,6 +30,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.onap.aai.AAISetup; +import org.onap.aai.DataLinkSetup; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.ModelType; @@ -37,6 +38,7 @@ import org.onap.aai.rest.RestTokens; import org.onap.aai.serialization.engines.QueryStyle; import org.onap.aai.serialization.engines.JanusGraphDBEngine; import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.springframework.test.annotation.DirtiesContext; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; @@ -54,10 +56,11 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; @RunWith(value = Parameterized.class) -public class GraphTraversalTest extends AAISetup { +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) +public class GraphTraversalTest extends DataLinkSetup { private TransactionalGraphEngine dbEngine; - private TransactionalGraphEngine dbEnginev9; + private TransactionalGraphEngine dbEngineDepthVersion; @Parameterized.Parameter(value = 0) public QueryStyle queryStyle; @@ -71,13 +74,13 @@ public class GraphTraversalTest extends AAISetup { } @Rule public ExpectedException thrown = ExpectedException.none(); - - + + /** * Configure. - * @throws Exception - * @throws SecurityException - * @throws NoSuchFieldException + * @throws Exception + * @throws SecurityException + * @throws NoSuchFieldException */ @Before public void configure() throws Exception { @@ -85,13 +88,13 @@ public class GraphTraversalTest extends AAISetup { new JanusGraphDBEngine(queryStyle, loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()), false); - - dbEnginev9 = + + dbEngineDepthVersion = new JanusGraphDBEngine(queryStyle, loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion()), false); } - + /** * Parent query. * @@ -101,9 +104,9 @@ public class GraphTraversalTest extends AAISetup { @Test public void parentQuery() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build(); - + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); - + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("physical-location-id", "key1").has("aai-node-type", "complex"); assertEquals( "gremlin query should be " + expected.toString(), @@ -123,7 +126,7 @@ public class GraphTraversalTest extends AAISetup { query.getParentResultType()); assertEquals("dependent",false, query.isDependent()); - + } /** @@ -161,9 +164,9 @@ public class GraphTraversalTest extends AAISetup { query.getResultType()); assertEquals("dependent",true, query.isDependent()); - + } - + /** * Naming exceptions. * @@ -208,9 +211,9 @@ public class GraphTraversalTest extends AAISetup { query.getContainerType()); assertEquals("dependent",true, query.isDependent()); - + } - + /** * Gets the all. * @@ -255,9 +258,9 @@ public class GraphTraversalTest extends AAISetup { query.getContainerType()); assertEquals("dependent",true, query.isDependent()); - + } - + @Test public void getAllParent() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers").build(); @@ -288,10 +291,10 @@ public class GraphTraversalTest extends AAISetup { query.getContainerType()); assertEquals("dependent",false, query.isDependent()); - + } - - + + /** * Gets the via query param. * @@ -315,7 +318,7 @@ public class GraphTraversalTest extends AAISetup { GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid") .has("aai-node-type", "cloud-region"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -339,7 +342,7 @@ public class GraphTraversalTest extends AAISetup { assertEquals("dependent",true, query.isDependent()); } - + @Test public void getViaDuplicateQueryParam() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant").build(); @@ -359,7 +362,7 @@ public class GraphTraversalTest extends AAISetup { GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid") .has("aai-node-type", "cloud-region"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -383,7 +386,7 @@ public class GraphTraversalTest extends AAISetup { assertEquals("dependent",true, query.isDependent()); } - + /** * Gets the plural via query param. * @@ -403,7 +406,7 @@ public class GraphTraversalTest extends AAISetup { GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("aai-node-type", "vnfc"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -427,7 +430,7 @@ public class GraphTraversalTest extends AAISetup { assertEquals("dependent",true, query.isDependent()); } - + /** * Gets the all query param naming exception. * @@ -441,7 +444,7 @@ public class GraphTraversalTest extends AAISetup { MultivaluedMap<String, String> map = new MultivaluedHashMap<>(); map.putSingle("cvlan-tag", "333"); QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map); - + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("vnf-id", "key1").has("aai-node-type", "vce") .in("org.onap.relationships.inventory.BelongsTo") @@ -476,9 +479,9 @@ public class GraphTraversalTest extends AAISetup { query.getContainerType()); assertEquals("dependent",true, query.isDependent()); - + } - + /** * Abstract type. * @@ -490,10 +493,10 @@ public class GraphTraversalTest extends AAISetup { URI uri = UriBuilder.fromPath("vnf/key1").build(); QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); - + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "generic-vnf")); - + GraphTraversal<Vertex, Vertex> expectedParent = expected; assertEquals( "gremlin query should be " + expected.toString(), @@ -511,12 +514,12 @@ public class GraphTraversalTest extends AAISetup { "result type should be vnf", "vnf", query.getResultType()); - + assertEquals("dependent",false, query.isDependent()); - + } - + /** * Non parent abstract type. * @@ -530,17 +533,17 @@ public class GraphTraversalTest extends AAISetup { thrown.expectMessage(containsString("not a valid path")); dbEngine.getQueryBuilder().createQueryFromURI(uri); } - + @Test public void parentAbstractTypeWithNesting() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("vnf/key1/vf-modules/vf-module/key2").build(); - + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); - + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "generic-vnf")) .union(__.in("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "vf-module")).has("vf-module-id", "key2"); - + GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "generic-vnf")); assertEquals( @@ -559,11 +562,11 @@ public class GraphTraversalTest extends AAISetup { "result type should be vf-module", "vf-module", query.getResultType()); - + assertEquals("dependent",true, query.isDependent()); - + } - + @Test public void getViaBadQueryParam() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/a/b/tenants/tenant").build(); @@ -571,11 +574,11 @@ public class GraphTraversalTest extends AAISetup { map.putSingle("tenant-n231ame", "Tenant1"); thrown.expect(AAIException.class); thrown.expect(hasProperty("code", is("AAI_3000"))); - + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map); } - + @Test public void getPluralViaBadQueryParam() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/a/b/tenants").build(); @@ -583,11 +586,11 @@ public class GraphTraversalTest extends AAISetup { map.putSingle("tenant-n231ame", "Tenant1"); thrown.expect(AAIException.class); thrown.expect(hasProperty("code", is("AAI_3000"))); - + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map); } - + @Test public void getPluralViaDuplicateQueryParam() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("network/vnfcs").build(); @@ -606,7 +609,7 @@ public class GraphTraversalTest extends AAISetup { GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("aai-node-type", "vnfc"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -630,19 +633,19 @@ public class GraphTraversalTest extends AAISetup { assertEquals("dependent",true, query.isDependent()); } - + @Test public void dbAliasedSearch() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("network/generic-vnfs").build(); MultivaluedMap<String, String> map = new MultivaluedHashMap<>(); map.putSingle("persona-model-customization-id", "key2"); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri, map); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri, map); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("aai-node-type", "generic-vnf") .has("model-customization-id", "key2"); GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("aai-node-type", "generic-vnf"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -651,7 +654,7 @@ public class GraphTraversalTest extends AAISetup { "parent", expectedParent.toString(), query.getQueryBuilder().getParentQuery().getQuery().toString()); - + assertEquals( "result type should be", "generic-vnf", @@ -661,22 +664,22 @@ public class GraphTraversalTest extends AAISetup { "", query.getParentResultType()); assertEquals("dependent",true, query.isDependent()); - - + + } - + @Test public void dataLinkedSearch() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("network/vpn-bindings").build(); MultivaluedMap<String, String> map = new MultivaluedHashMap<>(); map.putSingle("global-route-target", "key2"); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri, map); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri, map); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("aai-node-type", "vpn-binding") .where(__.in("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key2")); GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("aai-node-type", "vpn-binding"); - + assertEquals( "gremlin query should be " + expected.toString(), expected.toString(), @@ -685,7 +688,7 @@ public class GraphTraversalTest extends AAISetup { "parent", expectedParent.toString(), query.getQueryBuilder().getParentQuery().getQuery().toString()); - + assertEquals( "result type should be", "vpn-binding", @@ -701,7 +704,7 @@ public class GraphTraversalTest extends AAISetup { public void pluralCousin() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers").build(); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("physical-location-id", "key1") .has("aai-node-type", "complex") @@ -735,7 +738,7 @@ public class GraphTraversalTest extends AAISetup { public void specificCousin() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2").build(); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("physical-location-id", "key1") .has("aai-node-type", "complex") @@ -770,7 +773,7 @@ public class GraphTraversalTest extends AAISetup { public void doubleSpecificCousin() throws UnsupportedEncodingException, AAIException { URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2/related-to/vservers/vserver/key3").build(); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("physical-location-id", "key1") .has("aai-node-type", "complex") @@ -811,7 +814,7 @@ public class GraphTraversalTest extends AAISetup { thrown.expect(AAIException.class); thrown.expectMessage(containsString(RestTokens.COUSIN.toString())); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri); } @@ -821,7 +824,7 @@ public class GraphTraversalTest extends AAISetup { thrown.expect(AAIException.class); thrown.expectMessage(containsString("chain plurals")); - QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); - + QueryParser query = dbEngineDepthVersion.getQueryBuilder().createQueryFromURI(uri); + } } diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java index f266fc07..376b7933 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java @@ -48,7 +48,7 @@ public class LegacyQueryTest extends AAISetup { private DynamicJAXBContext context = nodeIngestor.getContextForVersion(version); public void setup(){ - version = new SchemaVersion("v8"); + version = new SchemaVersion("v10"); dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java index f072bb1b..dfb251b1 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java @@ -54,19 +54,19 @@ public class RelationshipGremlinQueryTest extends AAISetup { private TransactionalGraphEngine dbEngine; private SchemaVersion version; private DynamicJAXBContext context = injestor.getContextForVersion(version); - + @Rule public ExpectedException thrown = ExpectedException.none(); @Before public void setup(){ - version = new SchemaVersion("v8"); + version = new SchemaVersion("v10"); dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false); } - + /** * Parent query. * @@ -76,7 +76,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { */ @Test public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException { - + String content = "{" + "\"related-to\" : \"pserver\"," @@ -85,7 +85,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"key1\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -93,11 +93,11 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')"; assertEquals( "gremlin query should be " + expected, @@ -111,7 +111,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be pserver", "pserver", query.getResultType()); - + } /** @@ -134,7 +134,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"key2\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -142,7 +142,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); @@ -163,7 +163,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { "lag-interface", query.getResultType()); } - + /** * Naming exceptions. * @@ -187,7 +187,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"655\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -195,15 +195,15 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')" + ".has('cvlan-tag', 655)"; - String expectedParent = + String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2')"; @@ -219,9 +219,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be cvlan-tag", "cvlan-tag", query.getResultType()); - + } - + /** * Scrambled relationship. * @@ -253,7 +253,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "}"; scrambledRelationshipSpec(content); } - + /** * Reversed relationship. * @@ -285,7 +285,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "}"; scrambledRelationshipSpec(content); } - + /** * Ordered ambiguous relationship. * @@ -317,7 +317,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "}"; scrambledRelationshipSpec(content); } - + /** * Scrambled relationship spec. * @@ -328,7 +328,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { */ public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException { - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -336,17 +336,17 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')" + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')" + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')" + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')" + ".has('l3-interface-ipv4-address', 'key5')"; - String expectedParent = + String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')" + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')" @@ -364,9 +364,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list", query.getResultType()); - + } - + /** * Short circuit. * @@ -391,7 +391,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"655\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -399,15 +399,15 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')" + ".has('cvlan-tag', 655)"; - String expectedParent = + String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2')"; @@ -423,9 +423,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be cvlan-tag", "cvlan-tag", query.getResultType()); - + } - + @Test public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException { String content = @@ -433,7 +433,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"related-to\" : \"cvlan-tag\"," + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\"" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -441,15 +441,15 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')" + ".has('cvlan-tag', 655)"; - String expectedParent = + String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + ".has('interface-id', 'key2')"; @@ -465,9 +465,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be cvlan-tag", "cvlan-tag", query.getResultType()); - + } - + /** * Double key. * @@ -491,8 +491,8 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"key3\"" + "}]" + "}"; - - + + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -500,16 +500,16 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')" + ".has('target-pe', 'key2')" + ".has('availability-zone-name', 'key3')"; - String expectedParent = + String expectedParent = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"; assertEquals( @@ -524,9 +524,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be ctag-pool", "ctag-pool", query.getResultType()); - + } - + /** * Abstract type. * @@ -544,8 +544,8 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "\"relationship-value\" : \"key1\"" + " }]" + "}"; - - + + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -553,18 +553,18 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))"; - - String expectedParent = + + String expectedParent = ".has('vnf-id', 'key1')" + ".has('aai-node-type', P.within('vce','generic-vnf'))"; - + assertEquals( "gremlin query should be " + expected, expected, @@ -577,9 +577,9 @@ public class RelationshipGremlinQueryTest extends AAISetup { "result type should be vnf", "vnf", query.getResultType()); - + } - + /** * Invalid node name. * @@ -611,7 +611,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "}"; thrown.expect(AAIException.class); thrown.expectMessage(containsString("invalid object name")); - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -619,12 +619,12 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); } - + /** * Invalid property name. * @@ -656,7 +656,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { + "}"; thrown.expect(AAIException.class); thrown.expectMessage(containsString("invalid property name")); - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -664,7 +664,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java index 2846e7fc..4baa944b 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java @@ -51,7 +51,7 @@ public class RelationshipQueryTest extends AAISetup { @Before public void setup(){ - version = new SchemaVersion("v8"); + version = new SchemaVersion("v10"); dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), @@ -66,7 +66,7 @@ public class RelationshipQueryTest extends AAISetup { */ @Test public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException { - + String content = "{" + "\"related-to\" : \"pserver\"," @@ -75,7 +75,7 @@ public class RelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"key1\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -83,11 +83,11 @@ public class RelationshipQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')"; assertEquals( "gremlin query should be " + expected, @@ -101,7 +101,7 @@ public class RelationshipQueryTest extends AAISetup { "result type should be pserver", "pserver", query.getResultType()); - + } /** @@ -125,7 +125,7 @@ public class RelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"key2\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -133,13 +133,13 @@ public class RelationshipQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').out('hasLAGInterface').has('aai-node-type', 'lag-interface')" + ".has('interface-name', 'key2')"; - String parentExpected = + String parentExpected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')"; assertEquals( "gremlin query should be for node", @@ -154,7 +154,7 @@ public class RelationshipQueryTest extends AAISetup { "lag-interface", query.getResultType()); } - + /** * Naming exceptions. * @@ -179,7 +179,7 @@ public class RelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"655\"" + "}]" + "}"; - + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -187,17 +187,17 @@ public class RelationshipQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('vnf-id', 'key1').has('aai-node-type', 'vce').in('org.onap.relationships.inventory.BelongsTo')" + ".has('aai-node-type', 'port-group').has('interface-id', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')" + ".has('cvlan-tag', 655)"; - String expectedParent = + String expectedParent = ".has('vnf-id', 'key1').has('aai-node-type', 'vce').in('org.onap.relationships.inventory.BelongsTo')" + ".has('aai-node-type', 'port-group').has('interface-id', 'key2')"; - + assertEquals( "gremlin query should be " + expected, expected, @@ -210,9 +210,9 @@ public class RelationshipQueryTest extends AAISetup { "result type should be cvlan-tag", "cvlan-tag", query.getResultType()); - + } - + /** * Double key. * @@ -237,8 +237,8 @@ public class RelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"key3\"" + "}]" + "}"; - - + + Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); @@ -246,16 +246,16 @@ public class RelationshipQueryTest extends AAISetup { Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); - String expected = + String expected = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')" + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')" + ".has('target-pe', 'key2')" + ".has('availability-zone-name', 'key3')"; - String expectedParent = + String expectedParent = ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"; assertEquals( @@ -270,7 +270,7 @@ public class RelationshipQueryTest extends AAISetup { "result type should be ctag-pool", "ctag-pool", query.getResultType()); - + } - + } diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java index f7e239b4..10174b69 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java @@ -49,14 +49,14 @@ import static org.junit.Assert.assertEquals; @Ignore public class UniqueRelationshipQueryTest extends AAISetup { - @Autowired + @Autowired private NodeIngestor ingestor ; - + private TransactionalGraphEngine dbEngine; private SchemaVersion version ; private DynamicJAXBContext context = ingestor.getContextForVersion(version); private Unmarshaller unmarshaller = null; - + /** * Setup. * @@ -64,7 +64,7 @@ public class UniqueRelationshipQueryTest extends AAISetup { */ @Before public void setup() throws JAXBException { - version = new SchemaVersion("v8"); + version = new SchemaVersion("v10"); dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false); @@ -73,7 +73,7 @@ public class UniqueRelationshipQueryTest extends AAISetup { unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true); } - + /** * Parent query. * @@ -83,7 +83,7 @@ public class UniqueRelationshipQueryTest extends AAISetup { */ @Test public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException { - + String content = "{" + "\"related-to\" : \"pserver\"," @@ -92,21 +92,21 @@ public class UniqueRelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"key1\"" + "}]" + "}"; - + Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String key = "pserver/key1"; - GraphTraversal<Vertex, Vertex> expected = + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key); String resultType = "pserver"; String containerType = ""; - + testSet(query, expected, expected, resultType, containerType); - + } /** @@ -129,25 +129,25 @@ public class UniqueRelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"key2\"" + "}]" + "}"; - + Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String key = "pserver/key1/lag-interface/key2"; - GraphTraversal<Vertex, Vertex> expected = + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key); - GraphTraversal<Vertex, Vertex> parentExpected = + GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", "pserver/key1"); String resultType = "lag-interface"; String containerType = ""; - + testSet(query, expected, parentExpected, resultType, containerType); } - + /** * Naming exceptions. * @@ -171,25 +171,25 @@ public class UniqueRelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"655\"" + "}]" + "}"; - + Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String key = "vce/key1/port-group/key2/cvlan-tag/655"; - GraphTraversal<Vertex, Vertex> expected = + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key); - GraphTraversal<Vertex, Vertex> parentExpected = + GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", "vce/key1/port-group/key2"); String resultType = "cvlan-tag"; String containerType = ""; - + testSet(query, expected, parentExpected, resultType, containerType); - + } - + /** * Double key. * @@ -210,26 +210,26 @@ public class UniqueRelationshipQueryTest extends AAISetup { + " \"relationship-value\" : \"key2\"" + " }]" + "}"; - + Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String key = "service-capability/key1/key2"; - GraphTraversal<Vertex, Vertex> expected = + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key); - GraphTraversal<Vertex, Vertex> parentExpected = + GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", "service-capability/key1/key2"); String resultType = "service-capability"; String containerType = ""; - + testSet(query, expected, parentExpected, resultType, containerType); - + } - + /** * Short circuit. * @@ -254,11 +254,11 @@ public class UniqueRelationshipQueryTest extends AAISetup { + "\"relationship-value\" : \"655\"" + "}]" + "}"; - + Object obj = context.newDynamicEntity("Relationship"); DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue(); - + Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity); QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj); String key = "vce/key1/port-group/key2/cvlan-tag/655"; @@ -266,11 +266,11 @@ public class UniqueRelationshipQueryTest extends AAISetup { GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", "vce/key1/port-group/key2"); String resultType = "cvlan-tag"; String containerType = ""; - + testSet(query, expected, parentExpected, resultType, containerType); - + } - + /** * Test set. * diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java index 5c31fd01..a173a37e 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java @@ -47,7 +47,7 @@ public class UniqueURIQueryTest extends AAISetup { private TransactionalGraphEngine dbEngine; private SchemaVersion version; private DynamicJAXBContext context = nodeIngestor.getContextForVersion(version); - + /** * Parent query. * @@ -56,7 +56,7 @@ public class UniqueURIQueryTest extends AAISetup { */ @Test public void parentQuery() throws UnsupportedEncodingException, AAIException { - version = new SchemaVersion("v8"); + version = new SchemaVersion("v10"); dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false); @@ -67,11 +67,11 @@ public class UniqueURIQueryTest extends AAISetup { String parentResultType = ""; String resultType = "complex"; String containerType = ""; - + testSet(query, expected, expected, parentResultType, resultType, containerType); - + } - + /** * Parent plural query. * @@ -86,9 +86,9 @@ public class UniqueURIQueryTest extends AAISetup { String parentResultType = ""; String resultType = "complex"; String containerType = "complexes"; - + testSet(query, expected, expected, parentResultType, resultType, containerType); - + } /** @@ -108,11 +108,11 @@ public class UniqueURIQueryTest extends AAISetup { String parentResultType = "complex"; String resultType = "ctag-pool"; String containerType = ""; - + testSet(query, expected, parentExpected, parentResultType, resultType, containerType); - + } - + /** * Naming exceptions. * @@ -130,11 +130,11 @@ public class UniqueURIQueryTest extends AAISetup { String parentResultType = "port-group"; String resultType = "cvlan-tag"; String containerType = ""; - + testSet(query, expected, parentExpected, parentResultType, resultType, containerType); - + } - + /** * Gets the all. * @@ -153,11 +153,11 @@ public class UniqueURIQueryTest extends AAISetup { String parentResultType = "port-group"; String resultType = "cvlan-tag"; String containerType = "cvlan-tags"; - + testSet(query, expected, parentExpected, parentResultType, resultType, containerType); - + } - + /** * Test set. * diff --git a/aai-core/src/test/java/org/onap/aai/parsers/relationship/RelationshipToURITest.java b/aai-core/src/test/java/org/onap/aai/parsers/relationship/RelationshipToURITest.java index 363def60..f3b85778 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/relationship/RelationshipToURITest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/relationship/RelationshipToURITest.java @@ -30,6 +30,7 @@ import org.onap.aai.introspection.*; import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException; import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException; import org.onap.aai.setup.SchemaVersion; +import org.springframework.test.annotation.DirtiesContext; import java.io.FileInputStream; import java.io.IOException; @@ -40,11 +41,11 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class RelationshipToURITest extends AAISetup { private final ModelType modelType = ModelType.MOXY; private final SchemaVersion version10 = new SchemaVersion("v10"); - private final SchemaVersion version9 = new SchemaVersion("v9"); @Rule @@ -90,35 +91,6 @@ public class RelationshipToURITest extends AAISetup { } @Test - public void successV9() throws AAIException, URISyntaxException, IOException { - Loader loader = loaderFactory.createLoaderForVersion(modelType, version9); - Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-failv10-successv9.json")); - URI expected = new URI("/network/generic-vnfs/generic-vnf/key2"); - - RelationshipToURI parse = new RelationshipToURI(loader, obj); - URI uri = parse.getUri(); - - assertEquals("related-link is equal", expected, uri); - - - } - - @Test - public void failV9() throws AAIException, URISyntaxException, IOException { - Loader loader = loaderFactory.createLoaderForVersion(modelType, version9); - Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-successv10-failv9.json")); - URI expected = new URI("/network/generic-vnfs/generic-vnf/key1"); - - thrown.expect(AAIIdentityMapParseException.class); - thrown.expect(hasProperty("code", is("AAI_3000"))); - RelationshipToURI parse = new RelationshipToURI(loader, obj); - - - URI uri = parse.getUri(); - - } - - @Test public void failNothingToParse() throws AAIException, URISyntaxException, IOException { Loader loader = loaderFactory.createLoaderForVersion(modelType, version10); Introspector obj = loader.unmarshal("relationship", this.getJsonString("nothing-to-parse.json")); diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java index b585f0cc..42cfd922 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java @@ -54,7 +54,7 @@ public class URIParserTest extends AAISetup { */ @PostConstruct public void createLoader(){ - loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion("v8")); + loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion("v10")); } @Test diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToExtensionInformationTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToExtensionInformationTest.java index 4f949f90..16cc14a1 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToExtensionInformationTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToExtensionInformationTest.java @@ -38,7 +38,7 @@ import static org.junit.Assert.assertEquals; public class URIToExtensionInformationTest extends AAISetup { - private Loader v8Loader ; + private Loader specificLoader ; /** * Vservers V 7. @@ -51,13 +51,13 @@ public class URIToExtensionInformationTest extends AAISetup { @PostConstruct public void createLoader(){ - v8Loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion("v8")); + specificLoader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion("v10")); } @Test public void vserversV8() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException { - URI uri = UriBuilder.fromPath("/aai/" + v8Loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/testOwner1/testRegion1/tenants/tenant/key1/vservers/vserver/key2").build(); - URIToExtensionInformation parse = new URIToExtensionInformation(v8Loader, uri); + URI uri = UriBuilder.fromPath("/aai/" + specificLoader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/testOwner1/testRegion1/tenants/tenant/key1/vservers/vserver/key2").build(); + URIToExtensionInformation parse = new URIToExtensionInformation(specificLoader, uri); String namespace = "cloudInfrastructure"; String preMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPreProc"; 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 fc2c64a1..c2a25eac 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 @@ -31,6 +31,7 @@ import org.onap.aai.db.props.AAIProperties; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.springframework.test.annotation.DirtiesContext; import javax.annotation.PostConstruct; import javax.ws.rs.core.UriBuilder; @@ -43,6 +44,7 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class URIToObjectTest extends AAISetup { private SchemaVersion version ; diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java index ffb56057..7c8d6c9c 100644 --- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java +++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java @@ -74,7 +74,9 @@ import static org.junit.Assert.*; }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @TestPropertySource(properties = { - "schema.translator.list = config" + "schema.translator.list = config", + "schema.nodes.location=src/test/resources/onap/oxm", + "schema.edges.location=src/test/resources/onap/dbedgerules" }) public abstract class QueryBuilderTestAbstraction { @@ -84,7 +86,7 @@ public abstract class QueryBuilderTestAbstraction { @Autowired protected EdgeSerializer testEdgeSer; - + @Autowired protected LoaderFactory loaderFactory; @@ -103,7 +105,7 @@ public abstract class QueryBuilderTestAbstraction { public void configure() throws Exception { loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()); - + g = graph.traversal(); } @@ -116,39 +118,39 @@ public abstract class QueryBuilderTestAbstraction { public static void teardown() throws Exception { graph.close(); } - + @Test public void createEdgeGVnfToVnfcTraversal() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","myvnf").next(); Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); testEdgeSer.addEdge(g, gvnf, vnfc, "uses"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc"); - + assertEquals(vnfc, tQ.next()); - + } - + @Test public void createEdgeLinterfaceToLogicalLinkTraversal() throws AAIException { - + Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next(); Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next(); testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface); tQ.createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link"); - + Vertex next = tQ.next(); - + assertEquals(logicalLink, next); - + } - + @SuppressWarnings("rawtypes") @Test public void createEdgeLinterfaceToLogicalLinkTraversal_tree() throws AAIException { @@ -200,263 +202,263 @@ public abstract class QueryBuilderTestAbstraction { @Test public void createEdgeLinterfaceToLogicalLinkIntrospectorTraversal() throws AAIException { - + Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next(); Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next(); testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface); tQ.createEdgeTraversal(EdgeType.COUSIN, loader.introspectorFromName("l-interface"), loader.introspectorFromName("logical-link")); - + Vertex next = tQ.next(); - + assertEquals(logicalLink, next); - + } - + @Test public void createEdgeLinterfaceToLogicalLinkVertexToIntrospectorTraversal() throws AAIException { - + Vertex lInterface = g.addV("aai-node-type","l-interface","interface-name","l-interface-a").next(); Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next(); testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface); tQ.createEdgeTraversal(EdgeType.COUSIN, lInterface, loader.introspectorFromName("logical-link")); - + Vertex next = tQ.next(); - + assertEquals(logicalLink, next); - + } - + @Test public void edgeToVertexTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, vnfc1); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc"); - + List<Vertex> list = tQ.toList(); assertEquals("Has 1 vertexes ", 1, list.size()); assertTrue("Has vertex on the default edge ", list.contains(vnfc1)); - + } - + @Test public void edgeToVertexTraversalSingleOutRuleTest() throws AAIException { - + Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - + testEdgeSer.addEdge(g, vce, vnfc1); - + QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce); tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "vnfc"); - + QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1); tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vce"); - + List<Vertex> list1 = tQ1.toList(); List<Vertex> list2 = tQ2.toList(); - + assertEquals("1 - Has 1 vertexes ", 1, list1.size()); assertTrue("1 - traversal results in vnfc ", list1.contains(vnfc1)); assertEquals("2 - Has 1 vertexes ", 1, list2.size()); assertTrue("2 - traversal results in vce ", list2.contains(vce)); - + } - + @Test public void edgeToVertexTraversalSingleInRuleTest() throws AAIException { - + Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + testEdgeSer.addEdge(g, vce, pserver); - + QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce); tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "pserver"); - + List<Vertex> list = tQ1.toList(); assertEquals("1 - Has 1 vertexes ", 1, list.size()); assertTrue("1 - traversal results in vnfc ", list.contains(pserver)); - + } - + @Test public void edgeToVertexMultiRuleTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + testEdgeSer.addEdge(g, gvnf, vnfc1); testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc"); - + List<Vertex> list = tQ.toList(); assertEquals("Has 2 vertexes ", 2, list.size()); assertTrue("Has vertex on the default edge ", list.contains(vnfc1)); assertTrue("Has vertex on the re-uses edge ", list.contains(vnfc2)); - + } - + @Test public void edgeToVertexMultiLabelTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, vnfc1); testEdgeSer.addEdge(g, pserver, vnfc1); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(vnfc1); tQ.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "generic-vnf"); - + List<Vertex> list = tQ.toList(); assertEquals("Has 1 vertexes ", 1, list.size()); assertTrue("Only returns the generic vnf vertex", list.contains(gvnf)); - + } - + @Test public void limitTraversalTest() throws AAIException { - + g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g); tQ.getVerticesByProperty("aai-node-type","vnfc").limit(1); - + List<Vertex> list = tQ.toList(); assertEquals("Has 1 vertexes ", 1, list.size()); - + } - + @Test public void getVertexesByPropertiesTraversalTest() throws AAIException { - + g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g); tQ.getVerticesByProperty("vnfc-name", Arrays.asList("a-name", "b-name")); - + List<Vertex> list = tQ.toList(); assertEquals("Has 2 vertexes ", 2, list.size()); - + } - + @Test public void getVertexesByIndexedPropertyTraversalTest() throws AAIException { - + g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g); tQ.getVerticesByIndexedProperty("aai-node-type","vnfc"); - + List<Vertex> list = tQ.toList(); assertEquals("Has 2 vertexes ", 2, list.size()); - + } - + @Test public void dedupTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, pserver); testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").dedup(); - + List<Vertex> list = tQ.toList(); - + assertEquals("Has 2 vertexes ", 1, list.size()); assertTrue("result has pserver ", list.contains(pserver)); - + } - + @Test public void storeCapTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, pserver); testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B"); - + GremlinTraversal<BulkSet<Vertex>> tQ = new GremlinTraversal<>(loader, g, gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x"); - + List<BulkSet<Vertex>> list = tQ.toList(); - + assertEquals("Has 2 vertexes ", 1, list.size()); assertEquals("result has pserver ",pserver, list.get(0).iterator().next()); - + } - + @Test public void storeCapUnfoldTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, pserver); testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x").unfold(); - + List<Vertex> list = tQ.toList(); - + assertEquals("Has 2 vertexes ", 2, list.size()); assertTrue("result has pserver ", list.contains(pserver)); - + } - + @Test public void nextAndHasNextTraversalTest() throws AAIException { - + Vertex v1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); Vertex v2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g); tQ.getVerticesByProperty("aai-node-type","vnfc"); - + List<Vertex> list = new ArrayList<>(); - + assertTrue("Has next 1 ",tQ.hasNext()); list.add(tQ.next()); assertTrue("Has next 2 ",tQ.hasNext()); @@ -465,146 +467,146 @@ public abstract class QueryBuilderTestAbstraction { assertTrue("Has all the vertexes", list.contains(v1) && list.remove(v2)); } - + @Test public void edgeToVertexMultiRuleOutTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, pserver); testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver"); - + List<Vertex> list = tQ.toList(); - + assertEquals("Has 2 vertexes ", 2, list.size()); assertTrue("result has pserver ", list.contains(pserver)); - + } - + @Test public void edgeToVertexMultiRuleInTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next(); - + testEdgeSer.addEdge(g, gvnf, complex); testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B"); - + QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf); tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "complex"); - + List<Vertex> list = tQ.toList(); - + assertEquals("Has 2 vertexes ", 2, list.size()); assertTrue("result has pserver ", list.contains(complex)); - + } @Test public void edgeTraversalSingleInRuleTest() throws AAIException { - + Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + Edge e = testEdgeSer.addEdge(g, vce, pserver); - + QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce); tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "pserver"); - + List<Edge> list = tQ1.toList(); assertEquals("1 - Has 1 edge ", 1, list.size()); assertTrue("1 - traversal results in edge ", list.contains(e)); - + } - + @Test public void edgeTraversalSingleOutRuleTest() throws AAIException { - + Vertex vce = g.addV("aai-node-type","vce","vnf-id","vce").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - + Edge e = testEdgeSer.addEdge(g, vce, vnfc1); - + QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce); tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "vnfc"); - + List<Edge> list1 = tQ1.toList(); - + assertEquals("1 - Has 1 edge ", 1, list1.size()); assertTrue("1 - traversal results in edge ", list1.contains(e)); - + } @Test public void edgeTraversalMultiRuleOutTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - + Edge e1 = testEdgeSer.addEdge(g, gvnf, pserver); Edge e2 = testEdgeSer.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B"); - + QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf); tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "pserver"); - + List<Edge> list = tQ.toList(); - + assertEquals("Has 2 edges ", 2, list.size()); assertTrue("result has default edge ", list.contains(e1)); assertTrue("result has other edge ", list.contains(e2)); - + } - + @Test public void edgeTraversalMultiRuleInTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex complex = g.addV("aai-node-type","complex","physical-location-id","a-name").next(); - + Edge e1 = testEdgeSer.addEdge(g, gvnf, complex); Edge e2 = testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B"); - + QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf); tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "complex"); - + List<Edge> list = tQ.toList(); - + assertEquals("Has 2 edges ", 2, list.size()); assertTrue("result has default edge ", list.contains(e1)); assertTrue("result has other edge ", list.contains(e2)); - + } - + @Test public void edgeTraversalMultiRuleTraversalTest() throws AAIException { - + Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next(); Vertex vnfc1 = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); Vertex vnfc2 = g.addV("aai-node-type","vnfc","vnfc-name","b-name").next(); - + Edge e1 = testEdgeSer.addEdge(g, gvnf, vnfc1); Edge e2 = testEdgeSer.addEdge(g, gvnf, vnfc2, "re-uses"); - + QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf); tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "vnfc"); - + List<Edge> list = tQ.toList(); assertEquals("Has 2 edges ", 2, list.size()); assertTrue("result has default edge ", list.contains(e1)); assertTrue("result has other edge ", list.contains(e2)); - + } @@ -727,11 +729,11 @@ public abstract class QueryBuilderTestAbstraction { } protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v); - + protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(); - + protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v); - + protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(); protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v); @@ -741,5 +743,5 @@ public abstract class QueryBuilderTestAbstraction { protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(Vertex v); protected abstract QueryBuilder<Path> getNewPathTraversalWithTestEdgeRules(); - + } diff --git a/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java b/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java index 71e53be8..f0618b02 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java @@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphTransaction; +import org.junit.Ignore; import org.junit.Test; import org.onap.aai.AAISetup; import org.onap.aai.HttpTestUtil; @@ -71,12 +72,16 @@ public class PserverDuplicateTest extends AAISetup { .mapToObj((i) -> (Callable<Void>) () -> { JanusGraphTransaction transaction = janusGraph.newTransaction(); GraphTraversalSource g = transaction.traversal(); - g.addV() - .property(AAIProperties.AAI_URI, aaiUri) - .property(AAIProperties.NODE_TYPE, "pserver") - .property("hostname", hostname) - .next(); - transaction.commit(); + try { + g.addV() + .property(AAIProperties.AAI_URI, aaiUri) + .property(AAIProperties.NODE_TYPE, "pserver") + .property("hostname", hostname) + .next(); + transaction.commit(); + } catch (Exception e) { + throw new Exception("Duplicate was found, error"); + } return null; }).collect(Collectors.toList()) , 7, TimeUnit.SECONDS @@ -97,7 +102,7 @@ public class PserverDuplicateTest extends AAISetup { } - @Test + @Ignore public void testWhenDuplicatesExistInGraphThatGetAllSuceeds() throws InterruptedException { int totalRetries = getNumOfRetries(); diff --git a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java index 8ff56839..f7bea7c3 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java @@ -33,6 +33,7 @@ import org.onap.aai.introspection.*; import org.onap.aai.serialization.engines.QueryStyle; import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.test.annotation.DirtiesContext; import javax.ws.rs.core.Response; import java.util.Arrays; @@ -44,6 +45,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @RunWith(value = Parameterized.class) +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class PserverTest extends AAISetup{ private static EELFLogger logger = EELFManager.getInstance().getLogger(PserverTest.class); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java index 77ee36c1..d63220b7 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java @@ -30,6 +30,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.onap.aai.AAISetup; +import org.onap.aai.DataLinkSetup; import org.onap.aai.dbmap.DBConnectionType; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; @@ -57,7 +58,7 @@ import static org.mockito.Mockito.when; @RunWith(value = Parameterized.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -public class DbAliasTest extends AAISetup { +public class DbAliasTest extends DataLinkSetup { private JanusGraph graph; diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java index 42775cbf..cbc1bd9a 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java @@ -28,6 +28,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.onap.aai.AAISetup; +import org.onap.aai.util.AAIConstants; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.dbmap.DBConnectionType; import org.onap.aai.edges.EdgeIngestor; @@ -457,6 +458,14 @@ public class DbSerializerTest extends AAISetup { } @Test + public void verifyResourceVersion_DeleteTest() throws AAIException { + engine.startTransaction(); + + assertTrue (dbser.verifyResourceVersion("delete", "generic-vnf", "current-res-ver", AAIConstants.AAI_RESVERSION_DISABLED_UUID_DEFAULT, + "generic-vnfs/generic-vnf/myid")); + + } + @Test public void trimClassNameTest() throws AAIException { assertEquals("GenericVnf", dbser.trimClassName("GenericVnf")); assertEquals("GenericVnf", dbser.trimClassName("org.onap.aai.GenericVnf")); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java index 1226eda1..a74ceee8 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java @@ -69,7 +69,9 @@ import static org.mockito.Mockito.when; IntrospectionConfig.class }) @TestPropertySource(properties = { - "schema.translator.list = config" + "schema.translator.list = config", + "schema.nodes.location=src/test/resources/onap/oxm", + "schema.edges.location=src/test/resources/onap/dbedgerules" }) public class DbSerializer_needsFakeRulesTest { @@ -79,7 +81,7 @@ public class DbSerializer_needsFakeRulesTest { public ExpectedException thrown = ExpectedException.none(); protected static Graph graph; - + @Autowired protected EdgeSerializer edgeSer; @Autowired @@ -114,7 +116,7 @@ public class DbSerializer_needsFakeRulesTest { System.setProperty("AJSC_HOME", "."); System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/"); - + } @Before @@ -636,8 +638,8 @@ public class DbSerializer_needsFakeRulesTest { private DBSerializer getDBSerializerWithSpecificEdgeRules() throws NoSuchFieldException, AAIException, IllegalAccessException { - - + + DBSerializer localDbser = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST"); return localDbser; } diff --git a/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java b/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java index f1d2fd63..6d17674a 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java @@ -46,7 +46,7 @@ public class TreeBackedVertexTest { startKey = g.addV(T.label, "vserver").as("v1").property("test", "hello") .addV(T.label, "vserver").as("v2") - .addV(T.label, "interface").property("name", "interface 1").as("v7").addInE("hasChild", "v2").property(EdgeProperty.CONTAINS.toString(), true) + .addV(T.label, "interface").property("name", "interface 1").as("v10").addInE("hasChild", "v2").property(EdgeProperty.CONTAINS.toString(), true) .addV(T.label, "pserver").property("name", "pserver 1").as("v4").addOutE("runsOn", "v1").property(EdgeProperty.CONTAINS.toString(), false) .addV(T.label, "interface").property("name", "interface 2").as("v3").addInE("hasChild", "v1").property(EdgeProperty.CONTAINS.toString(), true) .addV(T.label, "address").property("name", "address 1").addInE("hasChild", "v3").property(EdgeProperty.CONTAINS.toString(), true) diff --git a/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforDataLink.java b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforDataLink.java new file mode 100644 index 00000000..36d5fe77 --- /dev/null +++ b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforDataLink.java @@ -0,0 +1,56 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-18 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.testutils; + +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; + +import java.util.*; + +public class TestUtilConfigTranslatorforDataLink extends ConfigTranslator { + + public TestUtilConfigTranslatorforDataLink(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } + + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(new SchemaVersion("v1"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_one.xml")); + input.put(new SchemaVersion("v2"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_two.xml")); + input.put(new SchemaVersion("v3"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_three.xml")); + input.put(new SchemaVersion("v4"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_four.xml")); + return input; + } + + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(new SchemaVersion("v1"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_one.json")); + input.put(new SchemaVersion("v2"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_two.json")); + input.put(new SchemaVersion("v3"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_three.json")); + input.put(new SchemaVersion("v4"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_four.json")); + return input; + } +} diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java index b19a524b..c839619d 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java @@ -32,6 +32,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -330,19 +331,22 @@ public class NodesYAMLfromOXMTest { sb.append(" null\n parameters:\n"); sb.append(" - name: global-customer-id\n"); sb.append(" in: query\n"); - sb.append(" description:\n"); + sb.append(" description: Global customer id used across to uniquely identify customer.\n"); sb.append(" required: false\n"); sb.append(" type: string\n"); + sb.append(" example: __GLOBAL-CUSTOMER-ID__\n"); sb.append(" - name: subscriber-name\n"); sb.append(" in: query\n"); - sb.append(" description:\n"); + sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n"); sb.append(" required: false\n"); sb.append(" type: string\n"); + sb.append(" example: __SUBSCRIBER-NAME__\n"); sb.append(" - name: subscriber-type\n"); sb.append(" in: query\n"); - sb.append(" description:\n"); + sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n"); sb.append(" required: false\n"); sb.append(" type: string\n"); + sb.append(" example: __SUBSCRIBER-TYPE__\n"); sb.append(" /nodes/service-subscriptions?parameter=value[¶meter2=value2]:\n"); sb.append(" get:\n"); sb.append(" tags:\n"); @@ -362,9 +366,10 @@ public class NodesYAMLfromOXMTest { sb.append(" null\n parameters:\n"); sb.append(" - name: service-type\n"); sb.append(" in: query\n"); - sb.append(" description:\n"); + sb.append(" description: Value defined by orchestration to identify this service.\n"); sb.append(" required: false\n"); sb.append(" type: string\n"); + sb.append(" example: __SERVICE-TYPE__\n"); return sb.toString(); } public String YAMLdefs() { diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java index cfab4cc2..6058ecee 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java @@ -70,16 +70,16 @@ public class XSDElementTest { @Before public void setUp() throws Exception { - setUp(0); + setUp(0); } - - public void setUp(int sbopt) throws Exception { + + public void setUp( int sbopt ) throws Exception { StringBuilder sb = new StringBuilder(maxSizeForXml); addNamespace(sb); addBusiness(sb); - addCustomers(sb); + addCustomers(sb); if ( sbopt == 0 ) { - addCustomer(sb); + addCustomer(sb); } else { addCustomerNoSubscriberType(sb); addCustomerSubscriberType(sb); @@ -89,7 +89,7 @@ public class XSDElementTest { addEndOfXML(sb); testXML = sb.toString(); init(); - } +} private void addNamespace(StringBuilder sb){ sb.append("<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n"); @@ -192,7 +192,6 @@ public class XSDElementTest { sb.append("</xml-properties>\n"); sb.append("</xml-element>\n"); sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n"); -// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n"); sb.append("</java-attributes>\n"); sb.append("<xml-properties>\n"); sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n"); @@ -204,7 +203,7 @@ public class XSDElementTest { sb.append("<xml-property name=\"namespace\" value=\"business\" />\n"); sb.append("</xml-properties>\n"); sb.append("</java-type>\n"); - } + } private void addCustomerSubscriberType(StringBuilder sb){ sb.append("<java-type name=\"Customer\">\n"); @@ -222,7 +221,7 @@ public class XSDElementTest { sb.append("<xml-property name=\"container\" value=\"customers\" />\n"); sb.append("</xml-properties>\n"); sb.append("</java-type>\n"); - } + } private void addServiceSubscriptions(StringBuilder sb){ sb.append("<java-type name=\"ServiceSubscriptions\">\n"); |