From 6c7e376c12005118da96506d3f83c594b727750b Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Tue, 7 Jan 2020 21:19:21 -0500 Subject: 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) Change-Id: I704981c6b3413872975b9e94a4b79cc0a1790795 --- .../catalogdb/catalogrest/QueryServiceVnfTest.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java (limited to 'adapters/mso-catalog-db-adapter/src/test') 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); + } + + +} -- cgit 1.2.3-korg