From cf1ab5db1033e403dfc839d5fbbe0580be1d497b Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Wed, 4 Mar 2020 14:21:12 +0000 Subject: Resolved JsonElement issue for grpc server and other classes Issue-ID: CLI-247 Signed-off-by: priyanka.akhade Change-Id: Ifcfba782ec6454f58d1df11e6ab7db3e1a04d17b --- .../src/main/java/org/onap/cli/http/mock/MockRequest.java | 10 ++++------ .../src/main/java/org/onap/cli/http/mock/MockResponse.java | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'validate/sample-mock-generator') diff --git a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java index 2ad9b85c..3bba8c21 100644 --- a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java +++ b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java @@ -20,8 +20,7 @@ import java.io.IOException; import java.net.URL; import java.util.Map; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import com.google.gson.JsonParser; import com.google.gson.JsonElement; public class MockRequest { @@ -29,8 +28,6 @@ public class MockRequest { private String uri; private Map headers; private JsonElement json; - private static Gson gson = new GsonBuilder().serializeNulls().create(); - public String getMethod() { return method; } @@ -64,9 +61,10 @@ public class MockRequest { public void setJson(String json) throws IOException { if (!json.isEmpty()) { try { - this.json = gson.fromJson(json,JsonElement.class); + JsonParser parser = new JsonParser(); + this.json = parser.parse(json); } catch (Exception e) { - this.json = gson.fromJson("{}",JsonElement.class); + this.json = new JsonParser().parse("{}"); } } diff --git a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java index 9184d3ad..30f64f20 100644 --- a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java +++ b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java @@ -18,15 +18,12 @@ package org.onap.cli.http.mock; import java.io.IOException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; +import com.google.gson.JsonParser; public class MockResponse { private int status; private JsonElement json; - private static Gson gson = new GsonBuilder().serializeNulls().create(); - public int getStatus() { return status; } @@ -42,9 +39,10 @@ public class MockResponse { public void setJson(String json) throws IOException { if (json != null && !json.isEmpty()) { try { - this.json = gson.fromJson(json,JsonElement.class); + JsonParser parser = new JsonParser(); + this.json = parser.parse(json); } catch (Exception e) { - this.json = gson.fromJson("{}", JsonElement.class); + this.json = new JsonParser().parse("{}"); } } } -- cgit 1.2.3-korg