summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorsblimkie <steven.blimkie@amdocs.com>2018-03-15 13:53:15 -0400
committersblimkie <steven.blimkie@amdocs.com>2018-03-15 13:53:15 -0400
commitd41ef90610aadb5aa3372d5922155e4fc4e0a407 (patch)
tree14e2a48d3d8aa4b1bce5c49c052fcd9e93e69227 /src/test/java/org
parentb6ec637f5ee03c573855431e65fcb6ab0f321851 (diff)
Add junit tests
Add junit tests Change-Id: Iaa22b0faa206114ef39648d451a5275205d14d9a Issue-ID: AAI-885 Signed-off-by: sblimkie <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/crud/event/GraphEventTest.java130
-rw-r--r--src/test/java/org/onap/crud/service/AaiResourceServiceTest.java (renamed from src/test/java/org/onap/schema/AaiResourceServiceTest.java)3
-rw-r--r--src/test/java/org/onap/crud/service/BulkPayloadTest.java73
-rw-r--r--src/test/java/org/onap/crud/service/CrudRestServiceTest.java241
-rw-r--r--src/test/java/org/onap/crud/service/TestDao.java194
-rw-r--r--src/test/java/org/onap/crud/service/TestHeaders.java91
-rw-r--r--src/test/java/org/onap/crud/service/TestRequest.java459
-rw-r--r--src/test/java/org/onap/crud/service/TestUriInfo.java148
-rw-r--r--src/test/java/org/onap/schema/RelationshipSchemaTest.java4
9 files changed, 1339 insertions, 4 deletions
diff --git a/src/test/java/org/onap/crud/event/GraphEventTest.java b/src/test/java/org/onap/crud/event/GraphEventTest.java
new file mode 100644
index 0000000..f9a4c6c
--- /dev/null
+++ b/src/test/java/org/onap/crud/event/GraphEventTest.java
@@ -0,0 +1,130 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.event;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.ws.rs.core.Response.Status;
+
+import org.junit.Test;
+import org.onap.crud.entity.Edge;
+import org.onap.crud.entity.Vertex;
+import org.onap.crud.event.GraphEvent;
+import org.onap.crud.event.GraphEvent.GraphEventOperation;
+import org.onap.crud.event.GraphEvent.GraphEventResult;
+import org.onap.crud.event.GraphEventVertex;
+import org.onap.crud.exception.CrudException;
+
+public class GraphEventTest {
+ private final String vertexPayload = "{" +
+ "\"key\": \"test-uuid\"," +
+ "\"type\": \"pserver\"," +
+ "\"properties\": {" +
+ "\"fqdn\": \"myhost.onap.com\"," +
+ "\"hostname\": \"myhost\" } }";
+
+ private final String edgePayload = "{" +
+ "\"key\": \"test-uuid\"," +
+ "\"type\": \"tosca.relationships.HostedOn\"," +
+ "\"properties\": {" +
+ "\"prevent-delete\": \"NONE\" }," +
+ "\"source\": {" +
+ "\"key\": \"50bdab41-ad1c-4d00-952c-a0aa5d827811\", \"type\": \"vserver\"}," +
+ "\"target\": {" +
+ "\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" +
+ " }";
+
+ @Test
+ public void validateGraphEvent() throws CrudException, IOException {
+ // Test building event from json
+ File file = new File("src/test/resources/payloads/graphVertexEvent.json");
+ String payloadStr = readFileToString(file);
+ GraphEvent event = GraphEvent.fromJson(payloadStr);
+ assertTrue(event.getOperation() == GraphEventOperation.UPDATE);
+ assertTrue(event.getDbTransactionId().equals("b3e2853e-f643-47a3-a0c3-cb54cc997ad3"));
+ assertTrue(event.getTimestamp() == Long.parseLong("1514927928167"));
+ assertTrue(event.getTransactionId().equals("c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4"));
+ assertTrue(event.getObjectKey().equals("mykey"));
+ assertTrue(event.getObjectType().equals("vertex->pserver"));
+ assertTrue(event.getVertex().getId().equals("mykey"));
+ assertTrue(event.getVertex().getModelVersion().equals("v11"));
+ assertTrue(event.getVertex().getType().equals("pserver"));
+ assertTrue(event.getVertex().getProperties() != null);
+ assertTrue(event.getVertex().toVertex() != null);
+ assertTrue(event.getVertex().toJson() != null);
+
+ // Test building event from vertex
+ Vertex vertex = Vertex.fromJson(vertexPayload, "v11");
+ event = GraphEvent.builder(GraphEventOperation.CREATE).vertex(GraphEventVertex.fromVertex(vertex, "v11")).build();
+ assertTrue(event.getOperation() == GraphEventOperation.CREATE);
+
+
+ // Test building event from edge
+ Edge edge = Edge.fromJson(edgePayload);
+ event = GraphEvent.builder(GraphEventOperation.UPDATE).edge(GraphEventEdge.fromEdge(edge, "v11")).build();
+ assertTrue(event.getOperation() == GraphEventOperation.UPDATE);
+ assertTrue(event.getObjectKey().equals("test-uuid"));
+ assertTrue(event.getObjectType().equals("edge->tosca.relationships.HostedOn"));
+ assertTrue(event.getEdge().getId().equals("test-uuid"));
+ assertTrue(event.getEdge().getType().equals("tosca.relationships.HostedOn"));
+ assertTrue(event.getEdge().getProperties() != null);
+ assertTrue(event.getEdge().toEdge() != null);
+ assertTrue(event.getEdge().toJson() != null);
+
+ // Test Getters/Setters
+ event.setDbTransactionId("a");
+ assertTrue(event.getDbTransactionId().equals("a"));
+ event.setErrorMessage("error");
+ assertTrue(event.getErrorMessage().equals("error"));
+ event.setResult(GraphEventResult.FAILURE);
+ assertTrue(event.getResult() == GraphEventResult.FAILURE);
+ event.setHttpErrorStatus(Status.BAD_REQUEST);
+ assertTrue(event.getHttpErrorStatus() == Status.BAD_REQUEST);
+ event.setTimestamp(1234567);
+ assertTrue(event.getTimestamp() == Long.parseLong("1234567"));
+ }
+
+ public static String readFileToString(File aFile) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(aFile));
+ try {
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ line = br.readLine();
+ }
+
+ return sb.toString().replaceAll("\\s+", "");
+ } finally {
+ try {
+ br.close();
+ } catch (IOException e) {
+ fail("Unexpected IOException: " + e.getMessage());
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/onap/schema/AaiResourceServiceTest.java b/src/test/java/org/onap/crud/service/AaiResourceServiceTest.java
index 9fc1446..5eb8a68 100644
--- a/src/test/java/org/onap/schema/AaiResourceServiceTest.java
+++ b/src/test/java/org/onap/crud/service/AaiResourceServiceTest.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.schema;
+package org.onap.crud.service;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -33,7 +33,6 @@ import org.onap.aai.serialization.db.EdgeRule;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.db.EdgeType;
import org.onap.crud.exception.CrudException;
-import org.onap.crud.service.AaiResourceService;
import org.onap.crud.service.EdgePayload;
import com.google.gson.JsonElement;
diff --git a/src/test/java/org/onap/crud/service/BulkPayloadTest.java b/src/test/java/org/onap/crud/service/BulkPayloadTest.java
new file mode 100644
index 0000000..89c2269
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/BulkPayloadTest.java
@@ -0,0 +1,73 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+public class BulkPayloadTest {
+
+ @Test
+ public void testBulkPayload() throws Exception {
+ BulkPayload p = new BulkPayload();
+ JsonObject root = new JsonObject();
+ JsonArray vertices = new JsonArray();
+ JsonObject v1 = new JsonObject();
+ JsonObject v2 = new JsonObject();
+ JsonObject prop = new JsonObject();
+
+ prop.addProperty("p1", "value1");
+ prop.addProperty("p2", "value2");
+ v1.add("v1", prop);
+ v2.add("v2", prop);
+
+ vertices.add(v1);
+ vertices.add(v2);
+
+ root.add("objects", vertices);
+
+ String s = "{\"objects\":[{\"v1\":{\"p1\":\"value1\",\"p2\":\"value2\"}},{\"v2\":{\"p1\":\"value1\",\"p2\":\"value2\"}}]}";
+
+ p = BulkPayload.fromJson(s);
+
+ List<JsonElement> po = p.getObjects();
+ List<String> ids = new ArrayList<String>();
+ for (JsonElement e : po) {
+ Set<Map.Entry<String, JsonElement>> entries = e.getAsJsonObject().entrySet();
+
+ for (Map.Entry<String, JsonElement> entry : entries) {
+ ids.add(entry.getKey());
+ }
+ }
+
+ System.out.println("root: " + root.toString());
+ System.out.println("payload ids: " + ids.toString());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/crud/service/CrudRestServiceTest.java b/src/test/java/org/onap/crud/service/CrudRestServiceTest.java
new file mode 100644
index 0000000..029fd52
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/CrudRestServiceTest.java
@@ -0,0 +1,241 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.crud.exception.CrudException;
+import org.onap.schema.RelationshipSchemaLoader;
+
+
+
+public class CrudRestServiceTest {
+ private final String putVertexPayload = "{" +
+ "\"id\": \"test-uuid\"," +
+ "\"type\": \"pserver\"," +
+ "\"properties\": {" +
+ "\"fqdn\": \"myhost.onap.com\"," +
+ "\"hostname\": \"myhost\" } }";
+
+ private final String postVertexPayload = "{" +
+ "\"type\": \"pserver\"," +
+ "\"properties\": {" +
+ "\"fqdn\": \"myhost.onap.com\"," +
+ "\"hostname\": \"myhost\" } }";
+
+ private final String postMissingPropVertexPayload = "{" +
+ "\"type\": \"pserver\"," +
+ "\"properties\": {" +
+ "\"fqdn\": \"myhost.onap.com\"," +
+ "\"equip-type\": \"box\" } }";
+
+ private final String postEdgePayload = "{" +
+ "\"type\": \"tosca.relationships.HostedOn\"," +
+ "\"source\": \"services/inventory/v12/vserver/50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
+ "\"target\": \"services/inventory/v12/pserver/1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
+ "\"properties\": {" +
+ "\"prevent-delete\": \"NONE\" } }";
+
+
+ private CrudRestService mockService;
+
+ @Before
+ public void init() throws Exception {
+ ClassLoader classLoader = getClass().getClassLoader();
+ File dir = new File(classLoader.getResource("model").getFile());
+ System.setProperty("CONFIG_HOME", dir.getParent());
+ RelationshipSchemaLoader.resetVersionContextMap();
+
+ CrudGraphDataService service = new CrudGraphDataService(new TestDao());
+ CrudRestService restService = new CrudRestService(service, null);
+ mockService = Mockito.spy(restService);
+
+ Mockito.doReturn(true).when(mockService).validateRequest(Mockito.any(HttpServletRequest.class),
+ Mockito.anyString(), Mockito.anyString(), Mockito.any(CrudRestService.Action.class), Mockito.anyString(),
+ Mockito.any(HttpHeaders.class));
+ }
+
+ @Test
+ public void testDelete() throws CrudException {
+ Response response;
+
+ response = mockService.deleteVertex("", "v11", "pserver", "872dd5df-0be9-4167-95e9-2cf4b21165ed",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ assertTrue(response.getStatus() == 200);
+
+ response = mockService.deleteEdge("", "v11", "tosca.relationships.HostedOn", "872dd5df-0be9-4167-95e9-2cf4b21165ed",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ assertTrue(response.getStatus() == 200);
+ }
+
+ @Test
+ public void testAddVertex() throws CrudException {
+ Response response;
+
+ response = mockService.addVertex(postMissingPropVertexPayload, "v11", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 400);
+
+ response = mockService.addVertex(postVertexPayload, "v11", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 201);
+
+ response = mockService.addVertex(postMissingPropVertexPayload, "v11", "pserver", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 400);
+
+ response = mockService.addVertex(postVertexPayload, "v11", "pserver", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 201);
+ }
+
+ @Test
+ public void testAddEdge() throws CrudException {
+ Response response;
+
+ response = mockService.addEdge(postEdgePayload, "v11", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 201);
+
+ response = mockService.addEdge(postEdgePayload, "v11", "tosca.relationships.HostedOn", "services/inventory/v11",
+ new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 201);
+ }
+
+ @Test
+ public void testUpdateVertex() throws CrudException {
+ Response response;
+
+ // Test ID mismatch
+ response = mockService.updateVertex(putVertexPayload, "v11", "pserver", "bad-id",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 400);
+
+ // Success case
+ response = mockService.updateVertex(putVertexPayload, "v11", "pserver", "test-uuid",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+
+ // Patch
+ response = mockService.patchVertex(putVertexPayload, "v11", "pserver", "test-uuid",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+ }
+
+ @Test
+ public void testUpdateEdge() throws CrudException {
+ Response response;
+
+ response = mockService.updateEdge(postEdgePayload, "v11", "tosca.relationships.HostedOn", "my-uuid",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+
+ // Patch
+ response = mockService.patchEdge(postEdgePayload, "v11", "tosca.relationships.HostedOn", "my-uuid",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+ }
+
+ @Test
+ public void testGet() throws CrudException {
+ Response response;
+
+ response = mockService.getVertex("", "v11", "pserver", "872dd5df-0be9-4167-95e9-2cf4b21165ed",
+ "services/inventory/v11", new TestHeaders(), new TestUriInfo(), new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+
+ response = mockService.getEdge("", "v11", "tosca.relationships.HostedOn", "872dd5df-0be9-4167-95e9-2cf4b21165ed",
+ "services/inventory/v11", new TestHeaders(), new TestUriInfo(), new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+
+ response = mockService.getVertices("", "v11", "pserver",
+ "services/inventory/v11", new TestHeaders(), new TestUriInfo(), new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+
+ response = mockService.getEdges("", "v11", "tosca.relationships.HostedOn",
+ "services/inventory/v11", new TestHeaders(), new TestUriInfo(), new TestRequest());
+ System.out.println("Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+ }
+
+ @Test
+ public void testBulk() throws CrudException, IOException {
+ Response response;
+
+ File bulkFile = new File("src/test/resources/payloads/bulk.json");
+ String payloadStr = readFileToString(bulkFile);
+ System.out.println(payloadStr);
+
+ response = mockService.addBulk(payloadStr, "v11", "",
+ "services/inventory/v11", new TestHeaders(), null, new TestRequest());
+ System.out.println("Bulk Response: " + response.getStatus() + "\n" + response.getEntity().toString());
+ assertTrue(response.getStatus() == 200);
+ }
+
+ public static String readFileToString(File aFile) throws IOException {
+
+ BufferedReader br = new BufferedReader(new FileReader(aFile));
+ try {
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ line = br.readLine();
+ }
+
+ return sb.toString().replaceAll("\\s+", "");
+ } finally {
+ try {
+ br.close();
+ } catch (IOException e) {
+ fail("Unexpected IOException: " + e.getMessage());
+ }
+ }
+ }
+
+}
diff --git a/src/test/java/org/onap/crud/service/TestDao.java b/src/test/java/org/onap/crud/service/TestDao.java
new file mode 100644
index 0000000..5af85f0
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/TestDao.java
@@ -0,0 +1,194 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.crud.dao.GraphDao;
+import org.onap.crud.entity.Edge;
+import org.onap.crud.entity.Vertex;
+import org.onap.crud.exception.CrudException;
+
+public class TestDao implements GraphDao {
+
+ private final String champVertex = "{" +
+ "\"key\": \"test-uuid\"," +
+ "\"type\": \"pserver\"," +
+ "\"properties\": {" +
+ "\"fqdn\": \"myhost.onap.com\"," +
+ "\"hostname\": \"myhost\" } }";
+
+ private final String champEdge = "{" +
+ "\"key\": \"test-uuid\"," +
+ "\"type\": \"tosca.relationships.HostedOn\"," +
+ "\"properties\": {" +
+ "\"prevent-delete\": \"NONE\" }," +
+ "\"source\": {" +
+ "\"key\": \"50bdab41-ad1c-4d00-952c-a0aa5d827811\", \"type\": \"vserver\"}," +
+ "\"target\": {" +
+ "\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" +
+ " }";
+
+ @Override
+ public Vertex getVertex(String id, String version) throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams)
+ throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
+ List<Edge> list = new ArrayList<Edge>();
+ list.add(Edge.fromJson(champEdge));
+ return list;
+ }
+
+ @Override
+ public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
+ List<Vertex> list = new ArrayList<Vertex>();
+ list.add(Vertex.fromJson(champVertex, "v11"));
+ return list;
+ }
+
+ @Override
+ public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version)
+ throws CrudException {
+ List<Vertex> list = new ArrayList<Vertex>();
+ list.add(Vertex.fromJson(champVertex, "v11"));
+ return list;
+ }
+
+ @Override
+ public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+ @Override
+ public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
+ List<Edge> list = new ArrayList<Edge>();
+ list.add(Edge.fromJson(champEdge));
+ return list;
+ }
+
+ @Override
+ public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version)
+ throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public void deleteVertex(String id, String type) throws CrudException {
+
+ }
+
+ @Override
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version)
+ throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+ @Override
+ public Edge updateEdge(Edge edge) throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+ @Override
+ public void deleteEdge(String id, String type) throws CrudException {
+
+ }
+
+ @Override
+ public String openTransaction() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void commitTransaction(String id) throws CrudException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void rollbackTransaction(String id) throws CrudException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean transactionExists(String id) throws CrudException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId)
+ throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version,
+ String txId) throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+ @Override
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId)
+ throws CrudException {
+ return Vertex.fromJson(champVertex, "v11");
+ }
+
+ @Override
+ public Edge updateEdge(Edge edge, String txId) throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+ @Override
+ public void deleteVertex(String id, String type, String txId) throws CrudException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteEdge(String id, String type, String txId) throws CrudException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Edge getEdge(String id, String type, String txId) throws CrudException {
+ return Edge.fromJson(champEdge);
+ }
+
+}
diff --git a/src/test/java/org/onap/crud/service/TestHeaders.java b/src/test/java/org/onap/crud/service/TestHeaders.java
new file mode 100644
index 0000000..6e30471
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/TestHeaders.java
@@ -0,0 +1,91 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
+public class TestHeaders implements HttpHeaders {
+
+ @Override
+ public List<Locale> getAcceptableLanguages() {
+ return null;
+ }
+
+ @Override
+ public List<MediaType> getAcceptableMediaTypes() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Cookie> getCookies() {
+ return null;
+ }
+
+ @Override
+ public Date getDate() {
+ return null;
+ }
+
+ @Override
+ public String getHeaderString(String arg0) {
+ return null;
+ }
+
+ @Override
+ public Locale getLanguage() {
+ return null;
+ }
+
+ @Override
+ public int getLength() {
+ return 0;
+ }
+
+ @Override
+ public MediaType getMediaType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getRequestHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getRequestHeaders() {
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.add("X-FromAppId", "test-app");
+ map.add("X-TransactionId", "65f7e29c-57fd-45b2-bfd5-19e25c59110e");
+ return map;
+ }
+
+}
diff --git a/src/test/java/org/onap/crud/service/TestRequest.java b/src/test/java/org/onap/crud/service/TestRequest.java
new file mode 100644
index 0000000..f5ee7d6
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/TestRequest.java
@@ -0,0 +1,459 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
+
+public class TestRequest implements HttpServletRequest {
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getAttribute(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getContentLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getContentLengthLong() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public DispatcherType getDispatcherType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ServletInputStream getInputStream() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getLocalAddr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getLocalName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getLocalPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Locale getLocale() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<Locale> getLocales() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getParameter(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, String[]> getParameterMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getParameterNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String[] getParameterValues(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProtocol() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BufferedReader getReader() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRealPath(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRemoteAddr() {
+ return "127.0.0.1";
+ }
+
+ @Override
+ public String getRemoteHost() {
+ return "127.0.0.1";
+ }
+
+ @Override
+ public int getRemotePort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getScheme() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServerName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getServerPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isSecure() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void removeAttribute(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAttribute(String arg0, Object arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public AsyncContext startAsync() throws IllegalStateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest arg0, ServletResponse arg1) throws IllegalStateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean authenticate(HttpServletResponse arg0) throws IOException, ServletException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String changeSessionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getAuthType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getContextPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Cookie[] getCookies() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getDateHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getHeaders(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getIntHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getMethod() {
+ return "OP";
+ }
+
+ @Override
+ public Part getPart(String arg0) throws IOException, ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Part> getParts() throws IOException, ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPathInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPathTranslated() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getQueryString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRequestURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public StringBuffer getRequestURL() {
+ return new StringBuffer();
+ }
+
+ @Override
+ public String getRequestedSessionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromCookie() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromURL() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromUrl() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdValid() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isUserInRole(String arg0) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void login(String arg0, String arg1) throws ServletException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void logout() throws ServletException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public <T extends HttpUpgradeHandler> T upgrade(Class<T> arg0) throws IOException, ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/src/test/java/org/onap/crud/service/TestUriInfo.java b/src/test/java/org/onap/crud/service/TestUriInfo.java
new file mode 100644
index 0000000..980f0da
--- /dev/null
+++ b/src/test/java/org/onap/crud/service/TestUriInfo.java
@@ -0,0 +1,148 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
+ * 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.crud.service;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+public class TestUriInfo implements UriInfo {
+
+ @Override
+ public URI getAbsolutePath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UriBuilder getAbsolutePathBuilder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URI getBaseUri() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UriBuilder getBaseUriBuilder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<Object> getMatchedResources() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getMatchedURIs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getMatchedURIs(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPath(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters() {
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.add("hostname", "myhost");
+ return map;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters(boolean arg0) {
+ return null;
+ }
+
+ @Override
+ public URI getRequestUri() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UriBuilder getRequestUriBuilder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URI relativize(URI arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URI resolve(URI arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/src/test/java/org/onap/schema/RelationshipSchemaTest.java b/src/test/java/org/onap/schema/RelationshipSchemaTest.java
index c5fbf9d..7d54a30 100644
--- a/src/test/java/org/onap/schema/RelationshipSchemaTest.java
+++ b/src/test/java/org/onap/schema/RelationshipSchemaTest.java
@@ -71,7 +71,7 @@ public class RelationshipSchemaTest {
loadRelations(versionContextMap);
assertNotNull(versionContextMap.get("v11").lookupRelation("availability-zone:complex:groupsResourcesIn"));
assertTrue(versionContextMap.get("v11")
- .lookupRelation("availability-zone:complex:groupsResourcesIn").containsKey("usesResource"));
+ .lookupRelation("availability-zone:complex:groupsResourcesIn").containsKey("prevent-delete"));
}
@Test
@@ -80,7 +80,7 @@ public class RelationshipSchemaTest {
loadRelations(versionContextMap);
assertNotNull(versionContextMap.get("v11").lookupRelationType("groupsResourcesIn"));
assertTrue(versionContextMap.get("v11")
- .lookupRelation("availability-zone:complex:groupsResourcesIn").containsKey("usesResource"));
+ .lookupRelation("availability-zone:complex:groupsResourcesIn").containsKey("prevent-delete"));
}
private void loadRelations(Map<String, RelationshipSchema> map){