diff options
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java')
-rw-r--r-- | vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java index 3893d56a..1da85f4d 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/scenario/VTPScenarioResourceTest.java @@ -15,13 +15,14 @@ */ package org.onap.vtp.scenario; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import mockit.Mock; import mockit.MockUp; import org.junit.Before; import org.junit.Test; import org.onap.vtp.VTPResource; +import org.onap.vtp.error.VTPError; import java.io.IOException; import java.util.List; @@ -41,10 +42,10 @@ public class VTPScenarioResourceTest { public void testListTestScenariosHandler() throws Exception { new MockUp<VTPResource>() { @Mock - public JsonNode makeRpcAndGetJson(List<String> args) throws IOException { - ObjectMapper mapper = new ObjectMapper(); + protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPError.VTPException, IOException { + JsonParser jsonParser = new JsonParser(); String jsonvalue = "[{\"product\":\"onap-dublin\",\"description\":\"its 4th release\"}]"; - JsonNode jsonNode = mapper.readTree(jsonvalue); + JsonElement jsonNode = jsonParser.parse(jsonvalue); return jsonNode; } }; @@ -55,22 +56,31 @@ public class VTPScenarioResourceTest { public void testListTestSutiesHandler() throws Exception { new MockUp<VTPResource>() { @Mock - public JsonNode makeRpcAndGetJson(List<String> args) throws IOException { - ObjectMapper mapper = new ObjectMapper(); + protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPError.VTPException, IOException { + JsonParser jsonParser = new JsonParser(); String jsonvalue = "[{\"product\":\"onap-dublin\",\"service\":\"test\",\"description\":\"its 4th release\"}]"; - JsonNode jsonNode = mapper.readTree(jsonvalue); + JsonElement jsonNode = jsonParser.parse(jsonvalue); return jsonNode; } }; assertNotNull(vtpScenarioResource.listTestSutiesHandler("open-cli")); } - @Test(expected = Exception.class) + @Test public void testListTestcasesHandler() throws Exception { + new MockUp<VTPResource>() { + @Mock + protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPError.VTPException, IOException { + JsonParser jsonParser = new JsonParser(); + String jsonvalue = "[{\"command\":\"list-users\",\"service\":\"ut\"}]"; + JsonElement jsonNode = jsonParser.parse(jsonvalue); + return jsonNode; + } + }; + vtpScenarioResource.listTestcasesHandler("testsuite", "open-cli"); } - @Test(expected = Exception.class) public void testListTestcases() throws Exception { vtpScenarioResource.listTestcases("open-cli", "testsuite"); } @@ -84,14 +94,13 @@ public class VTPScenarioResourceTest { public void testGetTestcaseHandler() throws Exception { new MockUp<VTPResource>() { @Mock - public JsonNode makeRpcAndGetJson(List<String> args) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - + protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPError.VTPException, IOException { + JsonParser jsonParser = new JsonParser(); String jsonvalue = "{\"schema\":{\"name\":\"cli\",\"product\":\"onap-dublin\",\"description\":\"its 4th release\"," + "\"service\":\"test\",\"author\":\"jitendra\",\"inputs\":[{\"name\":\"abc\",\"description\":\"abc\"," + "\"type\":\"abc\",\"is_optional\":\"yes\",\"default_value\":\"abc\",\"metadata\":\"abc\"}]," + "\"outputs\":[{\"name\":\"abc\",\"description\":\"abc\",\"type\":\"abc\"}]}}"; - JsonNode jsonNode = mapper.readTree(jsonvalue); + JsonElement jsonNode = jsonParser.parse(jsonvalue); return jsonNode; } }; |