diff options
author | Kanagaraj Manickam <kanagaraj.manickam@huawei.com> | 2020-03-05 06:35:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-03-05 06:35:52 +0000 |
commit | 7fd4e74500eaf8d684f615495f7debddc146b888 (patch) | |
tree | 188e48cdf8dae87a820fd5688a74e6123d501fbc /validate | |
parent | ee6c134312bff3506f4f7eca695dad7d0dfec2d9 (diff) | |
parent | cf1ab5db1033e403dfc839d5fbbe0580be1d497b (diff) |
Merge "Resolved JsonElement issue for grpc server and other classes"
Diffstat (limited to 'validate')
-rw-r--r-- | validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java | 10 | ||||
-rw-r--r-- | validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java | 10 |
2 files changed, 8 insertions, 12 deletions
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<String, String> 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("{}"); } } } |