diff options
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("{}"); } } } |