From: sblimkie Date: Thu, 15 Mar 2018 17:53:15 +0000 (-0400) Subject: Add junit tests X-Git-Tag: 2.0.0-ONAP~14 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fgizmo.git;a=commitdiff_plain;h=d41ef90610aadb5aa3372d5922155e4fc4e0a407 Add junit tests Add junit tests Change-Id: Iaa22b0faa206114ef39648d451a5275205d14d9a Issue-ID: AAI-885 Signed-off-by: sblimkie --- diff --git a/src/main/java/org/onap/crud/service/BulkPayload.java b/src/main/java/org/onap/crud/service/BulkPayload.java index 9b7b4cf..8dc99c4 100644 --- a/src/main/java/org/onap/crud/service/BulkPayload.java +++ b/src/main/java/org/onap/crud/service/BulkPayload.java @@ -22,16 +22,12 @@ package org.onap.crud.service; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import org.onap.crud.exception.CrudException; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.Set; import javax.ws.rs.core.Response.Status; @@ -81,41 +77,4 @@ public class BulkPayload { return "BulkPayload [objects=" + objects + ", relationships=" + relationships + "]"; } - public static void main(String[] args) 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 po = p.getObjects(); - List ids = new ArrayList(); - for (JsonElement e : po) { - Set> entries = e.getAsJsonObject().entrySet(); - - for (Map.Entry 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/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java index dbe9d68..2af205a 100644 --- a/src/main/java/org/onap/crud/service/CrudRestService.java +++ b/src/main/java/org/onap/crud/service/CrudRestService.java @@ -72,6 +72,13 @@ public class CrudRestService { this.graphDataService = graphDataService; this.auth = new Auth(CrudServiceConstants.CRD_AUTH_FILE); } + + // For unit testing + public CrudRestService(AbstractGraphDataService graphDataService, Auth auth) throws Exception { + this.graphDataService = graphDataService; + this.auth = auth; + } + public enum Action { POST, GET, PUT, DELETE, PATCH 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 similarity index 96% rename from src/test/java/org/onap/schema/AaiResourceServiceTest.java rename to 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 po = p.getObjects(); + List ids = new ArrayList(); + for (JsonElement e : po) { + Set> entries = e.getAsJsonObject().entrySet(); + + for (Map.Entry 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 queryParams) + throws CrudException { + return Vertex.fromJson(champVertex, "v11"); + } + + @Override + public List getVertexEdges(String id, Map queryParams) throws CrudException { + List list = new ArrayList(); + list.add(Edge.fromJson(champEdge)); + return list; + } + + @Override + public List getVertices(String type, Map filter, String version) throws CrudException { + List list = new ArrayList(); + list.add(Vertex.fromJson(champVertex, "v11")); + return list; + } + + @Override + public List getVertices(String type, Map filter, HashSet properties, String version) + throws CrudException { + List list = new ArrayList(); + list.add(Vertex.fromJson(champVertex, "v11")); + return list; + } + + @Override + public Edge getEdge(String id, String type, Map queryParams) throws CrudException { + return Edge.fromJson(champEdge); + } + + @Override + public List getEdges(String type, Map filter) throws CrudException { + List list = new ArrayList(); + list.add(Edge.fromJson(champEdge)); + return list; + } + + @Override + public Vertex addVertex(String type, Map properties, String version) throws CrudException { + return Vertex.fromJson(champVertex, "v11"); + } + + @Override + public Vertex updateVertex(String id, String type, Map 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 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 properties, String version, String txId) + throws CrudException { + return Vertex.fromJson(champVertex, "v11"); + } + + @Override + public Edge addEdge(String type, Vertex source, Vertex target, Map properties, String version, + String txId) throws CrudException { + return Edge.fromJson(champEdge); + } + + @Override + public Vertex updateVertex(String id, String type, Map 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 getAcceptableLanguages() { + return null; + } + + @Override + public List getAcceptableMediaTypes() { + return null; + } + + @Override + public Map 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 getRequestHeader(String arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public MultivaluedMap getRequestHeaders() { + MultivaluedMap map = new MultivaluedHashMap(); + 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 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 getLocales() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getParameter(String arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getParameterMap() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration 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 getHeaderNames() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Enumeration 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 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 upgrade(Class 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 getMatchedResources() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getMatchedURIs() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List 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 getPathParameters() { + // TODO Auto-generated method stub + return null; + } + + @Override + public MultivaluedMap getPathParameters(boolean arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getPathSegments() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getPathSegments(boolean arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public MultivaluedMap getQueryParameters() { + MultivaluedMap map = new MultivaluedHashMap(); + map.add("hostname", "myhost"); + return map; + } + + @Override + public MultivaluedMap 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 map){ diff --git a/src/test/resources/model/edge_properties_v10.json b/src/test/resources/model/edge_properties_v10.json index 7cbddae..8d00636 100644 --- a/src/test/resources/model/edge_properties_v10.json +++ b/src/test/resources/model/edge_properties_v10.json @@ -1,10 +1,6 @@ { - "isParent":"java.lang.Boolean", - "isParent-REV":"java.lang.Boolean", - "usesResource":"java.lang.Boolean", - "usesResource-REV":"java.lang.Boolean", - "SVC-INFRA":"java.lang.Boolean", - "SVC-INFRA-REV":"java.lang.Boolean", - "hasDelTarget":"java.lang.Boolean", - "hasDelTarget-REV":"java.lang.Boolean" -} + "contains-other-v": "java.lang.String", + "delete-other-v": "java.lang.String", + "SVC-INFRA": "java.lang.String", + "prevent-delete": "java.lang.String" +} \ No newline at end of file diff --git a/src/test/resources/model/edge_properties_v11.json b/src/test/resources/model/edge_properties_v11.json index ce0e6d5..8d00636 100644 --- a/src/test/resources/model/edge_properties_v11.json +++ b/src/test/resources/model/edge_properties_v11.json @@ -1,10 +1,6 @@ { - "isParent": "java.lang.Boolean", - "isParent-REV": "java.lang.Boolean", - "usesResource": "java.lang.Boolean", - "usesResource-REV": "java.lang.Boolean", - "SVC-INFRA": "java.lang.Boolean", - "SVC-INFRA-REV": "java.lang.Boolean", - "hasDelTarget": "java.lang.Boolean", - "hasDelTarget-REV": "java.lang.Boolean" - } \ No newline at end of file + "contains-other-v": "java.lang.String", + "delete-other-v": "java.lang.String", + "SVC-INFRA": "java.lang.String", + "prevent-delete": "java.lang.String" +} \ No newline at end of file diff --git a/src/test/resources/model/edge_properties_v8.json b/src/test/resources/model/edge_properties_v8.json index 7cbddae..8d00636 100644 --- a/src/test/resources/model/edge_properties_v8.json +++ b/src/test/resources/model/edge_properties_v8.json @@ -1,10 +1,6 @@ { - "isParent":"java.lang.Boolean", - "isParent-REV":"java.lang.Boolean", - "usesResource":"java.lang.Boolean", - "usesResource-REV":"java.lang.Boolean", - "SVC-INFRA":"java.lang.Boolean", - "SVC-INFRA-REV":"java.lang.Boolean", - "hasDelTarget":"java.lang.Boolean", - "hasDelTarget-REV":"java.lang.Boolean" -} + "contains-other-v": "java.lang.String", + "delete-other-v": "java.lang.String", + "SVC-INFRA": "java.lang.String", + "prevent-delete": "java.lang.String" +} \ No newline at end of file diff --git a/src/test/resources/model/edge_properties_v9.json b/src/test/resources/model/edge_properties_v9.json index 2ffcabb..8d00636 100644 --- a/src/test/resources/model/edge_properties_v9.json +++ b/src/test/resources/model/edge_properties_v9.json @@ -1,10 +1,6 @@ { - "isParent":"java.lang.Boolean", - "isParent-REV":"java.lang.Boolean", - "usesResource":"java.lang.Boolean", - "usesResource-REV":"java.lang.Boolean", - "SVC-INFRA":"java.lang.Boolean", - "SVC-INFRA-REV":"java.lang.Boolean", - "hasDelTarget":"java.lang.Boolean", - "hasDelTarget-REV":"java.lang.Boolean" -} + "contains-other-v": "java.lang.String", + "delete-other-v": "java.lang.String", + "SVC-INFRA": "java.lang.String", + "prevent-delete": "java.lang.String" +} \ No newline at end of file diff --git a/src/test/resources/payloads/bulk.json b/src/test/resources/payloads/bulk.json new file mode 100644 index 0000000..3d514a3 --- /dev/null +++ b/src/test/resources/payloads/bulk.json @@ -0,0 +1,80 @@ +{ + "objects":[ + { + "operation":"add", + "v1":{ + "type":"vserver", + "properties":{ + "vserver-id":"VSER1", + "vserver-name":"test-vserver", + "vserver-name2":"alt-test-vserver", + "vserver-selflink":"http://1.2.3.4/moreInfo", + "in-maint":false, + "is-closed-loop-disabled":false + } + } + }, + { + "operation":"modify", + "v2":{ + "id":"50bdab41-ad1c-4d00-952c-a0aa5d827811", + "type":"pserver", + "properties":{ + "ptnii-equip-name":"e-name", + "equip-type":"server", + "hostname":"steve-host2", + "equip-vendor":"HP", + "equip-model":"DL380p-nd", + "fqdn":"myhost.onap.net", + "purpose":"my-purpose", + "ipv4-oam-address":"1.2.3.4" + } + } + }, + { + "operation":"delete", + "v3":{ + "id":"50bdab41-ad1c-4d00-952c-a0aa5d827811", + "type":"pserver" + } + } + ], + "relationships":[ + { + "operation":"add", + "e1":{ + "type":"tosca.relationships.HostedOn", + "source":"services/inventory/v11/vserver/50bdab41-ad1c-4d00-952c-a0aa5d827811", + "target":"services/inventory/v11/pserver/1d326bc7-b985-492b-9604-0d5d1f06f908", + "properties":{ + "contains-other-v":"NONE", + "delete-other-v":"NONE", + "SVC-INFRA":"OUT", + "prevent-delete":"IN" + } + } + }, + { + "operation":"modify", + "e2":{ + "id":"50bdab41-ad1c-4d00-952c-a0aa5d827811", + "type":"tosca.relationships.HostedOn", + "source":"services/inventory/v11/vserver/50bdab41-ad1c-4d00-952c-a0aa5d827811", + "target":"services/inventory/v11/pserver/1d326bc7-b985-492b-9604-0d5d1f06f908", + "properties":{ + "contains-other-v":"NONE", + "delete-other-v":"NONE", + "SVC-INFRA":"OUT", + "prevent-delete":"IN" + } + } + }, + { + "operation":"delete", + "e3":{ + "id":"50bdab41-ad1c-4d00-952c-a0aa5d827811", + "type":"tosca.relationships.HostedOn" + } + } + ] +} diff --git a/src/test/resources/payloads/graphVertexEvent.json b/src/test/resources/payloads/graphVertexEvent.json new file mode 100644 index 0000000..7e1fd62 --- /dev/null +++ b/src/test/resources/payloads/graphVertexEvent.json @@ -0,0 +1,23 @@ + { + "timestamp": 1514927928167, + "operation": "UPDATE", + "vertex": { + "properties": { + "ipv4-oam-address": "1.2.3.4", + "resource-version": "1477013499", + "purpose": "my-purpose", + "fqdn": "myhost.onap.net", + "in-maint": false, + "equip-model": "DL380p-nd", + "equip-vendor": "HP", + "equip-type": "server", + "hostname": "myhost", + "ptnii-equip-name": "e-name" + }, + "key": "mykey", + "type": "pserver", + "schema-version": "v11" + }, + "transaction-id": "c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4", + "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3" + }