From 42f69562851f7eb7041cf37592436477d3703fe2 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 16 Nov 2018 14:37:34 +0530 Subject: Add criteria to vnftest run result Issue-ID: VNFSDK-334 Change-Id: I5c8fdf1fc7615da1be980ca15448d63eb097ec18 Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/vnfsdk/marketplace/resource/VTPResource.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java index 685e0090..a59a8856 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java @@ -41,6 +41,7 @@ import org.open.infc.grpc.client.OpenRemoteCli; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.internal.LinkedTreeMap; @@ -113,6 +114,15 @@ public class VTPResource { JsonNode resultJson = mapper.readTree(result.getOutput()); ((ObjectNode)resultJson).put("build_tag", System.getenv("BUILD_TAG")); + + JsonNode results = resultJson.get("results"); + if (results != null && results.isArray()) { + ArrayNode resultsArray = (ArrayNode)results; + if (resultsArray.size() >= 0) { + String error = resultsArray.get(0).get("error").asText(); + ((ObjectNode)resultJson).put("criteria", "SUCCESS".equalsIgnoreCase(error) ? "PASS" : "FAILED"); + } + } return Response.ok(resultJson.toString(), MediaType.APPLICATION_JSON).build(); } -- cgit 1.2.3-korg