summaryrefslogtreecommitdiffstats
path: root/ms/gra/gra-app/src/test/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-11-29 16:01:45 -0500
committerDan Timoney <dtimoney@att.com>2021-12-02 12:58:16 -0500
commit4d0e2bd865cf490eb3f8d72dbbf02dd3ba8e5178 (patch)
treeed14c5b16345b2dab67e5b380037b95e6eb1d328 /ms/gra/gra-app/src/test/java
parent749b6f7c68f3a343ba9aae5a2f5f0f5d6d1909ea (diff)
Add test cases for gra microservice
Add test cases for GRA microservice to address test coverage being under target Issue-ID: SDNC-1638 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: If9422cdb577ef3984f17f4ef7aa2cd7e362e2fd4
Diffstat (limited to 'ms/gra/gra-app/src/test/java')
-rw-r--r--ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java21
-rw-r--r--ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java975
-rw-r--r--ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkInstanceGroupTest.java139
-rw-r--r--ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetworkTest.java42
4 files changed, 1176 insertions, 1 deletions
diff --git a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
index 8c311fb..76f4712 100644
--- a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
+++ b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java
@@ -182,6 +182,27 @@ public class ConfigApiPreloadControllerTest {
}
@Test
+ public void configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypePreloadDataPreloadNetworkTopologyInformationGet() throws Exception {
+ // Clean up data
+ configPreloadDataRepository.deleteAll();
+
+ // Test with data
+ loadData(CONFIG_PRELOAD_URL, "src/test/resources/preload1-net-model-info.json");
+ assert(configPreloadDataRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/preload-network-topology-information/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ configPreloadDataRepository.deleteAll();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/preload-network-topology-information/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+ @Test
public void configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypePostNoData() throws Exception {
// Clean up data
configPreloadDataRepository.deleteAll();
diff --git a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
index dd5a6a4..544ae88 100644
--- a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
+++ b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java
@@ -2,6 +2,7 @@ package org.onap.sdnc.apps.ms.gra.controllers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.IOException;
@@ -38,9 +39,12 @@ public class ConfigApiServicesControllerTest {
private final static String TEST_SVC_INSTANCE_ID = "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca";
private final static String TEST_VNF_ID = "fae319cc-68d6-496f-be1e-a09e133c71d4";
private final static String TEST_VF_MODULE_ID = "45841173-3729-4a1d-a811-a3bde399e22d";
+ private final static String TEST_NETWORK_INSTANCE_GROUP = "netgrp123";
private final static String CONFIG_SERVICES_URL = "/config/GENERIC-RESOURCE-API:services/";
private final static String CONFIG_SERVICES_SERVICE_URL = "/config/GENERIC-RESOURCE-API:services/service/";
+ private final static String CONFIG_CR_ARS_URL = "/config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/";
private final static String CONFIG_CR_ARS_CR_AR_URL = "/config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/";
+ private final static String CONFIG_PM_CONFIGS_CONFIG_URL = "/config/GENERIC-RESOURCE-API:port-mirror-configurations/";
private final static String CONFIG_PM_CONFIGS_PM_CONFIG_URL = "/config/GENERIC-RESOURCE-API:port-mirror-configurations/port-mirror-configuration/";
@Autowired
@@ -102,7 +106,7 @@ public class ConfigApiServicesControllerTest {
// Add service data - service, vnf, vf-module
loadServicesData("src/test/resources/service1.json");
assertEquals(1, configServicesRepository.count());
- assertEquals(0, configNetworksRepository.count());
+ assertEquals(2, configNetworksRepository.count());
assertEquals(1, configVnfsRepository.count());
assertEquals(1, configVfModulesRepository.count());
@@ -432,6 +436,284 @@ public class ConfigApiServicesControllerTest {
}
@Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidPut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-netinstancegrp-network.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+
+ // Test with existing data - should return 204
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidPost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-netinstancegrp-network.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+
+ // Test with existing data - should return 409
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(409, mvcResult.getResponse().getStatus());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidVpnBindingsVpnBindingIdDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind1/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind1/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidVpnBindingsVpnBindingIdGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind1/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind1/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidVpnBindingsVpnBindingIdPut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-netinstancegrp-vpnbind.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+
+ // Test with existing data - should return 204
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworkInstanceGroupsNetworkInstanceGroupNetworkInstanceGroupIdNetworksNetworkNetworkidVpnBindingsVpnBindingIdPost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-netinstancegrp-vpnbind.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+
+ // Test with existing data - should return 409
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/network-instance-groups/network-instance-group/"+TEST_NETWORK_INSTANCE_GROUP+"/networks/network/net123/vpn-bindings/vpnbind3/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(409, mvcResult.getResponse().getStatus());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceStatusDelete() throws Exception {
// Clean up data
clearServicesData();
@@ -747,6 +1029,621 @@ public class ConfigApiServicesControllerTest {
}
@Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net123");
+ assertEquals(0, networks.size());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidPut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net124");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 204
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net124");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidPost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net124");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 409
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net124/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(409, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net124");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkLevelOperStatusDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net123");
+ assertEquals(1, networks.size());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkLevelOperStatusGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkLevelOperStatusPut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-oper-status.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but this network has no oper status
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 204
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkLevelOperStatusPost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-oper-status.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 409
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-level-oper-status/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkTopologyNetworkTopologyIdentifierStructureDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net123");
+ assertEquals(1, networks.size());
+
+
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkProvidedAllottedResourcesDelete() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Load data
+ loadServicesData("src/test/resources/service1.json");
+ assertEquals(1, configServicesRepository.count());
+
+ // Test with data
+ mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, services.size());
+ assertNotNull(services.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net123");
+ assertEquals(1, networks.size());
+
+
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkProvidedAllottedResourcesGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkProvidedAllottedResourcesPut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-allotted-resource.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but this network has no oper status
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 201
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkProvidedAllottedResourcesPost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-allotted-resource.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 201
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-provided-allotted-resources/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkTopologyNetworkTopologyIdentifierStructureGet() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ // Test with data
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ // Test with no data
+ clearServicesData();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net123/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(""))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkTopologyNetworkTopologyIdentifierStructurePut() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-id-structure.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but this network has no oper status
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 204
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataNetworksNetworkNetworkidNetworkDataNetworkTopologyNetworkTopologyIdentifierStructurePost() throws Exception {
+ // Clean up data
+ clearServicesData();
+
+ String content = readFileContent("src/test/resources/service1-network-id-structure.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ assertEquals(0, configServicesRepository.count());
+
+ // Test with data, but not this network
+ loadServicesData("src/test/resources/service1.json");
+ assert(configServicesRepository.count() > 0);
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ assertEquals(1, configServicesRepository.count());
+ List<ConfigServices> updatedService = configServicesRepository.findBySvcInstanceId(TEST_SVC_INSTANCE_ID);
+ assertEquals(1, updatedService.size());
+ assertNotEquals(null, updatedService.get(0).getSvcData());
+ List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Test with existing data - should return 409
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+TEST_SVC_INSTANCE_ID+"/service-data/networks/network/net125/network-data/network-topology/network-topology-identifier-structure/").contentType(MediaType.APPLICATION_JSON).content(content))
+ .andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+ networks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(TEST_SVC_INSTANCE_ID, "net125");
+ assertEquals(1, networks.size());
+ assertNotNull(networks.get(0).getNetworkData());
+
+ // Clean up data
+ clearServicesData();
+ }
+
+
+ @Test
+ public void configGENERICRESOURCEAPIportMirrorConfigurationsPut() throws Exception {
+ // Clean up data
+ configPortMirrorConfigurationsRepository.deleteAll();
+
+ String content = readFileContent("src/test/resources/port-mirror-configurations-1.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+
+ // Test with existing port-mirror-configuration
+ // Load data
+ loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json");
+ assertEquals(1, configPortMirrorConfigurationsRepository.count());
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configPortMirrorConfigurationsRepository.count());
+
+ // Clean up data
+ configPortMirrorConfigurationsRepository.deleteAll();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIportMirrorConfigurationsPost() throws Exception {
+ // Clean up data
+ configPortMirrorConfigurationsRepository.deleteAll();
+
+ String content = readFileContent("src/test/resources/port-mirror-configurations-1.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+
+ // Test with existing port-mirror-configuration
+ // Load data
+ loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json");
+ assertEquals(1, configPortMirrorConfigurationsRepository.count());
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(409, mvcResult.getResponse().getStatus());
+ assertEquals(1, configPortMirrorConfigurationsRepository.count());
+
+ // Clean up data
+ configPortMirrorConfigurationsRepository.deleteAll();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIportMirrorConfigurationsGet() throws Exception {
+ // Clean up data
+ configPortMirrorConfigurationsRepository.deleteAll();
+
+ // Test with data
+ loadPortMirrorConfigurationData("src/test/resources/port-mirror-configuration-1.json");
+ assert(configPortMirrorConfigurationsRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content("")).andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+
+ // Test with no data
+ configPortMirrorConfigurationsRepository.deleteAll();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PM_CONFIGS_CONFIG_URL)
+ .contentType(MediaType.APPLICATION_JSON).content("")).andReturn();
+
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+ @Test
public void configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdPut() throws Exception {
// Clean up data
configPortMirrorConfigurationsRepository.deleteAll();
@@ -849,6 +1746,82 @@ public class ConfigApiServicesControllerTest {
}
@Test
+ public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesPut() throws Exception {
+ // Clean up data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+
+ String content = readFileContent("src/test/resources/contrail-route-allotted-resources-1.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+
+ // Test with existing allotted-resource
+ // Load data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+ loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json");
+ assertEquals(1, configContrailRouteAllottedResourcesRepository.count());
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(204, mvcResult.getResponse().getStatus());
+ assertEquals(1, configContrailRouteAllottedResourcesRepository.count());
+
+ // Clean up data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesPost() throws Exception {
+ // Clean up data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+
+ String content = readFileContent("src/test/resources/contrail-route-allotted-resources-1.json");
+
+ // Test with no data
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(201, mvcResult.getResponse().getStatus());
+
+ // Test with existing allotted-resource
+ // Load data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+ loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json");
+ assertEquals(1, configContrailRouteAllottedResourcesRepository.count());
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content(content)).andReturn();
+ assertEquals(409, mvcResult.getResponse().getStatus());
+ assertEquals(1, configContrailRouteAllottedResourcesRepository.count());
+
+ // Clean up data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+ }
+
+ @Test
+ public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesGet() throws Exception {
+ // Clean up data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+
+ // Test with data
+ loadContrailRouteAllottedResourceData("src/test/resources/contrail-route-allotted-resource-1.json");
+ assert(configContrailRouteAllottedResourcesRepository.count() > 0);
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content("")).andReturn();
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+
+ // Test with no data
+ configContrailRouteAllottedResourcesRepository.deleteAll();
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_CR_ARS_URL)
+ .contentType(MediaType.APPLICATION_JSON).content("")).andReturn();
+
+ assertEquals(404, mvcResult.getResponse().getStatus());
+ }
+
+ @Test
public void configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdPut() throws Exception {
// Clean up data
configContrailRouteAllottedResourcesRepository.deleteAll();
diff --git a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkInstanceGroupTest.java b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkInstanceGroupTest.java
new file mode 100644
index 0000000..0d129ee
--- /dev/null
+++ b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkInstanceGroupTest.java
@@ -0,0 +1,139 @@
+package org.onap.sdnc.apps.ms.gra.swagger.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class GenericResourceApiNetworkinstancegroupNetworkInstanceGroupTest {
+
+ @Test
+ public void testNetworkInstanceGroup() {
+ GenericResourceApiNetworkinstancegroupNetworkInstanceGroup netGroup1 = createTestInstance();
+ GenericResourceApiNetworkinstancegroupNetworkInstanceGroup netGroup2 = createTestInstance();
+
+ assertTrue(netGroup1.equals(netGroup2));
+ assertEquals(netGroup1.toString(), netGroup2.toString());
+
+ }
+
+
+ private GenericResourceApiNetworkinstancegroupNetworkInstanceGroup createTestInstance() {
+ GenericResourceApiNetworkinstancegroupNetworkInstanceGroup netGroup = new GenericResourceApiNetworkinstancegroupNetworkInstanceGroup();
+
+ netGroup.setNetworkInstanceGroupFunction("function1");
+ netGroup.networkInstanceGroupFunction(netGroup.getNetworkInstanceGroupFunction());
+ netGroup.setNetworkInstanceGroupId("123");
+ netGroup.networkInstanceGroupId(netGroup.getNetworkInstanceGroupId());
+ netGroup.setServiceInstanceId("service123");
+ netGroup.serviceInstanceId(netGroup.getServiceInstanceId());
+ assertEquals("function1", netGroup.getNetworkInstanceGroupFunction());
+ assertEquals("123", netGroup.getNetworkInstanceGroupId());
+ assertEquals("service123", netGroup.getServiceInstanceId());
+
+ GenericResourceApiOnapmodelinformationOnapModelInformation modelInfo = new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ modelInfo.setModelCustomizationUuid("123456");
+ modelInfo.setModelInvariantUuid("123456");
+ modelInfo.setModelName("model_t");
+ modelInfo.setModelUuid("123456");
+ modelInfo.setModelVersion("1");
+ netGroup.setOnapModelInformation(modelInfo);
+ netGroup.onapModelInformation(netGroup.getOnapModelInformation());
+ assertEquals("123456", netGroup.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("123456", netGroup.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals("model_t", netGroup.getOnapModelInformation().getModelName());
+ assertEquals("123456", netGroup.getOnapModelInformation().getModelUuid());
+ assertEquals("1", netGroup.getOnapModelInformation().getModelVersion());
+
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupAggregateRoutePolicy aggregateRoutePolicy = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupAggregateRoutePolicy();
+ aggregateRoutePolicy.setAggregateRoutePolicyName("agPolicy1");
+ aggregateRoutePolicy.setIpv4AggregateRouteLevel("1");
+ aggregateRoutePolicy.setIpv6AggregateRouteLevel("2");
+ netGroup.setAggregateRoutePolicy(aggregateRoutePolicy);
+ netGroup.aggregateRoutePolicy(netGroup.getAggregateRoutePolicy());
+ assertEquals("agPolicy1", netGroup.getAggregateRoutePolicy().getAggregateRoutePolicyName());
+ assertEquals("1", netGroup.getAggregateRoutePolicy().getIpv4AggregateRouteLevel());
+ assertEquals("2", netGroup.getAggregateRoutePolicy().getIpv6AggregateRouteLevel());
+
+ GenericResourceApiAggregateroutesAggregateRoutes agItem = new GenericResourceApiAggregateroutesAggregateRoutes();
+ agItem.setCidrMask("12");
+ agItem.setIpVersion("ipv4");
+ agItem.setRouteId("route1");
+ agItem.setStartAddress("127.0.0.0");
+ netGroup.addAggregateRoutesItem(agItem);
+ netGroup.setAggregateRoutes(netGroup.getAggregateRoutes());
+ netGroup.aggregateRoutes(netGroup.getAggregateRoutes());
+ List<GenericResourceApiAggregateroutesAggregateRoutes> agRoutes = netGroup.getAggregateRoutes();
+ assertEquals(1, agRoutes.size());
+ assertEquals("12", agRoutes.get(0).getCidrMask());
+ assertEquals("ipv4", agRoutes.get(0).getIpVersion());
+ assertEquals("route1", agRoutes.get(0).getRouteId());
+ assertEquals("127.0.0.0", agRoutes.get(0).getStartAddress());
+
+ GenericResourceApiSubnetsSubnets subnetItem = new GenericResourceApiSubnetsSubnets();
+ subnetItem.setAddrFromStart(GenericResourceApiAddrFromStartEnumeration.Y);
+ subnetItem.setCidrMask("12");
+ subnetItem.setDhcpEnabled(GenericResourceApiDhcpEnabledEnumeration.Y);
+ subnetItem.setDhcpStartAddress("10.1.1.1");
+ subnetItem.setDhcpEndAddress("10.1.1.127");
+ subnetItem.setGatewayAddress("10.1.1.255");
+ subnetItem.setIpVersion("ipv4");
+ subnetItem.setStartAddress("10.1.1.0");
+ subnetItem.setSubnetName("subnet1");
+ subnetItem.setSubnetRole("client");
+ netGroup.addSubnetsItem(subnetItem);
+ netGroup.setSubnets(netGroup.getSubnets());
+ netGroup.subnets(netGroup.getSubnets());
+ List<GenericResourceApiSubnetsSubnets> subnets = netGroup.getSubnets();
+ assertEquals(1, subnets.size());
+ assertEquals(GenericResourceApiAddrFromStartEnumeration.Y, subnets.get(0).getAddrFromStart());
+ assertEquals("12", subnets.get(0).getCidrMask());
+ assertEquals(GenericResourceApiDhcpEnabledEnumeration.Y, subnets.get(0).getDhcpEnabled());
+ assertEquals("10.1.1.1", subnets.get(0).getDhcpStartAddress());
+ assertEquals("10.1.1.127", subnets.get(0).getDhcpEndAddress());
+ assertEquals("ipv4", subnets.get(0).getIpVersion());
+ assertEquals("10.1.1.0", subnets.get(0).getStartAddress());
+ assertEquals("subnet1", subnets.get(0).getSubnetName());
+ assertEquals("client", subnets.get(0).getSubnetRole());
+
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupSubnetAssignmentPolicy subnetAssignmentPolicy = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupSubnetAssignmentPolicy();
+ subnetAssignmentPolicy.setSubnetUse("optional");
+ netGroup.setSubnetAssignmentPolicy(subnetAssignmentPolicy);
+ netGroup.subnetAssignmentPolicy(netGroup.getSubnetAssignmentPolicy());
+ assertEquals("optional", netGroup.getSubnetAssignmentPolicy().getSubnetUse());
+
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupVpnBindingPolicy vpnBindingPolicy = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupVpnBindingPolicy();
+ vpnBindingPolicy.setGlobalRouteTarget("target1");
+ vpnBindingPolicy.setRouteTargetRole("role1");
+ vpnBindingPolicy.setVpnBinding("binding1");
+ vpnBindingPolicy.setVpnName("vpn1");
+ vpnBindingPolicy.setVpnPlatform("platform1");
+ vpnBindingPolicy.setVpnType("type1");
+ netGroup.setVpnBindingPolicy(vpnBindingPolicy);
+ netGroup.vpnBindingPolicy(netGroup.getVpnBindingPolicy());
+ assertEquals("target1", netGroup.getVpnBindingPolicy().getGlobalRouteTarget());
+ assertEquals("role1", netGroup.getVpnBindingPolicy().getRouteTargetRole());
+ assertEquals("binding1", netGroup.getVpnBindingPolicy().getVpnBinding());
+ assertEquals("vpn1", netGroup.getVpnBindingPolicy().getVpnName());
+ assertEquals("platform1", netGroup.getVpnBindingPolicy().getVpnPlatform());
+ assertEquals("type1", netGroup.getVpnBindingPolicy().getVpnType());
+
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworks networks = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworks();
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetwork networkItem = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetwork();
+ networkItem.setNetworkId("123");
+ networkItem.setNetworkStatus("active");
+ networkItem.setNeutronNetworkId("123");
+ networks.addNetworkItem(networkItem);
+ netGroup.setNetworks(networks);
+ netGroup.networks(netGroup.getNetworks());
+ assertEquals(1, netGroup.getNetworks().getNetwork().size());
+ assertEquals("123", netGroup.getNetworks().getNetwork().get(0).getNetworkId());
+ assertEquals("123", netGroup.getNetworks().getNetwork().get(0).getNeutronNetworkId());
+ assertEquals("active", netGroup.getNetworks().getNetwork().get(0).getNetworkStatus());
+
+ return(netGroup);
+ }
+
+}
diff --git a/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetworkTest.java b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetworkTest.java
new file mode 100644
index 0000000..a5794e4
--- /dev/null
+++ b/ms/gra/gra-app/src/test/java/org/onap/sdnc/apps/ms/gra/swagger/model/GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetworkTest.java
@@ -0,0 +1,42 @@
+package org.onap.sdnc.apps.ms.gra.swagger.model;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import org.junit.Test;
+
+public class GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetworkTest {
+
+ @Test
+ public void testCreateInstance() {
+ GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetwork network = new GenericResourceApiNetworkinstancegroupNetworkinstancegroupNetworksNetwork();
+
+ network.setNetworkId("123");
+ network.networkId("123");
+ network.setNetworkStatus("active");
+ network.networkStatus("active");
+ network.setNeutronNetworkId("123");
+ network.neutronNetworkId("123");
+ network.setVlanTagId(123L);
+ network.vlanTagId(123L);
+
+ GenericResourceApiVpnbindingsVpnBindings vpnBinding = new GenericResourceApiVpnbindingsVpnBindings();
+ vpnBinding.setAicZone("aic1");
+ vpnBinding.setGlobalRouteTarget("target1");
+ vpnBinding.setRouteTargetRole("role1");
+ vpnBinding.setVpnBindingId("123");
+ vpnBinding.setVpnName("name1");
+ network.addVpnBindingsItem(vpnBinding);
+ List<GenericResourceApiVpnbindingsVpnBindings> vpnBindings = network.getVpnBindings();
+ network.setVpnBindings(vpnBindings);
+ network.vpnBindings(vpnBindings);
+
+ assertEquals("123", network.getNetworkId());
+ assertEquals("active", network.getNetworkStatus());
+ assertEquals("123", network.getNeutronNetworkId());
+ assertEquals((Long) 123L, network.getVlanTagId());
+
+
+
+ }
+}