From b100c49fbd130e4fe58ce82f1e5f765f13917703 Mon Sep 17 00:00:00 2001 From: Kanagaraj M Date: Fri, 2 Aug 2019 14:10:30 +0530 Subject: Update framework Issue-ID: CLI-169 Change-Id: Ice38da575d2e349bb875149afd894e348bc20253 Signed-off-by: Kanagaraj Manickam k00365106 --- .../src/main/java/org/onap/cli/http/mock/MockRequest.java | 9 +++++++-- .../src/main/java/org/onap/cli/http/mock/MockResponse.java | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'validate/sample-mock-generator/src/main/java') 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 cbb2a26a..d1d8b08d 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,6 +20,7 @@ import java.io.IOException; import java.net.URL; import java.util.Map; +import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -61,8 +62,12 @@ public class MockRequest { public void setJson(String json) throws IOException { if (!json.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - this.json = objectMapper.readTree(json); + try { + ObjectMapper objectMapper = new ObjectMapper(); + this.json = objectMapper.readTree(json); + } catch (Exception e) { + this.json = new ObjectMapper().readTree("{}"); + } } } 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 7e8cdca8..d7999bea 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 @@ -38,9 +38,13 @@ public class MockResponse { } public void setJson(String json) throws IOException { - if (json != null && !json.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - this.json = objectMapper.readTree(json); + if (!json.isEmpty()) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + this.json = objectMapper.readTree(json); + } catch (Exception e) { + this.json = new ObjectMapper().readTree("{}"); + } } } } -- cgit 1.2.3-korg