diff options
Diffstat (limited to 'models-interactions/model-simulators')
2 files changed, 48 insertions, 3 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java index 1af0b767c..b06a66f41 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java @@ -25,6 +25,7 @@ import com.google.gson.Gson; import java.util.UUID; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -36,7 +37,7 @@ import org.onap.policy.so.SoRequestStatus; import org.onap.policy.so.SoResponse; -@Path("/serviceInstantiation") +@Path("/") public class SoSimulatorJaxRs { /** @@ -47,7 +48,7 @@ public class SoSimulatorJaxRs { * @return the response */ @POST - @Path("/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") + @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId, @@ -69,4 +70,36 @@ public class SoSimulatorJaxRs { return new Gson().toJson(response); } + + /** + * SO Delete. + * + * @param serviceInstanceId the service instance Id + * @param vnfInstanceId the VNF Id + * @return the response + */ + @DELETE + @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces("application/json") + public String soDelete(@PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, + @PathParam("vfModuleInstanceId") final String vfModuleInstanceId) { + final SoRequest request = new SoRequest(); + final SoRequestStatus requestStatus = new SoRequestStatus(); + requestStatus.setRequestState("COMPLETE"); + request.setRequestStatus(requestStatus); + request.setRequestId(UUID.randomUUID()); + + final SoResponse response = new SoResponse(); + + final SoRequestReferences requestReferences = new SoRequestReferences(); + final String requestId = UUID.randomUUID().toString(); + requestReferences.setRequestId(requestId); + response.setRequestReferences(requestReferences); + + response.setRequest(request); + + return new Gson().toJson(response); + } } diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java index b287e3d81..723619e1c 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java @@ -134,7 +134,7 @@ public class SoSimulatorTest { } @Test - public void testResponse() { + public void testPost() { final String request = Serialization.gsonPretty.toJson(this.createTestRequest()); final Pair<Integer, String> httpDetails = new RestManager().post( "http://localhost:6667/serviceInstantiation/v7/serviceInstances/12345/vnfs/12345/vfModules/scaleOut", @@ -144,4 +144,16 @@ public class SoSimulatorTest { final SoResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SoResponse.class); assertNotNull(response); } + + @Test + public void testDelete() { + final String request = Serialization.gsonPretty.toJson(this.createTestRequest()); + final Pair<Integer, String> httpDetails = new RestManager().delete( + "http://localhost:6667/serviceInstances/v7/12345/vnfs/12345/vfModules/12345", + "username", + "password", new HashMap<>(), "application/json", request); + assertNotNull(httpDetails); + final SoResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SoResponse.class); + assertNotNull(response); + } } |