summaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-01-07 21:19:21 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-01-07 21:19:21 -0500
commit6c7e376c12005118da96506d3f83c594b727750b (patch)
treeab42aeb65a1cba380be96b94fd5e0e702b93e1bc /adapters/mso-catalog-db-adapter/src/test
parent8f37667d999101c2e4e395d810376173a5714794 (diff)
Drop Resource Input Field if not valid JSON
Drop Resource Input Field if not valid JSON Drop Resource Input Field if not valid JSON Issue-ID: SO-2587 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I704981c6b3413872975b9e94a4b79cc0a1790795
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java
new file mode 100644
index 0000000000..b71808b2c8
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java
@@ -0,0 +1,36 @@
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import static org.junit.Assert.assertEquals;
+import org.json.JSONException;
+import org.junit.Test;
+
+
+public class QueryServiceVnfTest extends QueryServiceVnfs {
+
+ private QueryServiceVnfs queryServiceVnf = new QueryServiceVnfs();
+
+ private final String invalidJSON =
+ "\"{\\\\\\\"nf_function\\\\\\\":\\\\\\\"DO_STUFF\\\\\\\",\\\"_image_name\\\\\\\":\\\\\\\"test_image\\\"";
+
+ private final String validJSON = "\"{\"nf_function\":\"DO_STUFF\",\"image_name\":\"test_image\"}";
+
+ @Test
+ public void test_IsValidJsonTrue() throws JSONException {
+ boolean isValidJson = queryServiceVnf.isJSONValid(validJSON);
+ assertEquals(true, isValidJson);
+ }
+
+ @Test
+ public void test_IsValidJsonFalse() throws JSONException {
+ boolean isValidJson = queryServiceVnf.isJSONValid(invalidJSON);
+ assertEquals(false, isValidJson);
+ }
+
+ @Test
+ public void test_IsValidJsonNull() throws JSONException {
+ boolean isValidJson = queryServiceVnf.isJSONValid(null);
+ assertEquals(false, isValidJson);
+ }
+
+
+}