From b5b99b72733ca5c064b46fdf4527ace28b8b545b Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Fri, 12 May 2017 17:36:59 -0400 Subject: Add all of the traversal source files Change-Id: Id31f4bdda9c86f782f86829f8b86dada959a9729 Signed-off-by: Venkata Harish K Kajur --- .../openecomp/aai/dbgraphgen/DbEdgeGroupTest.java | 104 ++++++++ .../aai/dbgraphgen/ModelBasedProcessingTest.java | 86 ++++++ .../aai/dbgraphmap/SearchGraphEdgeRuleTest.java | 59 +++++ .../org/openecomp/aai/rest/search/QueryTest.java | 85 ++++++ .../aai/rest/util/ValidateEncodingTest.java | 101 +++++++ .../org/openecomp/aai/transforms/JoltTestUtil.java | 61 +++++ .../LowerHyphenToLowerCamelConverterTest.java | 73 ++++++ .../openecomp/aai/transforms/MapTraverserTest.java | 56 ++++ .../etc/appprops/aaiconfig.properties | 105 ++++++++ .../etc/appprops/error.properties | 163 ++++++++++++ .../bundleconfig-local/etc/auth/aai_policy.json | 37 +++ .../resources/config/etc/titan-cached.properties | 37 +++ .../resources/config/etc/titan-realtime.properties | 34 +++ .../src/test/resources/inmemory_titan.properties | 21 ++ aai-traversal/src/test/resources/log4j.properties | 3 + aai-traversal/src/test/resources/logback.xml | 292 +++++++++++++++++++++ .../resources/maputils/testcases/TestCase1.json | 32 +++ .../resources/maputils/testcases/TestCase2.json | 40 +++ .../src/test/resources/test_aaiconfig.properties | 97 +++++++ 19 files changed, 1486 insertions(+) create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphEdgeRuleTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java create mode 100644 aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java create mode 100644 aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties create mode 100644 aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties create mode 100644 aai-traversal/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json create mode 100644 aai-traversal/src/test/resources/config/etc/titan-cached.properties create mode 100644 aai-traversal/src/test/resources/config/etc/titan-realtime.properties create mode 100644 aai-traversal/src/test/resources/inmemory_titan.properties create mode 100644 aai-traversal/src/test/resources/log4j.properties create mode 100644 aai-traversal/src/test/resources/logback.xml create mode 100644 aai-traversal/src/test/resources/maputils/testcases/TestCase1.json create mode 100644 aai-traversal/src/test/resources/maputils/testcases/TestCase2.json create mode 100644 aai-traversal/src/test/resources/test_aaiconfig.properties (limited to 'aai-traversal/src/test') diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java new file mode 100644 index 0000000..e0ad9fc --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.dbgraphgen; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.Test; + +public class DbEdgeGroupTest { + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleMany2Many() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "l-interface", "logical-link")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleMany2ManyRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "logical-link", "l-interface")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleOne2One() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "l-interface", "sriov-vf")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleOne2OneRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "sriov-vf", "l-interface")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleMany2One() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertTrue((Boolean)method.invoke(new DbEdgeGroup(), "cloud-region", "complex")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleMany2OneRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "complex", "cloud-region")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleOne2Many() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "cloud-region", "tenant")); + } + + @Test + public void additionalEdgeWouldBreakMultEdgeRuleOne2ManyRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + + Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class); + method.setAccessible(true); + + assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "tenant", "cloud-region")); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java new file mode 100644 index 0000000..30aa812 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.dbgraphgen; +//package org.openecomp.aai.dbgen; +// +//import java.util.ArrayList; +// +//import org.junit.BeforeClass; +//import org.junit.Rule; +//import org.junit.Test; +//import org.junit.rules.ExpectedException; +// +//import org.openecomp.aai.exceptions.AAIException; +//import org.openecomp.aai.ingestModel.DbMaps; +//import org.openecomp.aai.ingestModel.IngestModelMoxyOxm; +//import org.openecomp.aai.util.AAIConstants; +// +//public class ModelBasedProcessingTest { +// +// private static DbMaps dbMaps = null; +// private static ModelBasedProcessing processor; +// @BeforeClass +// public static void configure() throws Exception { +// System.setProperty("AJSC_HOME", "."); +// System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); +// ArrayList apiVersions = new ArrayList(); +// apiVersions.add("v9"); +// apiVersions.add("v8"); +// apiVersions.add("v7"); +// apiVersions.add("v2"); +// IngestModelMoxyOxm m = new IngestModelMoxyOxm(); +// m.init(apiVersions); +// +// dbMaps = m.dbMapsContainer.get(AAIConstants.AAI_DEFAULT_API_VERSION); +// processor = new ModelBasedProcessing(); +// +// } +// +// @Rule +// public ExpectedException expectedEx = ExpectedException.none(); +// +// @Test +// public void check4EdgeRuleThrowsExceptionWhenNodeTypeADoesNotExist() throws Exception { +// String nodeTypeA = "cccomplex"; +// String nodeTypeB = "pserver"; +// expectedEx.expect(AAIException.class); +// expectedEx.expectMessage("AAI_6115"); +// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps); +// } +// +// @Test +// public void check4EdgeRuleThrowsExceptionWhenNodeTypeBDoesNotExist() throws Exception { +// String nodeTypeA = "complex"; +// String nodeTypeB = "ppppserver"; +// expectedEx.expect(AAIException.class); +// expectedEx.expectMessage("AAI_6115"); +// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps); +// } +// +// @Test +// public void check4EdgeRuleThrowsExceptionWhenNoRuleExists() throws Exception { +// String nodeTypeA = "complex"; +// String nodeTypeB = "service"; +// expectedEx.expect(AAIException.class); +// expectedEx.expectMessage("AAI_6120"); +// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps); +// } +//} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphEdgeRuleTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphEdgeRuleTest.java new file mode 100644 index 0000000..7484353 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphmap/SearchGraphEdgeRuleTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.dbgraphmap; + +import static org.junit.Assert.assertEquals; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import org.openecomp.aai.exceptions.AAIException; + +public class SearchGraphEdgeRuleTest { + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void getEdgeLabelTest() throws AAIException { + String[] label = SearchGraph.getEdgeLabel("customer", "service-subscription"); + + assertEquals("subscribesTo", label[0]); + } + + @Test + public void getEdgeLabelThrowsExceptionWhenNoRuleExists() throws Exception { + String nodeTypeA = "complex"; + String nodeTypeB = "service"; + expectedEx.expect(AAIException.class); + expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: complex, service."); + SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB); + } + + @Test + public void getEdgeLabelThrowsExceptionWhenNodeTypesDoNotExist() throws Exception { + String nodeTypeA = "A"; + String nodeTypeB = "B"; + expectedEx.expect(AAIException.class); + expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: A, B."); + SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java new file mode 100644 index 0000000..0df8ee3 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/QueryTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.rest.search; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.serialization.db.EdgeRules; +import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public abstract class QueryTest { + + protected Graph graph; + private GremlinServerSingleton gremlinServerSingleton; + private GremlinGroovyShellSingleton shell; + + protected final List expectedResult = new ArrayList<>(); + protected final EdgeRules rules = EdgeRules.getInstance(); + + + public QueryTest() throws AAIException, NoEdgeRuleFoundException { + setUp(); + } + public void setUp() throws AAIException, NoEdgeRuleFoundException { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + graph = TinkerGraph.open(); + createGraph(); + gremlinServerSingleton = GremlinServerSingleton.getInstance(); + shell = GremlinGroovyShellSingleton.getInstance(); + } + + public void run() { + + String query = "g." + gremlinServerSingleton.getStoredQuery(getQueryName()); + + Map params = new HashMap<>(); + + GraphTraversal g = graph.traversal().V(); + addStartNode(g); + params.put("g", g); + addParam(params); + GraphTraversal result = (GraphTraversal)shell.executeTraversal(query, params); + + List vertices = result.toList(); + assertTrue("all vertices found", vertices.containsAll(expectedResult) && expectedResult.containsAll(vertices)); + + } + + protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException; + + protected abstract String getQueryName(); + + protected abstract void addStartNode(GraphTraversal g); + + protected abstract void addParam(Map params); +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java new file mode 100644 index 0000000..8c6450d --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.rest.util; + +import static org.junit.Assert.*; + +import java.io.UnsupportedEncodingException; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; + +import org.junit.Test; +import org.mockito.Mockito; + +public class ValidateEncodingTest { + + + @Test + public void badPath() throws UnsupportedEncodingException { + String badPath = "/aai/v6/network/vces/vce/blahh::blach/others/other/jklfea{}"; + UriInfo mockUriInfo = getMockUriInfo(badPath, new MultivaluedHashMap()); + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + } + + @Test + public void goodPath() throws UnsupportedEncodingException { + String goodPath = "/aai/v6/network/vces/vce/blahh%3A%3Ablach/others/other/jklfea%7B%7D"; + UriInfo mockUriInfo = getMockUriInfo(goodPath, new MultivaluedHashMap()); + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(true, validator.validate(mockUriInfo)); + } + + @Test + public void badQueryParamsKey() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test2"); + map.putSingle("bad::bad", "test3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + + } + @Test + public void badQueryParamsValue() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test//:2"); + map.putSingle("badbad", "test3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + } + @Test + public void goodQueryParams() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test2"); + map.putSingle("badbad", "~test%2F%2F%3A3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(true, validator.validate(mockUriInfo)); + } + + private UriInfo getMockUriInfo(String path, MultivaluedMap map) { + UriInfo mockUriInfo = Mockito.mock(UriInfo.class); + Mockito.when(mockUriInfo.getPath(false)).thenReturn(path); + Mockito.when(mockUriInfo.getQueryParameters(false)).thenReturn(map); + + return mockUriInfo; + } + +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java b/aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java new file mode 100644 index 0000000..7df2790 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/transforms/JoltTestUtil.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.transforms; + + +import java.io.IOException; + +import org.junit.Assert; + +import com.bazaarvoice.jolt.ArrayOrderObliviousDiffy; +import com.bazaarvoice.jolt.Diffy; +import com.bazaarvoice.jolt.JsonUtils; + +public class JoltTestUtil { + + private static final Diffy diffy = new Diffy(); + private static final Diffy arrayOrderObliviousDiffy = new ArrayOrderObliviousDiffy(); + + public static void runDiffy( String failureMessage, Object expected, Object actual ) throws IOException { + runDiffy( diffy, failureMessage, expected, actual ); + } + + public static void runDiffy( Object expected, Object actual ) throws IOException { + runDiffy( diffy, "Failed", expected, actual ); + } + + public static void runArrayOrderObliviousDiffy( String failureMessage, Object expected, Object actual ) throws IOException { + runDiffy( arrayOrderObliviousDiffy, failureMessage, expected, actual ); + } + + public static void runArrayOrderObliviousDiffy( Object expected, Object actual ) throws IOException { + runDiffy( arrayOrderObliviousDiffy, "Failed", expected, actual ); + } + + + private static void runDiffy( Diffy diffy, String failureMessage, Object expected, Object actual ) { + String actualObject = JsonUtils.toPrettyJsonString( actual ); + Diffy.Result result = diffy.diff( expected, actual ); + if (!result.isEmpty()) { + Assert.fail( "\nActual object\n" + actualObject + "\n" + failureMessage + "\nDiffy output\n" + result.toString()); + } + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java b/aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java new file mode 100644 index 0000000..3dc5299 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverterTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.transforms; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import java.util.Arrays; +import java.util.Collection; + +import static org.junit.Assert.*; + +@RunWith(Parameterized.class) +public class LowerHyphenToLowerCamelConverterTest { + + private Converter converter = new LowerHyphenToLowerCamelConverter(); + + private String input; + private String expected; + + public LowerHyphenToLowerCamelConverterTest(String input, String expected){ + this.input = input; + this.expected = expected; + } + + /** + * Data Provider for the Lower Hyphen to Camel Converter Tests + * Make sure the capitalization is not lost during the conversion + * @return + */ + @Parameters + public static Collection data(){ + + return Arrays.asList(new Object[][]{ + {null, null}, + {"test-name", "testName"}, + {"test---name", "testName"}, // Case multiple + {"testName", "testName"}, // Case where upper case word shouldn't be lowercased + {"test-name-cool", "testNameCool"}, + {"test-name-Cool", "testNameCool"}, + {"test-name-Cool-Name-wow----Rest", "testNameCoolNameWowRest"}, + {"test-name#fast#", "testName#fast#"}, + {"test-name---", "testName"}, + {"----test-name", "TestName"}, + }); + } + + @Test + public void testIfInputSuccessfullyModified(){ + String actual = converter.convert(input); + assertEquals(expected, actual); + } +} diff --git a/aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java b/aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java new file mode 100644 index 0000000..e3b7760 --- /dev/null +++ b/aai-traversal/src/test/java/org/openecomp/aai/transforms/MapTraverserTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 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.openecomp.aai.transforms; + +import org.openecomp.aai.transforms.LowerCamelToLowerHyphenConverter; +import org.openecomp.aai.transforms.MapTraverser; +import com.bazaarvoice.jolt.JsonUtils; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; + +public class MapTraverserTest { + + private final String testResources = "src/test/resources/maputils/testcases/"; + + private String[] testCases = { "TestCase1.json", "TestCase2.json" }; + private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter()); + + @Test(expected = NullPointerException.class) + public void testIfMapIsNullThrowNullPointerException(){ + Map map = null; + traverser.convertKeys(map); + } + + @Test + public void runTestCases() throws IOException { + + for(String testCase : testCases){ + Map values = JsonUtils.filepathToMap(testResources + testCase); + + Object input = values.get("input"); + Object actual = traverser.convertKeys((Map)input); + Object output = values.get("output"); + JoltTestUtil.runArrayOrderObliviousDiffy( "failed case " + testCase, output, actual ); + } + } +} diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties new file mode 100644 index 0000000..a29948c --- /dev/null +++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties @@ -0,0 +1,105 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 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========================================================= +### + +#################################################################### +# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE +# TEMPLATE AND *ALL* DATAFILES +#################################################################### + +aai.config.checktime=1000 + +# this could come from siteconfig.pl? +aai.config.nodename=AutomaticallyOverwritten + +aai.logging.hbase.interceptor=true +aai.logging.hbase.enabled=true +aai.logging.hbase.logrequest=true +aai.logging.hbase.logresponse=true + +aai.logging.trace.enabled=true +aai.logging.trace.logrequest=false +aai.logging.trace.logresponse=false + +aai.transaction.logging=true +aai.transaction.logging.get=true +aai.transaction.logging.post=true + +aai.server.url.base=https://localhost:8446/aai/ +aai.server.url=https://localhost:8446/aai/v10/ +aai.global.callback.url=https://localhost:8446/aai/ + +aai.auth.cspcookies_on=false +aai.dbmodel.filename=ex5.json +aai.truststore.filename=aai_keystore +aai.truststore.passwd.x= +aai.keystore.filename=aai-client-cert.p12 +aai.keystore.passwd.x= + +# for transaction log +hbase.table.name=aailogging-dev1.dev +hbase.notificationTable.name=aainotification-dev1.dev +hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS +hbase.zookeeper.quorum=ONAPserverTBD +hbase.zookeeper.property.clientPort=2181 +hbase.zookeeper.znode.parent=/hbase-unsecure + +# single primary server +aai.primary.filetransfer.serverlist=ONAPserverTBD +aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo +aai.primary.filetransfer.pingtimeout=5000 +aai.primary.filetransfer.pingcount=5 + +#rsync properties +aai.rsync.command=rsync +aai.rsync.options.list=-v|-t +aai.rsync.remote.user=aaiadmin +aai.rsync.enabled=y + +aai.notification.current.version=v10 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v9 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v9 + +# Used by Model-processing code +aai.model.delete.sleep.per.vtx.msec=500 +aai.model.query.resultset.maxcount=30 +aai.model.query.timeout.sec=90 + +aai.model.proc.max.levels=50 +aai.edgeTag.proc.max.levels=50 + +# Used by the ForceDelete tool +aai.forceDel.protected.nt.list=cloud-region +aai.forceDel.protected.edge.count=10 +aai.forceDel.protected.descendant.count=10 + +aai.dmaap.workload.enableEventProcessing=true + +aai.realtime.clients=RO,SDNC,MSO + +aai.server.rebind=g diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties new file mode 100644 index 0000000..4e98d62 --- /dev/null +++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties @@ -0,0 +1,163 @@ +# Adding comment trying to trigger a build +#------------------------------------------------------------------------------- ---------- +#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message +#------------------------------------------------------------------------------- ---------- +# testing code, please don't change unless error utility source code changes +AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing + +# General success +AAI_0000=0:0:INFO:0000:200:0000:Success + +# health check success +AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2 +AAI_0002=0:0:INFO:0002:200:0001:Successful health check + +# Success with additional info +AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4 +AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db + +#--- aairest: 3000-3299 +# svc errors +AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2 +AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2 +AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2 +AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2 +AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s) +AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s) +AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2 +AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8 +AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL +# pol errors +AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1 +AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2 +AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2 +AAI_3300=5:1:WARN:3300:403:3300:Unauthorized +AAI_3301=5:1:WARN:3301:401:3301:Stale credentials +AAI_3302=5:1:WARN:3302:401:3301:Not authenticated +AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry + +#--- aaigen: 4000-4099 +AAI_4000=5:4:ERROR:4000:500:3002:Internal Error +AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found +AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file +AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file +AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file +AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter +AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service +AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error +AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error +AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header +AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header +AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response +AAI_4012=5:4:ERROR:4012:500:3002:Bad rule data in RestRules +AAI_4013=5:4:ERROR:4013:500:3002:Error connecting to AAI REST API +AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header +AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property +AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all" +AAI_4017=5:2:INFO:4017:400:3000:Could not set property +AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer +#--- aaidbmap: 5101-5199 +AAI_5101=5:4:FATAL:5101:500:3002:Could not connect to database +AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open +AAI_5103=5:4:ERROR:5103:500:3002:Unexpected error during commit +AAI_5104=5:4:ERROR:5104:500:3002:Unexpected error during rollback +AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database +AAI_5106=5:4:WARN:5106:404:3001:Node not found +AAI_5107=5:2:WARN:5107:400:3000:Required information missing +AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored + +#--- aaidbgen: 6101-6199 +AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed +AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType +AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data +AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data +AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps +AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType +AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data +AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data +AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value +AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted +AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error +AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode() +AAI_6114=5:4:INFO:6114:404:3001:Node Not Found +AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType +AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property +AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated +AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed. +AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed +AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data +AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request +AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate +AAI_6124=5:4:ERROR:6124:500:3000:File read/write error +AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set +AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted +AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found +AAI_6128=5:4:INFO:6128:500:3000:Unexpected error +AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node +AAI_6130=5:4:WARN:6130:412:3000:Precondition Required +AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed +AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition +AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition +AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount +AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create +AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items +AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices +AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices +AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist +AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated +AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query +AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction +AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found +AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph +AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship + +#--- aaicsvp: 7101-7199 +AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing +AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory +#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user +AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory +AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists +AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete +AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist +AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist +AAI_7109=5:4:ERROR:7109:500:3002:Error closing file +AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file +AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script +AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file +AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error +AAI_7114=5:4:ERROR:7114:500:3002:Input file error +AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error +AAI_7116=5:4:ERROR:7116:500:3002:Request error +AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object +AAI_7118=5:4:ERROR:7118:500:3002:Script Error +AAI_7119=5:4:ERROR:7119:500:3002:Unknown host + +#--- aaisdnc: 7201-7299 +AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl +AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API +AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API +AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate +AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL + +#--- NotificationEvent, using UEB space +AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed + +#--- aairestctlr: 7401-7499 +AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API +AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error +AAI_7403=5:4:WARN:7403:400:3001:Request error +AAI_7404=5:4:INFO:7404:404:3001:Node not found + +#--- aaiauth: 9101-9199 +AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function +AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source +AAI_9103=5:0:WARN:9103:403:3300:User not found +AAI_9104=5:0:WARN:9104:401:3302:Authentication error +AAI_9105=5:0:WARN:9105:403:3300:Authorization error +AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId +#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request +AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin + +#--- aaiinstar: 9201-9299 +AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification +AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json b/aai-traversal/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json new file mode 100644 index 0000000..9706ce9 --- /dev/null +++ b/aai-traversal/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json @@ -0,0 +1,37 @@ +{ + "roles": [{ + "name": "testRole", + "functions": [{ + "name": "testFunction", + "methods": [{ + "name": "GET" + }, { + "name": "DELETE" + }, { + "name": "PUT" + } + ] + } + ], + "users": [{ + "username": "testUser" + } + ] + }, { + "name": "testBasicAuth", + "functions": [{ + "name": "testBasicAuthFuncyion", + "methods": [{ + "name": "GET" + } + ] + } + ], + "users": [{ + "user": "testBasicAuthUser", + "pass": "OBF:1ytc1vu91v2p1rxf1mqh1v8s1z0d1msn1san1mqf1z0h1v9u1msl1rvf1v1p1vv11yta" + } + ] + } + ] +} \ No newline at end of file diff --git a/aai-traversal/src/test/resources/config/etc/titan-cached.properties b/aai-traversal/src/test/resources/config/etc/titan-cached.properties new file mode 100644 index 0000000..6408909 --- /dev/null +++ b/aai-traversal/src/test/resources/config/etc/titan-cached.properties @@ -0,0 +1,37 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 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========================================================= +### + +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=ONAPserverTBD + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +#caching on +cache.db-cache = true +cache.db-cache-clean-wait = 20 +cache.db-cache-time = 180000 +cache.db-cache-size = 0.3 + +#load graphson file on startup +load.snapshot.file=false diff --git a/aai-traversal/src/test/resources/config/etc/titan-realtime.properties b/aai-traversal/src/test/resources/config/etc/titan-realtime.properties new file mode 100644 index 0000000..c50b141 --- /dev/null +++ b/aai-traversal/src/test/resources/config/etc/titan-realtime.properties @@ -0,0 +1,34 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 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========================================================= +### + +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=ONAPserverTBD + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +# Setting db-cache to false ensure the fastest propagation of changes across servers +cache.db-cache = false + +#load graphson file on startup +load.snapshot.file=true diff --git a/aai-traversal/src/test/resources/inmemory_titan.properties b/aai-traversal/src/test/resources/inmemory_titan.properties new file mode 100644 index 0000000..46695d6 --- /dev/null +++ b/aai-traversal/src/test/resources/inmemory_titan.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 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========================================================= +### + +storage.backend=inmemory diff --git a/aai-traversal/src/test/resources/log4j.properties b/aai-traversal/src/test/resources/log4j.properties new file mode 100644 index 0000000..2e68f61 --- /dev/null +++ b/aai-traversal/src/test/resources/log4j.properties @@ -0,0 +1,3 @@ +log4j.logger.org.apache.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.client=WARN \ No newline at end of file diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml new file mode 100644 index 0000000..735e70d --- /dev/null +++ b/aai-traversal/src/test/resources/logback.xml @@ -0,0 +1,292 @@ + + + + ${module.ajsc.namespace.name} + + + + + + + + ERROR + ACCEPT + DENY + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/rest/metric.log + + ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/debug.log + + ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + WARN + ACCEPT + DENY + + ${logDirectory}/rest/error.log + + ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + audit + + co\=aairest + + level == INFO && audit.matches(formattedMessage) + + ACCEPT + DENY + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/audit-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip + + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + ${logDirectory}/rest/perform.log + + ${logDirectory}/rest/perform-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip + + + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${JMS_LOGGER_AUDIT_QUEUE_BINDING} + + + + + + + + ${JMS_LOGGER_PERF_QUEUE_BINDING} + + + + + + + 1000 + 0 + + + + + 1000 + 0 + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-traversal/src/test/resources/maputils/testcases/TestCase1.json b/aai-traversal/src/test/resources/maputils/testcases/TestCase1.json new file mode 100644 index 0000000..1f7a794 --- /dev/null +++ b/aai-traversal/src/test/resources/maputils/testcases/TestCase1.json @@ -0,0 +1,32 @@ +{ + "input": { + "myImage": { + "imageId": "test-imageId-1", + "imageName": "test-image-name", + "imageList": [ + { + "imageListName": "testListName", + "imageListId": "testListId", + "imageListNumber": 200, + "imageListBoolean": true, + "imageListNull": null + } + ] + } + }, + "output": { + "my-image": { + "image-id": "test-imageId-1", + "image-name": "test-image-name", + "image-list": [ + { + "image-list-name": "testListName", + "image-list-id": "testListId", + "image-list-number": 200, + "image-list-boolean": true, + "image-list-null": null + } + ] + } + } +} \ No newline at end of file diff --git a/aai-traversal/src/test/resources/maputils/testcases/TestCase2.json b/aai-traversal/src/test/resources/maputils/testcases/TestCase2.json new file mode 100644 index 0000000..9b8a1e3 --- /dev/null +++ b/aai-traversal/src/test/resources/maputils/testcases/TestCase2.json @@ -0,0 +1,40 @@ +{ + "input": { + "myImage": { + "imageId": "test-imageId-1", + "imageName": "test-image-name", + "imageList": [ + { + "imageListName": "testListName", + "imageListId": "testListId", + "imageArray": [ + [ + { + "imageNestedArrayElement": "value" + } + ] + ] + } + ] + } + }, + "output": { + "my-image": { + "image-id": "test-imageId-1", + "image-name": "test-image-name", + "image-list": [ + { + "image-list-name": "testListName", + "image-list-id": "testListId", + "image-array": [ + [ + { + "image-nested-array-element": "value" + } + ] + ] + } + ] + } + } +} \ No newline at end of file diff --git a/aai-traversal/src/test/resources/test_aaiconfig.properties b/aai-traversal/src/test/resources/test_aaiconfig.properties new file mode 100644 index 0000000..0af948a --- /dev/null +++ b/aai-traversal/src/test/resources/test_aaiconfig.properties @@ -0,0 +1,97 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 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========================================================= +### + +#################################################################### +# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE +# TEMPLATE AND *ALL* DATAFILES +#################################################################### + +aai.config.checktime=1000 + +# this could come from siteconfig.pl? +aai.config.nodename=AutomaticallyOverwritten + +aai.logging.hbase.interceptor=true +aai.logging.hbase.enabled=true +aai.logging.hbase.logrequest=true +aai.logging.hbase.logresponse=true + +aai.logging.trace.enabled=true +aai.logging.trace.logrequest=false +aai.logging.trace.logresponse=false + +aai.auth.cspcookies_on=false +aai.dbmodel.filename=ex5.json + +aai.server.url.base=https://localhost:8446/aai/ +aai.server.url=https://localhost:8446/aai/v10/ + +aai.truststore.filename=aai_keystore +aai.truststore.passwd.x= +aai.keystore.filename=aai-client-cert.p12 +aai.keystore.passwd.x= + +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=hbase +storage.hostname=ONAPserverTBD +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +# Setting db-cache to false ensure the fastest propagation of changes across servers +cache.db-cache = false +#cache.db-cache-clean-wait = 20 +#cache.db-cache-time = 180000 +#cache.db-cache-size = 0.5 + +# for transaction log +hbase.table.name=aailogging-dev1.dev +hbase.notificationTable.name=aainotification-dev1.dev +hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS +hbase.zookeeper.quorum=ONAPserverTBD +hbase.zookeeper.property.clientPort=2181 +hbase.zookeeper.znode.parent=/hbase-unsecure + +# single primary server +aai.primary.filetransfer.serverlist=ONAPserverTBD +aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo +aai.primary.filetransfer.pingtimeout=5000 +aai.primary.filetransfer.pingcount=5 + +#rsync properties +aai.rsync.command=rsync +aai.rsync.options.list=-v|-t +aai.rsync.remote.user=aaiadmin +aai.rsync.enabled=y + +aai.notification.current.version=v10 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v9 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v10 + + -- cgit 1.2.3-korg