From 3341eca5cdef51891157f35320afed58a1aef711 Mon Sep 17 00:00:00 2001 From: rope252 Date: Fri, 7 Feb 2020 16:06:41 +0000 Subject: SOL003 Adapter Package Management - Terminate Subscription Change-Id: I11e73f166bdab1b69b40640394ca9abb304b5be5 Issue-ID: SO-2419 Signed-off-by: rope252 --- ...ackageManagementSubscriptionControllerTest.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test') diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java index f90978e0d5..3d26c33679 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java @@ -68,6 +68,7 @@ import org.springframework.web.client.RestTemplate; import org.springframework.http.HttpMethod; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; /** @@ -199,6 +200,41 @@ public class Sol003PackageManagementSubscriptionControllerTest { assertEquals(HttpStatus.OK, response.getStatusCode()); } + @Test + public void testSuccessDeleteSubscriptionWithSubscriptionId() throws GeneralSecurityException { + final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest(); + final PkgmSubscription pkgmSubscription = buildPkgmSubscription(); + final String subscriptionId = pkgmSubscription.getId(); + + mockRestServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST)) + .andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo(msbEndpoint + "/" + subscriptionId)).andExpect(method(HttpMethod.DELETE)) + .andRespond(withStatus(HttpStatus.NO_CONTENT)); + + final ResponseEntity responsePost = + (ResponseEntity) sol003PackageManagementSubscriptionController + .postSubscriptionRequest(pkgmSubscriptionRequest); + + + final ResponseEntity responseDelete = + sol003PackageManagementSubscriptionController.deleteSubscription(subscriptionId); + + // Attempt to retrieve the subscription after delete + final ResponseEntity responseGetSubscription = + (ResponseEntity) sol003PackageManagementSubscriptionController + .getSubscription(subscriptionId); + + assertEquals(HttpStatus.NOT_FOUND, responseGetSubscription.getStatusCode()); + assertEquals(HttpStatus.NO_CONTENT, responseDelete.getStatusCode()); + } + + @Test + public void testFailDeleteSubscriptionWithInvalidSubscriptionId() throws URISyntaxException, InterruptedException { + final ResponseEntity responseDelete = (ResponseEntity) sol003PackageManagementSubscriptionController + .deleteSubscription("invalidSubscriptionId"); + assertEquals(HttpStatus.NOT_FOUND, responseDelete.getStatusCode()); + } + private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() { final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest(); final SubscriptionsFilter sub = buildSubscriptionsFilter(); -- cgit 1.2.3-korg