### Question:
Sol003PackageManagementSubscriptionController { @PostMapping(value = "/subscriptions") public ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called", pkgmSubscriptionRequest); final Optional<String> exists = subscriptionManager.getSubscriptionId(pkgmSubscriptionRequest); if (exists.isPresent()) { final URI subscriptionUri = subscriptionManager.getSubscriptionUri(exists.get()); final HttpHeaders headers = createLocationHeader(subscriptionUri); logger.info("PkgmSubscriptionRequest already exists with uri {} ", subscriptionUri); return new ResponseEntity<>(headers, HttpStatus.SEE_OTHER); } logger.debug("No duplicate Subscription exists, continuing with POST."); final Optional<InlineResponse201> optionalInlineResponse = subscriptionManager.createSubscription(pkgmSubscriptionRequest); if (optionalInlineResponse.isPresent()) { InlineResponse201 inlineResponse = optionalInlineResponse.get(); final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse.getId()); final HttpHeaders headers = createLocationHeader(subscriptionUri); logger.debug("Sending response with uri {} ", subscriptionUri); return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED); } final String errorMessage = "A null response was received during the postSubscriptionRequest call."; logger.error(errorMessage); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage)); } @Autowired  Sol003PackageManagementSubscriptionController(final SubscriptionManager subscriptionManager); @PostMapping(value = "/subscriptions") ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest); @GetMapping(value = "/subscriptions") ResponseEntity<List<InlineResponse201>> getSubscriptions(); @GetMapping(value = "/subscriptions/{subscriptionId}") ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId); @DeleteMapping(value = "/subscriptions/{subscriptionId}") ResponseEntity<?> deleteSubscription(@PathVariable("subscriptionId") final String subscriptionId);  }### Answer:
@Test public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException { final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest(); final ResponseEntity<InlineResponse201> response = (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri()); final SubscriptionsLinks subscriptionsLinks = new SubscriptionsLinks(); final VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf(); vnfPackagesLinksSelf.setHref("https: + "/subscriptions/" + response.getBody().getId()); subscriptionsLinks.setSelf(vnfPackagesLinksSelf); assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter()); assertEquals(subscriptionsLinks, response.getBody().getLinks()); assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter()); assert (response.getHeaders().equals(headers)); assertThat(response.getStatusCode(), is(HttpStatus.CREATED)); assertNotNull(response.getBody().getCallbackUri()); }
@Test public void testFailPostSubscriptionAlreadyExists() throws GeneralSecurityException { final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest(); final ResponseEntity<InlineResponse2002> response = (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final PkgmSubscriptionRequest pkgmSubscriptionRequest2 = buildPkgmSubscriptionRequest(); final ResponseEntity<InlineResponse2002> response2002 = (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest2); assertEquals(HttpStatus.SEE_OTHER, response2002.getStatusCode()); }