2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.spike.event.incoming;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import java.io.IOException;
26 import java.net.URISyntaxException;
27 import org.junit.Test;
28 import org.onap.aai.spike.event.envelope.EventEnvelopeParser;
29 import org.onap.aai.spike.event.outgoing.SpikeGraphEvent;
30 import org.onap.aai.spike.exception.SpikeException;
31 import org.onap.aai.spike.test.util.TestFileReader;
33 public class GizmoGraphEventTest {
36 public void TestToSpikeGraphEvent() throws SpikeException, IOException, URISyntaxException {
37 String champNotification =
38 TestFileReader.getFileAsString("event/champ-update-notification-raw-with-relationship.json");
40 GizmoGraphEvent gizmoGraphEvent = new EventEnvelopeParser().parseEvent(champNotification);
41 SpikeGraphEvent spikeGraphEvent = gizmoGraphEvent.toSpikeGraphEvent();
43 assertEquals("b9c7d24a-64a5-4b89-a10a-a89ce58b1caa", spikeGraphEvent.getRelationship().getId());
44 assertEquals("537494bd-1e8a-4198-9712-8cefa0f80457", spikeGraphEvent.getRelationship().getSource().getId());
45 assertEquals("981c0494-c742-4d75-851c-8194bbbd8a96", spikeGraphEvent.getRelationship().getTarget().getId());
49 public void TestGetObjectKey() {
51 GizmoGraphEvent gizmoGraphEvent;
53 gizmoGraphEvent = new GizmoGraphEvent();
54 GizmoVertex vertex = new GizmoVertex();
55 vertex.setId("addfff68");
56 gizmoGraphEvent.setVertex(vertex);
57 objectKey = gizmoGraphEvent.getObjectKey();
58 assertEquals("addfff68", objectKey);
60 gizmoGraphEvent = new GizmoGraphEvent();
61 GizmoEdge relationship = new GizmoEdge();
62 relationship.setId("909d");
64 gizmoGraphEvent.setRelationship(relationship);
65 objectKey = gizmoGraphEvent.getObjectKey();
66 assertEquals("909d", objectKey);
68 gizmoGraphEvent = new GizmoGraphEvent();
69 objectKey = gizmoGraphEvent.getObjectKey();
70 assertNull(objectKey);
74 public void TestGetObjectType() {
76 String type = "pserver";
77 GizmoGraphEvent gizmoGraphEvent;
79 gizmoGraphEvent = new GizmoGraphEvent();
80 GizmoVertex vertex = new GizmoVertex();
82 gizmoGraphEvent.setVertex(vertex);
83 objectType = gizmoGraphEvent.getObjectType();
84 assertEquals("Vertex->" + type, objectType);
86 gizmoGraphEvent = new GizmoGraphEvent();
87 GizmoEdge relationship = new GizmoEdge();
88 relationship.setType(type);
90 gizmoGraphEvent.setRelationship(relationship);
91 objectType = gizmoGraphEvent.getObjectType();
92 assertEquals("Relationship->" + type, objectType);
94 gizmoGraphEvent = new GizmoGraphEvent();
95 objectType = gizmoGraphEvent.getObjectType();
96 assertNull(objectType);