Merge "Replace json_templater usage"
diff --git a/plans/dcaegen2-pmmapper/pmmapper/assets/config.json b/plans/dcaegen2-pmmapper/pmmapper/assets/config.json
index 0b62454..aacbb5b 100644
--- a/plans/dcaegen2-pmmapper/pmmapper/assets/config.json
+++ b/plans/dcaegen2-pmmapper/pmmapper/assets/config.json
@@ -1,39 +1,35 @@
{
- "pm-mapper-filter": { "filters":[]},
- "streams_subscribes": {
- "dmaap_subscriber": {
- "type": "data_router",
- "aaf_username": null,
- "aaf_password": null,
- "dmaap_info": {
- "location": "csit-pmmapper",
- "delivery_url": "http://dcae-pm-mapper:8081/delivery",
- "username": "username",
- "password": "password",
- "subscriber_id": "1"
- }
- }
- },
- "streams_publishes": {
- "dmaap_publisher": {
- "type": "message_router",
- "aaf_password": null,
- "dmaap_info": {
- "topic_url": "http://message-router:3904/events/PM_MAPPER",
- "client_role": "org.onap.dmaap.mr.topic",
- "location": "csit-pmmapper",
- "client_id": null
- },
- "aaf_username": null
- }
- },
- "dmaap_dr_feed_name": "1",
- "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
- "services_calls": {},
- "enable_http": true,
- "key_store_path": "/opt/app/pm-mapper/etc/cert.jks.b64",
- "key_store_pass_path": "/opt/app/pm-mapper/etc/jks.pass",
- "trust_store_path": "/opt/app/pm-mapper/etc/trust.jks.b64",
- "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass"
-
+ "pm-mapper-filter": { "filters":[]},
+ "key_store_path": "/opt/app/pm-mapper/etc/cert.jks.b64",
+ "key_store_pass_path": "/opt/app/pm-mapper/etc/jks.pass",
+ "trust_store_path": "/opt/app/pm-mapper/etc/trust.jks.b64",
+ "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass",
+ "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+ "dmaap_dr_feed_name": "1",
+ "aaf_identity": "aaf_admin@people.osaaf.org",
+ "aaf_password": "demo123456!",
+ "enable_http": true,
+ "streams_publishes": {
+ "dmaap_publisher": {
+ "type": "message_router",
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/org.onap.dmaap.mr.VES_PM",
+ "client_role": "org.onap.dcae.pmPublisher",
+ "location": "csit-pmmapper",
+ "client_id": "1562763644939"
+ }
+ }
+ },
+ "streams_subscribes": {
+ "dmaap_subscriber": {
+ "type": "data_router",
+ "dmaap_info": {
+ "username": "username",
+ "password": "password",
+ "location": "csit-pmmapper",
+ "delivery_url": "http://dcae-pm-mapper:8081/delivery",
+ "subscriber_id": 1
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json b/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json
deleted file mode 100644
index 4d20974..0000000
--- a/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "topicName":"PM_MAPPER",
- "topicDescription":"PM Mapper VES Event",
- "owner":"pmmapper"
-}
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js b/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js
new file mode 100644
index 0000000..a6a6130
--- /dev/null
+++ b/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js
@@ -0,0 +1,25 @@
+var httpServer = function() {
+var http = require('http'),
+url = require('url'),
+fs = require('fs'),
+
+start = function(port) {
+ var server = http.createServer(function(req, res) {
+ processHttpRequest(res);
+ });
+ server.listen(port, function() {
+ console.log('Listening on ' + port + '...');
+ });
+},
+
+processHttpRequest = function(res) {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end('Published Successfully.\n');
+};
+
+return {
+ start: start
+}
+}();
+
+httpServer.start(3904);
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml b/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml
index 2e3919b..7646c0b 100644
--- a/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml
+++ b/plans/dcaegen2-pmmapper/pmmapper/composefile/docker-compose-pmmapper.yml
@@ -2,7 +2,7 @@
services:
pmmapper:
container_name: pmmapper
- image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:latest
+ image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:1.1.3
ports:
- "8081:8081"
environment:
diff --git a/plans/dcaegen2-pmmapper/pmmapper/setup.sh b/plans/dcaegen2-pmmapper/pmmapper/setup.sh
index e52195f..29b8d9c 100644
--- a/plans/dcaegen2-pmmapper/pmmapper/setup.sh
+++ b/plans/dcaegen2-pmmapper/pmmapper/setup.sh
@@ -71,7 +71,7 @@
CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
-sed -i 's/4.4.4.4/'$DMAAP_MR_IP'/g' docker-compose.yml
+sed -i 's/4.4.4.4/'$MARIADB'/g' docker-compose.yml
docker-compose up -d
cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
@@ -119,15 +119,19 @@
curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
-# Create PM Mapper tocic in Message Router
-curl -v -X POST http://${DMAAP_MR_IP}:3904/topics/create -d @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json -H "Content-Type: application/json"
+# Simulation setup for Message Router
+docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js mariadb:/
+docker exec mariadb /bin/bash -c "apt update"
+sleep 2
+docker exec mariadb /bin/bash -c "apt install nodejs -y"
+sleep 10
+docker exec mariadb /bin/bash -c "nodejs mrserver.js &" &
+
PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
cat /tmp/pmmapper.log
docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
sleep 10
curl -k https://$DR_PROV_IP:8443/internal/prov
-curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000
-
#Pass any variables required by Robot test suites in ROBOT_VARIABLES
ROBOT_VARIABLES="-v CONSUL_IP:${CONSUL_IP} -v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v CBS_IP:${CBS_IP} -v PMMAPPER_IP:${PMMAPPER_IP} -v DR_NODE_IP:${DR_NODE_IP}"
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/docker-compose.yml b/plans/so/integration-etsi-testing/docker-compose.yml
index 85921ef..068349f 100644
--- a/plans/so/integration-etsi-testing/docker-compose.yml
+++ b/plans/so/integration-etsi-testing/docker-compose.yml
@@ -308,6 +308,24 @@
max-size: "30m"
max-file: "5"
################################################################################
+ vnfm-simulator:
+ image: ${NEXUS_DOCKER_REPO_MSO}/onap/so/vnfm-simulator:${TAG}
+ ports:
+ - "9093:9093"
+ environment:
+ - APP=VNFM-SIMULATOR
+ - JVM_ARGS=-Xms64m -Xmx512m
+ hostname:
+ vnfm-simulator
+ depends_on:
+ - mariadb
+ - vnfm-adapter
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "30m"
+ max-file: "5"
+################################################################################
workaround-config:
image: jobs/workaround-job-container:latest
ports:
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/ApplicationConfigration.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/ApplicationConfigration.java
index a2f47ad..b1f1779 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/ApplicationConfigration.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/ApplicationConfigration.java
@@ -20,8 +20,11 @@
package org.onap.so.aai.simulator.configration;
import static org.onap.so.aai.simulator.utils.Constants.CUSTOMER_CACHE;
+import static org.onap.so.aai.simulator.utils.Constants.NODES_CACHE;
+import static org.onap.so.aai.simulator.utils.Constants.OWNING_ENTITY_CACHE;
import static org.onap.so.aai.simulator.utils.Constants.PROJECT_CACHE;
import java.util.Arrays;
+import java.util.List;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
@@ -46,7 +49,9 @@
@Bean
public CacheManager cacheManager() {
final SimpleCacheManager manager = new SimpleCacheManager();
- manager.setCaches(Arrays.asList(getCache(CUSTOMER_CACHE), getCache(PROJECT_CACHE)));
+ final List<Cache> caches = Arrays.asList(getCache(CUSTOMER_CACHE), getCache(PROJECT_CACHE),
+ getCache(NODES_CACHE), getCache(OWNING_ENTITY_CACHE));
+ manager.setCaches(caches);
return manager;
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/BusinessController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/BusinessController.java
index b5682f0..0189a42 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/BusinessController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/BusinessController.java
@@ -20,8 +20,9 @@
package org.onap.so.aai.simulator.controller;
import static org.onap.so.aai.simulator.utils.Constants.CUSTOMER_URL;
-import static org.onap.so.aai.simulator.utils.Constants.ERROR_MESSAGE;
-import static org.onap.so.aai.simulator.utils.Constants.ERROR_MESSAGE_ID;
+import static org.onap.so.aai.simulator.utils.Constants.SERVICE_RESOURCE_TYPE;
+import static org.onap.so.aai.simulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
+import static org.onap.so.aai.simulator.utils.Utils.getRequestErrorResponseEntity;
import static org.onap.so.aai.simulator.utils.Utils.getResourceVersion;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
@@ -30,18 +31,21 @@
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.ServiceSubscription;
+import org.onap.so.aai.simulator.models.NodeServiceInstance;
import org.onap.so.aai.simulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.so.aai.simulator.utils.RequestErrorBuilder;
+import org.onap.so.aai.simulator.service.providers.NodesCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
+import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -53,12 +57,17 @@
@RequestMapping(path = CUSTOMER_URL)
public class BusinessController {
+ private static final String SERVICE_SUBSCRIPTION = "service-subscription";
+ private static final String CUSTOMER_TYPE = "Customer";
private static final Logger LOGGER = LoggerFactory.getLogger(BusinessController.class);
private final CustomerCacheServiceProvider cacheServiceProvider;
+ private final NodesCacheServiceProvider nodesCacheServiceProvider;
@Autowired
- public BusinessController(final CustomerCacheServiceProvider cacheServiceProvider) {
+ public BusinessController(final CustomerCacheServiceProvider cacheServiceProvider,
+ final NodesCacheServiceProvider nodesCacheServiceProvider) {
this.cacheServiceProvider = cacheServiceProvider;
+ this.nodesCacheServiceProvider = nodesCacheServiceProvider;
}
@GetMapping(value = "{global-customer-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -74,7 +83,7 @@
}
LOGGER.error("Couldn't find {} in cache", globalCustomerId);
- return getRequestErrorResponseEntity(request);
+ return getRequestErrorResponseEntity(request, CUSTOMER_TYPE);
}
@PutMapping(value = "/{global-customer-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
@@ -109,9 +118,27 @@
LOGGER.error("Couldn't find 'global customer id': {} and 'service type': {} in cache", globalCustomerId,
serviceType);
- return getRequestErrorResponseEntity(request);
+ return getRequestErrorResponseEntity(request, SERVICE_SUBSCRIPTION);
}
+ @PutMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putServiceSubscription(@PathVariable("global-customer-id") final String globalCustomerId,
+ @PathVariable("service-type") final String serviceType,
+ @RequestBody final ServiceSubscription serviceSubscription, final HttpServletRequest request) {
+ LOGGER.info("Will add service subscription for 'global customer id': {} and 'service type': {} ...",
+ globalCustomerId, serviceType);
+
+ if (cacheServiceProvider.putServiceSubscription(globalCustomerId, serviceType, serviceSubscription)) {
+ LOGGER.info("Successfully add service subscription in cache ...");
+ return ResponseEntity.accepted().build();
+ }
+
+ LOGGER.error("Couldn't add service subscription using 'global customer id': {} and 'service type': {}",
+ globalCustomerId, serviceType);
+ return getRequestErrorResponseEntity(request, SERVICE_SUBSCRIPTION);
+ }
+
@GetMapping(
value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances",
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -171,6 +198,7 @@
public ResponseEntity<?> putSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
@PathVariable("service-type") final String serviceType,
@PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String invocationId,
@RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
LOGGER.info(
@@ -183,6 +211,8 @@
if (cacheServiceProvider.putServiceInstance(globalCustomerId, serviceType, serviceInstanceId,
serviceInstance)) {
+ nodesCacheServiceProvider.putNodeServiceInstance(serviceInstanceId, new NodeServiceInstance(
+ globalCustomerId, serviceType, serviceInstanceId, SERVICE_RESOURCE_TYPE, request.getRequestURI()));
return ResponseEntity.accepted().build();
}
@@ -191,12 +221,28 @@
return getRequestErrorResponseEntity(request);
}
- private ResponseEntity<?> getRequestErrorResponseEntity(final HttpServletRequest request) {
- return new ResponseEntity<>(new RequestErrorBuilder().messageId(ERROR_MESSAGE_ID).text(ERROR_MESSAGE)
- .variables(request.getMethod(), request.getRequestURI(),
- "Node Not Found:No Node of type service-instance found at: " + request.getRequestURI(),
- "ERR.5.4.6114")
- .build(), HttpStatus.NOT_FOUND);
+ @PostMapping(
+ value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> patchSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
+ @PathVariable("service-type") final String serviceType,
+ @PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride,
+ @RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
+
+ LOGGER.info(
+ "Will post service instance for 'global customer id': {}, 'service type': {}, 'service instance id: '{} and '{}': {}...",
+ globalCustomerId, serviceType, serviceInstanceId, X_HTTP_METHOD_OVERRIDE, xHttpHeaderOverride);
+
+ if (HttpMethod.PATCH.toString().equalsIgnoreCase(xHttpHeaderOverride)) {
+ cacheServiceProvider.patchServiceInstance(globalCustomerId, serviceType, serviceInstanceId,
+ serviceInstance);
+ return ResponseEntity.accepted().build();
+ }
+ LOGGER.error("{} not supported ... ", xHttpHeaderOverride);
+
+ return getRequestErrorResponseEntity(request);
}
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/NodesController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/NodesController.java
new file mode 100644
index 0000000..4fa4d40
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/NodesController.java
@@ -0,0 +1,110 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.controller;
+
+import static org.onap.so.aai.simulator.utils.Constants.NODES_URL;
+import static org.onap.so.aai.simulator.utils.Constants.RESOURCE_LINK;
+import static org.onap.so.aai.simulator.utils.Constants.RESOURCE_TYPE;
+import static org.onap.so.aai.simulator.utils.Utils.getRequestErrorResponseEntity;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.aai.simulator.models.Format;
+import org.onap.so.aai.simulator.models.NodeServiceInstance;
+import org.onap.so.aai.simulator.models.Result;
+import org.onap.so.aai.simulator.service.providers.CustomerCacheServiceProvider;
+import org.onap.so.aai.simulator.service.providers.NodesCacheServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Controller
+@RequestMapping(path = NODES_URL)
+public class NodesController {
+
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NodesController.class);
+
+ private final NodesCacheServiceProvider cacheServiceProvider;
+
+ private final CustomerCacheServiceProvider customerCacheServiceProvider;
+
+ @Autowired
+ public NodesController(final CustomerCacheServiceProvider customerCacheServiceProvider,
+ final NodesCacheServiceProvider cacheServiceProvider) {
+ this.customerCacheServiceProvider = customerCacheServiceProvider;
+ this.cacheServiceProvider = cacheServiceProvider;
+ }
+
+ @GetMapping(value = "/service-instances/service-instance/{service-instance-id}",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getProject(@PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
+ LOGGER.info("retrieving service instance using 'service-instance-id': {} and format: {}...", serviceInstanceId,
+ format);
+
+ final Optional<NodeServiceInstance> optional = cacheServiceProvider.getNodeServiceInstance(serviceInstanceId);
+ if (!optional.isPresent()) {
+ LOGGER.error("Couldn't find {} in cache", serviceInstanceId);
+ return getRequestErrorResponseEntity(request);
+ }
+
+ final Format value = Format.forValue(format);
+ final NodeServiceInstance nodeServiceInstance = optional.get();
+ switch (value) {
+ case PATHED:
+ LOGGER.info("found project {} in cache", nodeServiceInstance);
+ final Map<String, Object> map = new HashMap<>();
+ map.put(RESOURCE_TYPE, nodeServiceInstance.getResourceType());
+ map.put(RESOURCE_LINK, nodeServiceInstance.getResourceLink());
+ return ResponseEntity.ok(new Result(map));
+ case RAW:
+ final Optional<ServiceInstance> serviceInstance =
+ customerCacheServiceProvider.getServiceInstance(nodeServiceInstance.getGlobalCustomerId(),
+ nodeServiceInstance.getServiceType(), nodeServiceInstance.getServiceInstanceId());
+ if (serviceInstance.isPresent()) {
+ return ResponseEntity.ok(serviceInstance.get());
+ }
+ LOGGER.info("Unable to find Service instance in cahce using {}", nodeServiceInstance);
+ return getRequestErrorResponseEntity(request);
+ default:
+ break;
+ }
+ LOGGER.error("invalid format type :{}", format);
+ return getRequestErrorResponseEntity(request);
+
+
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/OwningEntityController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/OwningEntityController.java
new file mode 100644
index 0000000..e3d6b4f
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/OwningEntityController.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.controller;
+
+import static org.onap.so.aai.simulator.utils.Constants.OWNING_ENTITY;
+import static org.onap.so.aai.simulator.utils.Constants.OWNING_ENTITY_URL;
+import static org.onap.so.aai.simulator.utils.Utils.getRequestErrorResponseEntity;
+import static org.onap.so.aai.simulator.utils.Utils.getResourceVersion;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.OwningEntity;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.aai.simulator.models.Format;
+import org.onap.so.aai.simulator.models.Result;
+import org.onap.so.aai.simulator.service.providers.OwnEntityCacheServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Controller
+@RequestMapping(path = OWNING_ENTITY_URL)
+public class OwningEntityController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OwningEntityController.class);
+
+ private final OwnEntityCacheServiceProvider cacheServiceProvider;
+
+ @Autowired
+ public OwningEntityController(final OwnEntityCacheServiceProvider cacheServiceProvider) {
+ this.cacheServiceProvider = cacheServiceProvider;
+ }
+
+
+ @PutMapping(value = "{owning-entity-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putOwningEntity(@RequestBody final OwningEntity owningEntity,
+ @PathVariable("owning-entity-id") final String owningEntityId, final HttpServletRequest request) {
+ LOGGER.info("Will add OwningEntity to cache with key 'owning-entity-id': {} ...",
+ owningEntity.getOwningEntityId());
+
+ if (owningEntity.getResourceVersion() == null || owningEntity.getResourceVersion().isEmpty()) {
+ owningEntity.setResourceVersion(getResourceVersion());
+
+ }
+ cacheServiceProvider.putOwningEntity(owningEntityId, owningEntity);
+ return ResponseEntity.accepted().build();
+ }
+
+ @GetMapping(value = "{owning-entity-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getOwningEntity(@PathVariable("owning-entity-id") final String owningEntityId,
+ @RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
+ @RequestParam(name = "resultSize", required = false) final Integer resultSize,
+ @RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
+ LOGGER.info("retrieving owning entity for 'owning-entity-id': {} ...", owningEntityId);
+
+ final Optional<OwningEntity> optional = cacheServiceProvider.getOwningEntity(owningEntityId);
+ if (!optional.isPresent()) {
+ LOGGER.error("Couldn't find {} in cache", owningEntityId);
+ return getRequestErrorResponseEntity(request);
+ }
+
+ final Format value = Format.forValue(format);
+ switch (value) {
+ case RAW:
+ final OwningEntity owningEntity = optional.get();
+ LOGGER.info("found OwningEntity {} in cache", owningEntity);
+ return ResponseEntity.ok(owningEntity);
+ case COUNT:
+ final Map<String, Object> map = new HashMap<>();
+ map.put(OWNING_ENTITY, 1);
+ return ResponseEntity.ok(new Result(map));
+ default:
+ break;
+ }
+ LOGGER.error("invalid format type :{}", format);
+ return getRequestErrorResponseEntity(request);
+ }
+
+ @PutMapping(value = "/{owning-entity-id}/relationship-list/relationship",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putOwningEntityRelationShip(@RequestBody final Relationship relationship,
+ @PathVariable("owning-entity-id") final String owningEntityId, final HttpServletRequest request) {
+
+ LOGGER.info("adding relationship for owning-entity-id: {} ...", owningEntityId);
+ if (cacheServiceProvider.putOwningEntityRelationShip(owningEntityId, relationship)) {
+ LOGGER.info("added OwningEntity relationship {} in cache", relationship);
+ return ResponseEntity.accepted().build();
+ }
+ LOGGER.error("Couldn't add relationship for {} in cache", owningEntityId);
+ return getRequestErrorResponseEntity(request);
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java
index e88bf22..0c3b3b7 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java
@@ -19,14 +19,19 @@
*/
package org.onap.so.aai.simulator.controller;
+import static org.onap.so.aai.simulator.utils.Constants.PROJECT;
import static org.onap.so.aai.simulator.utils.Constants.PROJECT_URL;
import static org.onap.so.aai.simulator.utils.Utils.getRequestErrorResponseEntity;
import static org.onap.so.aai.simulator.utils.Utils.getResourceVersion;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.aai.simulator.models.Format;
+import org.onap.so.aai.simulator.models.Result;
import org.onap.so.aai.simulator.service.providers.ProjectCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,6 +43,7 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
/**
* @author waqas.ikram@ericsson.com
@@ -73,17 +79,31 @@
@GetMapping(value = "/{project-name}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getProject(@PathVariable("project-name") final String projectName,
- final HttpServletRequest request) {
+ @RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
+ @RequestParam(name = "resultSize", required = false) final Integer resultSize,
+ @RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
LOGGER.info("retrieving project for 'project-name': {} ...", projectName);
final Optional<Project> optional = cacheServiceProvider.getProject(projectName);
- if (optional.isPresent()) {
- final Project project = optional.get();
- LOGGER.info("found project {} in cache", project);
- return ResponseEntity.ok(project);
+ if (!optional.isPresent()) {
+ LOGGER.error("Couldn't find {} in cache", projectName);
+ return getRequestErrorResponseEntity(request);
}
- LOGGER.error("Couldn't find {} in cache", projectName);
+ final Format value = Format.forValue(format);
+ switch (value) {
+ case RAW:
+ final Project project = optional.get();
+ LOGGER.info("found project {} in cache", project);
+ return ResponseEntity.ok(project);
+ case COUNT:
+ final Map<String, Object> map = new HashMap<>();
+ map.put(PROJECT, 1);
+ return ResponseEntity.ok(new Result(map));
+ default:
+ break;
+ }
+ LOGGER.error("invalid format type :{}", format);
return getRequestErrorResponseEntity(request);
}
@@ -94,14 +114,12 @@
@PathVariable("project-name") final String projectName, final HttpServletRequest request) {
LOGGER.info("adding relationship for project-name: {} ...", projectName);
- final boolean result = cacheServiceProvider.putProjectRelationShip(projectName, relationship);
- if (result) {
+ if (cacheServiceProvider.putProjectRelationShip(projectName, relationship)) {
LOGGER.info("added project relationship {} in cache", relationship);
return ResponseEntity.accepted().build();
}
LOGGER.error("Couldn't find {} in cache", projectName);
return getRequestErrorResponseEntity(request);
-
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Format.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Format.java
new file mode 100644
index 0000000..f6ff240
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Format.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.models;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public enum Format {
+
+ COUNT("count"), RAW("raw"), PATHED("pathed");
+
+ private final String value;
+
+ private Format(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static Format forValue(final String value) {
+ for (final Format format : Format.values()) {
+ if (format.getValue().equals(value)) {
+ return format;
+ }
+ }
+ return RAW;
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/NodeServiceInstance.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/NodeServiceInstance.java
new file mode 100644
index 0000000..f549850
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/NodeServiceInstance.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.models;
+
+import java.io.Serializable;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class NodeServiceInstance implements Serializable {
+
+ private static final long serialVersionUID = -3314166327618070948L;
+
+ private String globalCustomerId;
+ private String serviceType;
+ private String serviceInstanceId;
+ private String resourceType;
+ private String resourceLink;
+
+ public NodeServiceInstance() {}
+
+
+ public NodeServiceInstance(final String globalCustomerId, final String serviceType, final String serviceInstanceId,
+ final String resourceType, final String resourceLink) {
+ this.globalCustomerId = globalCustomerId;
+ this.serviceType = serviceType;
+ this.serviceInstanceId = serviceInstanceId;
+ this.resourceType = resourceType;
+ this.resourceLink = resourceLink;
+ }
+
+
+ /**
+ * @return the globalCustomerId
+ */
+ public String getGlobalCustomerId() {
+ return globalCustomerId;
+ }
+
+
+ /**
+ * @param globalCustomerId the globalCustomerId to set
+ */
+ public void setGlobalCustomerId(final String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ }
+
+
+ /**
+ * @return the serviceType
+ */
+ public String getServiceType() {
+ return serviceType;
+ }
+
+
+ /**
+ * @param serviceType the serviceType to set
+ */
+ public void setServiceType(final String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+
+ /**
+ * @return the serviceInstanceId
+ */
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+
+ /**
+ * @param serviceInstanceId the serviceInstanceId to set
+ */
+ public void setServiceInstanceId(final String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+
+ /**
+ * @return the resourceType
+ */
+ public String getResourceType() {
+ return resourceType;
+ }
+
+
+ /**
+ * @param resourceType the resourceType to set
+ */
+ public void setResourceType(final String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+
+ /**
+ * @return the resourceLink
+ */
+ public String getResourceLink() {
+ return resourceLink;
+ }
+
+
+ /**
+ * @param resourceLink the resourceLink to set
+ */
+ public void setResourceLink(final String resourceLink) {
+ this.resourceLink = resourceLink;
+ }
+
+
+ @Override
+ public String toString() {
+ return "NodeServiceInstance [globalCustomerId=" + globalCustomerId + ", serviceType=" + serviceType
+ + ", serviceInstanceId=" + serviceInstanceId + ", resourceType=" + resourceType + ", resourceLink="
+ + resourceLink + "]";
+ }
+
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Result.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Result.java
new file mode 100644
index 0000000..6aa9256
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/models/Result.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.models;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@JsonRootName(value = "result")
+public class Result {
+
+ private List<Map<String, Object>> values = new ArrayList<>();
+
+ public Result() {}
+
+ public Result(final Map<String, Object> value) {
+ this.values.add(value);
+ }
+
+ /**
+ * @return the values
+ */
+ public List<Map<String, Object>> getValues() {
+ return values;
+ }
+
+ /**
+ * @param values the values to set
+ */
+ public void setValues(final List<Map<String, Object>> values) {
+ this.values = values;
+ }
+
+
+ @JsonIgnore
+ @Override
+ public String toString() {
+ return "Result [values=" + values + "]";
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/AbstractCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/AbstractCacheServiceProvider.java
new file mode 100644
index 0000000..4a45e81
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/AbstractCacheServiceProvider.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.service.providers;
+
+import java.util.concurrent.ConcurrentHashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public abstract class AbstractCacheServiceProvider {
+
+ private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
+
+ private final CacheManager cacheManager;
+
+ public AbstractCacheServiceProvider(final CacheManager cacheManager) {
+ this.cacheManager = cacheManager;
+ }
+
+ protected void clearCahce(final String name) {
+ final Cache cache = cacheManager.getCache(name);
+ if (cache != null) {
+ final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
+ LOGGER.info("Clear all entries from cahce: {}", cache.getName());
+ nativeCache.clear();
+ }
+ }
+
+ protected Cache getCache(final String name) {
+ return cacheManager.getCache(name);
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java
index 51fc554..713da54 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java
@@ -37,6 +37,9 @@
Optional<ServiceSubscription> getServiceSubscription(final String globalCustomerId, final String serviceType);
+ boolean putServiceSubscription(final String globalCustomerId, final String serviceType,
+ final ServiceSubscription serviceSubscription);
+
Optional<ServiceInstances> getServiceInstances(final String globalCustomerId, final String serviceType,
final String serviceInstanceName);
@@ -46,6 +49,9 @@
boolean putServiceInstance(final String globalCustomerId, final String serviceType, final String serviceInstanceId,
final ServiceInstance serviceInstance);
+ boolean patchServiceInstance(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId, final ServiceInstance serviceInstance);
+
void clearAll();
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java
index 11a82be..c3b5a47 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java
@@ -21,12 +21,12 @@
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.onap.aai.domain.yang.Customer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.ServiceSubscription;
+import org.onap.aai.domain.yang.ServiceSubscriptions;
import org.onap.so.aai.simulator.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,20 +40,20 @@
*
*/
@Service
-public class CustomerCacheServiceProviderImpl implements CustomerCacheServiceProvider {
+public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements CustomerCacheServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomerCacheServiceProviderImpl.class);
- public final CacheManager cacheManager;
@Autowired
public CustomerCacheServiceProviderImpl(final CacheManager cacheManager) {
- this.cacheManager = cacheManager;
+ super(cacheManager);
}
@Override
public Optional<Customer> getCustomer(final String globalCustomerId) {
LOGGER.info("getting customer from cache using key: {}", globalCustomerId);
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
return Optional.of(value);
@@ -64,7 +64,7 @@
@Override
public void putCustomer(final String globalCustomerId, final Customer customer) {
LOGGER.info("Adding customer: {} with key: {} in cache ...", customer, globalCustomerId);
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
cache.put(globalCustomerId, customer);
}
@@ -75,7 +75,7 @@
LOGGER.info("getting service subscription from cache for globalCustomerId: {} and serviceType: {}",
globalCustomerId, serviceType);
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
@@ -91,7 +91,7 @@
public Optional<ServiceInstances> getServiceInstances(final String globalCustomerId, final String serviceType,
final String serviceInstanceName) {
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -119,7 +119,7 @@
@Override
public Optional<ServiceInstance> getServiceInstance(final String globalCustomerId, final String serviceType,
final String serviceInstanceId) {
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -145,7 +145,7 @@
final String serviceInstanceId, final ServiceInstance serviceInstance) {
LOGGER.info("Adding serviceInstance: {} in cache ...", serviceInstance, globalCustomerId);
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
+ final Cache cache = getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -171,6 +171,48 @@
return false;
}
+ @Override
+ public boolean putServiceSubscription(final String globalCustomerId, final String serviceType,
+ final ServiceSubscription serviceSubscription) {
+
+ final Optional<Customer> customerOptional = getCustomer(globalCustomerId);
+
+ if (customerOptional.isPresent()) {
+ final Customer customer = customerOptional.get();
+ if (customer.getServiceSubscriptions() == null) {
+ final ServiceSubscriptions serviceSubscriptions = new ServiceSubscriptions();
+ customer.setServiceSubscriptions(serviceSubscriptions);
+ return serviceSubscriptions.getServiceSubscription().add(serviceSubscription);
+ }
+
+ final Optional<ServiceSubscription> serviceSubscriptionOptional = customer.getServiceSubscriptions()
+ .getServiceSubscription().stream().filter(s -> serviceType.equals(s.getServiceType())).findFirst();
+
+ if (!serviceSubscriptionOptional.isPresent()) {
+ return customer.getServiceSubscriptions().getServiceSubscription().add(serviceSubscription);
+ }
+ LOGGER.error("ServiceSubscription already exists {}", serviceSubscriptionOptional.get().getServiceType());
+ return false;
+ }
+ LOGGER.error("Unable to add ServiceSubscription to cache becuase customer does not exits ...");
+ return false;
+ }
+
+ @Override
+ public boolean patchServiceInstance(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId, final ServiceInstance serviceInstance) {
+ final Optional<ServiceInstance> instance = getServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
+ if (instance.isPresent()) {
+ final ServiceInstance cachedServiceInstance = instance.get();
+ LOGGER.info("Changing OrchestrationStatus from {} to {} ", cachedServiceInstance.getOrchestrationStatus(),
+ serviceInstance.getOrchestrationStatus());
+ cachedServiceInstance.setOrchestrationStatus(serviceInstance.getOrchestrationStatus());
+ return true;
+ }
+ LOGGER.error("Unable to find ServiceInstance ...");
+ return false;
+ }
+
private ServiceInstances getServiceInstances(final Optional<ServiceSubscription> optional) {
final ServiceSubscription serviceSubscription = optional.get();
final ServiceInstances serviceInstances = serviceSubscription.getServiceInstances();
@@ -184,10 +226,7 @@
@Override
public void clearAll() {
- final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
- final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
- LOGGER.info("Clear all entries from cahce: {}", cache.getName());
- nativeCache.clear();
+ clearCahce(Constants.CUSTOMER_CACHE);
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProvider.java
new file mode 100644
index 0000000..bf444f2
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProvider.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.service.providers;
+
+import java.util.Optional;
+import org.onap.so.aai.simulator.models.NodeServiceInstance;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public interface NodesCacheServiceProvider {
+
+ void putNodeServiceInstance(final String serviceInstanceId, final NodeServiceInstance nodeServiceInstance);
+
+ Optional<NodeServiceInstance> getNodeServiceInstance(final String serviceInstanceId);
+
+ void clearAll();
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProviderImpl.java
new file mode 100644
index 0000000..0f0ac11
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/NodesCacheServiceProviderImpl.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.service.providers;
+
+import static org.onap.so.aai.simulator.utils.Constants.NODES_CACHE;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import org.onap.so.aai.simulator.models.NodeServiceInstance;
+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;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Service
+public class NodesCacheServiceProviderImpl extends AbstractCacheServiceProvider implements NodesCacheServiceProvider {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NodesCacheServiceProviderImpl.class);
+
+
+ @Autowired
+ public NodesCacheServiceProviderImpl(final CacheManager cacheManager) {
+ super(cacheManager);
+ }
+
+ @Override
+ public void putNodeServiceInstance(final String serviceInstanceId, final NodeServiceInstance nodeServiceInstance) {
+ final Cache cache = getCache(NODES_CACHE);
+ LOGGER.info("Adding {} to cache with key: {}...", nodeServiceInstance, serviceInstanceId);
+ cache.put(serviceInstanceId, nodeServiceInstance);
+ }
+
+ @Override
+ public Optional<NodeServiceInstance> getNodeServiceInstance(final String serviceInstanceId) {
+ final Cache cache = getCache(NODES_CACHE);
+ final NodeServiceInstance value = cache.get(serviceInstanceId, NodeServiceInstance.class);
+ if (value != null) {
+ return Optional.of(value);
+ }
+ LOGGER.error("Unable to find node service instance in cache using key:{} ", serviceInstanceId);
+ return Optional.empty();
+ }
+
+ @Override
+ public void clearAll() {
+ final Cache cache = getCache(NODES_CACHE);
+ final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
+ LOGGER.info("Clear all entries from cahce: {}", cache.getName());
+ nativeCache.clear();
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProvider.java
new file mode 100644
index 0000000..a7b6409
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProvider.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.service.providers;
+
+import java.util.Optional;
+import org.onap.aai.domain.yang.OwningEntity;
+import org.onap.aai.domain.yang.Relationship;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public interface OwnEntityCacheServiceProvider {
+
+ void putOwningEntity(final String owningEntityId, final OwningEntity owningEntity);
+
+ Optional<OwningEntity> getOwningEntity(final String owningEntityId);
+
+ boolean putOwningEntityRelationShip(String owningEntityId, Relationship relationship);
+
+ void clearAll();
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProviderImpl.java
new file mode 100644
index 0000000..6b7af02
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/OwnEntityCacheServiceProviderImpl.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.service.providers;
+
+import static org.onap.so.aai.simulator.utils.Constants.OWNING_ENTITY_CACHE;
+import static org.onap.so.aai.simulator.utils.Constants.SERVICE_RESOURCE_TYPE;
+import java.util.Optional;
+import org.onap.aai.domain.yang.OwningEntity;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipList;
+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;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Service
+public class OwnEntityCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements OwnEntityCacheServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OwnEntityCacheServiceProviderImpl.class);
+ private static final String RELATIONSHIPS_LABEL = "org.onap.relationships.inventory.BelongsTo";
+
+ @Autowired
+ public OwnEntityCacheServiceProviderImpl(final CacheManager cacheManager) {
+ super(cacheManager);
+ }
+
+ @Override
+ public void putOwningEntity(final String owningEntityId, final OwningEntity owningEntity) {
+ LOGGER.info("Adding OwningEntity: {} with name to cache", owningEntityId, owningEntity);
+ final Cache cache = getCache(OWNING_ENTITY_CACHE);
+ cache.put(owningEntityId, owningEntity);
+ }
+
+ @Override
+ public Optional<OwningEntity> getOwningEntity(final String owningEntityId) {
+ LOGGER.info("getting OwningEntity from cache using key: {}", owningEntityId);
+ final Cache cache = getCache(OWNING_ENTITY_CACHE);
+ final OwningEntity value = cache.get(owningEntityId, OwningEntity.class);
+ if (value != null) {
+ return Optional.of(value);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public boolean putOwningEntityRelationShip(final String owningEntityId, final Relationship relationship) {
+ final Cache cache = getCache(OWNING_ENTITY_CACHE);
+ final OwningEntity value = cache.get(owningEntityId, OwningEntity.class);
+ if (value != null) {
+ RelationshipList relationshipList = value.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ value.setRelationshipList(relationshipList);
+ }
+
+ if (relationship.getRelatedTo() == null) {
+ relationship.setRelatedTo(SERVICE_RESOURCE_TYPE);
+ }
+ if (relationship.getRelationshipLabel() == null) {
+ relationship.setRelationshipLabel(RELATIONSHIPS_LABEL);
+ }
+
+ return relationshipList.getRelationship().add(relationship);
+ }
+ LOGGER.error("OwningEntity not found in cache for {}", owningEntityId);
+ return false;
+ }
+
+ @Override
+ public void clearAll() {
+ clearCahce(OWNING_ENTITY_CACHE);
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.java
index ec9e4e5..59060f2 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.java
@@ -32,7 +32,7 @@
void putProject(final String projectName, final Project project);
Optional<Project> getProject(final String projectName);
-
+
boolean putProjectRelationShip(final String projectName, final Relationship relationship);
void clearAll();
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java
index c1148d2..4fca311 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java
@@ -20,8 +20,8 @@
package org.onap.so.aai.simulator.service.providers;
import static org.onap.so.aai.simulator.utils.Constants.PROJECT_CACHE;
+import static org.onap.so.aai.simulator.utils.Constants.SERVICE_RESOURCE_TYPE;
import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
@@ -37,21 +37,23 @@
*
*/
@Service
-public class ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvider {
+public class ProjectCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements ProjectCacheServiceProvider {
+
+ private static final String RELATIONSHIPS_LABEL = "org.onap.relationships.inventory.Uses";
private static final Logger LOGGER = LoggerFactory.getLogger(ProjectCacheServiceProviderImpl.class);
- public final CacheManager cacheManager;
@Autowired
public ProjectCacheServiceProviderImpl(final CacheManager cacheManager) {
- this.cacheManager = cacheManager;
+ super(cacheManager);
}
@Override
public void putProject(final String projectName, final Project project) {
LOGGER.info("Adding project: {} with name to cache", project, projectName);
- final Cache cache = cacheManager.getCache(PROJECT_CACHE);
+ final Cache cache = getCache(PROJECT_CACHE);
cache.put(projectName, project);
}
@@ -59,7 +61,7 @@
@Override
public Optional<Project> getProject(final String projectName) {
LOGGER.info("getting project from cache using key: {}", projectName);
- final Cache cache = cacheManager.getCache(PROJECT_CACHE);
+ final Cache cache = getCache(PROJECT_CACHE);
final Project value = cache.get(projectName, Project.class);
if (value != null) {
return Optional.of(value);
@@ -69,7 +71,7 @@
@Override
public boolean putProjectRelationShip(final String projectName, final Relationship relationship) {
- final Cache cache = cacheManager.getCache(PROJECT_CACHE);
+ final Cache cache = getCache(PROJECT_CACHE);
final Project value = cache.get(projectName, Project.class);
if (value != null) {
RelationshipList relationshipList = value.getRelationshipList();
@@ -77,17 +79,23 @@
relationshipList = new RelationshipList();
value.setRelationshipList(relationshipList);
}
+
+ if (relationship.getRelatedTo() == null) {
+ relationship.setRelatedTo(SERVICE_RESOURCE_TYPE);
+ }
+ if (relationship.getRelationshipLabel() == null) {
+ relationship.setRelationshipLabel(RELATIONSHIPS_LABEL);
+ }
+
return relationshipList.getRelationship().add(relationship);
}
+ LOGGER.error("Project not found in cache for {}", projectName);
return false;
}
@Override
public void clearAll() {
- final Cache cache = cacheManager.getCache(PROJECT_CACHE);
- final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
- LOGGER.info("Clear all entries from cahce: {}", cache.getName());
- nativeCache.clear();
+ clearCahce(PROJECT_CACHE);
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java
index 54e5323..3d1f85d 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java
@@ -25,7 +25,9 @@
*/
public class Constants {
- public static final String BASE_URL = "/simulator/aai/v15/";
+ public static final String BASE_URL = "/aai/v15";
+
+ public static final String NODES_URL = BASE_URL + "/nodes";
public static final String BUSINESS_URL = BASE_URL + "/business";
@@ -33,16 +35,34 @@
public static final String PROJECT_URL = BUSINESS_URL + "/projects/project/";
+ public static final String OWNING_ENTITY_URL = BUSINESS_URL + "/owning-entities/owning-entity";
+
public static final String HEALTHY = "healthy";
public static final String CUSTOMER_CACHE = "customer-cache";
public static final String PROJECT_CACHE = "project-cache";
+ public static final String NODES_CACHE = "nodes-cache";
+
+ public static final String OWNING_ENTITY_CACHE = "owning-entity-cache";
+
+ public static final String PROJECT = "project";
+
+ public static final String OWNING_ENTITY = "owning-entity";
+
+ public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
+
public static final String ERROR_MESSAGE_ID = "SVC3001";
public static final String ERROR_MESSAGE = "Resource not found for %1 using id %2 (msg=%3) (ec=%4)";
+ public static final String SERVICE_RESOURCE_TYPE = "service-instance";
+
+ public static final String RESOURCE_LINK = "resource-link";
+
+ public static final String RESOURCE_TYPE = "resource-type";
+
private Constants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java
index db90a23..81deb86 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java
@@ -37,12 +37,19 @@
return System.currentTimeMillis() + EMPTY_STRING;
}
+ public static ResponseEntity<?> getRequestErrorResponseEntity(final HttpServletRequest request,
+ final String nodeType) {
+ return new ResponseEntity<>(
+ new RequestErrorBuilder().messageId(ERROR_MESSAGE_ID).text(ERROR_MESSAGE)
+ .variables(request.getMethod(), request.getRequestURI(), "Node Not Found:No Node of " + nodeType
+ + " service-instance found at: " + request.getRequestURI(), "ERR.5.4.6114")
+ .build(),
+ HttpStatus.NOT_FOUND);
+ }
+
+
public static ResponseEntity<?> getRequestErrorResponseEntity(final HttpServletRequest request) {
- return new ResponseEntity<>(new RequestErrorBuilder().messageId(ERROR_MESSAGE_ID).text(ERROR_MESSAGE)
- .variables(request.getMethod(), request.getRequestURI(),
- "Node Not Found:No Node of type service-instance found at: " + request.getRequestURI(),
- "ERR.5.4.6114")
- .build(), HttpStatus.NOT_FOUND);
+ return getRequestErrorResponseEntity(request, Constants.SERVICE_RESOURCE_TYPE);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/BusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/BusinessControllerTest.java
index 341c1b3..ed9a129 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/BusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/BusinessControllerTest.java
@@ -23,12 +23,17 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.so.aai.simulator.controller.TestUtils.getFile;
-import static org.onap.so.aai.simulator.controller.TestUtils.getJsonString;
-import static org.onap.so.aai.simulator.controller.TestUtils.getObjectFromFile;
-import java.io.File;
+import static org.onap.so.aai.simulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
+import static org.onap.so.aai.simulator.utils.TestConstants.CUSTOMERS_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_INSTANCES_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_INSTANCE_ID;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_INSTANCE_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_NAME;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_TYPE;
+import static org.onap.so.aai.simulator.utils.TestUtils.getJsonString;
import java.io.IOException;
-import java.nio.file.Files;
import java.util.Optional;
import java.util.UUID;
import org.junit.After;
@@ -42,6 +47,7 @@
import org.onap.so.aai.simulator.utils.Constants;
import org.onap.so.aai.simulator.utils.RequestError;
import org.onap.so.aai.simulator.utils.ServiceException;
+import org.onap.so.aai.simulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -67,23 +73,9 @@
@Configuration
public class BusinessControllerTest {
- private static final String SERVICE_INSTANCES_URL = "/service-instances";
+ private static final String FIREWALL_SERVICE_TTYPE = "Firewall";
- private static final String SERVICE_NAME = "ServiceTest";
-
- private static final String SERVICE_INSTANCE_ID = "ccece8fe-13da-456a-baf6-41b3a4a2bc2b";
-
- private static final String SERVICE_INSTANCE_URL =
- SERVICE_INSTANCES_URL + "/service-instance/" + SERVICE_INSTANCE_ID;
-
- private static final String SERVICE_TYPE = "vCPE";
-
- private static final String SERVICE_SUBSCRIPTIONS_URL =
- "/service-subscriptions/service-subscription/" + SERVICE_TYPE;
-
- private static final String GLOBAL_CUSTOMER_ID = "DemoCustomer";
-
- private static final String CUSTOMERS_URL = Constants.CUSTOMER_URL + GLOBAL_CUSTOMER_ID;
+ private static final String ORCHESTRATION_STATUS = "Active";
@LocalServerPort
private int port;
@@ -300,10 +292,76 @@
}
+ @Test
+ public void test_PathSericeInstance_usingServiceInstanceId_OrchStatusChangedInCache() throws Exception {
+
+ final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final ResponseEntity<Void> serviceInstancePutResponse = invokeHttpPut(url, getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, serviceInstancePutResponse.getStatusCode());
+
+ final HttpHeaders httpHeaders = getHttpHeaders();
+ httpHeaders.add(X_HTTP_METHOD_OVERRIDE, HttpMethod.PATCH.toString());
+
+ final HttpEntity<?> orchStatuUpdateServiceInstance =
+ getHttpEntity(getOrchStatuUpdateServiceInstance(), httpHeaders);
+
+ final ResponseEntity<Void> orchStatuUpdateServiceInstanceResponse =
+ invokeHttpPost(orchStatuUpdateServiceInstance, url, getOrchStatuUpdateServiceInstance());
+
+ assertEquals(HttpStatus.ACCEPTED, orchStatuUpdateServiceInstanceResponse.getStatusCode());
+
+
+ final ResponseEntity<ServiceInstance> actual =
+ restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final ServiceInstance actualServiceInstance = actual.getBody();
+
+ assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
+ assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
+ assertEquals(ORCHESTRATION_STATUS, actualServiceInstance.getOrchestrationStatus());
+
+ }
+
+ @Test
+ public void test_putServiceSubscription_successfullyAddedToCache() throws Exception {
+ final String serviceSubscriptionurl =
+ getCustomerEndPointUrl() + "/service-subscriptions/service-subscription/" + FIREWALL_SERVICE_TTYPE;
+
+ final ResponseEntity<Void> customerPutResponse = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ assertEquals(HttpStatus.ACCEPTED, customerPutResponse.getStatusCode());
+
+ final ResponseEntity<Void> serviceSubscriptionPutResponse =
+ invokeHttpPut(serviceSubscriptionurl, getServiceSubscription());
+ assertEquals(HttpStatus.ACCEPTED, serviceSubscriptionPutResponse.getStatusCode());
+
+ final ResponseEntity<ServiceSubscription> actual = restTemplate.exchange(serviceSubscriptionurl, HttpMethod.GET,
+ new HttpEntity<>(getHttpHeaders()), ServiceSubscription.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final ServiceSubscription actualServiceSubscription = actual.getBody();
+ assertEquals(FIREWALL_SERVICE_TTYPE, actualServiceSubscription.getServiceType());
+
+ }
+
private String getCustomer() throws Exception, IOException {
return getJsonString("test-data/business-customer.json");
}
+ private String getServiceSubscription() throws Exception, IOException {
+ return getJsonString("test-data/service-subscription.json");
+ }
+
+
private String getCustomerEndPointUrl() {
return TestUtils.getBaseUrl(port) + CUSTOMERS_URL;
}
@@ -313,10 +371,18 @@
return restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Void.class);
}
+ private ResponseEntity<Void> invokeHttpPost(final HttpEntity<?> httpEntity, final String url, final Object obj) {
+ return restTemplate.exchange(url, HttpMethod.POST, httpEntity, Void.class);
+ }
+
private HttpEntity<?> getHttpEntity(final Object obj) {
return new HttpEntity<>(obj, getHttpHeaders());
}
+ private HttpEntity<?> getHttpEntity(final Object obj, final HttpHeaders headers) {
+ return new HttpEntity<>(obj, headers);
+ }
+
private HttpHeaders getHttpHeaders() {
return TestUtils.getHttpHeaders(username);
}
@@ -325,4 +391,8 @@
return getJsonString("test-data/service-instance.json");
}
+ private String getOrchStatuUpdateServiceInstance() throws Exception, IOException {
+ return getJsonString("test-data/service-instance-orch-status-update.json");
+ }
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/NodesControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/NodesControllerTest.java
new file mode 100644
index 0000000..5ea6dff
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/NodesControllerTest.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.aai.simulator.utils.Constants.RESOURCE_LINK;
+import static org.onap.so.aai.simulator.utils.Constants.RESOURCE_TYPE;
+import static org.onap.so.aai.simulator.utils.Constants.SERVICE_RESOURCE_TYPE;
+import static org.onap.so.aai.simulator.utils.TestConstants.CUSTOMERS_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_INSTANCE_ID;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_INSTANCE_URL;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_NAME;
+import static org.onap.so.aai.simulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
+import static org.onap.so.aai.simulator.utils.TestUtils.getJsonString;
+import java.io.IOException;
+import java.util.Map;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.aai.simulator.models.Format;
+import org.onap.so.aai.simulator.models.Result;
+import org.onap.so.aai.simulator.service.providers.CustomerCacheServiceProvider;
+import org.onap.so.aai.simulator.service.providers.NodesCacheServiceProvider;
+import org.onap.so.aai.simulator.utils.Constants;
+import org.onap.so.aai.simulator.utils.TestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Configuration;
+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.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Configuration
+public class NodesControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Value("${spring.security.username}")
+ private String username;
+
+ @Autowired
+ private NodesCacheServiceProvider nodesCacheServiceProvider;
+
+ @Autowired
+ private CustomerCacheServiceProvider customerCacheServiceProvider;
+
+ @After
+ public void after() {
+ nodesCacheServiceProvider.clearAll();
+ customerCacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_getNodesSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
+ throws Exception {
+
+ final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final ResponseEntity<Void> response2 = invokeHttpPut(url, getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
+
+ final ResponseEntity<ServiceInstance> actual =
+ restTemplate.exchange(getNodesEndPointUrl() + SERVICE_INSTANCE_URL, HttpMethod.GET,
+ new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final ServiceInstance actualServiceInstance = actual.getBody();
+
+ assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
+ assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
+
+ }
+
+ @Test
+ public void test_getNodesSericeInstance_usingServiceInstanceIdAndFormatPathed_ableToRetrieveServiceInstanceFromCache()
+ throws Exception {
+
+ final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final ResponseEntity<Void> response2 = invokeHttpPut(url, getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
+
+ final ResponseEntity<Result> actual = restTemplate.exchange(
+ getNodesEndPointUrl() + SERVICE_INSTANCE_URL + "?format=" + Format.PATHED.getValue(), HttpMethod.GET,
+ new HttpEntity<>(getHttpHeaders()), Result.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final Result result = actual.getBody();
+
+ assertNotNull(result.getValues());
+ assertFalse(result.getValues().isEmpty());
+ final Map<String, Object> actualMap = result.getValues().get(0);
+
+ assertEquals(CUSTOMERS_URL + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL, actualMap.get(RESOURCE_LINK));
+ assertEquals(SERVICE_RESOURCE_TYPE, actualMap.get(RESOURCE_TYPE));
+
+ }
+
+ private String getNodesEndPointUrl() {
+ return TestUtils.getBaseUrl(port) + Constants.NODES_URL;
+ }
+
+
+ private String getCustomerEndPointUrl() {
+ return TestUtils.getBaseUrl(port) + CUSTOMERS_URL;
+ }
+
+ private String getCustomer() throws Exception, IOException {
+ return getJsonString("test-data/business-customer.json");
+ }
+
+ private String getServiceInstance() throws Exception, IOException {
+ return getJsonString("test-data/service-instance.json");
+ }
+
+ private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
+ final HttpEntity<?> httpEntity = getHttpEntity(obj);
+ return restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Void.class);
+ }
+
+ private HttpEntity<?> getHttpEntity(final Object obj) {
+ return new HttpEntity<>(obj, getHttpHeaders());
+ }
+
+ private HttpHeaders getHttpHeaders() {
+ return TestUtils.getHttpHeaders(username);
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/OwningEntityControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/OwningEntityControllerTest.java
new file mode 100644
index 0000000..bbb2cad
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/OwningEntityControllerTest.java
@@ -0,0 +1,172 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.aai.simulator.utils.TestConstants.RELATIONSHIP_URL;
+import static org.onap.so.aai.simulator.utils.TestUtils.getFile;
+import static org.onap.so.aai.simulator.utils.TestUtils.getHttpHeaders;
+import static org.onap.so.aai.simulator.utils.TestUtils.getJsonString;
+import java.io.IOException;
+import java.nio.file.Files;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.OwningEntity;
+import org.onap.so.aai.simulator.models.Format;
+import org.onap.so.aai.simulator.models.Result;
+import org.onap.so.aai.simulator.service.providers.OwnEntityCacheServiceProvider;
+import org.onap.so.aai.simulator.utils.Constants;
+import org.onap.so.aai.simulator.utils.TestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Configuration
+public class OwningEntityControllerTest {
+ private static final String OWNING_ENTITY_JSON_FILE = "test-data/owning-entity.json";
+
+ private static final String OWN_ENTITY_ID_VALUE = "oe_1";
+ private static final String OWN_ENTITY_NAME_VALUE = "oe_2";
+
+ private static final String OWNING_ENTITY_RELATION_SHIP_JSON_FILE = "test-data/owning-entity-relation-ship.json";
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Value("${spring.security.username}")
+ private String username;
+
+ @Autowired
+ private OwnEntityCacheServiceProvider cacheServiceProvider;
+
+ @After
+ public void after() {
+ cacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_putOwningEntity_successfullyAddedToCache() throws Exception {
+ final String url = getOwningEntityEndPointUrl() + "/" + OWN_ENTITY_ID_VALUE;
+ final String body = new String(Files.readAllBytes(getFile(OWNING_ENTITY_JSON_FILE).toPath()));
+ final ResponseEntity<Void> actual = invokeHttpPut(url, body);
+
+ assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+
+ final ResponseEntity<OwningEntity> actualResponse = invokeHttpGet(url, OwningEntity.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final OwningEntity actualOwningEntity = actualResponse.getBody();
+ assertEquals(OWN_ENTITY_ID_VALUE, actualOwningEntity.getOwningEntityId());
+ assertEquals(OWN_ENTITY_NAME_VALUE, actualOwningEntity.getOwningEntityName());
+ assertNotNull(actualOwningEntity.getResourceVersion());
+
+ }
+
+ @Test
+ public void test_getOwningEntityCount_correctResult() throws Exception {
+ final String url = getOwningEntityEndPointUrl() + "/" + OWN_ENTITY_ID_VALUE;
+ final String body = new String(Files.readAllBytes(getFile(OWNING_ENTITY_JSON_FILE).toPath()));
+ final ResponseEntity<Void> actual = invokeHttpPut(url, body);
+
+ assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+
+ final ResponseEntity<Result> actualResponse =
+ invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=" + Format.COUNT.getValue(), Result.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final Result result = actualResponse.getBody();
+ assertNotNull(result.getValues());
+ assertFalse(result.getValues().isEmpty());
+ assertEquals(1, result.getValues().get(0).get(Constants.OWNING_ENTITY));
+ }
+
+ @Test
+ public void test_putOwningEntityRelationShip_successfullyAddedToCache() throws Exception {
+ final String url = getOwningEntityEndPointUrl() + "/" + OWN_ENTITY_ID_VALUE;
+ final ResponseEntity<Void> actual = invokeHttpPut(url, getJsonString(OWNING_ENTITY_JSON_FILE));
+ assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+
+ final String owningEntityRelationshipUrl = url + RELATIONSHIP_URL;
+
+ final ResponseEntity<Void> putResponse = invokeHttpPut(owningEntityRelationshipUrl, getRelationship());
+
+ assertEquals(HttpStatus.ACCEPTED, putResponse.getStatusCode());
+
+ final ResponseEntity<OwningEntity> actualResponse = invokeHttpGet(url, OwningEntity.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final OwningEntity actualOwningEntity = actualResponse.getBody();
+ assertEquals(OWN_ENTITY_ID_VALUE, actualOwningEntity.getOwningEntityId());
+ assertEquals(OWN_ENTITY_NAME_VALUE, actualOwningEntity.getOwningEntityName());
+ assertNotNull(actualOwningEntity.getRelationshipList());
+ assertFalse(actualOwningEntity.getRelationshipList().getRelationship().isEmpty());
+ assertNotNull(actualOwningEntity.getRelationshipList().getRelationship().get(0));
+
+ }
+
+ private String getRelationship() throws IOException {
+ return TestUtils.getJsonString(OWNING_ENTITY_RELATION_SHIP_JSON_FILE);
+ }
+
+ private <T> ResponseEntity<T> invokeHttpGet(final String url, final Class<T> clazz) {
+ return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(username)), clazz);
+ }
+
+ private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
+ final HttpEntity<?> httpEntity = getHttpEntity(obj);
+ return restTemplate.exchange(url, HttpMethod.PUT, httpEntity, Void.class);
+ }
+
+ private HttpEntity<?> getHttpEntity(final Object obj) {
+ return new HttpEntity<>(obj, getHttpHeaders(username));
+ }
+
+ private String getOwningEntityEndPointUrl() {
+ return TestUtils.getBaseUrl(port) + Constants.OWNING_ENTITY_URL;
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java
index 73fdb2c..ba6ad97 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java
@@ -23,17 +23,19 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.so.aai.simulator.controller.TestUtils.getFile;
-import static org.onap.so.aai.simulator.controller.TestUtils.getHttpHeaders;
-import static org.onap.so.aai.simulator.controller.TestUtils.getJsonString;
+import static org.onap.so.aai.simulator.utils.TestUtils.getFile;
+import static org.onap.so.aai.simulator.utils.TestUtils.getHttpHeaders;
+import static org.onap.so.aai.simulator.utils.TestUtils.getJsonString;
import java.io.IOException;
import java.nio.file.Files;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.domain.yang.Project;
+import org.onap.so.aai.simulator.models.Result;
import org.onap.so.aai.simulator.service.providers.ProjectCacheServiceProvider;
import org.onap.so.aai.simulator.utils.Constants;
+import org.onap.so.aai.simulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -125,6 +127,25 @@
}
+ @Test
+ public void test_getProjectCount_correctResult() throws Exception {
+ final String url = getProjectEndPointUrl() + "/" + PROJECT_NAME_VALUE;
+ final String body = new String(Files.readAllBytes(getFile(BUSINESS_PROJECT_JSON_FILE).toPath()));
+ final ResponseEntity<Void> actual = invokeHttpPut(url, body);
+
+ assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+
+ final ResponseEntity<Result> actualResponse =
+ invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=count", Result.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final Result result = actualResponse.getBody();
+ assertNotNull(result.getValues());
+ assertFalse(result.getValues().isEmpty());
+ assertEquals(1, result.getValues().get(0).get(Constants.PROJECT));
+ }
+
private <T> ResponseEntity<T> invokeHttpGet(final String url, final Class<T> clazz) {
return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(username)), clazz);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestConstants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestConstants.java
new file mode 100644
index 0000000..f57c946
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestConstants.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.aai.simulator.utils;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class TestConstants {
+
+ public static final String SERVICE_INSTANCES_URL = "/service-instances";
+
+ public static final String SERVICE_NAME = "ServiceTest";
+
+ public static final String SERVICE_INSTANCE_ID = "ccece8fe-13da-456a-baf6-41b3a4a2bc2b";
+
+ public static final String SERVICE_INSTANCE_URL =
+ SERVICE_INSTANCES_URL + "/service-instance/" + SERVICE_INSTANCE_ID;
+
+ public static final String SERVICE_TYPE = "vCPE";
+
+ public static final String SERVICE_SUBSCRIPTIONS_URL =
+ "/service-subscriptions/service-subscription/" + SERVICE_TYPE;
+
+ public static final String GLOBAL_CUSTOMER_ID = "DemoCustomer";
+
+ public static final String CUSTOMERS_URL = Constants.CUSTOMER_URL + GLOBAL_CUSTOMER_ID;
+
+ public static final String RELATIONSHIP_URL = "/relationship-list/relationship";
+
+ private TestConstants() {}
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestUtils.java
similarity index 97%
rename from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/TestUtils.java
rename to plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestUtils.java
index c03f5ce..73e43b1 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/TestUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/utils/TestUtils.java
@@ -17,7 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-package org.onap.so.aai.simulator.controller;
+package org.onap.so.aai.simulator.utils;
import java.io.File;
import java.io.IOException;
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json
new file mode 100644
index 0000000..1c41947
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json
@@ -0,0 +1,3 @@
+{
+ "related-link": "/business/customers/customer/NordixDemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ccece8fe-13da-456a-baf6-41b3a4a2bc2b"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity.json
new file mode 100644
index 0000000..7248d41
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity.json
@@ -0,0 +1,4 @@
+{
+ "owning-entity-id": "oe_1",
+ "owning-entity-name": "oe_2"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-instance-orch-status-update.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-instance-orch-status-update.json
new file mode 100644
index 0000000..5cd566a
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-instance-orch-status-update.json
@@ -0,0 +1,5 @@
+{
+ "service-instance-id": "ccece8fe-13da-456a-baf6-41b3a4a2bc2b",
+ "service-instance-name": "ServiceTest",
+ "orchestration-status": "Active"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-subscription.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-subscription.json
new file mode 100644
index 0000000..e1b4f4f
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/service-subscription.json
@@ -0,0 +1,3 @@
+{
+ "service-type": "Firewall"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml b/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml
index 5736c8e..755e541 100644
--- a/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml
+++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml
@@ -6,11 +6,9 @@
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
-
<artifactId>docker</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
-
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
@@ -18,13 +16,11 @@
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.28.0</version>
-
<configuration>
<verbose>true</verbose>
<apiVersion>1.23</apiVersion>
<pullRegistry>${docker.pull.registry}</pullRegistry>
<pushRegistry>${docker.push.registry}</pushRegistry>
-
<images>
<image>
<name>jobs/workaround-job-container</name>
@@ -82,7 +78,6 @@
</image>
</images>
</configuration>
-
<executions>
<execution>
<id>clean-images</id>
@@ -94,7 +89,6 @@
<removeAll>true</removeAll>
</configuration>
</execution>
-
<execution>
<id>generate-images</id>
<phase>generate-sources</phase>
@@ -103,7 +97,6 @@
</goals>
</execution>
</executions>
-
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -115,9 +108,7 @@
</plugin>
</plugins>
</build>
-
<dependencies>
-
<dependency>
<groupId>org.onap.so.simulators</groupId>
<artifactId>sdc-simulator</artifactId>
@@ -129,6 +120,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
-
-</project>
+</project>
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml
index 397d4a7..e5cc3d3 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml
@@ -1,15 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>so-simulators</artifactId>
<groupId>org.onap.so.simulators</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
-
<artifactId>sdc-simulator</artifactId>
<name>${project.artifactId}</name>
-
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
@@ -32,5 +42,4 @@
</plugin>
</plugins>
</build>
-
-</project>
+</project>
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/configration/WebSecurityConfigImpl.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/configration/WebSecurityConfigImpl.java
new file mode 100644
index 0000000..bf97178
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/configration/WebSecurityConfigImpl.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.sdc.simulator.configration;
+
+import org.onap.so.sdc.simulator.utils.Constants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends WebSecurityConfigurerAdapter {
+
+ private final String username;
+ private final String password;
+ private final String role;
+
+ public WebSecurityConfigImpl(@Value("${spring.security.username}") final String username,
+ @Value("${spring.security.password}") final String password,
+ @Value("${spring.security.role}") final String role) {
+ this.username = username;
+ this.password = password;
+ this.role = role;
+ }
+
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers(Constants.CATALOG_URL + "/**/**").authenticated().and()
+ .httpBasic();
+ }
+
+ @Bean
+ public BCryptPasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Autowired
+ public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
+ auth.inMemoryAuthentication().passwordEncoder(passwordEncoder()).withUser(username).password(password)
+ .roles(role);
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/CatalogController.java
similarity index 79%
rename from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java
rename to plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/CatalogController.java
index b844caa..01c0b39 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/CatalogController.java
@@ -17,13 +17,12 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+package org.onap.so.sdc.simulator.controller;
-package org.onap.so.sdc.simulator;
-
+import static org.onap.so.sdc.simulator.utils.Constants.CATALOG_URL;
import java.util.Optional;
import javax.ws.rs.core.MediaType;
import org.onap.so.sdc.simulator.providers.ResourceProvider;
-import org.onap.so.sdc.simulator.utils.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,30 +31,24 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
+ *
*/
@RestController
-@RequestMapping(path = Constant.BASE_URL)
-public class SdcSimulatorController {
- private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class);
+@RequestMapping(path = CATALOG_URL)
+public class CatalogController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CatalogController.class);
private ResourceProvider resourceProvider;
- public SdcSimulatorController(@Autowired final ResourceProvider resourceProvider) {
+ @Autowired
+ public CatalogController(final ResourceProvider resourceProvider) {
this.resourceProvider = resourceProvider;
}
- @GetMapping(value = "/healthcheck", produces = MediaType.APPLICATION_JSON)
- @ResponseStatus(code = HttpStatus.OK)
- public String healthCheck() {
- LOGGER.info("Running health check ...");
- return Constant.HEALTHY;
- }
-
@GetMapping(value = "/resources/{csarId}/toscaModel", produces = MediaType.APPLICATION_OCTET_STREAM)
public ResponseEntity<byte[]> getCsar(@PathVariable("csarId") final String csarId) {
LOGGER.info("Running getCsar for {} ...", csarId);
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/SdcSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/SdcSimulatorController.java
new file mode 100644
index 0000000..2baf203
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/controller/SdcSimulatorController.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.sdc.simulator.controller;
+
+import javax.ws.rs.core.MediaType;
+import org.onap.so.sdc.simulator.utils.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@RestController
+@RequestMapping(path = Constants.BASE_URL)
+public class SdcSimulatorController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class);
+
+ @GetMapping(value = "/healthcheck", produces = MediaType.APPLICATION_JSON)
+ @ResponseStatus(code = HttpStatus.OK)
+ public String healthCheck() {
+ LOGGER.info("Running health check ...");
+ return Constants.HEALTHY;
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/providers/ResourceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/providers/ResourceProviderImpl.java
index cdc96f6..efc98de 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/providers/ResourceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/providers/ResourceProviderImpl.java
@@ -26,7 +26,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
-import org.onap.so.sdc.simulator.utils.Constant;
+import org.onap.so.sdc.simulator.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -83,6 +83,6 @@
* Used in test
*/
String getDefaultCsarPath() {
- return Constant.DEFAULT_CSAR_PATH;
+ return Constants.DEFAULT_CSAR_PATH;
}
}
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constant.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constants.java
similarity index 88%
rename from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constant.java
rename to plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constants.java
index d22de71..4fa0688 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constant.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constants.java
@@ -18,9 +18,11 @@
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
*/
-public class Constant {
+public class Constants {
- public static final String BASE_URL = "/simulator/sdc/v1/catalog";
+ public static final String BASE_URL = "/sdc/v1";
+
+ public static final String CATALOG_URL = BASE_URL + "/catalog";
public static final String HEALTHY = "healthy";
@@ -35,6 +37,5 @@
public static final String DEFAULT_CSAR_PATH = "/csar/" + DEFAULT_CSAR_NAME_WITH_EXT;
- private Constant() {
- }
+ private Constants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
index 89a13aa..5bb7950 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
@@ -1,5 +1,11 @@
server:
- port: 9991
- tomcat:
- max-threads: 4
+ port: 9991
+ tomcat:
+ max-threads: 4
ssl-enable: false
+spring:
+ security:
+ username: mso
+ #password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+ password: $2a$04$Lcu/DWdyXsl/a3A0iqHTfOX1.zHQ3DlQS/nOPfafT.9pWbeEqlF7W
+ role: mso
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/CatalogControllerTest.java
similarity index 67%
rename from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java
rename to plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/CatalogControllerTest.java
index 7834425..98ec448 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/CatalogControllerTest.java
@@ -17,37 +17,45 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
-package org.onap.so.sdc.simulator;
+package org.onap.so.sdc.simulator.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Base64;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.so.sdc.simulator.providers.ResourceProvider;
-import org.onap.so.sdc.simulator.utils.Constant;
+import org.onap.so.sdc.simulator.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpEntity;
+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;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
+ *
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@Configuration
-public class SdcSimulatorControllerTest {
+public class CatalogControllerTest {
+
+ private static final String PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
@LocalServerPort
private int port;
@@ -55,42 +63,48 @@
@Autowired
private TestRestTemplate restTemplate;
- @Test
- public void test_healthCheck_matchContent() {
- final String url = getBaseUrl() + "/healthcheck";
- final ResponseEntity<String> object = restTemplate.getForEntity(url, String.class);
-
- assertEquals(Constant.HEALTHY, object.getBody());
-
- }
+ @Value("${spring.security.username}")
+ private String username;
@Test
public void test_getCsar_validCsarId_matchContent() {
- final String url = getBaseUrl() + "/resources/" + Constant.DEFAULT_CSAR_NAME + "/toscaModel";
+ final String url = getBaseUrl() + "/resources/" + Constants.DEFAULT_CSAR_NAME + "/toscaModel";
- final ResponseEntity<byte[]> response = restTemplate.getForEntity(url, byte[].class);
+ final ResponseEntity<byte[]> response =
+ restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), byte[].class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.hasBody());
assertEquals(3982, response.getBody().length);
- assertEquals(HttpStatus.OK, response.getStatusCode());
}
@Test
public void test_getCsar_invalidCsar_internalServerError() {
final ResourceProvider mockedResourceProvider = Mockito.mock(ResourceProvider.class);
Mockito.when(mockedResourceProvider.getResource(Mockito.anyString())).thenReturn(Optional.empty());
- final SdcSimulatorController objUnderTest = new SdcSimulatorController(mockedResourceProvider);
+ final CatalogController objUnderTest = new CatalogController(mockedResourceProvider);
- final ResponseEntity<byte[]> response = objUnderTest.getCsar(Constant.DEFAULT_CSAR_NAME);
+ final ResponseEntity<byte[]> response = objUnderTest.getCsar(Constants.DEFAULT_CSAR_NAME);
assertFalse(response.hasBody());
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}
private String getBaseUrl() {
- return "http://localhost:" + port + Constant.BASE_URL;
+ return "http://localhost:" + port + Constants.CATALOG_URL;
+ }
+
+ private HttpHeaders getHttpHeaders() {
+ final HttpHeaders requestHeaders = new HttpHeaders();
+ requestHeaders.add("Authorization", getBasicAuth(username));
+ requestHeaders.setContentType(MediaType.APPLICATION_JSON);
+ return requestHeaders;
+ }
+
+ private String getBasicAuth(final String username) {
+ return "Basic " + new String(Base64.getEncoder().encodeToString((username + ":" + PASSWORD).getBytes()));
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/SdcSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/SdcSimulatorControllerTest.java
new file mode 100644
index 0000000..300b62a
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/controller/SdcSimulatorControllerTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.sdc.simulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.sdc.simulator.utils.Constants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Configuration
+public class SdcSimulatorControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Test
+ public void test_healthCheck_matchContent() {
+ final String url = "http://localhost:" + port + Constants.BASE_URL + "/healthcheck";
+ final ResponseEntity<String> object = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(Constants.HEALTHY, object.getBody());
+
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/providers/ResourceProviderImplTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/providers/ResourceProviderImplTest.java
index 4871d51..b112c40 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/providers/ResourceProviderImplTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/providers/ResourceProviderImplTest.java
@@ -30,7 +30,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.onap.so.sdc.simulator.utils.Constant;
+import org.onap.so.sdc.simulator.utils.Constants;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;
@@ -59,13 +59,13 @@
@Test
public void test_getResource_withoutValidPath_matchContent() throws IOException {
- final ClassPathResource classPathResource = new ClassPathResource(Constant.DEFAULT_CSAR_PATH, this.getClass());
+ final ClassPathResource classPathResource = new ClassPathResource(Constants.DEFAULT_CSAR_PATH, this.getClass());
final byte[] expectedResult = StreamUtils.copyToByteArray(classPathResource.getInputStream());
final ResourceProviderImpl objUnderTest = new ResourceProviderImpl("");
- assertArrayEquals(expectedResult, objUnderTest.getResource(Constant.DEFAULT_CSAR_NAME).get());
+ assertArrayEquals(expectedResult, objUnderTest.getResource(Constants.DEFAULT_CSAR_NAME).get());
}
@Test
@@ -77,7 +77,7 @@
return "/some/dummy/path";
}
};
- assertFalse(objUnderTest.getResource(Constant.DEFAULT_CSAR_NAME).isPresent());
+ assertFalse(objUnderTest.getResource(Constants.DEFAULT_CSAR_NAME).isPresent());
}
diff --git a/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml b/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml
index 59da2d9..3534055 100644
--- a/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml
+++ b/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml
@@ -86,7 +86,7 @@
ports:
- "8433:8433"
extra_hosts:
- - "dmaap-dr-node:DR_NODE_IP"
+ - "dmaap-dr-node:5.5.5.5"
consul:
container_name: consul
diff --git a/plans/usecases/5G-bulkpm/setup.sh b/plans/usecases/5G-bulkpm/setup.sh
index 1bba4f3..31ac227 100644
--- a/plans/usecases/5G-bulkpm/setup.sh
+++ b/plans/usecases/5G-bulkpm/setup.sh
@@ -136,7 +136,7 @@
# Data File Collector configuration :
-sed -i 's/DR_NODE_IP/'$DR_NODE_IP'/g' docker-compose.yml
+sed -i 's/5.5.5.5/'$DR_NODE_IP'/g' docker-compose.yml
cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json /tmp/
sed -i 's/dmaapmrhost/'${DMAAP_MR_IP}'/g' /tmp/datafile_endpoints.json
sed -i 's/dmaapdrhost/'${DR_PROV_IP}'/g' /tmp/datafile_endpoints.json
@@ -157,7 +157,7 @@
# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
for i in {1..10}; do
if [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
- [ $(docker inspect --format '{{ .State.Running }}' cbs) ]
+ [ $(docker inspect --format '{{ .State.Running }}' cbs) ]
then
echo "Data Router, Consul, Config Binding Service Services Running"
break
@@ -201,7 +201,7 @@
CBS_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cbs)
sed -i 's/CBSIP/'$CBS_IP'/g' docker-compose.yml
sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml
-sed -i 's/4.4.4.4/'$DMAAP_MR_IP'/g' docker-compose.yml
+sed -i 's/4.4.4.4/'$MARIADB'/g' docker-compose.yml
docker-compose up -d
cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose
@@ -221,19 +221,25 @@
docker restart pmmapper
sleep 5
+# Simulation setup for Message Router
+docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/mrserver.js mariadb:/
+docker exec mariadb /bin/bash -c "apt update"
+sleep 2
+docker exec mariadb /bin/bash -c "apt install nodejs -y"
+sleep 10
+docker exec mariadb /bin/bash -c "nodejs mrserver.js &" &
+
# Create PM Mapper feed and create PM Mapper subscriber on data router
#curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443
curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
# Create PM Mapper tocic in Message Router
-curl -v -X POST http://${DMAAP_MR_IP}:3904/topics/create -d @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createTopic.json -H "Content-Type: application/json"
PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper)
docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper.log
cat /tmp/pmmapper.log
docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
sleep 10
curl -k https://$DR_PROV_IP:8443/internal/prov
-curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000
#Pass any variables required by Robot test suites in ROBOT_VARIABLES
ROBOT_VARIABLES="-v DR_PROV_IP:${DR_PROV_IP} -v DR_NODE_IP:${DR_NODE_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v VESC_IP:${VESC_IP} -v VESC_PORT:${VESC_PORT} -v DR_SUBSCIBER_IP:${DR_SUBSCIBER_IP} -v SFTP_IP:${SFTP_IP}"
diff --git a/plans/usecases/5G-bulkpm/teardown.sh b/plans/usecases/5G-bulkpm/teardown.sh
index 782a289..73aaf3b 100644
--- a/plans/usecases/5G-bulkpm/teardown.sh
+++ b/plans/usecases/5G-bulkpm/teardown.sh
@@ -7,9 +7,6 @@
echo "===== PM MAPPER LOG ========"
cat /tmp/pmmapper_docker.log.robot
sleep 2
-echo "===== MR LOG ========"
-cat /tmp/mr.log
-sleep 2
kill-instance.sh $DMAAP
kill-instance.sh $KAFKA
kill-instance.sh $ZOOKEEPER
diff --git a/tests/dcaegen2-pmmapper/pmmapper/assets/pm_filter_config.json b/tests/dcaegen2-pmmapper/pmmapper/assets/pm_filter_config.json
index 1e3604f..992fdaa 100644
--- a/tests/dcaegen2-pmmapper/pmmapper/assets/pm_filter_config.json
+++ b/tests/dcaegen2-pmmapper/pmmapper/assets/pm_filter_config.json
@@ -7,39 +7,36 @@
"measTypes": ["attTCHSeizures","succTCHSeizures2","succImmediateAssignProcs8"]
}]
},
- "streams_subscribes": {
- "dmaap_subscriber": {
- "type": "data_router",
- "aaf_username": null,
- "aaf_password": null,
- "dmaap_info": {
- "location": "csit-pmmapper",
- "delivery_url": "http://dcae-pm-mapper:8081/delivery",
- "username": "username",
- "password": "password",
- "subscriber_id": "1"
- }
- }
- },
- "streams_publishes": {
- "dmaap_publisher": {
- "type": "message_router",
- "aaf_password": null,
- "dmaap_info": {
- "topic_url": "http://message-router:3904/events/PM_MAPPER",
- "client_role": "org.onap.dmaap.client.pub",
- "location": "csit-pmmapper",
- "client_id": null
- },
- "aaf_username": null
- }
- },
- "dmaap_dr_feed_name": "1",
- "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
- "services_calls": {},
- "enable_http": true,
"key_store_path": "/opt/app/pm-mapper/etc/cert.jks.b64",
"key_store_pass_path": "/opt/app/pm-mapper/etc/jks.pass",
"trust_store_path": "/opt/app/pm-mapper/etc/trust.jks.b64",
- "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass"
+ "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass",
+ "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+ "dmaap_dr_feed_name": "1",
+ "aaf_identity": "aaf_admin@people.osaaf.org",
+ "aaf_password": "demo123456!",
+ "enable_http": true,
+ "streams_publishes": {
+ "dmaap_publisher": {
+ "type": "message_router",
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/org.onap.dmaap.mr.VES_PM",
+ "client_role": "org.onap.dcae.pmPublisher",
+ "location": "csit-pmmapper",
+ "client_id": "1562763644939"
+ }
+ }
+ },
+ "streams_subscribes": {
+ "dmaap_subscriber": {
+ "type": "data_router",
+ "dmaap_info": {
+ "username": "username",
+ "password": "password",
+ "location": "csit-pmmapper",
+ "delivery_url": "http://dcae-pm-mapper:8081/delivery",
+ "subscriber_id": 1
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/dcaegen2-pmmapper/pmmapper/assets/vendor_filter_config.json b/tests/dcaegen2-pmmapper/pmmapper/assets/vendor_filter_config.json
index cbb313d..c2ac983 100644
--- a/tests/dcaegen2-pmmapper/pmmapper/assets/vendor_filter_config.json
+++ b/tests/dcaegen2-pmmapper/pmmapper/assets/vendor_filter_config.json
@@ -7,39 +7,36 @@
"measTypes": []
}]
},
- "streams_subscribes": {
- "dmaap_subscriber": {
- "type": "data_router",
- "aaf_username": null,
- "aaf_password": null,
- "dmaap_info": {
- "location": "csit-pmmapper",
- "delivery_url": "http://dcae-pm-mapper:8081/delivery",
- "username": "username",
- "password": "password",
- "subscriber_id": "1"
- }
- }
- },
- "streams_publishes": {
- "dmaap_publisher": {
- "type": "message_router",
- "aaf_password": null,
- "dmaap_info": {
- "topic_url": "http://message-router:3904/events/PM_MAPPER",
- "client_role": "org.onap.dmaap.client.pub",
- "location": "csit-pmmapper",
- "client_id": null
- },
- "aaf_username": null
- }
- },
- "dmaap_dr_feed_name": "1",
- "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
- "services_calls": {},
- "enable_http": true,
"key_store_path": "/opt/app/pm-mapper/etc/cert.jks.b64",
"key_store_pass_path": "/opt/app/pm-mapper/etc/jks.pass",
"trust_store_path": "/opt/app/pm-mapper/etc/trust.jks.b64",
- "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass"
+ "trust_store_pass_path": "/opt/app/pm-mapper/etc/trust.pass",
+ "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+ "dmaap_dr_feed_name": "1",
+ "aaf_identity": "aaf_admin@people.osaaf.org",
+ "aaf_password": "demo123456!",
+ "enable_http": true,
+ "streams_publishes": {
+ "dmaap_publisher": {
+ "type": "message_router",
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/org.onap.dmaap.mr.VES_PM",
+ "client_role": "org.onap.dcae.pmPublisher",
+ "location": "csit-pmmapper",
+ "client_id": "1562763644939"
+ }
+ }
+ },
+ "streams_subscribes": {
+ "dmaap_subscriber": {
+ "type": "data_router",
+ "dmaap_info": {
+ "username": "username",
+ "password": "password",
+ "location": "csit-pmmapper",
+ "delivery_url": "http://dcae-pm-mapper:8081/delivery",
+ "subscriber_id": 1
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/dcaegen2-pmmapper/pmmapper/pmmapper.robot b/tests/dcaegen2-pmmapper/pmmapper/pmmapper.robot
index c211e7d..dfd2b66 100644
--- a/tests/dcaegen2-pmmapper/pmmapper/pmmapper.robot
+++ b/tests/dcaegen2-pmmapper/pmmapper/pmmapper.robot
@@ -87,11 +87,6 @@
[Timeout] 1 minute
SendToDatarouter ${TYPE-C_PM_DATA_FILE_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=5
CheckLog ${CLI_EXEC_CLI_PM_LOG} Successfully published VES events to messagerouter
- CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=5
- Run Process ${CLI_MESSAGE_ROUTER_TOPIC} shell=yes
- CheckLog ${CLI_MR_LOG} measInfoId1
- CheckLog ${CLI_MR_LOG} measInfoId2
- CheckLog ${CLI_MR_LOG} measInfoId3
Verify 3GPP PM Mapper maps Type-A file based on counter filtering and publish 3gpp perf VES evnets to message router
[Tags] PM_MAPPER_08
@@ -102,18 +97,6 @@
Sleep 5s
SendToDatarouter ${TYPE-A_PM_DATA_FILE_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=6
CheckLog ${CLI_EXEC_CLI_PM_LOG} Successfully published VES events to messagerouter
- CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=6
- Run Process ${CLI_MESSAGE_ROUTER_TOPIC} shell=yes
- CheckLog ${CLI_MR_LOG} attTCHSeizures
- CheckLog ${CLI_MR_LOG} 234
- CheckLog ${CLI_MR_LOG} 890
- CheckLog ${CLI_MR_LOG} 456
- CheckLog ${CLI_MR_LOG} succTCHSeizures2
- CheckLog ${CLI_MR_LOG} 86,87,2,6,77,96,75,33,24
- CheckLog ${CLI_MR_LOG} succImmediateAssignProcs8
- CheckLog ${CLI_MR_LOG} 787
- CheckLog ${CLI_MR_LOG} 238
- CheckLog ${CLI_MR_LOG} 785
Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
[Tags] PM_MAPPER_09
@@ -132,7 +115,7 @@
[Documentation] Verify that PM Mapper correctly identifies a non-xml file.
[Timeout] 1 minute
SendToDatarouter ${NON_XML_FILE} ${VALID_METADATA_PATH} X-ONAP-RequestID=8
- CheckLog ${CLI_EXEC_CLI_PM_LOG} PM measurement file type not supported
+ CheckLog ${CLI_EXEC_CLI_PM_LOG} PM measurement file must have an extension of .xml
CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=8
diff --git a/tests/usecases/5G-bulkpm/BulkpmE2E.robot b/tests/usecases/5G-bulkpm/BulkpmE2E.robot
index cac93f7..e89d4d6 100644
--- a/tests/usecases/5G-bulkpm/BulkpmE2E.robot
+++ b/tests/usecases/5G-bulkpm/BulkpmE2E.robot
@@ -24,9 +24,7 @@
${CLI_EXEC_RENAME_METADATA} mv %{WORKSPACE}/A20181002.0000-1000-0015-1000_5G.xml.M %{WORKSPACE}/metadata.json
${CLI_EXEC_CLI_PMMAPPER_LOG} docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper_docker.log.robot
${CLI_EXEC_CLI_PMMAPPER_LOG_GREP} grep "XML validation successful Event" /tmp/pmmapper_docker.log.robot
-${CLI_EXEC_MR_PMMAPPER_TOPIC} curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000 > /tmp/mr.log
-${CLI_EXEC_CLI_PMMAPPER_TOPIC_LOG_GREP} grep "perf3gpp_RnNode-Ericsson_pmMeasResult" /tmp/mr.log
-
+${CLI_EXEC_CLI_PMMAPPER_LOG_GREP_VES} grep "Successfully published VES events to messagerouter" /tmp/pmmapper_docker.log.robot
${metadataSchemaPath} %{WORKSPACE}/tests/usecases/5G-bulkpm/assets/metadata.schema.json
${metadataJsonPath} %{WORKSPACE}/metadata.json
@@ -115,13 +113,11 @@
Should Be Equal As Strings ${cli_cmd_output.rc} 0
Should Contain ${cli_cmd_output.stdout} XML validation successful Event
-Verify PM-Mapper successfully publishes PMMeasResult VES onto the Message Router Topic PM_MAPPER
+Verify PM-Mapper successfully publishes VES event the Message Router
[Tags] Bulk_PM_E2E_08
[Documentation] Check that PM-Mapper publishes VES onto the Message Router
- ${cli_cmd_output}= Run Process ${CLI_EXEC_MR_PMMAPPER_TOPIC} shell=yes
+ ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_LOG} shell=yes
Log ${cli_cmd_output.stdout}
Should Be Equal As Strings ${cli_cmd_output.rc} 0
- ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_TOPIC_LOG_GREP} shell=yes
- Log ${cli_cmd_output.stdout}
- Should Be Equal As Strings ${cli_cmd_output.rc} 0
- Should Contain ${cli_cmd_output.stdout} perf3gpp_RnNode-Ericsson_pmMeasResult
\ No newline at end of file
+ ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_LOG_GREP_VES} shell=yes
+ Should Contain ${cli_cmd_output.stdout} Successfully published VES events to messagerouter
\ No newline at end of file