summaryrefslogtreecommitdiffstats
path: root/ms/generic-resource-api/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ms/generic-resource-api/src/test')
-rw-r--r--ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java4
-rw-r--r--ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java4
-rw-r--r--ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java4
-rw-r--r--ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java45
-rw-r--r--ms/generic-resource-api/src/test/resources/network-assign-rpc.json71
-rw-r--r--ms/generic-resource-api/src/test/resources/service-assign-rpc.json21
6 files changed, 129 insertions, 20 deletions
diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
index 7e7a3ac..49f3ae7 100644
--- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
+++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
@@ -42,7 +42,11 @@ public class ConfigApiPreloadControllerTest {
@BeforeClass
public static void setUp() throws Exception {
+ System.out.println("ConfigApiPreloadControllerTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir");
System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties");
+ System.setProperty("serviceLogicDirectory", "src/test/resources/svclogic");
+ System.setProperty("sdnc.config.dir", "src/test/resources");
+
}
@Test
diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
index 5653b3b..6329500 100644
--- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
+++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
@@ -47,7 +47,11 @@ public class ConfigApiServicesControllerTest {
@BeforeClass
public static void setUp() throws Exception {
+ System.out.println("ConfigApiServicesControllerTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir");
System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties");
+ System.setProperty("serviceLogicDirectory", "src/test/resources/svclogic");
+ System.setProperty("sdnc.config.dir", "src/test/resources");
+
}
diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java
index 0a19f39..260d66b 100644
--- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java
+++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java
@@ -20,7 +20,11 @@ public class GenericResourceMsAppTest {
@Before
public void setUp() throws Exception {
app = new GenericResourceMsApp();
+ System.out.println("GenericResourceMsAppTest: Setting serviceLogicProperties, serviceLogicDirectory and sdnc.config.dir");
System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties");
+ System.setProperty("serviceLogicDirectory", "src/test/resources/svclogic");
+ System.setProperty("sdnc.config.dir", "src/test/resources");
+
}
@Test
diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java
index 081199c..775be1b 100644
--- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java
+++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java
@@ -5,8 +5,11 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp;
import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository;
+import org.onap.sdnc.apps.ms.gra.data.ConfigServices;
import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository;
import org.onap.sdnc.apps.ms.gra.data.OperationalServicesRepository;
+import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceModelInfrastructure;
+import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicemodelinfrastructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
@@ -21,6 +24,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@@ -32,6 +37,7 @@ public class OperationsApiControllerTest {
private final static String PRELOAD_NETWORK_URL = "/operations/GENERIC-RESOURCE-API:preload-network-topology-operation/";
private final static String PRELOAD_VFMODULE_URL = "/operations/GENERIC-RESOURCE-API:preload-vf-module-topology-operation/";
private final static String SERVICE_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:service-topology-operation/";
+ private final static String NETWORK_TOPOLOGY_URL = "/operations/GENERIC-RESOURCE-API:network-topology-operation/";
@Autowired
@@ -123,6 +129,45 @@ public class OperationsApiControllerTest {
}
+ @Test
+ public void operationsGENERICRESOURCEAPInetworkTopologyOperationAssignPost() throws Exception {
+
+ // Remove any existing service data
+ configServicesRepository.deleteAll();
+ operationalServicesRepository.deleteAll();
+
+ // Load services data
+ loadServicesData("src/test/resources/service1.json");
+
+ // Add invalid content
+ String content = readFileContent("src/test/resources/preload1-rpc-vfmodule.json");
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(NETWORK_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Add valid content
+ content = readFileContent("src/test/resources/network-assign-rpc.json");
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(NETWORK_TOPOLOGY_URL).contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ }
+
+
+ private void loadServicesData(String path) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String content = readFileContent(path);
+ GenericResourceApiServiceModelInfrastructure services = objectMapper.readValue(content, GenericResourceApiServiceModelInfrastructure.class);
+
+ for (GenericResourceApiServicemodelinfrastructureService service : services.getService()) {
+ ConfigServices newService = new ConfigServices();
+ newService.setSvcInstanceId(service.getServiceInstanceId());
+ newService.setSvcData(objectMapper.writeValueAsString(service.getServiceData()));
+ newService.setServiceStatus(service.getServiceStatus());
+ configServicesRepository.save(newService);
+ }
+ }
+
private String readFileContent(String path) throws IOException {
String content = new String(Files.readAllBytes(Paths.get(path)));
return content;
diff --git a/ms/generic-resource-api/src/test/resources/network-assign-rpc.json b/ms/generic-resource-api/src/test/resources/network-assign-rpc.json
new file mode 100644
index 0000000..d6b9782
--- /dev/null
+++ b/ms/generic-resource-api/src/test/resources/network-assign-rpc.json
@@ -0,0 +1,71 @@
+{
+ "input": {
+ "request-information": {
+ "notification-url": "http://dev.null",
+ "order-number": "123",
+ "order-version": "version1",
+ "request-action": "CreateNetworkInstance",
+ "request-id": "req123",
+ "source": "curl"
+ },
+ "sdnc-request-header": {
+ "svc-action": "assign",
+ "svc-notification-url": "http://dev.null",
+ "svc-request-id": "svcreq123"
+ },
+ "service-information": {
+ "global-customer-id": "cust123",
+ "onap-model-information": {
+ "model-customization-uuid": "367a8ba9-057a-4506-b106-fbae818597c6",
+ "model-invariant-uuid": "367a8ba9-057a-4506-b106-fbae818597c6",
+ "model-name": "vBNG_0202",
+ "model-uuid": "00e50cbd-ef0f-4b28-821e-f2b583752dd3",
+ "model-version": "1920"
+ },
+ "service-id": "service1",
+ "service-instance-id": "service1",
+ "subscriber-name": "test",
+ "subscription-service-type": "test"
+ },
+ "network-request-input": {
+ "aic-clli": "complexMC",
+ "aic-cloud-region": "k8s_region_1",
+ "cloud-owner": "k8sCloudOwner",
+ "network-input-parameters": {
+ "param": [
+ {
+ "name": "test-param",
+ "resource-resolution-data": {
+ "capability-name": "myCapability",
+ "payload": "myPayload",
+ "resource-key": [
+ {
+ "name": "resource1",
+ "value": "hello_world"
+ }
+ ],
+ "status": "Pending"
+ },
+ "value": "HiThere"
+ }
+ ]
+ },
+ "network-instance-group-id": "netgrp123",
+ "network-name": "myNetwork",
+ "tenant": "k8s_tenant_1"
+ },
+ "network-information": {
+ "from-preload": true,
+ "network-id": "net123",
+ "network-technology": "virtio",
+ "network-type": "lan",
+ "onap-model-information": {
+ "model-customization-uuid": "367a8ba9-057a-4506-b106-fbae818597c6",
+ "model-invariant-uuid": "367a8ba9-057a-4506-b106-fbae818597c6",
+ "model-name": "vBNG_0202",
+ "model-uuid": "00e50cbd-ef0f-4b28-821e-f2b583752dd3",
+ "model-version": "1920"
+ }
+ }
+ }
+ }
diff --git a/ms/generic-resource-api/src/test/resources/service-assign-rpc.json b/ms/generic-resource-api/src/test/resources/service-assign-rpc.json
index a78e1af..31d3779 100644
--- a/ms/generic-resource-api/src/test/resources/service-assign-rpc.json
+++ b/ms/generic-resource-api/src/test/resources/service-assign-rpc.json
@@ -28,26 +28,7 @@
"subscription-service-type": "test"
},
"service-request-input": {
- "service-input-parameters": {
- "param": [
- {
- "name": "test-param",
- "resource-resolution-data": {
- "capability-name": "no-op",
- "payload": "hello-world",
- "resource-key": [
- {
- "name": "key",
- "value": "value"
- }
- ],
- "status": "pending"
- },
- "value": "hello-world"
- }
- ]
- },
- "service-instance-name": "service-instance-2"
+ "service-instance-name": "service-instance-1"
}
}
}