Adding line of business relationship endpoint 43/93943/2
authorwaqas.ikram <waqas.ikram@est.tech>
Tue, 20 Aug 2019 10:46:55 +0000 (10:46 +0000)
committerWaqas Ikram <waqas.ikram@est.tech>
Tue, 20 Aug 2019 10:47:10 +0000 (10:47 +0000)
Change-Id: I7e03a8faf50c0712e67c2f70819abbd2db0e25a6
Issue-ID: SO-2219
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
16 files changed:
plans/so/integration-etsi-testing/config/aai-simulator-populate-data/line-of-business.json [new file with mode: 0644]
plans/so/integration-etsi-testing/config/aai-simulator-populate-data/platform.json [new file with mode: 0644]
plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProvider.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf-relationship.json [moved from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json with 100% similarity]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/line-of-business-related-link.json [new file with mode: 0644]

diff --git a/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/line-of-business.json b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/line-of-business.json
new file mode 100644 (file)
index 0000000..a551f8f
--- /dev/null
@@ -0,0 +1,3 @@
+{
+    "line-of-business-name": "EtsiCsitLineOfBusiness"
+}
diff --git a/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/platform.json b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/platform.json
new file mode 100644 (file)
index 0000000..97e468e
--- /dev/null
@@ -0,0 +1,3 @@
+{
+    "platform-name": "EtsiCsitPlatform"
+}
index 1a00f71..2a805d6 100755 (executable)
@@ -54,6 +54,8 @@ populate_aai_simulator()
  CUSTOMER_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/customer.json
  PROJECT_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/project.json
  OWNING_ENTITY_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/owning-entity.json
+ LINE_OF_BUSINESS_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/line-of-business.json
+ PLATFORM_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/platform.json
  STATUS_CODE_ACCEPTED="202"
 
  echo "$SCRIPT_NAME $(current_timestamp): checking health of AAI Simulator"
@@ -92,6 +94,22 @@ populate_aai_simulator()
      exit 1
  fi
 
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Line Of Business"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/lines-of-business/line-of-business/EtsiCsitLineOfBusiness -X PUT -d @$"$LINE_OF_BUSINESS_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+     echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put line of business data in AAI Simulator. Status code received: $status_code"
+     exit 1
+ fi
+
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Platform"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/platforms/platform/EtsiCsitPlatform -X PUT -d @$"$PLATFORM_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+     echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put platform data in AAI Simulator. Status code received: $status_code"
+     exit 1
+ fi
+
  echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator Populated Successfully"
 }
 
index 537760c..173b109 100644 (file)
 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);
+
     }
 
 }
index 5c58518..d001972 100644 (file)
@@ -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());
 
index d4eb634..dbf5490 100644 (file)
@@ -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);
+
 
 }
index e225576..07c4647 100644 (file)
 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;
@@ -65,6 +71,37 @@ public class LinesOfBusinessCacheServiceProviderImpl extends AbstractCacheServic
         return Optional.empty();
     }
 
+    @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());
index daaef33..29b3af9 100644 (file)
@@ -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";
index 98b0fa7..438763e 100644 (file)
@@ -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);
     }
 
 }
index c219d3b..8412097 100644 (file)
@@ -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;
@@ -85,6 +87,9 @@ public class GenericVnfsControllerTest {
     @Autowired
     private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
 
+    @Autowired
+    private LinesOfBusinessCacheServiceProvider linesOfBusinessCacheServiceProvider;
+
     @Autowired
     private PlatformCacheServiceProvider platformVnfCacheServiceProvider;
 
@@ -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);
     }
index ba92b02..d5816d7 100644 (file)
 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);
     }
index e6cf399..ac8d295 100644 (file)
@@ -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);
index 698473f..018c056 100644 (file)
@@ -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());
     }
 
index c94baac..e91e1dc 100644 (file)
@@ -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/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 (file)
index 0000000..5ec5e9f
--- /dev/null
@@ -0,0 +1,3 @@
+{
+    "related-link": "/business/lines-of-business/line-of-business/LINE_OF_BUSINESS_1"
+}