From 1aa30b7d83f97103097c7f5d3e4cbd2fad92f659 Mon Sep 17 00:00:00 2001 From: Ritu Sood Date: Mon, 11 Sep 2017 14:20:13 -0700 Subject: Add VFC Response in Working Memory & JUNIT Adding code to insert VFC reponse in working memory and handling that response. Also adding JUNIT and yaml file for VoLTE usecase. Issue-Id: POLICY-212 Change-Id: I74a13272ccd931478d27d80715d8c3ac756fb5c7 Signed-off-by: Ritu Sood --- controlloop/common/model-impl/vfc/pom.xml | 6 ++++++ .../vfc/src/main/java/org/onap/policy/vfc/VFCManager.java | 8 +++++++- .../vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java | 4 +++- .../vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java | 4 +++- .../src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java | 6 +++++- 5 files changed, 24 insertions(+), 4 deletions(-) (limited to 'controlloop/common/model-impl') diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml index db86345e8..7672b1bc9 100644 --- a/controlloop/common/model-impl/vfc/pom.xml +++ b/controlloop/common/model-impl/vfc/pom.xml @@ -45,5 +45,11 @@ rest ${project.version} + + org.drools + drools-core + 6.5.0.Final + provided + diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java index 4797ab906..5cb6d6624 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java @@ -21,6 +21,7 @@ package org.onap.policy.vfc; import java.util.HashMap; import java.util.Map; +import org.drools.core.WorkingMemory; import org.onap.policy.vfc.util.Serialization; import org.onap.policy.rest.RESTManager; import org.onap.policy.rest.RESTManager.Pair; @@ -35,9 +36,11 @@ public final class VFCManager implements Runnable { private String username; private String password; private VFCRequest vfcRequest; + WorkingMemory workingMem; private static final Logger logger = LoggerFactory.getLogger(VFCManager.class); - public VFCManager(VFCRequest request) { + public VFCManager(WorkingMemory wm, VFCRequest request) { + workingMem = wm; vfcRequest = request; // TODO: Get base URL, username and password from MSB? // TODO: Following code is a placeholder, needs to be updated @@ -83,6 +86,7 @@ public final class VFCManager implements Runnable { Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class); + responseGet.requestId = vfcRequest.requestId.toString(); body = Serialization.gsonPretty.toJson(responseGet); logger.debug("Response to VFC Heal get:"); logger.debug(body); @@ -91,6 +95,7 @@ public final class VFCManager implements Runnable { if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") || responseGet.responseDescriptor.status.equalsIgnoreCase("error")) { logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status); + workingMem.insert(responseGet); break; } } @@ -102,6 +107,7 @@ public final class VFCManager implements Runnable { && (responseGet.responseDescriptor.status != null) && (!responseGet.responseDescriptor.status.isEmpty())) { logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status); + workingMem.insert(responseGet); } } catch (JsonSyntaxException e) { logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e); diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java index 9e3a77a2b..89c9b08ff 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java @@ -19,14 +19,16 @@ package org.onap.policy.vfc; import java.io.Serializable; +import java.util.UUID; import com.google.gson.annotations.SerializedName; public class VFCRequest implements Serializable { private static final long serialVersionUID = 3736300970326332512L; - // This field is not serialized and not part of JSON + // These fields are not serialized and not part of JSON public transient String nsInstanceId; + public transient UUID requestId; @SerializedName("healVnfData") public VFCHealRequest healRequest; diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java index 775d78f1d..5d6efa0ce 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java @@ -30,7 +30,9 @@ public class VFCResponse implements Serializable { public String jobId; @SerializedName("responseDescriptor") - VFCResponseDescriptor responseDescriptor; + public VFCResponseDescriptor responseDescriptor; + + public transient String requestId; public VFCResponse() { } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java index 9bf77c57c..62c61a7f6 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java @@ -27,7 +27,7 @@ public class VFCResponseDescriptor implements Serializable { private static final long serialVersionUID = 6827782899144150158L; @SerializedName("progress") - public String progress; + String progress; @SerializedName("status") String status; @@ -47,4 +47,8 @@ public class VFCResponseDescriptor implements Serializable { public VFCResponseDescriptor() { } + public String getStatus() { + return status; + } + } -- cgit 1.2.3-korg