From 132177fb71c08f157fb42037f9dd26ceb2d0ba43 Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Fri, 28 Feb 2020 05:47:34 +0000 Subject: Migrate to gson Issue-ID: CLI-247 Signed-off-by: priyanka.akhade Change-Id: If66134db5503382fb45210ece883402fc130ac93 --- .../java/org/onap/cli/validation/OnapValidationTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'validate/validation/src/test/java') diff --git a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java index 181ae515..e94de60a 100644 --- a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java +++ b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java @@ -17,6 +17,7 @@ package org.onap.cli.validation; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.io.File; @@ -48,6 +49,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Yaml; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + public class OnapValidationTest { public static final String SAMPLE_VERSION = "open_cli_sample_version"; @@ -64,6 +68,7 @@ public class OnapValidationTest { OnapCli cli = new OnapCli(); private static Logger LOG = LoggerFactory.getLogger(OnapValidationTest.class); + private static Gson gson = new GsonBuilder().serializeNulls().create(); private void handle(String[] args) { cli.resetExitCode(); @@ -261,4 +266,11 @@ public class OnapValidationTest { onapCli.handle(); assertEquals(OnapCliConstants.EXIT_SUCCESS, onapCli.getExitCode()); } + @Test + public void testOnapCommandSchemaInfoForUnknownFields(){ + OnapCommandSchemaInfo ocsi = new OnapCommandSchemaInfo(); + String testExp = "{\"schemaName\":\"testSchema\",\"schemaURI\":\"testUri\",\"unknownField\":\"unknown\"}"; + ocsi= gson.fromJson(testExp,OnapCommandSchemaInfo.class); + assertNotNull(ocsi); + } } -- cgit 1.2.3-korg