aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-09-20 11:20:28 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-20 11:20:28 +0000
commit1d2c8738cf1e56a8a24bcc433c33a62b5041baf0 (patch)
treedc57b0c768cbd884a40aa76fd09508d0014ce0f7 /controlloop/common
parent2face1b21badbca136b79d841a64a6278249af49 (diff)
parentc71f6e474049623ea7daaf42e585e143210b4c07 (diff)
Merge "Fixing VFC simulator for junit tests"
Diffstat (limited to 'controlloop/common')
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java2
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java17
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java4
3 files changed, 17 insertions, 6 deletions
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 a225f2d71..4797ab906 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
@@ -41,7 +41,7 @@ public final class VFCManager implements Runnable {
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
// TODO: Following code is a placeholder, needs to be updated
- setVFCParams("https://", "vfc", "vfc");
+ setVFCParams("http://localhost:6668", "username", "password");
}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index 51a85ce60..cd894825c 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -24,21 +24,30 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Context;
@Path("/api/nslcm/v1")
public class VfcSimulatorJaxRs {
@POST
@Path("/ns/{nsInstanceId}/heal")
- public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId)
+ public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
+ @Context final HttpServletResponse response)
{
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ try {
+ response.flushBuffer();
+ }catch(Exception e){}
+
return "{\"jobId\":\"1\"}";
}
@GET
- @Path("/jobs/{jobId}&responseId={responseId}")
- public String vfcGetQuery(@PathParam("jobId") String jobId, @PathParam("responseId") String responseId){
- return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": "+responseId+",\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
+ @Path("/jobs/{jobId}")
+ public String vfcGetQuery(@PathParam("jobId") String jobId) {
+ return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
}
}
+
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index 0fb41ab9b..7dadaadef 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
@@ -54,13 +55,14 @@ public class VfcSimulatorTest {
public void testPost(){
Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
assertNotNull(httpDetails);
+ assertTrue(httpDetails.a == 202);
VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
assertNotNull(response);
}
@Test
public void testGet(){
- Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234&responseId=5678", "username", "password", new HashMap<String, String>());
+ Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", new HashMap<String, String>());
assertNotNull(httpDetails);
VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
assertNotNull(response);