diff options
Diffstat (limited to 'plans/so')
16 files changed, 277 insertions, 22 deletions
diff --git a/plans/so/integration-etsi-testing/config/override-files/bpmn-infra/onapheat/override.yaml b/plans/so/integration-etsi-testing/config/override-files/bpmn-infra/onapheat/override.yaml index 684c675e..87e30663 100644 --- a/plans/so/integration-etsi-testing/config/override-files/bpmn-infra/onapheat/override.yaml +++ b/plans/so/integration-etsi-testing/config/override-files/bpmn-infra/onapheat/override.yaml @@ -358,7 +358,7 @@ spring: so: vnfm: adapter: - url: http://so-vnfm-adapter:9092/so/vnfm-adapter/v1/ + url: http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/ auth: Basic dm5mbTpwYXNzd29yZDEk org: onap: diff --git a/plans/so/integration-etsi-testing/config/override-files/so-vnfm-adapter/onapheat/override.yaml b/plans/so/integration-etsi-testing/config/override-files/so-vnfm-adapter/onapheat/override.yaml index 99c9dbd0..38c2f6d3 100644 --- a/plans/so/integration-etsi-testing/config/override-files/so-vnfm-adapter/onapheat/override.yaml +++ b/plans/so/integration-etsi-testing/config/override-files/so-vnfm-adapter/onapheat/override.yaml @@ -28,7 +28,7 @@ sdc: endpoint: http://sdc-simulator:9991/ toscametapath: Artifacts/Deployment/OTHER/TOSCA.meta vnfmadapter: - endpoint: http://so-vnfm-adapter:9092 + endpoint: http://so-vnfm-adapter.onap:9092 etsi-catalog-manager: vnfpkgm: endpoint: http://modeling-etsicatalog:8806/api/vnfpkgm/v1 diff --git a/plans/so/integration-etsi-testing/config/override-files/vnfm-simulator/onapheat/override.yaml b/plans/so/integration-etsi-testing/config/override-files/vnfm-simulator/onapheat/override.yaml index b57d0e85..b0f54e36 100644 --- a/plans/so/integration-etsi-testing/config/override-files/vnfm-simulator/onapheat/override.yaml +++ b/plans/so/integration-etsi-testing/config/override-files/vnfm-simulator/onapheat/override.yaml @@ -21,17 +21,17 @@ server: tomcat: max-threads: 50 ssl: - client-auth: need - key-alias: so@so.onap.org - key--store-password: '7Em3&j4.19xYiMelhD5?xbQ.' - key-store: classpath:so-vnfm-simulator.p12 - key-store-type: PKCS12 + enabled: false request: grant: - auth: twowaytls + auth: none dns: name: so-vnfm-simulator +vnfm-adapter: + base: + endpoint: http://so-vnfm-adapter.onap:9092 + vnfds: vnfdlist: - vnfdid: sgsn-mme_12df452s04131 diff --git a/plans/so/integration-etsi-testing/docker-compose.yml b/plans/so/integration-etsi-testing/docker-compose.yml index f1853e0e..cc753118 100644 --- a/plans/so/integration-etsi-testing/docker-compose.yml +++ b/plans/so/integration-etsi-testing/docker-compose.yml @@ -159,6 +159,8 @@ services: - DB_ADMIN_PASSWORD=so_Admin123 hostname: bpmn-infra.so.testlab.onap.org + links: + - "so-vnfm-adapter:so-vnfm-adapter.onap" depends_on: - mariadb - catalog-db-adapter @@ -288,6 +290,8 @@ services: - JVM_ARGS=-Xms64m -Xmx512m hostname: so-vnfm-simulator + links: + - "so-vnfm-adapter:so-vnfm-adapter.onap" depends_on: - mariadb - so-vnfm-adapter @@ -361,6 +365,8 @@ services: - SDC_ADDR=http://sdc-simulator:9991 hostname: modeling-etsicatalog + links: + - "so-vnfm-adapter:so-vnfm-adapter.onap" depends_on: - mariadb - sdc-simulator diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/pom.xml b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/pom.xml index 00fd81f1..bd507ca3 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/pom.xml +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/pom.xml @@ -136,6 +136,11 @@ <artifactId>httpclient</artifactId> <version>4.5.8</version> </dependency> + <dependency> + <groupId>org.onap.so.simulators</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> <plugins> diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java index b4657922..2e11714d 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java @@ -1,7 +1,10 @@ package org.onap.so.svnfm.simulator.config; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; import org.onap.so.svnfm.simulator.constants.Constant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.ApplicationArguments; @@ -16,6 +19,7 @@ import org.springframework.stereotype.Component; @Component public class ApplicationConfig implements ApplicationRunner { + private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationConfig.class); private static final String PORT = "local.server.port"; @@ -45,9 +49,18 @@ public class ApplicationConfig implements ApplicationRunner { @Bean public CacheManager cacheManager() { - final Cache inlineResponse201 = new ConcurrentMapCache(Constant.IN_LINE_RESPONSE_201_CACHE); + final Cache inlineResponse201 = getCache(Constant.IN_LINE_RESPONSE_201_CACHE); + final Cache vnfPkgOnboardingNotificationCache = getCache(Constant.VNF_PKG_ONBOARDING_NOTIFICATION_CACHE); + final List<Cache> caches = new ArrayList<>(); + caches.add(inlineResponse201); + caches.add(vnfPkgOnboardingNotificationCache); final SimpleCacheManager manager = new SimpleCacheManager(); - manager.setCaches(Arrays.asList(inlineResponse201)); + manager.setCaches(caches); return manager; } + + private Cache getCache(final String name) { + LOGGER.info("Creating cache with name: {}", name); + return new ConcurrentMapCache(name); + } } diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/constants/Constant.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/constants/Constant.java index ceb5be5a..c35be6d1 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/constants/Constant.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/constants/Constant.java @@ -37,9 +37,11 @@ public class Constant { public static final String VNF_CONFIG_PROPERTIES = "{\"isAutoScaleEnabled\": \"true\",\"isAutoHealingEnabled\": \"true\"}"; public static final String IN_LINE_RESPONSE_201_CACHE = "inlineResponse201"; + public static final String VNF_PKG_ONBOARDING_NOTIFICATION_CACHE = "vnfPackageOnboardingNotificationCache"; public static final String PACKAGE_MANAGEMENT_BASE_URL = "/vnfpkgm/v1"; public static final String SUBSCRIPTION_ENDPOINT = "/subscribe"; public static final String NOTIFICATION_ENDPOINT = "/notification"; - public static final String VNFM_ADAPTER_ENDPOINT = "https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; + public static final String NOTIFICATION_CACHE_TEST_ENDPOINT = "/notification-cache-test/{vnfPkgId}"; + public static final String VNFM_ADAPTER_ENDPOINT = "/so/vnfm-adapter/v1/"; public static final String VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT = VNFM_ADAPTER_ENDPOINT + "vnfpkgm/v1/subscriptions"; } diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/controller/SubscriptionNotificationController.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/controller/SubscriptionNotificationController.java index 2c6b8f24..1db20faf 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/controller/SubscriptionNotificationController.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/controller/SubscriptionNotificationController.java @@ -21,23 +21,39 @@ package org.onap.so.svnfm.simulator.controller; import javax.ws.rs.core.MediaType; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; 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.SubscriptionsAuthentication.AuthTypeEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsBasic; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; import org.onap.so.svnfm.simulator.constants.Constant; import org.onap.so.svnfm.simulator.services.SubscriptionManager; +import org.onap.so.svnfm.simulator.services.providers.VnfPkgOnboardingNotificationCacheServiceProviderImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Optional; /** * @author Eoin Hanan (eoin.hanan@est.tech) @@ -47,10 +63,18 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(path = Constant.PACKAGE_MANAGEMENT_BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) public class SubscriptionNotificationController { + + private static final Logger logger = LoggerFactory.getLogger(SubscriptionNotificationController.class); + private final Gson gson; @Autowired private SubscriptionManager subscriptionManager; + @Autowired + private VnfPkgOnboardingNotificationCacheServiceProviderImpl vnfPkgOnboardingNotificationCacheServiceProvider; - private static final Logger logger = LoggerFactory.getLogger(SubscriptionNotificationController.class); + @Autowired + public SubscriptionNotificationController() { + this.gson = new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter()).create(); + } @Value("${spring.security.usercredentials[0].username}") private String username; @@ -99,9 +123,94 @@ public class SubscriptionNotificationController { * @return */ @PostMapping(value = Constant.NOTIFICATION_ENDPOINT, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> postVnfPackageNotification(@RequestBody Object notification){ + public ResponseEntity<?> postVnfPackageNotification(@RequestBody final Object notification){ logger.info("Vnf Notification received:\n{}", notification); + final String notificationString = gson.toJson(notification); + addNotificationObjectToCache(notificationString); return ResponseEntity.noContent().build(); } + /** + * Testing endpoint for checking that notifications have been received + * + * @param vnfPkgId + * @return + */ + @GetMapping(value = Constant.NOTIFICATION_CACHE_TEST_ENDPOINT) + public ResponseEntity<?> getVnfPackageNotification(@PathVariable("vnfPkgId") final String vnfPkgId) { + logger.info("Getting notification with vnfPkgId: {}", vnfPkgId); + final Optional<VnfPackageOnboardingNotification> optionalVnfPackageOnboardingNotification = + vnfPkgOnboardingNotificationCacheServiceProvider.getVnfPkgOnboardingNotification(vnfPkgId); + if(optionalVnfPackageOnboardingNotification.isPresent()) { + VnfPackageOnboardingNotification vnfPackageOnboardingNotification = + optionalVnfPackageOnboardingNotification.get(); + logger.info("Return notification with vnfPkgId: {} and body {}", vnfPkgId, vnfPackageOnboardingNotification); + return ResponseEntity.ok().body(vnfPackageOnboardingNotification); + } + final String errorMessage = "No notification found with vnfPkgId: " + vnfPkgId; + logger.error(errorMessage); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorMessage); + } + + private void addNotificationObjectToCache(final String notification) { + logger.info("addNotificationObjectToCache(): {}", notification); + final String notificationType = getNotificationType(notification); + if (VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION.getValue() + .equals(notificationType)) { + final VnfPackageOnboardingNotification pkgOnboardingNotification = + gson.fromJson(notification, VnfPackageOnboardingNotification.class); + logger.info("Onboarding notification received:\n{}", pkgOnboardingNotification); + final String vnfPkgId = pkgOnboardingNotification.getVnfPkgId(); + vnfPkgOnboardingNotificationCacheServiceProvider.addVnfPkgOnboardingNotification(vnfPkgId, pkgOnboardingNotification); + } else if (VnfPackageChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.getValue() + .equals(notificationType)) { + final VnfPackageChangeNotification pkgChangeNotification = + gson.fromJson(notification, VnfPackageChangeNotification.class); + logger.info("Change notification received:\n{}", pkgChangeNotification); + } else { + final String errorMessage = "An error occurred. Notification type not supported for: " + notificationType; + logger.error(errorMessage); + throw new RuntimeException(errorMessage); + } + } + + private String getNotificationType(final String notification) { + try { + logger.info("getNotificationType() notification: {}", notification); + final JsonParser parser = new JsonParser(); + final JsonObject element = (JsonObject) parser.parse(notification); + return element.get("notificationType").getAsString(); + } catch (final Exception e) { + logger.error("An error occurred processing notificiation: {}", e.getMessage()); + } + throw new RuntimeException( + "Unable to parse notification type in object \n" + notification); + } + + public static class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { + + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + @Override + public void write(final JsonWriter out, final LocalDateTime localDateTime) throws IOException { + if (localDateTime == null) { + out.nullValue(); + } else { + out.value(FORMATTER.format(localDateTime)); + } + } + + @Override + public LocalDateTime read(final JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + final String dateTime = in.nextString(); + return LocalDateTime.parse(dateTime, FORMATTER); + } + } + } + } diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/SubscriptionManager.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/SubscriptionManager.java index 2050ab0d..d886da9b 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/SubscriptionManager.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/SubscriptionManager.java @@ -37,6 +37,9 @@ public class SubscriptionManager { @Value("${vnfm-adapter.auth.password}") private String password; + @Value("${vnfm-adapter.base.endpoint:http://so-vnfm-adapter.onap:9092}") + private String baseEndpoint; + @Autowired public SubscriptionManager( @Qualifier(SSL_BASED_CONFIGURABLE_REST_TEMPLATE) final RestTemplate restTemplate) { @@ -52,7 +55,7 @@ public class SubscriptionManager { public InlineResponse201 createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) { final byte[] encodedAuth = getBasicAuth(username, password); final String authHeader = "Basic " + new String(encodedAuth); - final String uri = Constant.VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT; + final String uri = baseEndpoint + Constant.VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT; final HttpHeaders headers = new HttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); headers.add(HttpHeaders.AUTHORIZATION, authHeader); diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProvider.java new file mode 100644 index 00000000..b62fb862 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProvider.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.svnfm.simulator.services.providers; + +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; +import java.util.Optional; + +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + */ +public interface VnfPkgOnboardingNotificationCacheServiceProvider { + + /** + * Add a VnfPkgOnboardingNotification to the cache + * @param vnfPkgId + * @param vnfPackageOnboardingNotification + */ + void addVnfPkgOnboardingNotification(final String vnfPkgId, final VnfPackageOnboardingNotification vnfPackageOnboardingNotification); + + /** + * Get a VnfPkgOnboardingNotification from the cache + * @param vnfPkgId + * @return + */ + Optional<VnfPackageOnboardingNotification> getVnfPkgOnboardingNotification(final String vnfPkgId); +} diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProviderImpl.java new file mode 100644 index 00000000..3f522138 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/providers/VnfPkgOnboardingNotificationCacheServiceProviderImpl.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.svnfm.simulator.services.providers; + +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; +import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider; +import org.onap.so.svnfm.simulator.constants.Constant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.stereotype.Service; +import java.util.Optional; + +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + */ +@Service +public class VnfPkgOnboardingNotificationCacheServiceProviderImpl extends AbstractCacheServiceProvider + implements VnfPkgOnboardingNotificationCacheServiceProvider { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfPkgOnboardingNotificationCacheServiceProviderImpl.class); + + @Autowired + public VnfPkgOnboardingNotificationCacheServiceProviderImpl(final CacheManager cacheManager) { + super(cacheManager); + } + + @Override public void addVnfPkgOnboardingNotification(final String vnfPkgId, + final VnfPackageOnboardingNotification vnfPackageOnboardingNotification) { + LOGGER.debug("Adding {} to cache with vnfPkgId: {}", vnfPackageOnboardingNotification, vnfPkgId); + getCache(Constant.VNF_PKG_ONBOARDING_NOTIFICATION_CACHE).put(vnfPkgId, vnfPackageOnboardingNotification); + } + + @Override public Optional<VnfPackageOnboardingNotification> getVnfPkgOnboardingNotification(final String vnfPkgId) { + LOGGER.debug("Getting vnfPkgOnboardingNotification from cache using vnfPkgId: {}", vnfPkgId); + final Cache cache = getCache(Constant.VNF_PKG_ONBOARDING_NOTIFICATION_CACHE); + final VnfPackageOnboardingNotification vnfPackageOnboardingNotification = cache.get(vnfPkgId, VnfPackageOnboardingNotification.class); + if (vnfPackageOnboardingNotification != null) { + return Optional.of(vnfPackageOnboardingNotification); + } + LOGGER.error("Unable to find vnfPkgOnboardingNotification in cache using vnfPkgId: {}", vnfPkgId); + return Optional.empty(); + } +} diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml index db2a6d4c..6079a799 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml @@ -47,6 +47,8 @@ vnfm-adapter: auth: name: vnfm password: password1$ + base: + endpoint: http://so-vnfm-adapter.onap:9092 vnfds: vnfdlist: - vnfdid: 1 @@ -88,4 +90,4 @@ vnfds: - vnfcid: VNFC8 resourceTemplateId: vnfd4_vnfc6 vduId: vnfd4_vduForVnfc6 - type: COMPUTE
\ No newline at end of file + type: COMPUTE diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/java/org/onap/so/svnfm/simulator/controllers/TestSubscriptionNotificationController.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/java/org/onap/so/svnfm/simulator/controllers/TestSubscriptionNotificationController.java index 743e2c04..ba8ec00b 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/java/org/onap/so/svnfm/simulator/controllers/TestSubscriptionNotificationController.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/java/org/onap/so/svnfm/simulator/controllers/TestSubscriptionNotificationController.java @@ -31,17 +31,20 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model. import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; import org.onap.so.svnfm.simulator.config.SvnfmApplication; +import org.onap.so.svnfm.simulator.controller.SubscriptionNotificationController; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; @@ -77,6 +80,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat public class TestSubscriptionNotificationController { private static final Logger LOGGER = getLogger(TestSubscriptionNotificationController.class); + private static final String SOL003_SUBSCRIPTION_URL = "http://so-vnfm-adapter.onap:9092" + VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT; @LocalServerPort private int port; @@ -85,7 +89,6 @@ public class TestSubscriptionNotificationController { private RestTemplate restTemplate; private MockRestServiceServer mockRestServiceServer; - @Autowired private TestRestTemplate testRestTemplate; private Gson gson; @@ -94,8 +97,11 @@ public class TestSubscriptionNotificationController { @Before public void setup() { mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build(); - gson = new GsonBuilder().create(); + gson = new GsonBuilder().registerTypeAdapter(LocalDateTime.class, + new SubscriptionNotificationController.LocalDateTimeTypeAdapter()).create(); vnfmSimulatorCallbackUrl = getBaseUrl(port) + PACKAGE_MANAGEMENT_BASE_URL + NOTIFICATION_ENDPOINT; + testRestTemplate = new TestRestTemplate( + new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson))); } @After @@ -118,7 +124,7 @@ public class TestSubscriptionNotificationController { new InlineResponse201().id("subscriptionId").filter(new SubscriptionsFilter1()) .callbackUri("callbackUri"); - mockRestServiceServer.expect(requestTo(VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(SOL003_SUBSCRIPTION_URL)).andExpect(method(HttpMethod.POST)) .andExpect(content().json(gson.toJson(pkgmSubscriptionRequest))) .andRespond(withSuccess(gson.toJson(inlineResponse), APPLICATION_JSON)); @@ -137,7 +143,7 @@ public class TestSubscriptionNotificationController { new InlineResponse201().id("subscriptionId").filter(new SubscriptionsFilter1()) .callbackUri("callbackUri"); - mockRestServiceServer.expect(requestTo(VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(SOL003_SUBSCRIPTION_URL)).andExpect(method(HttpMethod.POST)) .andExpect(content().json(gson.toJson(pkgmSubscriptionRequest))) .andRespond(withSuccess(gson.toJson(inlineResponse), APPLICATION_JSON)); @@ -152,8 +158,6 @@ public class TestSubscriptionNotificationController { final VnfPackageOnboardingNotification vnfPackageOnboardingNotification = gson.fromJson(getNotification(VNFPACKAGEONBOARDINGNOTIFICATION), VnfPackageOnboardingNotification.class); - final LocalDateTime timestamp = LocalDateTime.of(2020, 1, 1, 1, 1, 1, 1); - vnfPackageOnboardingNotification.setTimeStamp(timestamp); final ResponseEntity<?> responseEntity = postNotification(vnfPackageOnboardingNotification); assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode()); } diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/application.yaml index 3a2268cb..2f84beb9 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/application.yaml +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/application.yaml @@ -40,6 +40,8 @@ vnfm-adapter: auth: name: vnfm password: password1$ + base: + endpoint: http://so-vnfm-adapter.onap:9092 vnfds: vnfdlist: - vnfdid: 1 diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/test-data/vnf-package-onboarding-notification.json b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/test-data/vnf-package-onboarding-notification.json index 40b565be..bcc36592 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/test-data/vnf-package-onboarding-notification.json +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/test/resources/test-data/vnf-package-onboarding-notification.json @@ -1,6 +1,7 @@ { "id": "string", "notificationType": "VnfPackageOnboardingNotification", + "timeStamp":"2020-01-01 01:01:01", "subscriptionId": "string", "vnfPkgId": "string", "vnfdId": "string", diff --git a/plans/so/integration-etsi-testing/testplan.txt b/plans/so/integration-etsi-testing/testplan.txt index 17e28078..249010a9 100644 --- a/plans/so/integration-etsi-testing/testplan.txt +++ b/plans/so/integration-etsi-testing/testplan.txt @@ -1,5 +1,7 @@ # Test suites are relative paths under [integration/csit.git]/tests/. # Place the suites in run order. +so/etsi/etsi_vnf_subscription_tests.robot so/etsi/etsi_package_onboarding_tests.robot so/etsi/etsi_vnf_lcm_tests.robot so/etsi/etsi_vnf_package_management_tests.robot +so/etsi/etsi_vnf_notification_tests.robot |