aboutsummaryrefslogtreecommitdiffstats
path: root/validate
diff options
context:
space:
mode:
authorpriyanka.akhade <priyanka.akhade@huawei.com>2020-03-04 14:21:12 +0000
committerpriyanka.akhade <priyanka.akhade@huawei.com>2020-03-04 14:21:12 +0000
commitcf1ab5db1033e403dfc839d5fbbe0580be1d497b (patch)
tree3396e8fc8e02ae17e457aa9212a1759e51d01641 /validate
parent92d3092901ab1866766953e5f8d74bacf27bbc8f (diff)
Resolved JsonElement issue for grpc server and other classes
Issue-ID: CLI-247 Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com> Change-Id: Ifcfba782ec6454f58d1df11e6ab7db3e1a04d17b
Diffstat (limited to 'validate')
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java10
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java10
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("{}");
}
}
}