aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/so-simulators
diff options
context:
space:
mode:
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java27
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java37
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java234
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java44
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java49
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java15
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java20
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf-relationship.json (renamed from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json)0
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/line-of-business-related-link.json3
13 files changed, 277 insertions, 164 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
index 537760c8..173b1099 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
@@ -20,12 +20,14 @@
package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.LINES_OF_BUSINESS_URL;
+import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.LineOfBusiness;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.service.providers.LinesOfBusinessCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,7 +84,30 @@ public class LinesOfBusinessController {
return ResponseEntity.ok(platform);
}
LOGGER.error("Unable to find LineOfBusiness in cahce using {}", lineOfBusinessName);
- return getRequestErrorResponseEntity(request);
+ return getRequestErrorResponseEntity(request, LINE_OF_BUSINESS);
+ }
+
+ @PutMapping(value = "/{line-of-business-name}/relationship-list/relationship",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putRelationShip(@PathVariable("line-of-business-name") final String lineOfBusinessName,
+ @RequestBody final Relationship relationship, final HttpServletRequest request) {
+ LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+
+ final Optional<Relationship> optional =
+ cacheServiceProvider.addRelationShip(lineOfBusinessName, relationship, request.getRequestURI());
+
+ if (optional.isPresent()) {
+ final Relationship resultantRelationship = optional.get();
+ LOGGER.info("Relationship add, sending resultant relationship: {} in response ...", resultantRelationship);
+ return ResponseEntity.accepted().body(resultantRelationship);
+ }
+
+ LOGGER.error("Couldn't add {} relationship for 'line-of-business-name': {} ...", relationship.getRelatedTo(),
+ lineOfBusinessName);
+
+ return getRequestErrorResponseEntity(request, LINE_OF_BUSINESS);
+
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
index 5c585189..d0019727 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
@@ -87,7 +87,7 @@ public class PlatformController {
@PutMapping(value = "/{platform-name}/relationship-list/relationship",
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> putSericeInstanceRelationShip(@PathVariable("platform-name") final String platformName,
+ public ResponseEntity<?> putRelationShip(@PathVariable("platform-name") final String platformName,
@RequestBody final Relationship relationship, final HttpServletRequest request) {
LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java
index d4eb634c..dbf5490f 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.LineOfBusiness;
+import org.onap.aai.domain.yang.Relationship;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -32,5 +33,8 @@ public interface LinesOfBusinessCacheServiceProvider extends Clearable {
Optional<LineOfBusiness> getLineOfBusiness(final String lineOfBusinessName);
+ Optional<Relationship> addRelationShip(final String lineOfBusinessName, final Relationship relationship,
+ final String requestURI);
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
index e2255760..07c46472 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
@@ -20,8 +20,14 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.LINES_OF_BUSINESS_CACHE;
+import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS;
+import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.USES;
import java.util.Optional;
import org.onap.aai.domain.yang.LineOfBusiness;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,6 +72,37 @@ public class LinesOfBusinessCacheServiceProviderImpl extends AbstractCacheServic
}
@Override
+ public Optional<Relationship> addRelationShip(final String lineOfBusinessName, final Relationship relationship,
+ final String requestUri) {
+ final Optional<LineOfBusiness> optional = getLineOfBusiness(lineOfBusinessName);
+ if (optional.isPresent()) {
+ final LineOfBusiness lineOfBusiness = optional.get();
+ RelationshipList relationshipList = lineOfBusiness.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ lineOfBusiness.setRelationshipList(relationshipList);
+ }
+ relationshipList.getRelationship().add(relationship);
+
+ LOGGER.info("Successfully added relation to LineOfBusiness with name: {}", lineOfBusinessName);
+ final Relationship resultantRelationship = new Relationship();
+ resultantRelationship.setRelatedTo(LINE_OF_BUSINESS);
+ resultantRelationship.setRelationshipLabel(USES);
+ resultantRelationship.setRelatedLink(requestUri);
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME);
+ relationshipData.setRelationshipValue(lineOfBusiness.getLineOfBusinessName());
+ resultantRelationship.getRelationshipData().add(relationshipData);
+
+ return Optional.of(resultantRelationship);
+
+ }
+ LOGGER.error("Unable to find LineOfBusiness using name: {} ...", lineOfBusinessName);
+ return Optional.empty();
+ }
+
+ @Override
public void clearAll() {
clearCahce(LINES_OF_BUSINESS_CACHE.getName());
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
index daaef336..29b3af99 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
@@ -81,6 +81,10 @@ public class Constants {
public static final String PLATFORM_PLATFORM_NAME = "platform.platform-name";
+ public static final String LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME = "line-of-business.line-of-business-name";
+
+ public static final String LINE_OF_BUSINESS = "line-of-business";
+
public static final String SERVICE_SUBSCRIPTION = "service-subscription";
public static final String CUSTOMER_TYPE = "Customer";
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
index 98b0fa79..438763ed 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
@@ -37,7 +37,8 @@ import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_TYPE;
import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
-import static org.onap.so.aaisimulator.utils.TestUtils.getJsonString;
+import static org.onap.so.aaisimulator.utils.TestUtils.getCustomer;
+import static org.onap.so.aaisimulator.utils.TestUtils.getServiceInstance;
import java.io.IOException;
import java.util.Optional;
import java.util.UUID;
@@ -55,15 +56,13 @@ import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.utils.RequestError;
import org.onap.so.aaisimulator.utils.RequestErrorResponseUtils;
import org.onap.so.aaisimulator.utils.ServiceException;
+import org.onap.so.aaisimulator.utils.TestRestTemplateService;
import org.onap.so.aaisimulator.utils.TestUtils;
-import org.onap.so.simulator.model.UserCredentials;
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.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -81,7 +80,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Configuration
public class BusinessControllerTest {
- private static final String FIREWALL_SERVICE_TTYPE = "Firewall";
+ private static final String FIREWALL_SERVICE_TYPE = "Firewall";
private static final String ORCHESTRATION_STATUS = "Active";
@@ -89,10 +88,7 @@ public class BusinessControllerTest {
private int port;
@Autowired
- private TestRestTemplate restTemplate;
-
- @Autowired
- private UserCredentials userCredentials;
+ private TestRestTemplateService testRestTemplateService;
@Autowired
private CustomerCacheServiceProvider cacheServiceProvider;
@@ -104,20 +100,18 @@ public class BusinessControllerTest {
@Test
public void test_putCustomer_successfullyAddedToCache() throws Exception {
- final ResponseEntity<Void> actual = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
-
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
+ invokeCustomerEndPointAndAssertResponse();
assertTrue(cacheServiceProvider.getCustomer(GLOBAL_CUSTOMER_ID).isPresent());
}
@Test
public void test_getCustomer_ableToRetrieveCustomer() throws Exception {
- final String url = getCustomerEndPointUrl();
+ final String url = getUrl(CUSTOMERS_URL);
- invokeHttpPut(url, getCustomer());
+ final ResponseEntity<Void> response = testRestTemplateService.invokeHttpPut(url, getCustomer(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final ResponseEntity<Customer> actual =
- restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), Customer.class);
+ final ResponseEntity<Customer> actual = testRestTemplateService.invokeHttpGet(url, Customer.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -130,10 +124,9 @@ public class BusinessControllerTest {
@Test
public void test_getCustomer_returnRequestError_ifCustomerNotInCache() throws Exception {
- final String url = getCustomerEndPointUrl();
+ final String url = getUrl(CUSTOMERS_URL);
- final ResponseEntity<RequestError> actual =
- restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), RequestError.class);
+ final ResponseEntity<RequestError> actual = testRestTemplateService.invokeHttpGet(url, RequestError.class);
assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
@@ -149,12 +142,12 @@ public class BusinessControllerTest {
@Test
public void test_getServiceSubscription_ableToRetrieveServiceSubscriptionFromCache() throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL;
+ final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL);
- invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ invokeCustomerEndPointAndAssertResponse();
- final ResponseEntity<ServiceSubscription> actual = restTemplate.exchange(url, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), ServiceSubscription.class);
+ final ResponseEntity<ServiceSubscription> actual =
+ testRestTemplateService.invokeHttpGet(url, ServiceSubscription.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -168,13 +161,9 @@ public class BusinessControllerTest {
@Test
public void test_putSericeInstance_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());
+ invokeCustomerEndPointAndAssertResponse();
+ invokeServiceInstanceEndPointAndAssertResponse();
- invokeHttpPut(url, getServiceInstance());
final Optional<ServiceInstance> actual =
cacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
@@ -191,19 +180,15 @@ public class BusinessControllerTest {
public void test_getSericeInstance_usingServiceInstanceName_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());
+ invokeCustomerEndPointAndAssertResponse();
+ invokeServiceInstanceEndPointAndAssertResponse();
- invokeHttpPut(url, getServiceInstance());
- final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
+ final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
+ "?depth=2&service-instance-name=" + SERVICE_NAME;
- final ResponseEntity<ServiceInstances> actual = restTemplate.exchange(serviceInstanceUrl, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), ServiceInstances.class);
+ final ResponseEntity<ServiceInstances> actual =
+ testRestTemplateService.invokeHttpGet(serviceInstanceUrl, ServiceInstances.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -219,15 +204,13 @@ public class BusinessControllerTest {
public void test_getSericeInstance_usingServiceInstanceName_returnRequestErrorIfnoServiceInstanceFound()
throws Exception {
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ invokeCustomerEndPointAndAssertResponse();
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
+ final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
+ "?depth=2&service-instance-name=" + SERVICE_NAME;
- final ResponseEntity<RequestError> actual = restTemplate.exchange(serviceInstanceUrl, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), RequestError.class);
+ final ResponseEntity<RequestError> actual =
+ testRestTemplateService.invokeHttpGet(serviceInstanceUrl, RequestError.class);
assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -240,16 +223,13 @@ public class BusinessControllerTest {
public void test_getSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+ final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
-
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- invokeHttpPut(url, getServiceInstance());
+ invokeCustomerEndPointAndAssertResponse();
+ invokeServiceInstanceEndPointAndAssertResponse();
final ResponseEntity<ServiceInstance> actual =
- restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
+ testRestTemplateService.invokeHttpGet(url, ServiceInstance.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -264,19 +244,16 @@ public class BusinessControllerTest {
@Test
public void test_getSericeInstance_usinginvalidServiceInstanceId_shouldReturnError() throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+ invokeCustomerEndPointAndAssertResponse();
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ invokeServiceInstanceEndPointAndAssertResponse();
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- invokeHttpPut(url, getServiceInstance());
+ final String invalidServiceInstanceUrl = getUrl(CUSTOMERS_URL, 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);
+ final ResponseEntity<RequestError> actual =
+ testRestTemplateService.invokeHttpGet(invalidServiceInstanceUrl, RequestError.class);
assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
@@ -293,21 +270,15 @@ public class BusinessControllerTest {
@Test
public void test_getSericeInstance_usingInvalidServiceInstanceName_shouldReturnError() throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
-
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ invokeCustomerEndPointAndAssertResponse();
+ invokeServiceInstanceEndPointAndAssertResponse();
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Void> putRequestReponse = invokeHttpPut(url, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, putRequestReponse.getStatusCode());
-
- final String serviceInstanceUrl = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCES_URL
+ final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
+ "?service-instance-name=Dummy&depth=2";
- final ResponseEntity<RequestError> actual = restTemplate.exchange(serviceInstanceUrl, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), RequestError.class);
+ final ResponseEntity<RequestError> actual =
+ testRestTemplateService.invokeHttpGet(serviceInstanceUrl, RequestError.class);
assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
@@ -324,29 +295,21 @@ public class BusinessControllerTest {
@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 String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstancePutResponse = invokeHttpPut(url, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, serviceInstancePutResponse.getStatusCode());
+ invokeCustomerEndPointAndAssertResponse();
+ invokeServiceInstanceEndPointAndAssertResponse();
- final HttpHeaders httpHeaders = getHttpHeaders();
+ final HttpHeaders httpHeaders = testRestTemplateService.getHttpHeaders();
httpHeaders.add(X_HTTP_METHOD_OVERRIDE, HttpMethod.PATCH.toString());
- final HttpEntity<?> orchStatuUpdateServiceInstance =
- getHttpEntity(getOrchStatuUpdateServiceInstance(), httpHeaders);
-
- final ResponseEntity<Void> orchStatuUpdateServiceInstanceResponse =
- invokeHttpPost(orchStatuUpdateServiceInstance, url, getOrchStatuUpdateServiceInstance());
+ final ResponseEntity<Void> orchStatuUpdateServiceInstanceResponse = testRestTemplateService
+ .invokeHttpPost(httpHeaders, url, TestUtils.getOrchStatuUpdateServiceInstance(), Void.class);
assertEquals(HttpStatus.ACCEPTED, orchStatuUpdateServiceInstanceResponse.getStatusCode());
-
final ResponseEntity<ServiceInstance> actual =
- restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
+ testRestTemplateService.invokeHttpGet(url, ServiceInstance.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -362,115 +325,76 @@ public class BusinessControllerTest {
@Test
public void test_putServiceSubscription_successfullyAddedToCache() throws Exception {
final String serviceSubscriptionurl =
- getCustomerEndPointUrl() + "/service-subscriptions/service-subscription/" + FIREWALL_SERVICE_TTYPE;
+ getUrl(CUSTOMERS_URL, "/service-subscriptions/service-subscription/", FIREWALL_SERVICE_TYPE);
- final ResponseEntity<Void> customerPutResponse = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
- assertEquals(HttpStatus.ACCEPTED, customerPutResponse.getStatusCode());
+ invokeCustomerEndPointAndAssertResponse();
- final ResponseEntity<Void> serviceSubscriptionPutResponse =
- invokeHttpPut(serviceSubscriptionurl, getServiceSubscription());
- assertEquals(HttpStatus.ACCEPTED, serviceSubscriptionPutResponse.getStatusCode());
+ final ResponseEntity<Void> responseEntity = testRestTemplateService.invokeHttpPut(serviceSubscriptionurl,
+ TestUtils.getServiceSubscription(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- final ResponseEntity<ServiceSubscription> actual = restTemplate.exchange(serviceSubscriptionurl, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), ServiceSubscription.class);
+ final ResponseEntity<ServiceSubscription> actual =
+ testRestTemplateService.invokeHttpGet(serviceSubscriptionurl, ServiceSubscription.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
final ServiceSubscription actualServiceSubscription = actual.getBody();
- assertEquals(FIREWALL_SERVICE_TTYPE, actualServiceSubscription.getServiceType());
+ assertEquals(FIREWALL_SERVICE_TYPE, actualServiceSubscription.getServiceType());
}
@Test
public void test_putSericeInstanceRelatedTo_ableToRetrieveServiceInstanceFromCache() throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
+ final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
+ invokeCustomerEndPointAndAssertResponse();
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Void> responseEntity = invokeHttpPut(url, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+ invokeServiceInstanceEndPointAndAssertResponse();
final String relationShipUrl =
- getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL + RELATIONSHIP_URL;
+ getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL, RELATIONSHIP_URL);
+ final ResponseEntity<Relationship> responseEntity2 = testRestTemplateService.invokeHttpPut(relationShipUrl,
+ TestUtils.getRelationShipJsonObject(), Relationship.class);
- final HttpEntity<?> httpEntity = getHttpEntity(getRelationShipJsonObject());
- final ResponseEntity<Relationship> responseEntity2 =
- restTemplate.exchange(relationShipUrl, HttpMethod.PUT, httpEntity, Relationship.class);
assertEquals(HttpStatus.ACCEPTED, responseEntity2.getStatusCode());
final String genericVnfUrl = TestUtils.getBaseUrl(port) + GENERIC_VNF_URL + VNF_ID;
- final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, getGenericVnf());
+ final ResponseEntity<Void> genericVnfResponse =
+ testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- final ResponseEntity<GenericVnfs> actual =
- restTemplate.exchange(url + RELATED_TO_URL + "?vnf-name=" + GENERIC_VNF_NAME, HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), GenericVnfs.class);
+ final ResponseEntity<GenericVnfs> actual = testRestTemplateService
+ .invokeHttpGet(url + RELATED_TO_URL + "?vnf-name=" + GENERIC_VNF_NAME, GenericVnfs.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
-
+
assertTrue(actual.hasBody());
final GenericVnfs genericVnfs = actual.getBody();
assertFalse(genericVnfs.getGenericVnf().isEmpty());
final GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
assertEquals(GENERIC_VNF_NAME, genericVnf.getVnfName());
-
-
- }
-
- 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;
- }
-
- 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 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 void invokeServiceInstanceEndPointAndAssertResponse() throws IOException {
+ final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
+ final ResponseEntity<Void> responseEntity =
+ testRestTemplateService.invokeHttpPut(url, getServiceInstance(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
}
- private HttpHeaders getHttpHeaders() {
- return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
- }
+ private void invokeCustomerEndPointAndAssertResponse() throws Exception, IOException {
+ final ResponseEntity<Void> response =
+ testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), getCustomer(), Void.class);
- private String getServiceInstance() throws Exception, IOException {
- return getJsonString("test-data/service-instance.json");
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
}
- private String getOrchStatuUpdateServiceInstance() throws Exception, IOException {
- return getJsonString("test-data/service-instance-orch-status-update.json");
- }
- private String getRelationShipJsonObject() throws IOException {
- return getJsonString("test-data/service-Instance-relationShip.json");
- }
-
- private String getGenericVnf() throws IOException {
- return getJsonString("test-data/generic-vnf.json");
+ private String getUrl(final String... urls) {
+ return TestUtils.getUrl(port, urls);
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
index c219d3b8..84120979 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
@@ -27,6 +27,7 @@ import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.PLATFORM_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
@@ -49,6 +50,7 @@ import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
+import org.onap.so.aaisimulator.service.providers.LinesOfBusinessCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.PlatformCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestRestTemplateService;
@@ -86,6 +88,9 @@ public class GenericVnfsControllerTest {
private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
@Autowired
+ private LinesOfBusinessCacheServiceProvider linesOfBusinessCacheServiceProvider;
+
+ @Autowired
private PlatformCacheServiceProvider platformVnfCacheServiceProvider;
@After
@@ -93,6 +98,7 @@ public class GenericVnfsControllerTest {
customerCacheServiceProvider.clearAll();
genericVnfCacheServiceProvider.clearAll();
platformVnfCacheServiceProvider.clearAll();
+ linesOfBusinessCacheServiceProvider.clearAll();
}
@Test
@@ -222,6 +228,43 @@ public class GenericVnfsControllerTest {
}
+ @Test
+ public void test_putGenericVnfRelationToLineOfBusiness_successfullyAddedToCache() throws Exception {
+ addCustomerServiceAndGenericVnf();
+
+ final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final ResponseEntity<Void> responseEntity =
+ testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
+ .invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getLineOfBusinessRelatedLink(), Void.class);
+
+ assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
+
+ final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
+ assertTrue(genericVnfOptional.isPresent());
+ final GenericVnf actualGenericVnf = genericVnfOptional.get();
+ final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
+ assertNotNull(relationshipList);
+ assertFalse(relationshipList.getRelationship().isEmpty());
+
+ final Relationship relationship = relationshipList.getRelationship().get(0);
+
+ assertEquals(Constants.USES, relationship.getRelationshipLabel());
+ assertFalse(relationship.getRelationshipData().isEmpty());
+ assertEquals(1, relationship.getRelationshipData().size());
+
+ final List<RelationshipData> relationshipData = relationship.getRelationshipData();
+
+ final RelationshipData lineOfBusinessRelationshipData =
+ getRelationshipData(relationshipData, Constants.LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME);
+ assertNotNull(lineOfBusinessRelationshipData);
+ assertEquals(LINE_OF_BUSINESS_NAME, lineOfBusinessRelationshipData.getRelationshipValue());
+
+ }
+
private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
final ResponseEntity<Void> customerResponse =
testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
@@ -243,7 +286,6 @@ public class GenericVnfsControllerTest {
return relationshipData.stream().filter(data -> data.getRelationshipKey().equals(key)).findFirst().orElse(null);
}
-
private String getUrl(final String... urls) {
return TestUtils.getUrl(port, urls);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
index ba92b02d..d5816d75 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
@@ -20,15 +20,23 @@
package org.onap.so.aaisimulator.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.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
+import java.util.List;
+import java.util.Optional;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.domain.yang.LineOfBusiness;
+import org.onap.aai.domain.yang.RelatedToProperty;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.so.aaisimulator.service.providers.LinesOfBusinessCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
import org.onap.so.aaisimulator.utils.TestRestTemplateService;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -72,7 +80,8 @@ public class LinesOfBusinessControllerTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, lineOfBusinessResponse.getStatusCode());
- final ResponseEntity<LineOfBusiness> response = testRestTemplateService.invokeHttpGet(url, LineOfBusiness.class);
+ final ResponseEntity<LineOfBusiness> response =
+ testRestTemplateService.invokeHttpGet(url, LineOfBusiness.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.hasBody());
@@ -83,6 +92,44 @@ public class LinesOfBusinessControllerTest {
}
+ @Test
+ public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
+
+ final String url = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
+ final ResponseEntity<Void> response =
+ testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final String relationShipUrl = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME, RELATIONSHIP_URL);
+
+ final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
+ TestUtils.getGenericVnfRelationShip(), Relationship.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ final Optional<LineOfBusiness> optional =
+ linesOfBusinessCacheServiceProvider.getLineOfBusiness(LINE_OF_BUSINESS_NAME);
+ assertTrue(optional.isPresent());
+
+ final LineOfBusiness actual = optional.get();
+
+ assertNotNull(actual.getRelationshipList());
+ final List<Relationship> relationshipList = actual.getRelationshipList().getRelationship();
+ assertFalse("Relationship list should not be empty", relationshipList.isEmpty());
+ final Relationship relationship = relationshipList.get(0);
+
+ assertFalse("RelationshipData list should not be empty", relationship.getRelationshipData().isEmpty());
+ assertFalse("RelatedToProperty list should not be empty", relationship.getRelatedToProperty().isEmpty());
+
+ final RelationshipData relationshipData = relationship.getRelationshipData().get(0);
+ assertEquals(Constants.GENERIC_VNF_VNF_ID, relationshipData.getRelationshipKey());
+ assertEquals(TestConstants.VNF_ID, relationshipData.getRelationshipValue());
+
+ final RelatedToProperty relatedToProperty = relationship.getRelatedToProperty().get(0);
+ assertEquals(Constants.GENERIC_VNF_VNF_NAME, relatedToProperty.getPropertyKey());
+ assertEquals(TestConstants.GENERIC_VNF_NAME, relatedToProperty.getPropertyValue());
+
+ }
+
private String getUrl(final String... urls) {
return TestUtils.getUrl(port, urls);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
index e6cf399f..ac8d295a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
@@ -103,7 +103,7 @@ public class PlatformControllerTest {
final String platformRelationShipUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME, RELATIONSHIP_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService
- .invokeHttpPut(platformRelationShipUrl, TestUtils.getPlatformRelationShip(), Relationship.class);
+ .invokeHttpPut(platformRelationShipUrl, TestUtils.getGenericVnfRelationShip(), Relationship.class);
assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
final Optional<Platform> optional = platformCacheServiceProvider.getPlatform(PLATFORM_NAME);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java
index 698473ff..018c056a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java
@@ -51,12 +51,23 @@ public class TestRestTemplateService {
final HttpEntity<?> httpEntity = getHttpEntity(obj);
return restTemplate.exchange(url, HttpMethod.PUT, httpEntity, clazz);
}
-
+
+ public <T> ResponseEntity<T> invokeHttpPost(final String url, final Object obj, final Class<T> clazz) {
+ final HttpEntity<?> httpEntity = getHttpEntity(obj);
+ return restTemplate.exchange(url, HttpMethod.POST, httpEntity, clazz);
+ }
+
+ public <T> ResponseEntity<T> invokeHttpPost(final HttpHeaders headers, final String url, final Object obj,
+ final Class<T> clazz) {
+ final HttpEntity<Object> entity = new HttpEntity<>(obj, headers);
+ return restTemplate.exchange(url, HttpMethod.POST, entity, clazz);
+ }
+
private HttpEntity<?> getHttpEntity(final Object obj) {
return new HttpEntity<>(obj, getHttpHeaders());
}
- private HttpHeaders getHttpHeaders() {
+ public HttpHeaders getHttpHeaders() {
return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
index c94baac4..e91e1dc2 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
@@ -72,6 +72,10 @@ public class TestUtils {
return getJsonString("test-data/business-customer.json");
}
+ public static String getServiceSubscription() throws IOException {
+ return getJsonString("test-data/service-subscription.json");
+ }
+
public static String getServiceInstance() throws IOException {
return getJsonString("test-data/service-instance.json");
}
@@ -87,13 +91,17 @@ public class TestUtils {
public static String getPlatformRelatedLink() throws IOException {
return getJsonString("test-data/platform-related-link.json");
}
+
+ public static String getLineOfBusinessRelatedLink() throws IOException {
+ return getJsonString("test-data/line-of-business-related-link.json");
+ }
public static String getPlatform() throws IOException {
return getJsonString("test-data/platform.json");
}
- public static String getPlatformRelationShip() throws IOException {
- return getJsonString("test-data/platform-relationship.json");
+ public static String getGenericVnfRelationShip() throws IOException {
+ return getJsonString("test-data/generic-vnf-relationship.json");
}
public static String getLineOfBusiness() throws IOException {
@@ -114,9 +122,17 @@ public class TestUtils {
public static String getOwningEntity() throws IOException {
return getJsonString("test-data/owning-entity.json");
+ }
+ public static String getOrchStatuUpdateServiceInstance() throws IOException {
+ return getJsonString("test-data/service-instance-orch-status-update.json");
}
+ public static String getRelationShipJsonObject() throws IOException {
+ return getJsonString("test-data/service-Instance-relationShip.json");
+ }
+
+
public static String getUrl(final int port, final String... urls) {
final UriComponentsBuilder baseUri = UriComponentsBuilder.fromUriString("https://localhost:" + port);
for (final String url : urls) {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf-relationship.json
index a53ffa9c..a53ffa9c 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf-relationship.json
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/line-of-business-related-link.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/line-of-business-related-link.json
new file mode 100644
index 00000000..5ec5e9f0
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/line-of-business-related-link.json
@@ -0,0 +1,3 @@
+{
+ "related-link": "/business/lines-of-business/line-of-business/LINE_OF_BUSINESS_1"
+}