diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2020-03-09 19:27:19 +0000 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2020-03-10 18:09:25 +0000 |
commit | 3d7980f7f2e8255d3ef7911b5ba6fca4b0ccb00f (patch) | |
tree | 930b7649a90a676121d5bcc6170830376efe7286 /adapters | |
parent | 8429f063a6c3c14605cad891be1a627b0ad54f0c (diff) |
Updating operationalState and usageState to list
Change-Id: I59c22c3a9484a12ebd7831ceb693d90a6d1f4e7e
Issue-ID: SO-2714
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'adapters')
6 files changed, 147 insertions, 87 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json index 1f4a8ac306..17d81f44c1 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json @@ -1187,8 +1187,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -2024,8 +2030,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -4572,16 +4584,31 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } } } }, @@ -4803,18 +4830,32 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" - } - } + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } + } } }, "callbackUri": { "description": "String formatted according to IETF RFC 3986.\n", diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java index 6d566c07ad..f32a9b0fa9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java @@ -21,16 +21,16 @@ package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; @@ -62,7 +62,7 @@ public class PkgmSubscriptionRequestConverter implements private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( - final SubscriptionsFilter sol003SubscriptionsFilter) { + final SubscriptionsFilter1 sol003SubscriptionsFilter) { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter(); @@ -81,21 +81,40 @@ public class PkgmSubscriptionRequestConverter implements etsiCatalogManagerFilters .setOperationalState(getOperationalState(sol003SubscriptionsFilter.getOperationalState())); - etsiCatalogManagerFilters.setUsageState(null); + etsiCatalogManagerFilters.setUsageState(getUsageState(sol003SubscriptionsFilter.getUsageState())); return etsiCatalogManagerFilters; } - // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI - // Catalog Manager Swagger - // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once - // swagger is updated. + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( + final List<UsageStateEnum> usageStates) { + if (usageStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = + new ArrayList<>(); + usageStates.stream().forEach(state -> { + etsiCatalogUsageStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum + .fromValue(state.getValue())); + }); + return etsiCatalogUsageStates; + } + return Collections.emptyList(); + } + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( - final OperationalStateEnum operationalState) { - if (operationalState != null) { - return Arrays.asList( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum - .fromValue(operationalState.getValue())); + final List<OperationalStateEnum> operationalStates) { + if (operationalStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = + new ArrayList<>(); + operationalStates.forEach(state -> { + etsiCatalogOperationalStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum + .fromValue(state.getValue())); + }); + + return etsiCatalogOperationalStates; } return Collections.emptyList(); } @@ -165,12 +184,12 @@ public class PkgmSubscriptionRequestConverter implements final List<NotificationTypesEnum> notificationTypes) { if (notificationTypes != null && !notificationTypes.isEmpty()) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogManagerNotificationTypes = + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = new ArrayList<>(); - notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add( + notificationTypes.forEach(type -> etsiCatalogNotificationTypes.add( org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum .fromValue(type.getValue()))); - return etsiCatalogManagerNotificationTypes; + return etsiCatalogNotificationTypes; } return Collections.emptyList(); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java index a4c52fd13d..a23eb6c3e3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java @@ -34,14 +34,14 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServic import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +80,7 @@ public class SubscriptionManager { this.msoKeyString = msoKeyString; } - public Optional<InlineResponse2002> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) + public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = @@ -97,14 +97,14 @@ public class SubscriptionManager { packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest); - final InlineResponse2002 response2002 = new InlineResponse2002(); - response2002.setId(subscriptionId); - response2002.setFilter(pkgmSubscriptionRequest.getFilter()); - response2002.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); - response2002.setLinks(new SubscriptionsLinks() + final InlineResponse201 response = new InlineResponse201(); + response.setId(subscriptionId); + response.setFilter(pkgmSubscriptionRequest.getFilter()); + response.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); + response.setLinks(new SubscriptionsLinks() .self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString()))); - return Optional.of(response2002); + return Optional.of(response); } throw new InternalServerErrorException( "Received empty response from POST to ETSI Catalog Manager Subscription Endpoint."); @@ -114,7 +114,7 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest); } - public Optional<InlineResponse2002> getSubscription(final String subscriptionId) { + public Optional<InlineResponse201> getSubscription(final String subscriptionId) { logger.debug("Checking if subscrition with id: {} exists in ETSI Catalog Manager", subscriptionId); final Optional<NsdmSubscription> etsiCatalogSubscriptionOption = @@ -137,12 +137,12 @@ public class SubscriptionManager { return Optional.empty(); } - public List<InlineResponse2002> getSubscriptions() { + public List<InlineResponse201> getSubscriptions() { final Map<String, PkgmSubscriptionRequest> subscriptions = packageManagementCacheServiceProvider.getSubscriptions(); - final List<InlineResponse2002> response = new ArrayList<>(); + final List<InlineResponse201> response = new ArrayList<>(); subscriptions.forEach((key, value) -> { - final Optional<InlineResponse2002> optional = getSubscription(key); + final Optional<InlineResponse201> optional = getSubscription(key); if (optional.isPresent()) { response.add(optional.get()); } @@ -175,8 +175,8 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscription(subscriptionId); } - private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { - return new InlineResponse2002().id(id).filter(subscription.getFilter()) + private InlineResponse201 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { + return new InlineResponse201().id(id).filter(subscription.getFilter()) .callbackUri(subscription.getCallbackUri()); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java index 6db3797f9b..515e317496 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Optional; import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager; import org.slf4j.Logger; @@ -92,15 +92,15 @@ public class Sol003PackageManagementSubscriptionController { } logger.debug("No duplicate Subscription exists, continuing with POST."); - final Optional<InlineResponse2002> optionalInlineResponse2002 = + final Optional<InlineResponse201> optionalInlineResponse = subscriptionManager.createSubscription(pkgmSubscriptionRequest); - if (optionalInlineResponse2002.isPresent()) { - InlineResponse2002 inlineResponse2002 = optionalInlineResponse2002.get(); - final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse2002.getId()); + 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<>(inlineResponse2002, headers, HttpStatus.CREATED); + return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED); } final String errorMessage = "A null response was received during the postSubscriptionRequest call."; logger.error(errorMessage); @@ -113,9 +113,9 @@ public class Sol003PackageManagementSubscriptionController { * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK */ @GetMapping(value = "/subscriptions") - public ResponseEntity<List<InlineResponse2002>> getSubscriptions() { + public ResponseEntity<List<InlineResponse201>> getSubscriptions() { logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions."); - List<InlineResponse2002> subscriptionsList = subscriptionManager.getSubscriptions(); + List<InlineResponse201> subscriptionsList = subscriptionManager.getSubscriptions(); return new ResponseEntity<>(subscriptionsList, HttpStatus.OK); } @@ -128,7 +128,7 @@ public class Sol003PackageManagementSubscriptionController { @GetMapping(value = "/subscriptions/{subscriptionId}") public ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId) { logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId); - final Optional<InlineResponse2002> optional = subscriptionManager.getSubscription(subscriptionId); + final Optional<InlineResponse201> optional = subscriptionManager.getSubscription(subscriptionId); if (optional.isPresent()) { logger.debug("Return subscription with id {} and body {}", subscriptionId, optional); return new ResponseEntity<>(optional.get(), HttpStatus.OK); 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 7466895d97..9016cad528 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 @@ -54,15 +54,16 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; @@ -132,8 +133,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { @Test public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException { final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest(); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri()); @@ -178,22 +179,22 @@ public class Sol003PackageManagementSubscriptionControllerTest { mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final String subscriptionId = response.getBody().getId(); - final ResponseEntity<InlineResponse2002> response2002 = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> responseEntity = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .getSubscription(subscriptionId); final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri()); assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter()); assertEquals(response.getHeaders(), headers); - assertEquals(HttpStatus.OK, response2002.getStatusCode()); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter()); // Ensure CallBackUri is set to new URI assertNotEquals(pkgmSubscriptionRequest.getCallbackUri(), response.getBody().getCallbackUri()); @@ -204,10 +205,9 @@ public class Sol003PackageManagementSubscriptionControllerTest { final String invalidId = "invalidSubscriptionId"; mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + invalidId)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController - .getSubscription(invalidId); + final ResponseEntity<?> response = sol003PackageManagementSubscriptionController.getSubscription(invalidId); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); + assertTrue(response.getBody() instanceof ProblemDetails); } @Test @@ -221,14 +221,14 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); sol003PackageManagementSubscriptionController.postSubscriptionRequest(pkgmSubscriptionRequest); - final ResponseEntity<List<InlineResponse2002>> response = + final ResponseEntity<List<InlineResponse201>> response = sol003PackageManagementSubscriptionController.getSubscriptions(); - final List<InlineResponse2002> subscriptionsList = response.getBody(); + final List<InlineResponse201> subscriptionsList = response.getBody(); assertEquals(Objects.requireNonNull(response.getBody()).get(0).getFilter(), pkgmSubscriptionRequest.getFilter()); - assert (subscriptionsList != null); + assertNotNull(subscriptionsList != null); assertNotEquals('0', subscriptionsList.size()); assertEquals(HttpStatus.OK, response.getStatusCode()); } @@ -310,13 +310,13 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(buildPkgmSubscription()), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> responseEntity = testRestTemplate.postForEntity( + final ResponseEntity<InlineResponse201> responseEntity = testRestTemplate.postForEntity( LOCALHOST_URL + port + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", request, - InlineResponse2002.class); + InlineResponse201.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertTrue(responseEntity.hasBody()); - final InlineResponse2002 actual = responseEntity.getBody(); + final InlineResponse201 actual = responseEntity.getBody(); assertEquals(ID, actual.getId()); @@ -340,7 +340,7 @@ public class Sol003PackageManagementSubscriptionControllerTest { private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() { final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest(); - final SubscriptionsFilter sub = buildSubscriptionsFilter(); + final SubscriptionsFilter1 sub = buildSubscriptionsFilter(); final SubscriptionsAuthentication auth = new SubscriptionsAuthentication(); pkgmSubscriptionRequest.setFilter(sub); pkgmSubscriptionRequest.setCallbackUri(msbEndpoint.toString()); @@ -348,11 +348,11 @@ public class Sol003PackageManagementSubscriptionControllerTest { return pkgmSubscriptionRequest; } - private SubscriptionsFilter buildSubscriptionsFilter() { - final SubscriptionsFilter sub = new SubscriptionsFilter(); + private SubscriptionsFilter1 buildSubscriptionsFilter() { + final SubscriptionsFilter1 sub = new SubscriptionsFilter1(); final List<String> vnfdIdList = new ArrayList<>(); final List<String> vnfPkgIdList = new ArrayList<>(); - final List<NotificationTypesEnum> notificationTypes = new ArrayList<>(); + final List<SubscriptionsFilter1.NotificationTypesEnum> notificationTypes = new ArrayList<>(); final SubscriptionsFilterVnfProductsFromProviders subscriptionsFilterVnfProductsFromProviders = new SubscriptionsFilterVnfProductsFromProviders(); final List<SubscriptionsFilterVnfProductsFromProviders> vnfProductsFromProviders = new ArrayList<>(); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json index 85ffb99d8d..c38466f8e5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json @@ -28,7 +28,7 @@ "vnfPkgId": [ "VNFPKGID" ], - "operationalState": "ENABLED" + "operationalState": ["ENABLED"] }, "callbackUri": "http://so-vnfm-adapter:9093/api/vnfpkgm/v1/subscriptions", "authentication": |