aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorYoo, Brian (by703c) <by703c@att.com>2020-03-12 14:20:05 -0400
committerJames Forsyth <jf2512@att.com>2020-03-12 19:17:02 +0000
commit67b5d58cad5dfc1a7b075a685bb4e65c3dd5f632 (patch)
tree8082c0a30863d79c77c38a108c870aec192d43c6 /aai-core
parente062d90200373473b21b42b8b5f0d8ae18155494 (diff)
Adding test cases to aai-core to increase coverage
Issue-ID: AAI-2828 Change-Id: I81e62cb1e1e984291bcd77c544f18d2d511b9d07 Signed-off-by: Yoo, Brian (by703c) <by703c@att.com>
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java106
-rw-r--r--aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java224
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java282
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java49
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java148
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java99
-rw-r--r--aai-core/src/test/java/org/onap/aai/restcore/CustomJacksonJaxBJsonProviderTest.java35
-rw-r--r--aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java79
-rw-r--r--aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java105
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties4
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/relationship/related-link-and-relationship-data.json8
11 files changed, 1138 insertions, 1 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
new file mode 100644
index 00000000..eafffe63
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
@@ -0,0 +1,106 @@
+/**
+ * ============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.audit;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.aai.AAISetup;
+import org.onap.aai.concurrent.AaiCallable;
+import org.onap.aai.setup.SchemaServiceVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersionsBean;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.validation.constraints.AssertTrue;
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class ListEndpointsTest extends AAISetup {
+
+ private Properties properties;
+ private SchemaVersion version;
+ private ListEndpoints listEndpoints;
+
+ @Before
+ public void setUp() throws Exception {
+ properties = new Properties();
+ version = schemaVersions.getDefaultVersion();
+ listEndpoints = new ListEndpoints(basePath, schemaVersions.getDefaultVersion());
+ }
+
+ @Test
+ public void testGetEndpoints() {
+ Assert.assertTrue(listEndpoints != null);
+ List<String> list = listEndpoints.getEndpoints();
+ Assert.assertTrue(list != null && !list.isEmpty());
+
+ for (String endpoint : list) {
+ System.out.println("endpoints: " + endpoint);
+ }
+ }
+
+ @Test
+ public void testGetEndpointsWithParam() {
+ Assert.assertTrue(listEndpoints != null);
+ List<String> list = listEndpoints.getEndpoints();
+ Assert.assertTrue(list != null && !list.isEmpty());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testGetEndpoints_throwException() {
+ ListEndpoints listEndpointsFail = new ListEndpoints(basePath, null);
+ }
+
+ @Test
+ public void testGetLogicalNames() {
+ Assert.assertTrue(listEndpoints != null);
+ Map<String, String> map = listEndpoints.getLogicalNames();
+ Assert.assertTrue(map != null && !map.isEmpty());
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertTrue(listEndpoints != null);
+ String endpoints = listEndpoints.toString();
+ }
+
+ @Test
+ public void testToStrinWithParam() {
+ Assert.assertTrue(listEndpoints != null);
+ String endpoints = listEndpoints.toString("complex");
+ Assert.assertTrue(!endpoints.contains("complex"));
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
new file mode 100644
index 00000000..07fa3890
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
@@ -0,0 +1,224 @@
+/**
+ * ============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.db;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.apache.commons.io.IOUtils;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.junit.*;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+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.domain.model.AAIResource;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
+import org.onap.aai.parsers.query.QueryParser;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.*;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+@RunWith(value = Parameterized.class)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+public class DbMethHelperTest extends AAISetup {
+ private DbMethHelper dbMethHelper = new DbMethHelper();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+ protected static Graph graph;
+
+ @Autowired
+ protected EdgeSerializer edgeSer;
+
+ private SchemaVersion version;
+ private final ModelType introspectorFactoryType = ModelType.MOXY;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private TransactionalGraphEngine engine; // for tests that aren't mocking the engine
+ private DBSerializer dbser;
+ private TransactionalGraphEngine spy;
+ private TransactionalGraphEngine.Admin adminSpy;
+
+ @Parameterized.Parameter
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}});
+ }
+
+ @BeforeClass
+ public static void init() {
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ version = schemaVersions.getDefaultVersion();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(queryStyle, loader);
+ spy = spy(dbEngine);
+ adminSpy = spy(dbEngine.asAdmin());
+
+ engine = new JanusGraphDBEngine(queryStyle, loader);
+ dbser = new DBSerializer(version, dbEngine, introspectorFactoryType, "AAI-TEST");
+ dbMethHelper = new DbMethHelper(loader, spy);
+
+ Vertex pserver1 = graph.addVertex("aai-node-type", "pserver", "hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
+ Vertex pserver2 = graph.addVertex("aai-node-type", "pserver", "hostname", "testSearchVertexByIdentityMap-pserver-hostname-02");
+ Vertex genericVnf1 = graph.addVertex("aai-node-type", "generic-vnf", "vnf-id", "key1", "vnf-name", "vnfName1");
+ Vertex complex1 = graph.addVertex("aai-node-type", "complex", "physical-location-id", "id1");
+ GraphTraversalSource g = graph.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(g);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(g);
+ }
+
+ @Test
+ public void testSearchVertexByIdentityMap() throws Exception{
+ String type = "pserver";
+ Map<String, Object> map = new HashMap<>();
+ map.put("pserver.hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
+
+ Optional<Vertex> optionalVertex;
+ try {
+ optionalVertex = dbMethHelper.searchVertexByIdentityMap(type, map);
+ } catch (Exception e) {
+ throw new Exception(e);
+ }
+ Assert.assertEquals("vp[hostname->testSearchVertexById]", optionalVertex.get().property("hostname").toString());
+ }
+
+ @Test(expected = AmbiguousMapAAIException.class)
+ public void testSearchVertexByIdentityMap_throwAmbiguousMapAAIException() throws AmbiguousMapAAIException, Exception {
+ String type = "pserver";
+ Map<String, Object> map = new HashMap<>();
+ map.put("pserver.hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
+ map.put("complex.physical-location-id", "id1");
+
+ Optional<Vertex> optionalVertex;
+ try {
+ optionalVertex = dbMethHelper.searchVertexByIdentityMap(type, map);
+ } catch (AmbiguousMapAAIException e) {
+ throw new AmbiguousMapAAIException(e);
+ }
+ }
+
+ @Test
+ public void testLocateUniqueVertex() throws Exception {
+ String type = "complex";
+ Map<String, Object> map = new HashMap<>();
+ Vertex complex2 = graph.addVertex("aai-node-type", "complex", "physical-location-id", "id2");
+ map.put("physical-location-id", "id2");
+ Optional<Vertex> optionalVertex = dbMethHelper.locateUniqueVertex(type, map);
+ Assert.assertEquals("vp[physical-location-id->id2]", optionalVertex.get().property("physical-location-id").toString());
+ }
+
+ @Test(expected = AAIException.class)
+ public void testLocateUniqueVertex_throwsException() throws AAIException, Exception {
+ String type = "Pserver";
+ Map<String, Object> map = new HashMap<>();
+ Introspector obj = loader.unmarshal("relationship", this.getJsonString("related-link-and-relationship-data.json"));
+ map.put("hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
+ dbMethHelper.locateUniqueVertex(type, map);
+ }
+
+ @Test
+ public void testLocateUniqueVertex_returnNull() throws Exception {
+ String type = "complex";
+ Map<String, Object> map = new HashMap<>();
+ map.put("physical-location-id", "bogusId");
+ Optional<Vertex> optionalVertex = dbMethHelper.locateUniqueVertex(type, map);
+ Assert.assertEquals(optionalVertex, Optional.empty());
+ }
+
+ @Test
+ public void testGetVertexProperties() throws Exception {
+ Vertex pserver3 = graph.addVertex("aai-node-type", "pserver", "hostname", "testGetVertexProperties-pserver-hostname-01",
+ "ptnii-equip-name", "testGetVertexProperties-pserver-ptnii-equip-name-01");
+ String type = "pserver";
+ Map<String, Object> map = new HashMap<>();
+ map.put("pserver.hostname", "testGetVertexProperties-pserver-hostname-01");
+
+ Optional<Vertex> optionalVertex;
+ try {
+ optionalVertex = dbMethHelper.searchVertexByIdentityMap(type, map);
+ } catch (Exception e) {
+ throw new Exception(e);
+ }
+
+ Vertex v = optionalVertex.get();
+ List<String> vertexProperties = dbMethHelper.getVertexProperties(v);
+ Assert.assertTrue(vertexProperties.contains("Prop: [aai-node-type], val = [pserver] "));
+ Assert.assertTrue(vertexProperties.contains("Prop: [hostname], val = [testGetVertexProperties-pserver-hostname-01] "));
+ Assert.assertTrue(vertexProperties.contains("Prop: [ptnii-equip-name], val = [testGetVertexProperties-pserver-ptnii-equip-name-01] "));
+ }
+
+ @Test
+ public void testGetVertexProperties_nullParameter() {
+ List<String> vertexProperties = dbMethHelper.getVertexProperties(null);
+ Assert.assertTrue(vertexProperties.contains("null Node object passed to showPropertiesForNode()\n"));
+ Assert.assertTrue(vertexProperties.size() == 1);
+ }
+
+ private String getJsonString(String filename) throws IOException {
+ FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/relationship/" + filename);
+ String s = IOUtils.toString(is, "UTF-8");
+ IOUtils.closeQuietly(is);
+ return s;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ engine.rollback();
+ dbEngine.rollback();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ graph.close();
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java b/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java
new file mode 100644
index 00000000..61e76071
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java
@@ -0,0 +1,282 @@
+/**
+ * ============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.domain.model;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.audit.ListEndpoints;
+import org.onap.aai.setup.SchemaVersion;
+
+import java.util.*;
+
+public class AAIResourceTest extends AAISetup {
+ private AAIResource aaiResource;
+
+ @Before
+ public void setUp() throws Exception {
+ aaiResource = new AAIResource();
+ }
+
+ @Test
+ public void testGetterSetterParent() {
+ AAIResource aaiResourceParent = new AAIResource();
+ aaiResource.setParent(aaiResourceParent);
+ Assert.assertEquals(aaiResource.getParent(), aaiResourceParent);
+ }
+
+ @Test
+ public void testGetChildren() {
+ Assert.assertNotNull(aaiResource.getChildren());
+ }
+
+ @Test
+ public void testGetAaiResourceKeys() {
+ Assert.assertNotNull(aaiResource.getAaiResourceKeys());
+ }
+
+ @Test
+ public void testGetterSetterNamespace() {
+ String testNamespace = "testNamespace";
+ aaiResource.setNamespace(testNamespace);
+ Assert.assertEquals(testNamespace, aaiResource.getNamespace());
+ }
+
+ @Test
+ public void testGetterSetterResourceType() {
+ String testResourceType = "testResourceType";
+ aaiResource.setResourceType(testResourceType);
+ Assert.assertEquals(testResourceType, aaiResource.getResourceType());
+ }
+
+ @Test
+ public void testGetterSetterSimpleName() {
+ String testSimpleName = "testSimpleName";
+ aaiResource.setSimpleName(testSimpleName);
+ Assert.assertEquals(testSimpleName, aaiResource.getSimpleName());
+ }
+
+ @Test
+ public void testGetterSetterFullName() {
+ String testFullName = "testFullName";
+ aaiResource.setFullName(testFullName);
+ Assert.assertEquals(testFullName, aaiResource.getFullName());
+ }
+
+ @Test
+ public void testGetterSetterUri() {
+ String testUri = "testUri";
+ aaiResource.setUri(testUri);
+ Assert.assertEquals(testUri, aaiResource.getUri());
+ }
+
+ @Test
+ public void testGetterSetterResourceClassName() {
+ String testResourceClassName = "testResourceClassName";
+ aaiResource.setResourceClassName(testResourceClassName);
+ Assert.assertEquals(testResourceClassName, aaiResource.getResourceClassName());
+ }
+
+ @Test
+ public void testGetterSetterPropertyDataTypeMap() {
+ Map<String, String> propertyDataTypeMap = new HashMap<>();
+ aaiResource.setPropertyDataTypeMap(propertyDataTypeMap);
+ Assert.assertEquals(propertyDataTypeMap, aaiResource.getPropertyDataTypeMap());
+ }
+
+ @Test
+ public void testGetterSetterNodeMapIndexedProps() {
+ Multimap<String, String> nodeMapIndexedProps = ArrayListMultimap.create();
+ aaiResource.setNodeMapIndexedProps(nodeMapIndexedProps);
+ Assert.assertEquals(nodeMapIndexedProps, aaiResource.getNodeMapIndexedProps());
+ }
+
+ @Test
+ public void testGetterSetterNodeKeyProps() {
+ Multimap<String, String> nodeKeyProps = ArrayListMultimap.create();
+ aaiResource.setNodeKeyProps(nodeKeyProps);
+ Assert.assertEquals(nodeKeyProps, aaiResource.getNodeKeyProps());
+ }
+
+ @Test
+ public void testGetterSetterNodeNameProps() {
+ Multimap<String, String> nodeNameProps = ArrayListMultimap.create();
+ aaiResource.setNodeNameProps(nodeNameProps);
+ Assert.assertEquals(nodeNameProps, aaiResource.getNodeNameProps());
+ }
+
+ @Test
+ public void testGetterSetterNodeUniqueProps() {
+ Multimap<String, String> nodeUniqueProps = ArrayListMultimap.create();
+ aaiResource.setNodeUniqueProps(nodeUniqueProps);
+ Assert.assertEquals(nodeUniqueProps, aaiResource.getNodeUniqueProps());
+ }
+
+ @Test
+ public void testGetterSetterNodeReqProps() {
+ Multimap<String, String> nodeReqProps = ArrayListMultimap.create();
+ aaiResource.setNodeReqProps(nodeReqProps);
+ Assert.assertEquals(nodeReqProps, aaiResource.getNodeReqProps());
+ }
+
+ @Test
+ public void testGetterSetterApiVersion() {
+ String testApiVersion = "testApiVersion";
+ aaiResource.setApiVersion(testApiVersion);
+ Assert.assertEquals(testApiVersion, aaiResource.getApiVersion());
+ }
+
+ @Test
+ public void testGetterSetterRelationshipClass() {
+ String testRelationshipClass = "testRelationshipClass";
+ aaiResource.setRelationshipListClass(testRelationshipClass);
+ Assert.assertEquals(testRelationshipClass, aaiResource.getRelationshipListClass());
+ }
+
+ @Test
+ public void testGetterSetterRelationshipUtils() {
+ String testRelationshipUtils = "testRelationshipUtils";
+ aaiResource.setRelationshipUtils(testRelationshipUtils);
+ Assert.assertEquals(testRelationshipUtils, aaiResource.getRelationshipUtils());
+ }
+
+ @Test
+ public void testGetterSetterStringFields() {
+ Assert.assertNotNull(aaiResource.getStringFields());
+ ArrayList<String> stringFields = new ArrayList<>();
+ aaiResource.setStringFields(stringFields);
+ Assert.assertEquals(stringFields, aaiResource.getStringFields());
+ }
+
+ @Test
+ public void testGetterSetterStringListFields() {
+ Assert.assertNotNull(aaiResource.getStringListFields());
+ ArrayList<String> stringListFields = new ArrayList<>();
+ aaiResource.setStringListFields(stringListFields);
+ Assert.assertEquals(stringListFields, aaiResource.getStringListFields());
+ }
+
+ @Test
+ public void testGetterSetterLongFields() {
+ Assert.assertNotNull(aaiResource.getLongFields());
+ ArrayList<String> longFields = new ArrayList<>();
+ aaiResource.setLongFields(longFields);
+ Assert.assertEquals(longFields, aaiResource.getLongFields());
+ }
+
+ @Test
+ public void testGetterSetterIntFields() {
+ Assert.assertNotNull(aaiResource.getIntFields());
+ ArrayList<String> intFields = new ArrayList<>();
+ aaiResource.setIntFields(intFields);
+ Assert.assertEquals(intFields, aaiResource.getIntFields());
+ }
+
+ @Test
+ public void testGetterSetterShortFields() {
+ Assert.assertNotNull(aaiResource.getShortFields());
+ ArrayList<String> shortFields = new ArrayList<>();
+ aaiResource.setShortFields(shortFields);
+ Assert.assertEquals(shortFields, aaiResource.getShortFields());
+ }
+
+ @Test
+ public void testGetterSetterBooleanFields() {
+ Assert.assertNotNull(aaiResource.getBooleanFields());
+ ArrayList<String> booleanFields = new ArrayList<>();
+ aaiResource.setBooleanFields(booleanFields);
+ Assert.assertEquals(booleanFields, aaiResource.getBooleanFields());
+ }
+
+ @Test
+ public void testGetterSetterRequiredFields() {
+ Assert.assertNotNull(aaiResource.getRequiredFields());
+ ArrayList<String> requiredFields = new ArrayList<>();
+ aaiResource.setRequiredFields(requiredFields);
+ Assert.assertEquals(requiredFields, aaiResource.getRequiredFields());
+ }
+
+ @Test
+ public void testGetOrderedFields() {
+ Assert.assertNotNull(aaiResource.getOrderedFields());
+ }
+
+ @Test
+ public void testGetAllFields() {
+ Assert.assertNotNull(aaiResource.getAllFields());
+ }
+
+ @Test
+ public void testGetPluralName() {
+ AAIResource ar = new AAIResource();
+ ar.setSimpleName("List");
+ String pluralName = ar.getPluralName();
+ Assert.assertEquals("", pluralName);
+ ar.setFullName("Some/FullName/ExpectedValue/Here");
+ ar.setSimpleName("bogusValue");
+ pluralName = ar.getPluralName();
+ Assert.assertEquals("ExpectedValue", pluralName);
+ }
+
+ @Test
+ public void testGetterSetterNodeAltKey1Props() {
+ Multimap<String, String> nodeAltKey1Props = ArrayListMultimap.create();
+ aaiResource.setNodeAltKey1Props(nodeAltKey1Props);
+ Assert.assertEquals(nodeAltKey1Props, aaiResource.getNodeAltKey1Props());
+ }
+
+ @Test
+ public void testGetterSetterNodeDependencies() {
+ Multimap<String, String> _dbRulesNodeDependencies = ArrayListMultimap.create();
+ aaiResource.setNodeDependencies(_dbRulesNodeDependencies);
+ Assert.assertEquals(_dbRulesNodeDependencies, aaiResource.getNodeDependencies());
+ }
+
+ @Test
+ public void testGetterSetterRecurseToResource() {
+ AAIResource recurseToResource = new AAIResource();
+ recurseToResource.setFullName("FullNameTest");
+ aaiResource.setRecurseToResource(recurseToResource);
+ Assert.assertEquals(recurseToResource, aaiResource.getRecurseToResource());
+ }
+
+ @Test
+ public void testGetterSetterAllowDirectWrite() {
+ aaiResource.setAllowDirectWrite(true);
+ Assert.assertTrue(aaiResource.isAllowDirectWrite());
+ }
+
+ @Test
+ public void testGetterSetterAllowDirectRead() {
+ aaiResource.setAllowDirectRead(true);
+ Assert.assertTrue(aaiResource.isAllowDirectRead());
+ }
+
+ @Test
+ public void testGetAutoGenUuidFields() {
+ Assert.assertNotNull(aaiResource.getAutoGenUuidFields());
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java
new file mode 100644
index 00000000..79a9289a
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java
@@ -0,0 +1,49 @@
+/**
+ * ============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.domain.translog;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.domain.model.AAIResource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TransactionLogEntriesTest extends AAISetup {
+ private TransactionLogEntries transactionLogEntries;
+
+ @Before
+ public void setUp() {
+ transactionLogEntries = new TransactionLogEntries();
+ }
+
+ @Test
+ public void testGetterSetterParent() {
+ Assert.assertNotNull(transactionLogEntries.getTransactionLogEntries());
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java
new file mode 100644
index 00000000..b692519c
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java
@@ -0,0 +1,148 @@
+/**
+ * ============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.domain.translog;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.domain.model.AAIResource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TransactionLogEntryTest extends AAISetup {
+ private TransactionLogEntry transactionLogEntry;
+
+ @Before
+ public void setUp() {
+ transactionLogEntry = new TransactionLogEntry();
+ }
+
+ @Test
+ public void testGetterSetterTransactionLogEntryId() {
+ String testTransactionLogEntryId = "testTransactionLogEntryId";
+ transactionLogEntry.setTransactionLogEntryId(testTransactionLogEntryId);
+ Assert.assertEquals(testTransactionLogEntryId, transactionLogEntry.getTransactionLogEntryId());
+ }
+
+ @Test
+ public void testGetterSetterStatus() {
+ String testStatus = "testStatus";
+ transactionLogEntry.setStatus(testStatus);
+ Assert.assertEquals(testStatus, transactionLogEntry.getStatus());
+ }
+
+ @Test
+ public void testGetterSetterRqstDate() {
+ String testRqstDate = "testRqstDate";
+ transactionLogEntry.setRqstDate(testRqstDate);
+ Assert.assertEquals(testRqstDate, transactionLogEntry.getRqstDate());
+ }
+
+ @Test
+ public void testGetterSetterRespDate() {
+ String testRespDate = "testRespDate";
+ transactionLogEntry.setRespDate(testRespDate);
+ Assert.assertEquals(testRespDate, transactionLogEntry.getRespDate());
+ }
+
+ @Test
+ public void testGetterSetterSourceId() {
+ String testSourceId = "testSourceId";
+ transactionLogEntry.setSourceId(testSourceId);
+ Assert.assertEquals(testSourceId, transactionLogEntry.getSourceId());
+ }
+
+ @Test
+ public void testGetterSetterResourceId() {
+ String testResourceId = "testResourceId";
+ transactionLogEntry.setResourceId(testResourceId);
+ Assert.assertEquals(testResourceId, transactionLogEntry.getResourceId());
+ }
+
+ @Test
+ public void testGetterSetterResourceType() {
+ String testResourceType = "testResourceType";
+ transactionLogEntry.setResourceType(testResourceType);
+ Assert.assertEquals(testResourceType, transactionLogEntry.getResourceType());
+ }
+
+ @Test
+ public void testGetterSetterRqstBuf() {
+ String testRqstBuf = "testRqstBuf";
+ transactionLogEntry.setRqstBuf(testRqstBuf);
+ Assert.assertEquals(testRqstBuf, transactionLogEntry.getRqstBuf());
+ }
+
+ @Test
+ public void testGetterSetterRespBuf() {
+ String testRespBuf = "testRespBuf";
+ transactionLogEntry.setrespBuf(testRespBuf);
+ Assert.assertEquals(testRespBuf, transactionLogEntry.getrespBuf());
+ }
+
+ @Test
+ public void testGetterSetterNotificationPayload() {
+ String testNotificationPayload = "testNotificationPayload";
+ transactionLogEntry.setNotificationPayload(testNotificationPayload);
+ Assert.assertEquals(testNotificationPayload, transactionLogEntry.getNotificationPayload());
+ }
+
+ @Test
+ public void testGetterSetterNotificationId() {
+ String testNotificationId = "testNotificationId";
+ transactionLogEntry.setNotificationId(testNotificationId);
+ Assert.assertEquals(testNotificationId, transactionLogEntry.getNotificationId());
+ }
+
+ @Test
+ public void testGetterSetterNotificationStatus() {
+ String testNotificationStatus = "testNotificationStatus";
+ transactionLogEntry.setNotificationStatus(testNotificationStatus);
+ Assert.assertEquals(testNotificationStatus, transactionLogEntry.getNotificationStatus());
+ }
+
+ @Test
+ public void testGetterSetterNotificationTopic() {
+ String testNotificationTopic = "testNotificationTopic";
+ transactionLogEntry.setNotificationTopic(testNotificationTopic);
+ Assert.assertEquals(testNotificationTopic, transactionLogEntry.getNotificationTopic());
+ }
+
+ @Test
+ public void testGetterSetterNotificationEntityLink() {
+ String testNotificationEntityLink = "testNotificationEntityLink";
+ transactionLogEntry.setNotificationEntityLink(testNotificationEntityLink);
+ Assert.assertEquals(testNotificationEntityLink, transactionLogEntry.getNotificationEntityLink());
+ }
+
+ @Test
+ public void testGetterSetterNotificationAction() {
+ String testNotificationAction = "testNotificationAction";
+ transactionLogEntry.setNotificationAction(testNotificationAction);
+ Assert.assertEquals(testNotificationAction, transactionLogEntry.getNotificationAction());
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index 95220b1f..0adcbfe0 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -23,6 +23,9 @@ package org.onap.aai.rest.db;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.javatuples.Pair;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -136,7 +139,7 @@ public class HttpEntryTest extends AAISetup {
objType = "relationship";
}
Introspector obj;
- if (method.equals(HttpMethod.GET)) {
+ if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.GET_RELATIONSHIP)) {
obj = loader.introspectorFromName(objType);
} else {
obj = loader.unmarshal(objType, content, org.onap.aai.restcore.MediaType.getEnum("application/json"));
@@ -603,4 +606,98 @@ public class HttpEntryTest extends AAISetup {
assertThat("Related to pserver is returned.", respBody,
containsString("\"hostname\":\"junit-abstract-test-pserver\""));
}
+
+ @Test
+ public void getRelationshipListTest() throws UnsupportedEncodingException, AAIException {
+ traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
+ Loader loader = traversalHttpEntry.getLoader();
+ TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+
+ // Put pserver
+ String uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ String content = "{\"hostname\":\"httpEntryTest-pserver-01\"}";
+ doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ // Put complex
+ uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
+ content =
+ "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+
+ // Put Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
+ content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
+ + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}" +
+ "\"relationship-daasSta\":[{" +
+ "\"relationship-key\":\"complex.physical-location-id\"," +
+ "\"relationship-value\":\"httpEntryTest-complex-01\"" +
+ "}]";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+ assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
+
+ // Get Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ content = "";
+ response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri, content);
+ String expected = "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-data\":[{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"httpEntryTest-complex-01\"}]}]}";
+ Assert.assertEquals(expected, response.getEntity().toString());
+
+ dbEngine.rollback();
+ }
+
+ @Test
+ public void getRelationshipListTestWithFormatSimple() throws UnsupportedEncodingException, AAIException {
+ traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion());
+ Loader loader = traversalHttpEntry.getLoader();
+ TransactionalGraphEngine dbEngine = traversalHttpEntry.getDbEngine();
+
+ // Put pserver
+ String uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ String content = "{\"hostname\":\"httpEntryTest-pserver-01\"}";
+ doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ // Put complex
+ uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
+ content =
+ "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+
+ // Put Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
+ content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
+ + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}" +
+ "\"relationship-daasSta\":[{" +
+ "\"relationship-key\":\"complex.physical-location-id\"," +
+ "\"relationship-value\":\"httpEntryTest-complex-01\"" +
+ "}]";
+ Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+ assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
+
+ // GET complex
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ content = "";
+ response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+
+ // Get Relationship
+ uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
+ queryParameters.add("format", "resource");
+ content = "";
+ response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri, content);
+ String responsePayload = response.getEntity().toString();
+ JSONObject responseJsonObject = new JSONObject(responsePayload);
+ JSONArray responseResultsArray = responseJsonObject.getJSONArray("results");
+ String responseResults = responseResultsArray.get(0).toString();
+ JSONObject pserverResponseObject = new JSONObject(responseResults);
+ String pserverResponse = pserverResponseObject.get("pserver").toString();
+ JSONObject pserverResponseFields = new JSONObject(pserverResponse);
+ String pserverResponseRelationshipList = pserverResponseFields.get("relationship-list").toString();
+
+ String expected = "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-data\":[{\"relationship-value\":\"httpEntryTest-complex-01\",\"relationship-key\":\"complex.physical-location-id\"}],\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}]}";
+ assertEquals(expected, pserverResponseRelationshipList);
+// Assert.assertEquals(expected, response.getEntity().toString());
+ queryParameters.remove("format");
+
+ dbEngine.rollback();
+ }
+
+
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/restcore/CustomJacksonJaxBJsonProviderTest.java b/aai-core/src/test/java/org/onap/aai/restcore/CustomJacksonJaxBJsonProviderTest.java
new file mode 100644
index 00000000..8ea5722a
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/restcore/CustomJacksonJaxBJsonProviderTest.java
@@ -0,0 +1,35 @@
+/**
+ * ============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.restcore;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+
+public class CustomJacksonJaxBJsonProviderTest extends AAISetup {
+ public static CustomJacksonJaxBJsonProvider customJacksonJaxBJsonProvider;
+
+ @Test
+ public void testGetMapper() {
+ customJacksonJaxBJsonProvider = new CustomJacksonJaxBJsonProvider();
+ Assert.assertNotNull(customJacksonJaxBJsonProvider.getMapper());
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java b/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java
new file mode 100644
index 00000000..c86c371d
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java
@@ -0,0 +1,79 @@
+/**
+ * ============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.restcore;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphFactory;
+import org.junit.*;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.onap.aai.AAISetup;
+import org.onap.aai.db.DbMethHelper;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.*;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class JettyObfuscationConversionCommandLineUtilTest extends AAISetup {
+ public static JettyObfuscationConversionCommandLineUtil jettyObfuscationConversionCommandLineUtil;
+
+ @Test
+ public void testMainObfuscation() {
+ String[] args = {"-e", "[thisStringToObfuscate]"};
+ jettyObfuscationConversionCommandLineUtil.main(args);
+ Assert.assertTrue(true); // No exception was encountered
+ }
+
+ @Test
+ public void testMainDeobfuscation() {
+ String[] args = {"-d", "OBF:1pj11w261wmr1t3b1vgv1s9r1z7i1vuz1tae1qji1vg71mdb1vgn1qhs1ta01vub1z7k1sbj1vfz1t2v1wnf1w1c1pj5"};
+ jettyObfuscationConversionCommandLineUtil.main(args);
+ Assert.assertTrue(true); // No exception was encountered
+ }
+
+ @Test
+ public void testMain_failedParseInput() {
+ String[] args = {"-e [thisStringToObfuscate]"};
+ jettyObfuscationConversionCommandLineUtil.main(args);
+ Assert.assertTrue(true); // No exception was encountered
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java
new file mode 100644
index 00000000..6be45ff5
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java
@@ -0,0 +1,105 @@
+/**
+ * ============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.restcore;
+
+import com.google.common.collect.HashMultimap;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
+
+import javax.ws.rs.core.*;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+public class RESTAPITest extends AAISetup {
+ private static RESTAPI restapi;
+ private static HttpHeaders httpHeaders;
+ private static Callable callable;
+ private static UriInfo info;
+ private static Response response;
+
+ public static final String AAI_TIMEOUT_ENABLED = "aai.timeout.enabled";
+ public static final String AAI_TIMEOUT_BY_APP = "aai.timeout.by.app";
+ public static final String AAI_TIMEOUT_DEFAULT_LIMIT = "aai.timeout.default.limit";
+
+ @BeforeClass
+ public static void setUp() {
+ restapi = new RESTAPI();
+ httpHeaders = mock(HttpHeaders.class);
+ callable = mock(Callable.class);
+ info = mock(UriInfo.class);
+ response = mock(Response.class);
+ }
+
+ @Test
+ public void testGetFromAppId() throws AAIException {
+ List<String> fromAppIdList = new ArrayList<>();
+ fromAppIdList.add("from-app-id-01");
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(fromAppIdList);
+
+ String fromAppId = restapi.getFromAppId(httpHeaders);
+ Assert.assertEquals("from-app-id-01", fromAppId);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testGetFromAppId_throwAAIException() throws AAIException {
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(null);
+ restapi.getFromAppId(httpHeaders);
+ }
+
+ @Test
+ public void testGetTransId() throws AAIException {
+ List<String> transactionIdList = new ArrayList<>();
+ transactionIdList.add("transaction-id-01");
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(transactionIdList);
+
+ String transId = restapi.getTransId(httpHeaders);
+ Assert.assertEquals("transaction-id-01", transId);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testGetTransId_throwAAIException() throws AAIException {
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(null);
+ String transId = restapi.getTransId(httpHeaders);
+ }
+
+ @Test
+ public void testRunner() throws AAIException, Exception {
+ MultivaluedMap<String, String> requestHeaders = new MultivaluedHashMap<String, String>();
+ requestHeaders.add("X-FromAppId", "from-app-id-01");
+ requestHeaders.add("X-TransactionId", "transaction-id-01");
+ when(httpHeaders.getRequestHeaders()).thenReturn(requestHeaders);
+ when(callable.call()).thenReturn(response);
+
+ Response resp = restapi.runner(AAI_TIMEOUT_ENABLED, AAI_TIMEOUT_BY_APP, AAI_TIMEOUT_DEFAULT_LIMIT, httpHeaders, info, HttpMethod.GET, callable);
+ Assert.assertNotNull(resp);
+ }
+}
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
index f0e09d40..c7eaad36 100644
--- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties
@@ -57,3 +57,7 @@ aai.rest.getall.depthparam=someuuid
aaf.valid.issuer.wildcard=aaf wild card issuer|aafWildCardIssuer|OU=another
aai.implied.delete.whitelist.junit='pserver','l-interface'
+
+aai.timeout.enabled=true
+aai.timeout.by.app=from-app-id-01,100|from-app-id-02,200
+aai.timeout.default.limit=500
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/relationship/related-link-and-relationship-data.json b/aai-core/src/test/resources/bundleconfig-local/etc/relationship/related-link-and-relationship-data.json
new file mode 100644
index 00000000..da957497
--- /dev/null
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/relationship/related-link-and-relationship-data.json
@@ -0,0 +1,8 @@
+{
+ "related-to": "generic-vnf",
+ "related-link": "http://localhost/aai/v10/network/generic-vnfs/generic-vnf/key1",
+ "relationship-data" : [{
+ "relationship-key" : "generic-vnf.vnf-id",
+ "relationship-value":"key1"
+ }]
+}