aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java9
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java10
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java18
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java31
8 files changed, 33 insertions, 60 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
index fb32fb9605..d798267918 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
@@ -32,8 +32,12 @@ public class Constants {
public static final String SERVICE_VERSION = "v1";
public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION;
public static final String PACKAGE_MANAGEMENT_BASE_URL = BASE_URL + "/vnfpkgm/v1";
- public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL = BASE_URL + "/etsicatalogmanager/notification";
- public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL = BASE_URL + "/etsicatalogmanager";
+ public static final String ETSI_CATALOG_MANAGER_BASE_ENDPOINT = "/etsicatalogmanager";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT = "/notification";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL =
+ BASE_URL + ETSI_CATALOG_MANAGER_BASE_ENDPOINT;
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL =
+ ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL + ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT;
public static final String APPLICATION_ZIP = "application/zip";
public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification";
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java
index 1e0a18a339..f1815054e3 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,6 @@ import org.springframework.util.StringUtils;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@Primary
@Component
@@ -53,10 +52,10 @@ public class VnfmBasicHttpSecurityConfigurer implements HttpSecurityConfigurer {
http.csrf().disable().authorizeRequests().anyRequest().permitAll();
} else {
http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers(HttpMethod.GET, "/etsi/subscription/notification").permitAll().antMatchers("/**")
+ .antMatchers(HttpMethod.GET, Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll()
+ .antMatchers("/**")
.hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ","))
.and().httpBasic();
-
}
}
}
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 c6d51c99aa..d0fd4c9e7c 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
@@ -20,14 +20,10 @@
package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog;
-import static org.slf4j.LoggerFactory.getLogger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
-import javax.swing.text.html.Option;
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;
@@ -38,7 +34,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
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;
-import org.slf4j.Logger;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Service;
@@ -48,14 +43,11 @@ import org.springframework.stereotype.Service;
*
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@Service
public class PkgmSubscriptionRequestConverter implements
Converter<PkgmSubscriptionRequest, org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest> {
- private static final Logger logger = getLogger(PkgmSubscriptionRequestConverter.class);
-
@Override
public org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest convert(
PkgmSubscriptionRequest pkgmSubscriptionRequest) {
@@ -133,7 +125,8 @@ public class PkgmSubscriptionRequestConverter implements
final List<VnfProductsProviders> etsiCatalogManagerVnfProductsProviders = new ArrayList<>();
filterProductsFromProvider.forEach(vnfProduct -> {
etsiCatalogManagerVnfProductsProviders
- .add(new VnfProductsProviders().vnfProducts(getVnfProducts(vnfProduct.getVnfProducts())));
+ .add(new VnfProductsProviders().vnfProvider(vnfProduct.getVnfProvider())
+ .vnfProducts(getVnfProducts(vnfProduct.getVnfProducts())));
});
return etsiCatalogManagerVnfProductsProviders;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
index 573a798410..73ec7053a7 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
@@ -79,7 +79,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
etsiCatalogUrlProvider.getVnfPackageArtifactUrl(vnfPkgId, artifactPath), byte[].class);
logger.info("getVnfPackageArtifact Request to ETSI Catalog Manager Status Code: {}",
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
return Optional.ofNullable(response.getBody());
}
} catch (final HttpResouceNotFoundException httpResouceNotFoundException) {
@@ -104,7 +104,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
httpServiceProvider.getHttpResponse(etsiCatalogUrlProvider.getVnfPackagesUrl(), VnfPkgInfo[].class);
logger.info("getVnfPackages Request to ETSI Catalog Manager Status Code: {}",
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
if (response.hasBody()) {
final VnfPkgInfo[] vnfPackages = response.getBody();
assert (vnfPackages != null);
@@ -145,7 +145,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
.getHttpResponse(etsiCatalogUrlProvider.getVnfPackageUrl(vnfPkgId), VnfPkgInfo.class);
logger.info("getVnfPackage Request for vnfPkgId {} to ETSI Catalog Manager Status Code: {}", vnfPkgId,
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
if (response.hasBody()) {
final VnfPkgInfo vnfPkgInfo = response.getBody();
if (conversionService.canConvert(vnfPkgInfo.getClass(), InlineResponse2001.class)) {
@@ -183,7 +183,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
final ResponseEntity<PkgmSubscription> responseEntity =
httpServiceProvider.postHttpRequest(etsiCatalogManagerSubscriptionRequest,
etsiCatalogUrlProvider.getSubscriptionUrl(), PkgmSubscription.class);
- if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
if (responseEntity.hasBody()) {
return Optional.of(responseEntity.getBody());
}
@@ -209,7 +209,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
final ResponseEntity<Void> responseEntity = httpServiceProvider
.deleteHttpRequest(etsiCatalogUrlProvider.getSubscriptionUrl() + "/" + subscriptionId, Void.class);
- if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) {
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
logger.info("Subscription with ID: {} has been successfully deleted from the ETSI Catalog Manager",
subscriptionId);
return true;
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 bbf8b74952..efe747deae 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
@@ -31,7 +31,6 @@ import java.util.Objects;
import java.util.Optional;
import org.onap.so.adapters.vnfmadapter.Constants;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogUrlProvider;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
@@ -41,7 +40,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionRequestConversionException;
-import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -55,15 +53,12 @@ import org.springframework.stereotype.Service;
*
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@Service
public class SubscriptionManager {
private static final Logger logger = getLogger(SubscriptionManager.class);
private final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider;
- private final EtsiCatalogUrlProvider etsiCatalogUrlProvider;
- private final HttpRestServiceProvider httpServiceProvider;
private final ConversionService conversionService;
private final EtsiCatalogServiceProvider etsiCatalogServiceProvider;
private final String vnfmAdapterEndpoint;
@@ -73,16 +68,12 @@ public class SubscriptionManager {
@Autowired
public SubscriptionManager(final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider,
- final ConversionService conversionService, final HttpRestServiceProvider httpServiceProvider,
- final EtsiCatalogUrlProvider etsiCatalogUrlProvider,
- final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
+ final ConversionService conversionService, final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
@Value("${vnfmadapter.endpoint}") final String vnfmAdapterEndpoint,
@Value("${mso.key}") final String msoKeyString,
- @Value("${vnfmadapter.auth:D6CFE56451508B75536C5E8A1E7AE06D0346006A693BF29293A6E1C762EFD59C671911DB6E9294E4FE15E4C1C5524B}") final String vnfmAdapterAuth) {
+ @Value("${vnfmadapter.auth:BF29BA36F0CFE1C05507781F6B97EFBCA7EFAC9F595954D465FC43F646883EF585C20A58CBB02528A6FAAC}") final String vnfmAdapterAuth) {
this.packageManagementCacheServiceProvider = packageManagementCacheServiceProvider;
- this.etsiCatalogUrlProvider = etsiCatalogUrlProvider;
this.conversionService = conversionService;
- this.httpServiceProvider = httpServiceProvider;
this.etsiCatalogServiceProvider = etsiCatalogServiceProvider;
this.vnfmAdapterEndpoint = vnfmAdapterEndpoint;
this.vnfmAdapterAuth = vnfmAdapterAuth;
@@ -101,8 +92,8 @@ public class SubscriptionManager {
if (optionalEtsiCatalogManagerSubscription.isPresent()) {
PkgmSubscription etsiCatalogManagerSubscription = optionalEtsiCatalogManagerSubscription.get();
logger.debug("postPkgmSubscriptionRequest Response SubscriptionId: {}",
- Objects.requireNonNull(etsiCatalogManagerSubscription.getId().toString()));
- final String subscriptionId = etsiCatalogManagerSubscription.getId().toString();
+ Objects.requireNonNull(etsiCatalogManagerSubscription.getId()));
+ final String subscriptionId = etsiCatalogManagerSubscription.getId();
packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest);
@@ -120,7 +111,6 @@ public class SubscriptionManager {
}
-
public Optional<String> getSubscriptionId(final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
index c5bd5bc14e..b4004b083d 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
@@ -36,9 +36,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author Gareth Roper (gareth.roper@est.tech)
*/
@Controller
-@RequestMapping(value = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL,
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+@RequestMapping(value = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL)
public class EtsiSubscriptionNotificationController {
private static final Logger logger = getLogger(EtsiSubscriptionNotificationController.class);
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 4be0838c08..6db3797f9b 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
@@ -79,7 +79,7 @@ public class Sol003PackageManagementSubscriptionController {
@PostMapping(value = "/subscriptions")
public ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest)
throws GeneralSecurityException {
- logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called");
+ logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called", pkgmSubscriptionRequest);
// Check if subscription exists already.
final Optional<String> exists = subscriptionManager.getSubscriptionId(pkgmSubscriptionRequest);
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 3d26c33679..c776e55ff0 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
@@ -20,21 +20,25 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import java.security.GeneralSecurityException;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+import com.google.gson.Gson;
import java.net.URI;
import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
-import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,13 +55,13 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
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;
-import org.onap.so.utils.CryptoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -65,36 +69,24 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
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;
/**
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
-@SuppressWarnings("unchecked")
public class Sol003PackageManagementSubscriptionControllerTest {
- private static String subscriptionId;
private final Gson gson = new Gson();
-
+ private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
@Autowired
@Qualifier(CONFIGURABLE_REST_TEMPLATE)
private RestTemplate testRestTemplate;
-
private MockRestServiceServer mockRestServer;
-
@Autowired
private CacheManager cacheServiceProvider;
- private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
-
@Autowired
private Sol003PackageManagementSubscriptionController sol003PackageManagementSubscriptionController;
@@ -135,7 +127,6 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final ResponseEntity<InlineResponse2002> response =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
.postSubscriptionRequest(pkgmSubscriptionRequest);
- subscriptionId = Objects.requireNonNull(response.getBody()).getId();
// Create duplicate entry
final PkgmSubscriptionRequest pkgmSubscriptionRequest2 = buildPkgmSubscriptionRequest();
@@ -154,7 +145,7 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final ResponseEntity<InlineResponse2002> response =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
.postSubscriptionRequest(pkgmSubscriptionRequest);
- subscriptionId = Objects.requireNonNull(response.getBody()).getId();
+ final String subscriptionId = response.getBody().getId();
final ResponseEntity<InlineResponse2002> response2002 =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
@@ -162,9 +153,8 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri());
-
assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter());
- assert (response.getHeaders().equals(headers));
+ assertEquals(response.getHeaders(), headers);
assertEquals(HttpStatus.OK, response2002.getStatusCode());
assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter());
// Ensure CallBackUri is set to new URI
@@ -215,7 +205,6 @@ public class Sol003PackageManagementSubscriptionControllerTest {
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
.postSubscriptionRequest(pkgmSubscriptionRequest);
-
final ResponseEntity responseDelete =
sol003PackageManagementSubscriptionController.deleteSubscription(subscriptionId);