aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/dcae/vestest
diff options
context:
space:
mode:
authorPawelSzalapski <pawel.szalapski@nokia.com>2018-07-31 08:18:03 +0200
committerPawelSzalapski <pawel.szalapski@nokia.com>2018-08-01 09:56:00 +0200
commitfc073344d4c0eb8a28bf34c07a8439176cf846ca (patch)
tree01f5b4789c3d9369eaebb54a9f910a9fa400af1f /src/test/java/org/onap/dcae/vestest
parentd12cd3525284cc41414d8fdae09e2ffbc03a1fbb (diff)
Replace nsaCore library with Spring
Change-Id: I2227939a67a2cbba2d392136d49ef4419600d186 Issue-ID: DCAEGEN2-602 Signed-off-by: PawelSzalapski <pawel.szalapski@nokia.com>
Diffstat (limited to 'src/test/java/org/onap/dcae/vestest')
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java36
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestEventReceipt.java46
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java14
3 files changed, 25 insertions, 71 deletions
diff --git a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
index 49b53d24..09517ae3 100644
--- a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
+++ b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
@@ -64,11 +64,11 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader")
- .get("functionalRole").toString();
+ .get("functionalRole").toString();
System.out.println("event==" + jsonObject.toString());
System.out.println("functionRole==" + functionRole);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.commonEventHeader.nfNamingCode\",\"oldField\": \"event.commonEventHeader.functionalRole\"}");
+ "{\"field\": \"event.commonEventHeader.nfNamingCode\",\"oldField\": \"event.commonEventHeader.functionalRole\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.map(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.nfNamingCode").toString();
@@ -82,15 +82,15 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
final String alarmAdditionalInformation = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
- .get("alarmAdditionalInformation").toString();
+ .get("alarmAdditionalInformation").toString();
System.out.println("event==" + jsonObject.toString());
System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}");
+ "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.map(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventAdditionalInformation")
- .toString();
+ .toString();
System.out.println("modified event==" + jsonObject.toString());
System.out.println("responseData==" + responseData);
assertEquals(alarmAdditionalInformation, responseData);
@@ -104,14 +104,14 @@ public class TestConfigProcessor {
System.out.println("event==" + jsonObject.toString());
//System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");
+ "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors.receiveDiscards").toString();
System.out.println("receiveDiscards==" + receiveDiscards);
cpEvent.map(jsonArgs);
final String responseData = cpEvent
- .getEventObjectVal("event.faultFields.vNicPerformanceArray[0].receivedDiscardedPacketsAccumulated")
- .toString();
+ .getEventObjectVal("event.faultFields.vNicPerformanceArray[0].receivedDiscardedPacketsAccumulated")
+ .toString();
System.out.println("modified event==" + jsonObject.toString());
System.out.println("responseData==" + responseData);
assertEquals(receiveDiscards, responseData);
@@ -125,7 +125,7 @@ public class TestConfigProcessor {
System.out.println("event==" + jsonObject.toString());
//System.out.println("functionRole==" + functionRole);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.addAttribute(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
@@ -142,7 +142,7 @@ public class TestConfigProcessor {
System.out.println("event==" + jsonObject.toString());
//System.out.println("functionRole==" + functionRole);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.updateAttribute(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
@@ -156,16 +156,16 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
final String eventType = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("eventType")
- .toString();
+ .toString();
final String domain = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("domain")
- .toString();
+ .toString();
final String alarmCondition = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
- .get("alarmCondition").toString();
+ .get("alarmCondition").toString();
System.out.println("event==" + jsonObject.toString());
final String eventName = domain + "_" + eventType + "_" + alarmCondition;
System.out.println("eventName==" + eventName);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\":\"event.commonEventHeader.eventName\",\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\",\"$event.faultFields.alarmCondition\"],\"delimiter\":\"_\"}");
+ "{\"field\":\"event.commonEventHeader.eventName\",\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\",\"$event.faultFields.alarmCondition\"],\"delimiter\":\"_\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.concatenateValue(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.eventName").toString();
@@ -179,14 +179,14 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
final String memoryConfigured = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
- .get("memoryConfigured").toString();
+ .get("memoryConfigured").toString();
final String memoryUsed = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("memoryUsed")
- .toString();
+ .toString();
System.out.println("event==" + jsonObject.toString());
System.out.println("memoryConfigured==" + memoryConfigured);
System.out.println("memoryUsed==" + memoryUsed);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.memoryFree\",\"subtract\": [\"$event.faultFields.memoryConfigured\",\"$event.faultFields.memoryUsed\"]}");
+ "{\"field\": \"event.faultFields.memoryFree\",\"subtract\": [\"$event.faultFields.memoryConfigured\",\"$event.faultFields.memoryUsed\"]}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.subtractValue(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.memoryFree").toString();
@@ -202,7 +202,7 @@ public class TestConfigProcessor {
System.out.println("event==" + jsonObject.toString());
System.out.println("Testing SetValue");
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.setValue(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
diff --git a/src/test/java/org/onap/dcae/vestest/TestEventReceipt.java b/src/test/java/org/onap/dcae/vestest/TestEventReceipt.java
deleted file mode 100644
index a3893eaa..00000000
--- a/src/test/java/org/onap/dcae/vestest/TestEventReceipt.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcae.vestest;
-
-import static org.junit.Assert.assertEquals;
-
-import org.json.JSONObject;
-import org.junit.Test;
-import org.onap.dcae.commonFunction.CommonStartup;
-import org.onap.dcae.restapi.endpoints.EventReceipt;
-
-public class TestEventReceipt {
-
-
- @Test
- public void shouldGetSchemaFileLocationBasedOnVersion() {
- CommonStartup.schemaFileJson = new JSONObject("{\"v1\":\"filePath1\", \"v5\":\"filePath2\"}");
- String schemaFilePath = EventReceipt.schemaFileVersion("v5");
- assertEquals(schemaFilePath, "filePath2");
- }
-
- @Test
- public void shouldByDefaultReturnV5SchemaFileLocation() {
- CommonStartup.schemaFileJson = new JSONObject("{\"v1\":\"filePath1\", \"v5\":\"filePath2\"}");
- String schemaFilePath = EventReceipt.schemaFileVersion("v2");
- assertEquals(schemaFilePath, "filePath2");
- }
-
-}
diff --git a/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java b/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java
index 0489811d..c39fb013 100644
--- a/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java
+++ b/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java
@@ -28,24 +28,24 @@ import com.google.gson.JsonParser;
import java.io.IOException;
import java.nio.file.Paths;
import org.junit.Test;
-import org.onap.dcae.commonFunction.CommonStartup;
+import org.onap.dcae.SchemaValidator;
public class TestJsonSchemaValidation {
@Test
public void shouldValidEventPassSchema_27_2() throws IOException {
- String result = CommonStartup.validateAgainstSchema(
- readJSONFromFile("src/test/resources/VES_valid.txt").toString(),
- readJSONFromFile("etc/CommonEventFormat_27.2.json").toString());
+ String result = SchemaValidator.validateAgainstSchema(
+ readJSONFromFile("src/test/resources/VES_valid.txt").toString(),
+ readJSONFromFile("etc/CommonEventFormat_27.2.json").toString());
assertEquals(result, "true");
}
@Test
public void shouldInvalidEventDoesNotPassSchema_27_2() throws IOException {
- String result = CommonStartup.validateAgainstSchema(
- readJSONFromFile("src/test/resources/VES_invalid.txt").toString(),
- readJSONFromFile("etc/CommonEventFormat_27.2.json").toString());
+ String result = SchemaValidator.validateAgainstSchema(
+ readJSONFromFile("src/test/resources/VES_invalid.txt").toString(),
+ readJSONFromFile("etc/CommonEventFormat_27.2.json").toString());
assertEquals(result, "false");
}