aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/datarouter/entity/SuggestionSearchEntityTest.java (renamed from src/test/java/org/openecomp/datarouter/entity/SuggestionSearchEntityTest.java)2
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/GapEventTransformerTest.java68
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/OxmEntityTypeConverterTest.java41
-rw-r--r--src/test/resources/gap_event.json50
-rw-r--r--src/test/resources/gap_event_wrong.json50
5 files changed, 210 insertions, 1 deletions
diff --git a/src/test/java/org/openecomp/datarouter/entity/SuggestionSearchEntityTest.java b/src/test/java/org/onap/aai/datarouter/entity/SuggestionSearchEntityTest.java
index 4d48e83..3c56dc8 100644
--- a/src/test/java/org/openecomp/datarouter/entity/SuggestionSearchEntityTest.java
+++ b/src/test/java/org/onap/aai/datarouter/entity/SuggestionSearchEntityTest.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.datarouter.entity;
+package org.onap.aai.datarouter.entity;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/onap/aai/datarouter/policy/GapEventTransformerTest.java b/src/test/java/org/onap/aai/datarouter/policy/GapEventTransformerTest.java
new file mode 100644
index 0000000..355756b
--- /dev/null
+++ b/src/test/java/org/onap/aai/datarouter/policy/GapEventTransformerTest.java
@@ -0,0 +1,68 @@
+/**
+ * ============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.aai.datarouter.policy;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+
+
+
+public class GapEventTransformerTest {
+ GapEventTransformer policy;
+ String eventJson;
+ String eventJson2;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void init() throws Exception {
+ policy = new GapEventTransformer();
+ FileInputStream event = new FileInputStream(new File("src/test/resources/gap_event.json"));
+ eventJson = IOUtils.toString(event, "UTF-8");
+ FileInputStream event2 =
+ new FileInputStream(new File("src/test/resources/gap_event_wrong.json"));
+ eventJson2 = IOUtils.toString(event2, "UTF-8");
+
+ }
+
+ @Test
+ public void testTransform_success() throws Exception {
+ JSONObject newPayloadJson = policy.transformToSpikePattern(eventJson.toString());
+ JSONObject payloadEntity = newPayloadJson.getJSONObject("vertex");
+ assertTrue(newPayloadJson.has("vertex"));
+ assertTrue(newPayloadJson.has("operation"));
+ assertEquals(newPayloadJson.get("operation"), "UPDATE");
+
+
+ }
+
+ @Test(expected = Exception.class)
+ public void testTransform_badPayload_fail() throws Exception {
+ policy.transformToSpikePattern(eventJson2.toString());
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/datarouter/policy/OxmEntityTypeConverterTest.java b/src/test/java/org/onap/aai/datarouter/policy/OxmEntityTypeConverterTest.java
new file mode 100644
index 0000000..12e23be
--- /dev/null
+++ b/src/test/java/org/onap/aai/datarouter/policy/OxmEntityTypeConverterTest.java
@@ -0,0 +1,41 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.datarouter.policy;
+
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+/**
+ * Created by Bogumil Zebek on 6/21/18.
+ */
+public class OxmEntityTypeConverterTest {
+
+ private OxmEntityTypeConverter oxmEntityTypeConverter = new OxmEntityTypeConverter();
+
+ @Test
+ public void shouldConvertEntityTypeToOxmEntityType(){
+ Assertions.assertThat(oxmEntityTypeConverter.convert("generic-vnf")).isEqualTo("GenericVnf");
+ Assertions.assertThat(oxmEntityTypeConverter.convert("pserver")).isEqualTo("Pserver");
+ Assertions.assertThat(oxmEntityTypeConverter.convert("optical-router")).isEqualTo("OpticalRouter");
+ }
+
+} \ No newline at end of file
diff --git a/src/test/resources/gap_event.json b/src/test/resources/gap_event.json
new file mode 100644
index 0000000..05e8fc3
--- /dev/null
+++ b/src/test/resources/gap_event.json
@@ -0,0 +1,50 @@
+{
+ "event-header":{
+ "entity-type":"pserver",
+ "top-entity-type":"pserver",
+ "entity-link":"/services/inventory/v11/pservers?properties=all",
+ "event-type":"${crud.event.type.api}",
+ "domain":"dev",
+ "topic-name":"CRUD-DATA-EXPORT-SDWAN",
+ "event-id":"7445ecab-40fc-46a9-a595-42d940488b02"
+ },
+ "entity":{
+ "in":[
+ {
+ "id":"9387d038-1e4f-4a08-ac5e-97c09530bbd8",
+ "source":"services/inventory/v11/vserver/ad7c5ad8-142f-4cd1-b38a-11fd7d98239d",
+ "type":"tosca.relationships.HostedOn",
+ "url":"services/inventory/relationships/v12/tosca.relationships.HostedOn/9387d038-1e4f-4a08-ac5e-97c09530bbd8"
+ }
+ ],
+ "id":"441d5a1e-a107-4fc3-b885-ccf683e3513b",
+ "type":"pserver",
+ "url":"services/inventory/v11/pserver/441d5a1e-a107-4fc3-b885-ccf683e3513b",
+ "properties":{
+ "aai-last-mod-ts":"1522935511411",
+ "equip-type":"Rack Server",
+ "equip-vendor":"HP",
+ "serial-number":"S4MPLEDDD456D",
+ "pserver-id":"Pserver-AMT-8",
+ "aai-created-ts":"1522935511411",
+ "source-of-truth":"RO",
+ "number-of-cpus":10,
+ "aai-node-type":"pserver",
+ "hostname":"10_aaingenvnf-pserver-fw-8",
+ "equip-model":"PowerEdge R930",
+ "in-maint":false,
+ "resource-version":"64684545",
+ "disk-in-gigabytes":146,
+ "ram-in-megabytes":62914556,
+ "last-mod-source-of-truth":"RO"
+ },
+ "out":[
+ {
+ "id":"bfa7ec57-cfa6-4bda-b1dc-a11a192bacaa",
+ "type":"org.onap.relationships.inventory.LocatedIn",
+ "url":"services/inventory/relationships/v12/org.onap.relationships.inventory.LocatedIn/bfa7ec57-cfa6-4bda-b1dc-a11a192bacaa",
+ "target":"services/inventory/v11/complex/90564f64-d3c4-47f8-847d-553497f6b04a"
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/gap_event_wrong.json b/src/test/resources/gap_event_wrong.json
new file mode 100644
index 0000000..bf4135f
--- /dev/null
+++ b/src/test/resources/gap_event_wrong.json
@@ -0,0 +1,50 @@
+{
+ "event-header":{
+ "entity-type":"pserver",
+ "top-entity-type":"pserver",
+ "entity-link":"/services/inventory/v11/pservers?properties=all",
+ "event-type":"${crud.event.type.api}",
+ "domain":"dev",
+ "topic-name":"CRUD-DATA-EXPORT-SDWAN",
+ "event-id":"7445ecab-40fc-46a9-a595-42d940488b02"
+ },
+ "entity2":{
+ "in":[
+ {
+ "id":"9387d038-1e4f-4a08-ac5e-97c09530bbd8",
+ "source":"services/inventory/v11/vserver/ad7c5ad8-142f-4cd1-b38a-11fd7d98239d",
+ "type":"tosca.relationships.HostedOn",
+ "url":"services/inventory/relationships/v12/tosca.relationships.HostedOn/9387d038-1e4f-4a08-ac5e-97c09530bbd8"
+ }
+ ],
+ "id":"441d5a1e-a107-4fc3-b885-ccf683e3513b",
+ "type":"pserver",
+ "url":"services/inventory/v11/pserver/441d5a1e-a107-4fc3-b885-ccf683e3513b",
+ "properties":{
+ "aai-last-mod-ts":"1522935511411",
+ "equip-type":"Rack Server",
+ "equip-vendor":"HP",
+ "serial-number":"S4MPLEDDD456D",
+ "pserver-id":"Pserver-AMT-8",
+ "aai-created-ts":"1522935511411",
+ "source-of-truth":"RO",
+ "number-of-cpus":10,
+ "aai-node-type":"pserver",
+ "hostname":"10_aaingenvnf-pserver-fw-8",
+ "equip-model":"PowerEdge R930",
+ "in-maint":false,
+ "resource-version":"64684545",
+ "disk-in-gigabytes":146,
+ "ram-in-megabytes":62914556,
+ "last-mod-source-of-truth":"RO"
+ },
+ "out":[
+ {
+ "id":"bfa7ec57-cfa6-4bda-b1dc-a11a192bacaa",
+ "type":"org.onap.relationships.inventory.LocatedIn",
+ "url":"services/inventory/relationships/v12/org.onap.relationships.inventory.LocatedIn/bfa7ec57-cfa6-4bda-b1dc-a11a192bacaa",
+ "target":"services/inventory/v11/complex/90564f64-d3c4-47f8-847d-553497f6b04a"
+ }
+ ]
+ }
+} \ No newline at end of file