aboutsummaryrefslogtreecommitdiffstats
path: root/plans
diff options
context:
space:
mode:
Diffstat (limited to 'plans')
-rw-r--r--plans/so/integration-etsi-testing/config/certificates/aai-certificate/aai.crt31
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/ApplicationConfigration.java10
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/WebSecurityConfigImpl.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/AaiSimulatorController.java7
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/BusinessController.java39
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java107
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java (renamed from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CacheServiceProvider.java)2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java (renamed from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CacheServiceProviderImpl.java)22
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.java39
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java93
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java (renamed from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java)12
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java51
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/keystore/org.onap.so.p12bin0 -> 4047 bytes
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/AaiSimulatorControllerTest.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/BusinessControllerTest.java118
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java148
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/TestUtils.java73
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/configuration/TestRestTemplateConfigration.java71
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project.json3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh13
24 files changed, 737 insertions, 131 deletions
diff --git a/plans/so/integration-etsi-testing/config/certificates/aai-certificate/aai.crt b/plans/so/integration-etsi-testing/config/certificates/aai-certificate/aai.crt
new file mode 100644
index 00000000..9acb8bb9
--- /dev/null
+++ b/plans/so/integration-etsi-testing/config/certificates/aai-certificate/aai.crt
@@ -0,0 +1,31 @@
+Bag Attributes
+ friendlyName: so@so.onap.org
+ localKeyID: 54 69 6D 65 20 31 35 36 34 30 35 32 33 31 34 37 38 34
+subject=CN = aai-simulator, emailAddress = , OU = so@so.onap.org, OU = OSAAF, O = ONAP, C = US
+
+issuer=C = US, O = ONAP, OU = OSAAF, CN = intermediateCA_9
+
+-----BEGIN CERTIFICATE-----
+MIIEBzCCAu+gAwIBAgIIdC1kel7DdnYwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
+BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp
+bnRlcm1lZGlhdGVDQV85MB4XDTE5MDcyNTEwNTgzNFoXDTIwMDcyNTEwNTgzNFow
+bjEWMBQGA1UEAwwNYWFpLXNpbXVsYXRvcjEPMA0GCSqGSIb3DQEJARYAMRcwFQYD
+VQQLDA5zb0Bzby5vbmFwLm9yZzEOMAwGA1UECwwFT1NBQUYxDTALBgNVBAoMBE9O
+QVAxCzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+185xCE6cmsY6XB5Dd/5GlfuWjN05KKk3akymxhbJLa9ektlusmuTPt4cnxD+e4b6
+dymqHzQ6C206TBK1jaDzcF07Ag7VTpxmlgaSukQ+aZoXfIcs80lWCLnNvC2MrOuh
+9uhUILAmuddo01cIHJvti5R2g6BEirCGsVKBSwmXRotxHyzUg9IwOpeGy0G1ZDjU
+OiMqY5qOonVTEz1AganctdiWK1/eZ5IBD7gQwckS5n1a6RYMVSnr1vKLoiZq76Bp
+wKy3EBX16jlmQMC5Aj9/GDezJg0bPvlikL3VUsC76DRShucsxS3SzVxeAJ5nsH8S
+qUElpbe3uabhFG2qKmtvdwIDAQABo4HPMIHMMAkGA1UdEwQCMAAwDgYDVR0PAQH/
+BAQDAgXgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBUBgNVHSME
+TTBLgBSB95lbELnIjN7zUl7qTmmgQz6s3aEwpC4wLDEOMAwGA1UECwwFT1NBQUYx
+DTALBgNVBAoMBE9OQVAxCzAJBgNVBAYTAlVTggEHMB0GA1UdDgQWBBSQ54p+SID0
+2p21lUHY9YC1ZZfkZTAYBgNVHREEETAPgg1hYWktc2ltdWxhdG9yMA0GCSqGSIb3
+DQEBCwUAA4IBAQBRGK6Iyjc/0bC3+qjPuNwSlu1pUcgHtgxP/oTU5f9xMSkSjIP0
+weVnIEGOwlW8GRbDPQza14AHETTxJ17rv6p6h7l/dZZmbMPl2S+QXGptgDWR6zY7
+q5ROecGcQzgto6lTMcKgBMW+ct3Tb3khMqP6ewzGz85SY7BgyVE7HFG9M5BM3NhX
+ovAcj93C24DFKLDKxHrrsVIROlFk6QW2+kb0zo1YzVc6NNJY2ViXBrM5zrG21tDj
+VEv0JaHKPYhzWCb7ZcSSo/ftZ2yDsRGS8r6DK5sYCfLifloMVJhF04hOC+ZbxiiB
+JgYniQPmb0Zj5BfXWovdAe/89wr5aokQ3GZL
+-----END CERTIFICATE-----
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml
index 97d4d7d7..3dd82228 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml
@@ -32,6 +32,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 2e19f01f..a2f47ade 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
@@ -19,8 +19,9 @@
*/
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.PROJECT_CACHE;
import java.util.Arrays;
-import org.onap.so.aai.simulator.utils.Constant;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
@@ -44,9 +45,12 @@ public class ApplicationConfigration {
@Bean
public CacheManager cacheManager() {
- final Cache inlineResponse201 = new ConcurrentMapCache(Constant.CUSTOMER_CACHE);
final SimpleCacheManager manager = new SimpleCacheManager();
- manager.setCaches(Arrays.asList(inlineResponse201));
+ manager.setCaches(Arrays.asList(getCache(CUSTOMER_CACHE), getCache(PROJECT_CACHE)));
return manager;
}
+
+ private Cache getCache(final String name) {
+ return new ConcurrentMapCache(name);
+ }
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/WebSecurityConfigImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/WebSecurityConfigImpl.java
index 2e96b9fd..a4a1fb11 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/WebSecurityConfigImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/configration/WebSecurityConfigImpl.java
@@ -19,7 +19,7 @@
*/
package org.onap.so.aai.simulator.configration;
-import org.onap.so.aai.simulator.utils.Constant;
+import org.onap.so.aai.simulator.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@@ -53,7 +53,7 @@ public class WebSecurityConfigImpl extends WebSecurityConfigurerAdapter {
@Override
protected void configure(final HttpSecurity http) throws Exception {
- http.csrf().disable().authorizeRequests().antMatchers(Constant.BUSINESS_URL + "/**/**").authenticated().and()
+ http.csrf().disable().authorizeRequests().antMatchers(Constants.BUSINESS_URL + "/**/**").authenticated().and()
.httpBasic();
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/AaiSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/AaiSimulatorController.java
index 67cc34ff..af0a0150 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/AaiSimulatorController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/AaiSimulatorController.java
@@ -19,10 +19,9 @@
*/
package org.onap.so.aai.simulator.controller;
-import static org.onap.so.aai.simulator.utils.Constant.HEALTHY;
-import javax.ws.rs.PathParam;
+import static org.onap.so.aai.simulator.utils.Constants.HEALTHY;
import javax.ws.rs.core.MediaType;
-import org.onap.so.aai.simulator.utils.Constant;
+import org.onap.so.aai.simulator.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@@ -37,7 +36,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
*
*/
@Controller
-@RequestMapping(path = Constant.BASE_URL)
+@RequestMapping(path = Constants.BASE_URL)
public class AaiSimulatorController {
private static final Logger LOGGER = LoggerFactory.getLogger(AaiSimulatorController.class);
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 8f55d644..b5682f02 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
@@ -19,9 +19,10 @@
*/
package org.onap.so.aai.simulator.controller;
-import static org.onap.so.aai.simulator.utils.Constant.BUSINESS_URL;
-import static org.onap.so.aai.simulator.utils.Constant.ERROR_MESSAGE;
-import static org.onap.so.aai.simulator.utils.Constant.ERROR_MESSAGE_ID;
+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.Utils.getResourceVersion;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
@@ -29,7 +30,7 @@ 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.so.aai.simulator.service.providers.CacheServiceProvider;
+import org.onap.so.aai.simulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aai.simulator.utils.RequestErrorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,19 +50,18 @@ import org.springframework.web.bind.annotation.RequestParam;
*
*/
@Controller
-@RequestMapping(path = BUSINESS_URL)
+@RequestMapping(path = CUSTOMER_URL)
public class BusinessController {
private static final Logger LOGGER = LoggerFactory.getLogger(BusinessController.class);
- private final CacheServiceProvider cacheServiceProvider;
+ private final CustomerCacheServiceProvider cacheServiceProvider;
@Autowired
- public BusinessController(final CacheServiceProvider cacheServiceProvider) {
+ public BusinessController(final CustomerCacheServiceProvider cacheServiceProvider) {
this.cacheServiceProvider = cacheServiceProvider;
}
- @GetMapping(value = "/customers/customer/{global-customer-id}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @GetMapping(value = "{global-customer-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getCustomer(@PathVariable("global-customer-id") final String globalCustomerId,
final HttpServletRequest request) {
LOGGER.info("Will retrieve customer for 'global customer id': {} ...", globalCustomerId);
@@ -77,8 +77,7 @@ public class BusinessController {
return getRequestErrorResponseEntity(request);
}
- @PutMapping(value = "/customers/customer/{global-customer-id}",
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ @PutMapping(value = "/{global-customer-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putCustomer(@RequestBody final Customer customer,
@PathVariable("global-customer-id") final String globalCustomerId, final HttpServletRequest request) {
@@ -93,8 +92,7 @@ public class BusinessController {
}
- @GetMapping(
- value = "/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}",
+ @GetMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}",
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getCustomer(@PathVariable("global-customer-id") final String globalCustomerId,
@PathVariable("service-type") final String serviceType, final HttpServletRequest request) {
@@ -115,7 +113,7 @@ public class BusinessController {
}
@GetMapping(
- value = "/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances",
+ value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances",
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getSericeInstances(@PathVariable("global-customer-id") final String globalCustomerId,
@PathVariable("service-type") final String serviceType,
@@ -140,7 +138,7 @@ public class BusinessController {
}
@GetMapping(
- value = "/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ 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<?> getSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
@PathVariable("service-type") final String serviceType,
@@ -168,7 +166,7 @@ public class BusinessController {
}
@PutMapping(
- value = "/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ 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<?> putSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
@PathVariable("service-type") final String serviceType,
@@ -185,19 +183,14 @@ public class BusinessController {
if (cacheServiceProvider.putServiceInstance(globalCustomerId, serviceType, serviceInstanceId,
serviceInstance)) {
- ResponseEntity.accepted().build();
+ return ResponseEntity.accepted().build();
}
- LOGGER.error(
- "Couldn't add 'global customer id': {}, 'service type': {} and 'service instance id': {} with depth: {}, resultIndex:{}, resultSize: {} and format: {} to cache",
+ LOGGER.error("Couldn't add 'global customer id': {}, 'service type': {} and 'service instance id': {} to cache",
globalCustomerId, serviceType, serviceInstanceId);
return getRequestErrorResponseEntity(request);
}
- private String getResourceVersion() {
- return System.currentTimeMillis() + "";
- }
-
private ResponseEntity<?> getRequestErrorResponseEntity(final HttpServletRequest request) {
return new ResponseEntity<>(new RequestErrorBuilder().messageId(ERROR_MESSAGE_ID).text(ERROR_MESSAGE)
.variables(request.getMethod(), request.getRequestURI(),
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
new file mode 100644
index 00000000..e88bf22a
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/controller/ProjectController.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.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.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.service.providers.ProjectCacheServiceProvider;
+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;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Controller
+@RequestMapping(path = PROJECT_URL)
+public class ProjectController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProjectController.class);
+
+ private final ProjectCacheServiceProvider cacheServiceProvider;
+
+ @Autowired
+ public ProjectController(final ProjectCacheServiceProvider cacheServiceProvider) {
+ this.cacheServiceProvider = cacheServiceProvider;
+ }
+
+ @PutMapping(value = "/{project-name}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putProject(@RequestBody final Project project,
+ @PathVariable("project-name") final String projectName, final HttpServletRequest request) {
+ LOGGER.info("Will put project for 'project-name': {} ...", project.getProjectName());
+
+ if (project.getResourceVersion() == null || project.getResourceVersion().isEmpty()) {
+ project.setResourceVersion(getResourceVersion());
+
+ }
+ cacheServiceProvider.putProject(projectName, project);
+ return ResponseEntity.accepted().build();
+
+ }
+
+ @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) {
+ 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);
+ }
+
+ LOGGER.error("Couldn't find {} in cache", projectName);
+ return getRequestErrorResponseEntity(request);
+ }
+
+ @PutMapping(value = "/{project-name}/relationship-list/relationship",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putProjectRelationShip(@RequestBody final Relationship relationship,
+ @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) {
+ 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/service/providers/CacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java
index ca0340c6..51fc5546 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProvider.java
@@ -29,7 +29,7 @@ import org.onap.aai.domain.yang.ServiceSubscription;
* @author waqas.ikram@ericsson.com
*
*/
-public interface CacheServiceProvider {
+public interface CustomerCacheServiceProvider {
Optional<Customer> getCustomer(final String globalCustomerId);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java
index 5c55824d..11a82be8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/CustomerCacheServiceProviderImpl.java
@@ -27,7 +27,7 @@ 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.so.aai.simulator.utils.Constant;
+import org.onap.so.aai.simulator.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,20 +40,20 @@ import org.springframework.stereotype.Service;
*
*/
@Service
-public class CacheServiceProviderImpl implements CacheServiceProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(CacheServiceProviderImpl.class);
+public class CustomerCacheServiceProviderImpl implements CustomerCacheServiceProvider {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CustomerCacheServiceProviderImpl.class);
public final CacheManager cacheManager;
@Autowired
- public CacheServiceProviderImpl(final CacheManager cacheManager) {
+ public CustomerCacheServiceProviderImpl(final CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
@Override
public Optional<Customer> getCustomer(final String globalCustomerId) {
LOGGER.info("getting customer from cache using key: {}", globalCustomerId);
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
return Optional.of(value);
@@ -64,7 +64,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
@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(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
cache.put(globalCustomerId, customer);
}
@@ -75,7 +75,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
LOGGER.info("getting service subscription from cache for globalCustomerId: {} and serviceType: {}",
globalCustomerId, serviceType);
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
@@ -91,7 +91,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
public Optional<ServiceInstances> getServiceInstances(final String globalCustomerId, final String serviceType,
final String serviceInstanceName) {
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -119,7 +119,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
@Override
public Optional<ServiceInstance> getServiceInstance(final String globalCustomerId, final String serviceType,
final String serviceInstanceId) {
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -145,7 +145,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
final String serviceInstanceId, final ServiceInstance serviceInstance) {
LOGGER.info("Adding serviceInstance: {} in cache ...", serviceInstance, globalCustomerId);
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ final Cache cache = cacheManager.getCache(Constants.CUSTOMER_CACHE);
final Customer value = cache.get(globalCustomerId, Customer.class);
if (value != null) {
@@ -184,7 +184,7 @@ public class CacheServiceProviderImpl implements CacheServiceProvider {
@Override
public void clearAll() {
- final Cache cache = cacheManager.getCache(Constant.CUSTOMER_CACHE);
+ 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();
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
new file mode 100644
index 00000000..ec9e4e5d
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProvider.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.Project;
+import org.onap.aai.domain.yang.Relationship;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public interface ProjectCacheServiceProvider {
+
+ 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
new file mode 100644
index 00000000..c1148d2f
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.PROJECT_CACHE;
+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;
+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 ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProjectCacheServiceProviderImpl.class);
+
+ public final CacheManager cacheManager;
+
+ @Autowired
+ public ProjectCacheServiceProviderImpl(final CacheManager cacheManager) {
+ this.cacheManager = 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);
+ cache.put(projectName, project);
+ }
+
+
+ @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 Project value = cache.get(projectName, Project.class);
+ if (value != null) {
+ return Optional.of(value);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public boolean putProjectRelationShip(final String projectName, final Relationship relationship) {
+ final Cache cache = cacheManager.getCache(PROJECT_CACHE);
+ final Project value = cache.get(projectName, Project.class);
+ if (value != null) {
+ RelationshipList relationshipList = value.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ value.setRelationshipList(relationshipList);
+ }
+ return relationshipList.getRelationship().add(relationship);
+ }
+ 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();
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java
index 5a85be16..54e5323d 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constants.java
@@ -23,20 +23,26 @@ package org.onap.so.aai.simulator.utils;
* @author waqas.ikram@ericsson.com
*
*/
-public class Constant {
+public class Constants {
public static final String BASE_URL = "/simulator/aai/v15/";
- public static final String BUSINESS_URL = BASE_URL + "/business/";
+ public static final String BUSINESS_URL = BASE_URL + "/business";
+
+ public static final String CUSTOMER_URL = BUSINESS_URL + "/customers/customer/";
+
+ public static final String PROJECT_URL = BUSINESS_URL + "/projects/project/";
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 ERROR_MESSAGE_ID = "SVC3001";
public static final String ERROR_MESSAGE = "Resource not found for %1 using id %2 (msg=%3) (ec=%4)";
- private Constant() {}
+ 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
new file mode 100644
index 00000000..db90a235
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Utils.java
@@ -0,0 +1,51 @@
+/*-
+ * ============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;
+
+import static org.onap.so.aai.simulator.utils.Constants.ERROR_MESSAGE;
+import static org.onap.so.aai.simulator.utils.Constants.ERROR_MESSAGE_ID;
+import javax.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class Utils {
+
+ private static final String EMPTY_STRING = "";
+
+ public static final String getResourceVersion() {
+ return System.currentTimeMillis() + EMPTY_STRING;
+ }
+
+ 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);
+ }
+
+
+ private Utils() {}
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
index f0d7ba76..d4f42992 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
@@ -2,7 +2,11 @@ server:
port: 9993
tomcat:
max-threads: 4
-ssl-enable: false
+ ssl:
+ key-store: classpath:keystore/org.onap.so.p12
+ key-store-password: 'u!@JQoYD])@ykq.NKM,O7iA.'
+ keyStoreType: PKCS12
+ssl-enable: true
spring:
security:
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/keystore/org.onap.so.p12 b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/keystore/org.onap.so.p12
new file mode 100644
index 00000000..015f2bf6
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/keystore/org.onap.so.p12
Binary files differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/AaiSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/AaiSimulatorControllerTest.java
index bde46f42..59d3a556 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/AaiSimulatorControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/AaiSimulatorControllerTest.java
@@ -22,7 +22,7 @@ package org.onap.so.aai.simulator.controller;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.so.aai.simulator.utils.Constant;
+import org.onap.so.aai.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;
@@ -54,11 +54,11 @@ public class AaiSimulatorControllerTest {
final String url = getBaseUrl() + "/healthcheck";
final ResponseEntity<String> object = restTemplate.getForEntity(url, String.class);
- assertEquals(Constant.HEALTHY, object.getBody());
+ assertEquals(Constants.HEALTHY, object.getBody());
}
private String getBaseUrl() {
- return "http://localhost:" + port + Constant.BASE_URL;
+ return "https://localhost:" + port + Constants.BASE_URL;
}
}
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 d317e6b6..341c1b38 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,9 +23,12 @@ 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.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 java.io.IOException;
-import java.util.Base64;
+import java.nio.file.Files;
import java.util.Optional;
import java.util.UUID;
import org.junit.After;
@@ -35,8 +38,8 @@ 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.so.aai.simulator.service.providers.CacheServiceProvider;
-import org.onap.so.aai.simulator.utils.Constant;
+import org.onap.so.aai.simulator.service.providers.CustomerCacheServiceProvider;
+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.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +49,6 @@ 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.core.io.ClassPathResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -54,8 +56,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
/**
* @author waqas.ikram@ericsson.com
@@ -83,9 +83,7 @@ public class BusinessControllerTest {
private static final String GLOBAL_CUSTOMER_ID = "DemoCustomer";
- private static final String CUSTOMERS_URL = Constant.BUSINESS_URL + "customers/customer/" + GLOBAL_CUSTOMER_ID;
-
- private static final String PASSWORD = "aai.onap.org:demo123456!";
+ private static final String CUSTOMERS_URL = Constants.CUSTOMER_URL + GLOBAL_CUSTOMER_ID;
@LocalServerPort
private int port;
@@ -97,7 +95,7 @@ public class BusinessControllerTest {
private String username;
@Autowired
- private CacheServiceProvider cacheServiceProvider;
+ private CustomerCacheServiceProvider cacheServiceProvider;
@After
public void after() {
@@ -106,8 +104,7 @@ public class BusinessControllerTest {
@Test
public void test_putCustomer_successfullyAddedToCache() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
- final ResponseEntity<Void> actual = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> actual = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
assertTrue(cacheServiceProvider.getCustomer(GLOBAL_CUSTOMER_ID).isPresent());
@@ -115,10 +112,9 @@ public class BusinessControllerTest {
@Test
public void test_getCustomer_ableToRetrieveCustomer() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl();
- invokeHttpPut(url, customer);
+ invokeHttpPut(url, getCustomer());
final ResponseEntity<Customer> actual =
restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), Customer.class);
@@ -145,18 +141,17 @@ public class BusinessControllerTest {
final ServiceException serviceException = actualError.getServiceException();
assertNotNull(serviceException);
- assertEquals(Constant.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(Constant.ERROR_MESSAGE, serviceException.getText());
+ assertEquals(Constants.ERROR_MESSAGE_ID, serviceException.getMessageId());
+ assertEquals(Constants.ERROR_MESSAGE, serviceException.getText());
assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
}
@Test
public void test_getServiceSubscription_ableToRetrieveServiceSubscriptionFromCache() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL;
- invokeHttpPut(getCustomerEndPointUrl(), customer);
+ invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
final ResponseEntity<ServiceSubscription> actual = restTemplate.exchange(url, HttpMethod.GET,
new HttpEntity<>(getHttpHeaders()), ServiceSubscription.class);
@@ -172,18 +167,14 @@ public class BusinessControllerTest {
@Test
public void test_putSericeInstance_ableToRetrieveServiceInstanceFromCache() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ServiceInstance serviceInstance =
- getObjectFromFile(getFile("test-data/service-instance.json"), ServiceInstance.class);
-
- invokeHttpPut(url, serviceInstance);
+ invokeHttpPut(url, getServiceInstance());
final Optional<ServiceInstance> actual =
cacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
@@ -199,18 +190,14 @@ public class BusinessControllerTest {
@Test
public void test_getSericeInstance_usingServiceInstanceName_ableToRetrieveServiceInstanceFromCache()
throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ServiceInstance serviceInstance =
- getObjectFromFile(getFile("test-data/service-instance.json"), ServiceInstance.class);
-
- invokeHttpPut(url, serviceInstance);
+ invokeHttpPut(url, getServiceInstance());
final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
+ "?service-instance-name=" + SERVICE_NAME;
@@ -231,18 +218,14 @@ public class BusinessControllerTest {
@Test
public void test_getSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ServiceInstance serviceInstance =
- getObjectFromFile(getFile("test-data/service-instance.json"), ServiceInstance.class);
-
- invokeHttpPut(url, serviceInstance);
+ invokeHttpPut(url, getServiceInstance());
final ResponseEntity<ServiceInstance> actual =
restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
@@ -259,21 +242,17 @@ public class BusinessControllerTest {
@Test
public void test_getSericeInstance_usinginvalidServiceInstanceId_shouldReturnError() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ServiceInstance serviceInstance =
- getObjectFromFile(getFile("test-data/service-instance.json"), ServiceInstance.class);
+ invokeHttpPut(url, getServiceInstance());
- invokeHttpPut(url, serviceInstance);
-
- String invalidServiceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
- + "/service-instance/" + UUID.randomUUID();
+ final String invalidServiceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL
+ + SERVICE_INSTANCES_URL + "/service-instance/" + UUID.randomUUID();
final ResponseEntity<RequestError> actual = restTemplate.exchange(invalidServiceInstanceUrl, HttpMethod.GET,
new HttpEntity<>(getHttpHeaders()), RequestError.class);
@@ -284,26 +263,24 @@ public class BusinessControllerTest {
final ServiceException serviceException = actualError.getServiceException();
assertNotNull(serviceException);
- assertEquals(Constant.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(Constant.ERROR_MESSAGE, serviceException.getText());
+ assertEquals(Constants.ERROR_MESSAGE_ID, serviceException.getMessageId());
+ assertEquals(Constants.ERROR_MESSAGE, serviceException.getText());
assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
}
@Test
- public void test_getSericeInstance_usinginvalidServiceInstanceName_shouldReturnError() throws Exception {
- final Customer customer = getCustomer(getFile("test-data/business-customer.json"));
+ public void test_getSericeInstance_usingInvalidServiceInstanceName_shouldReturnError() throws Exception {
final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), customer);
+ final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ServiceInstance serviceInstance =
- getObjectFromFile(getFile("test-data/service-instance.json"), ServiceInstance.class);
+ final ResponseEntity<Void> putRequestReponse = invokeHttpPut(url, getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, putRequestReponse.getStatusCode());
- invokeHttpPut(url, serviceInstance);
final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
+ "?service-instance-name=Dummy&depth=2";
@@ -317,14 +294,18 @@ public class BusinessControllerTest {
final ServiceException serviceException = actualError.getServiceException();
assertNotNull(serviceException);
- assertEquals(Constant.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(Constant.ERROR_MESSAGE, serviceException.getText());
+ assertEquals(Constants.ERROR_MESSAGE_ID, serviceException.getMessageId());
+ assertEquals(Constants.ERROR_MESSAGE, serviceException.getText());
assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
}
+ private String getCustomer() throws Exception, IOException {
+ return getJsonString("test-data/business-customer.json");
+ }
+
private String getCustomerEndPointUrl() {
- return getBaseUrl() + CUSTOMERS_URL;
+ return TestUtils.getBaseUrl(port) + CUSTOMERS_URL;
}
private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
@@ -337,32 +318,11 @@ public class BusinessControllerTest {
}
private HttpHeaders getHttpHeaders() {
- final HttpHeaders requestHeaders = new HttpHeaders();
- requestHeaders.add("Authorization", getBasicAuth());
- return requestHeaders;
- }
-
- private File getFile(final String file) throws IOException {
- return new ClassPathResource(file).getFile();
- }
-
- private Customer getCustomer(final File file) throws Exception {
- return getObjectFromFile(file, Customer.class);
- }
-
- private <T> T getObjectFromFile(final File file, final Class<T> clazz) throws Exception {
- final ObjectMapper mapper = new ObjectMapper();
- mapper.registerModule(new JaxbAnnotationModule());
-
- return mapper.readValue(file, clazz);
- }
-
- private String getBasicAuth() {
- return "Basic " + new String(Base64.getEncoder().encodeToString((username + ":" + PASSWORD).getBytes()));
+ return TestUtils.getHttpHeaders(username);
}
- private String getBaseUrl() {
- return "http://localhost:" + port;
+ private String getServiceInstance() throws Exception, IOException {
+ return getJsonString("test-data/service-instance.json");
}
}
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
new file mode 100644
index 00000000..73fdb2c5
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/ProjectControllerTest.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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.controller.TestUtils.getFile;
+import static org.onap.so.aai.simulator.controller.TestUtils.getHttpHeaders;
+import static org.onap.so.aai.simulator.controller.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.service.providers.ProjectCacheServiceProvider;
+import org.onap.so.aai.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.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 ProjectControllerTest {
+
+ private static final String RELATIONSHIP_URL = "/relationship-list/relationship";
+
+ private static final String BUSINESS_PROJECT_JSON_FILE = "test-data/business-project.json";
+
+ private static final String PROJECT_RELATION_SHIP_JSON_FILE = "test-data/business-project-relation-ship.json";
+
+ private static final String PROJECT_NAME_VALUE = "PROJECT_NAME_VALUE";
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Value("${spring.security.username}")
+ private String username;
+
+ @Autowired
+ private ProjectCacheServiceProvider cacheServiceProvider;
+
+ @After
+ public void after() {
+ cacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_putProject_successfullyAddedToCache() 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<Project> actualResponse = invokeHttpGet(url, Project.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final Project actualProject = actualResponse.getBody();
+ assertEquals(PROJECT_NAME_VALUE, actualProject.getProjectName());
+ assertNotNull(actualProject.getResourceVersion());
+
+ }
+
+ @Test
+ public void test_putProjectRelationShip_successfullyAddedToCache() throws Exception {
+ final String url = getProjectEndPointUrl() + "/" + PROJECT_NAME_VALUE;
+ final ResponseEntity<Void> actual = invokeHttpPut(url, getJsonString(BUSINESS_PROJECT_JSON_FILE));
+ assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+
+ final String projectRelationshipUrl = url + RELATIONSHIP_URL;
+
+ final ResponseEntity<Void> putResponse = invokeHttpPut(projectRelationshipUrl, getRelationship());
+
+ assertEquals(HttpStatus.ACCEPTED, putResponse.getStatusCode());
+
+ final ResponseEntity<Project> actualResponse = invokeHttpGet(url, Project.class);
+
+ assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ assertTrue(actualResponse.hasBody());
+ final Project actualProject = actualResponse.getBody();
+ assertEquals(PROJECT_NAME_VALUE, actualProject.getProjectName());
+ assertNotNull(actualProject.getRelationshipList());
+ assertFalse(actualProject.getRelationshipList().getRelationship().isEmpty());
+ assertNotNull(actualProject.getRelationshipList().getRelationship().get(0));
+
+ }
+
+ 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 getProjectEndPointUrl() {
+ return TestUtils.getBaseUrl(port) + Constants.PROJECT_URL;
+ }
+
+ private String getRelationship() throws IOException, Exception {
+ return TestUtils.getJsonString(PROJECT_RELATION_SHIP_JSON_FILE);
+ }
+}
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/controller/TestUtils.java
new file mode 100644
index 00000000..c03f5ceb
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/TestUtils.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.controller;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Base64;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+
+public class TestUtils {
+
+ private static final String PASSWORD = "aai.onap.org:demo123456!";
+
+ public static HttpHeaders getHttpHeaders(final String username) {
+ final HttpHeaders requestHeaders = new HttpHeaders();
+ requestHeaders.add("Authorization", getBasicAuth(username));
+ requestHeaders.setContentType(MediaType.APPLICATION_JSON);
+ return requestHeaders;
+ }
+
+ public static File getFile(final String file) throws IOException {
+ return new ClassPathResource(file).getFile();
+ }
+
+ public static String getJsonString(final String file) throws IOException {
+ return new String(Files.readAllBytes(getFile(file).toPath()));
+ }
+
+ public static <T> T getObjectFromFile(final File file, final Class<T> clazz) throws Exception {
+ final ObjectMapper mapper = new ObjectMapper();
+ mapper.registerModule(new JaxbAnnotationModule());
+
+ return mapper.readValue(file, clazz);
+ }
+
+ public static String getBasicAuth(final String username) {
+ return "Basic " + new String(Base64.getEncoder().encodeToString((username + ":" + PASSWORD).getBytes()));
+ }
+
+ public static String getBaseUrl(final int port) {
+ return "https://localhost:" + port;
+ }
+
+ private TestUtils() {}
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/configuration/TestRestTemplateConfigration.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/configuration/TestRestTemplateConfigration.java
new file mode 100644
index 00000000..6e8ccac6
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/controller/configuration/TestRestTemplateConfigration.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.aai.simulator.controller.configuration;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Configuration
+public class TestRestTemplateConfigration {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestRestTemplateConfigration.class);
+
+ @Bean
+ public TestRestTemplate testRestTemplate() throws Exception {
+
+ final TestRestTemplate testRestTemplate = new TestRestTemplate();
+ ((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRestTemplate().getRequestFactory())
+ .setHttpClient(httpClient());
+ return testRestTemplate;
+
+ }
+
+ private CloseableHttpClient httpClient() throws Exception {
+ final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
+
+ final SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(
+ SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(), new HostnameVerifier() {
+ @Override
+ public boolean verify(final String hostname, final SSLSession session) {
+ LOGGER.warn("Skiping hostname verification ... ");
+ return true;
+ }
+
+ });
+
+ return HttpClients.custom().setSSLSocketFactory(csf).build();
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json
new file mode 100644
index 00000000..9f6e5f35
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json
@@ -0,0 +1,3 @@
+{
+ "related-link": "/aai/v15/business/customers/customer/NordixDemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ae93f2d8-7d06-4eeb-8712-93a2bdb776f6"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project.json
new file mode 100644
index 00000000..f78ddfaf
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project.json
@@ -0,0 +1,3 @@
+{
+ "project-name": "PROJECT_NAME_VALUE"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image
index f6f0fc9b..efd7833f 100644
--- a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image
+++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image
@@ -16,7 +16,7 @@ RUN apk --no-cache add curl netcat-openbsd sudo nss
# Create 'so' user
RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so
-RUN mkdir /app && mkdir /app/config && mkdir /app/logs
+RUN mkdir /app && mkdir /app/config && mkdir /app/logs && mkdir /app/ca-certificates
COPY maven/app.jar /app
COPY configs/logging/logback-spring.xml /app
@@ -27,5 +27,8 @@ RUN chown -R so:so /app && chmod 700 /app/*.sh
# Springboot configuration (required)
VOLUME /app/config
+# CA certificates
+VOLUME /app/ca-certificates
+
WORKDIR /app
CMD ["/app/start-app.sh"]
diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh
index 0ab3d27f..eb8ee2e5 100644
--- a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh
+++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh
@@ -22,6 +22,19 @@
touch /app/app.jar
+if [ "$(ls -1 /app/ca-certificates)" ]; then
+ needUpdate=FALSE
+ for certificate in `ls -1 /app/ca-certificates`; do
+ echo "Installing $certificate in /usr/local/share/ca-certificates"
+ cp /app/ca-certificates/$certificate /usr/local/share/ca-certificates/$certificate
+ needUpdate=TRUE
+ done
+ if [ $needUpdate = TRUE ]; then
+ echo "Updating ca-certificates . . ."
+ update-ca-certificates --fresh
+ fi
+fi
+
if [ -z "$APP" ]; then
echo "CONFIG ERROR: APP environment variable not set"
exit 1