diff options
author | 2021-11-29 16:01:45 -0500 | |
---|---|---|
committer | 2021-12-02 12:58:16 -0500 | |
commit | 4d0e2bd865cf490eb3f8d72dbbf02dd3ba8e5178 (patch) | |
tree | ed14c5b16345b2dab67e5b380037b95e6eb1d328 /ms/gra/gra-app/src | |
parent | 749b6f7c68f3a343ba9aae5a2f5f0f5d6d1909ea (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')
15 files changed, 1560 insertions, 3 deletions
diff --git a/ms/gra/gra-app/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java b/ms/gra/gra-app/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java index adcd504..44cd163 100644 --- a/ms/gra/gra-app/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java +++ b/ms/gra/gra-app/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java @@ -280,7 +280,7 @@ public class ServiceDataHelper { } public boolean networkExists(String svcInstanceId, String networkId) { - List<ConfigNetworks> configNetworks = configNetworksRepository.findBySvcInstanceId(svcInstanceId); + List<ConfigNetworks> configNetworks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(svcInstanceId, networkId); if ((configNetworks != null) && !configNetworks.isEmpty()) { return(true); } else { 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()); + + + + } +} diff --git a/ms/gra/gra-app/src/test/resources/contrail-route-allotted-resources-1.json b/ms/gra/gra-app/src/test/resources/contrail-route-allotted-resources-1.json new file mode 100644 index 0000000..4e34fe1 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/contrail-route-allotted-resources-1.json @@ -0,0 +1,35 @@ +{ + "contrail-route-allotted-resources" : { + "contrail-route-allotted-resource" : [ + { + "allotted-resource-id": "ar1", + "allotted-resource-data": { + "allotted-resource-oper-status": { + "create-timestamp": "2020-11-24T12:41:01.796Z", + "order-status": "Active" + }, + "contrail-route-topology": { + "contrail-route-assignments": { + "contrail-id": "cr1", + "dest-network": { + "network-id": "19cdfce4-9124-4bbf-83bd-5140931bb519", + "network-role": "pktmirror" + }, + "fq-name": "default-domain.GRP-27529-T-IST-13C.GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "source-network": { + "network-id": "1610d17a-fb91-48ac-9d4c-43f739fdbe54", + "network-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP" + } + }, + "allotted-resource-identifiers": { + "allotted-resource-id": "ar1", + "allotted-resource-type": "contrail-route", + "allotted-resource-name": "GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12_dyh2b_GRP-27529-T-SIL-13C_gn_SCTPA_IP_pktmirror_policy_32", + "parent-service-instance-id": "service1" + } + } + } + } + ] +} +} diff --git a/ms/gra/gra-app/src/test/resources/port-mirror-configurations-1.json b/ms/gra/gra-app/src/test/resources/port-mirror-configurations-1.json new file mode 100644 index 0000000..9d7f2f2 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/port-mirror-configurations-1.json @@ -0,0 +1,122 @@ +{ + "port-mirror-configurations" : { + "port-mirror-configuration": [ + { + "configuration-data": { + "configuration-oper-status": { + "last-action": "CreatePortMirrorConfigurationInstance", + "last-rpc-action": "activate", + "order-status": "Active" + }, + "configuration-operation-information": { + "configuration-information": { + "configuration-id": "pm-config-1", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "onap-model-information": { + "model-customization-uuid": "770c991a-47fb-4225-8d72-4790847f8307", + "model-invariant-uuid": "a81abec0-222e-4fb2-b1c6-c4162359b2b3", + "model-name": "Port Mirroring Configuration", + "model-uuid": "18af239e-5397-4224-816f-d2850f3fab38", + "model-version": "23.0" + } + }, + "port-mirror-configuration-request-input": { + "dest-port": { + "vnf-information": { + "vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5" + } + }, + "source-port": { + "vnf-information": { + "vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d" + } + } + }, + "request-information": { + "request-action": "CreatePortMirrorConfigurationInstance", + "request-id": "61fe8925-fb53-4968-b9de-74be4acd06cc", + "source": "MSO" + }, + "sdnc-request-header": { + "svc-action": "activate", + "svc-notification-url": "https://mso-sdnc-s3.ecomp.idns.aic.cip.att.com:30254/adapters/rest/SDNCNotify", + "svc-request-id": "ba937e51-6baf-486c-9851-3c6a646c9256" + }, + "service-information": { + "global-customer-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5", + "subscription-service-type": "Mobility" + } + }, + "port-mirror-configuration-topology": { + "configuration-identifiers": { + "configuration-id": "pm-config-1", + "configuration-name": "vMME02_VLC_Port_Mirroring_DYH2B_SCTPA", + "configuration-sub-type": "vprobe", + "configuration-type": "PORT-MIRROR", + "parent-service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "port-mirror-configuration-assignments": { + "cloud-owner": "att-aic", + "cloud-region-id": "dyh2b", + "dest-network-fqdn": "default-domain:GRP-27529-T-SIL-13B:GRP-27529-T-SIL-13B_vprobe_int_pkmirror1", + "dest-vnf-id": "039c2d5d-4efb-4145-9890-a6b5373cdfa5", + "dest-vnfc-instance-group-id": { + "configuration-id": "pm-config-1", + "instance-group-role": "pktmirror", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "owning-entity": "10c645f5-9924-4b89-bec0-b17cf49d3cad", + "probe-type": "vprobe", + "route-allotted-resource-id": "286d41ea-d644-46b2-98fc-643ea1b591d1", + "source-capacity": 100000, + "source-network-fqdn": "default-domain:GRP-27529-T-IST-13C:GRP-27529-T-SIL-13C_gn_SCTPA_IP_net_12", + "source-to-dest-maps": { + "source-to-dest-map": [ + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.4" + } + }, + "dest-port-id": "b91beeda-fae3-4a99-9354-06c965db83f7", + "dest-port-name": "zdyh2bprbvlba_module04-vlbagent_eph_aff_0_int_pktmirror_port_0-m5ylyrybbmmb", + "dest-vserver-id": "9e2fc5ea-a88f-4955-bda8-10e75c173a8e", + "source-port-id": "7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-port-name": "default-virtual-machine-interface-7b6ee74c-cc2c-4290-95f2-2d89a3c4da74", + "source-vserver-id": "2e3a8bb2-75ff-4e97-a888-961bfc624caa" + }, + { + "dest-ip-addresses": { + "ip-addresses": { + "ipv4-address": "107.114.102.3" + } + }, + "dest-port-id": "7cf3fda3-3153-4655-ae47-36fcf4439073", + "dest-port-name": "zdyh2bprbvlba_base_5-vlbagentbase_eph_aff_0_int_pktmirror_port_0-vkvey3eyoqk2", + "dest-vserver-id": "165db140-c09f-411a-bfdc-b8e6c7dbbda4", + "source-port-id": "0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-port-name": "default-virtual-machine-interface-0fd4c63c-6fda-4564-af10-d3be157279ef", + "source-vserver-id": "b5bf2e1f-9f90-445c-be00-2c882e82d1d7" + } + ] + }, + "source-vnf-id": "c5c92f5d-ed4d-4fb5-9ee1-b3eb562b1c6d", + "source-vnfc-instance-group-id": { + "configuration-id": "pm-config-1", + "instance-group-role": "GRP-27529-T-SIL-13C_gn_SCTPA_IP", + "service-instance-id": "156abc88-35d1-475a-85a1-e0e0a226cbd5" + }, + "tenant": "GRP-27529-T-IST-13C", + "tenant-context": "Test", + "tenant-id": "077445458306425499337c98bafc8c47", + "vnics-group-id": "97" + } + } + }, + "configuration-id": "pm-config-1" + } + ] + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-network.json b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-network.json new file mode 100644 index 0000000..f9114c0 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-network.json @@ -0,0 +1,15 @@ +{ + "network": + { + "network-id": "net124", + "vpn-bindings": [ + { + "vpn-binding-id": "vpnbind2", + "route-target-role": "both", + "vpn-name": "myvpn2", + "global-route-target": "target2", + "aic-zone": "RDM5" + } + ] + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-vpnbind.json b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-vpnbind.json new file mode 100644 index 0000000..4e8abc3 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp-vpnbind.json @@ -0,0 +1,10 @@ +{ + "vpn-bindings": + { + "vpn-binding-id": "vpnbind3", + "route-target-role": "both", + "vpn-name": "myvpn3", + "global-route-target": "target3", + "aic-zone": "RDM5" + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-netinstancegrp.json b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp.json new file mode 100644 index 0000000..5cd12db --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-netinstancegrp.json @@ -0,0 +1,35 @@ +{ + "network-instance-group" : { + "network-instance-group-id": "netgrp123", + "networks": { + "network": [ + { + "network-id": "net123", + "vpn-bindings": [ + { + "vpn-binding-id": "vpnbind1", + "route-target-role": "both", + "vpn-name": "myvpn", + "global-route-target": "target1", + "aic-zone": "RDM5" + } + ] + } + ] + }, + "subnet-key-value": "subnet1", + "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "subnet-assignment-policy": { + "subnet-use": "shared" + }, + "subnets": [ + { + "start-address": "10.1.1.1", + "ip-version": "4", + "dhcp-enabled": "N", + "subnet-name": "subnet1", + "cidr-mask": "26" + } + ] + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-network-allotted-resource.json b/ms/gra/gra-app/src/test/resources/service1-network-allotted-resource.json new file mode 100644 index 0000000..ff16380 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-network-allotted-resource.json @@ -0,0 +1,7 @@ +{ + "network-provided-allotted-resources": { + "network-provided-ar-id": [ + "ar123" + ] + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-network-id-structure.json b/ms/gra/gra-app/src/test/resources/service1-network-id-structure.json new file mode 100644 index 0000000..abc345d --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-network-id-structure.json @@ -0,0 +1,8 @@ +{ + "network-topology-identifier-structure": { + "network-technology": "soupcan", + "network-type": "CAMPBELLS_TOMATO", + "network-name": "popart", + "network-role": "dummy" + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-network-oper-status.json b/ms/gra/gra-app/src/test/resources/service1-network-oper-status.json new file mode 100644 index 0000000..1b69a3d --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-network-oper-status.json @@ -0,0 +1,5 @@ +{ + "oper-status": { + "order-status": "Created" + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1-network.json b/ms/gra/gra-app/src/test/resources/service1-network.json new file mode 100644 index 0000000..676dd35 --- /dev/null +++ b/ms/gra/gra-app/src/test/resources/service1-network.json @@ -0,0 +1,37 @@ +{ + "network": { + "network-id": "net124", + "network-data": { + "network-topology": { + "tenant": "tenant2", + "network-topology-identifier-structure": { + "network-technology": "soupcan", + "network-type": "CAMPBELLS_TOMATO", + "network-name": "andy", + "network-role": "dummy" + }, + "aic-cloud-region": "region1" + }, + "service-information": { + "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "onap-model-information": { + "model-invariant-uuid": "abcdef12345", + "model-uuid": "abcdef12345" + } + }, + "network-level-oper-status": { + "order-status": "Created" + }, + "network-request-input": { + "tenant": "tenant2", + "network-name": "andy", + "aic-cloud-region": "region1" + }, + "network-information": { + "network-type": "CAMPBELLS_TOMATO", + "network-id": "net124", + "from-preload": true + } + } + } +} diff --git a/ms/gra/gra-app/src/test/resources/service1.json b/ms/gra/gra-app/src/test/resources/service1.json index 806af9c..d7bc4c0 100644 --- a/ms/gra/gra-app/src/test/resources/service1.json +++ b/ms/gra/gra-app/src/test/resources/service1.json @@ -46,6 +46,114 @@ "svc-action": "assign", "svc-request-id": "6d06a832-69da-4369-9d99-049767a39400" }, + "network-instance-groups": { + "network-instance-group": [ + { + "network-instance-group-id": "netgrp123", + "networks" : { + "network" : [ + { + "network-id": "net123", + "vpn-bindings": [ + { + "vpn-binding-id": "vpnbind1", + "route-target-role": "both", + "vpn-name" : "myvpn", + "global-route-target": "target1", + "aic-zone": "RDM5" + } + ] + } + ] + }, + "subnet-key-value": "subnet1", + "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "subnet-assignment-policy": { + "subnet-use": "shared" + }, + "subnets": [ + { + "start-address": "10.1.1.1", + "ip-version": "4", + "dhcp-enabled": "N", + "subnet-name": "subnet1", + "cidr-mask": "26" + } + ] + } + ] + + }, + "networks": { + "network": [ + { + "network-id": "net123", + "network-data": { + "network-topology": { + "tenant": "tenant1", + "network-topology-identifier-structure": { + "network-technology": "soupcan", + "network-type": "CAMPBELLS_TOMATO", + "network-name": "warhol", + "network-role": "dummy" + }, + "aic-cloud-region": "region1" + }, + "service-information": { + "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "onap-model-information": { + "model-invariant-uuid": "abcdef12345", + "model-uuid": "abcdef12345" + } + }, + "network-level-oper-status": { + "order-status": "Created" + }, + "network-request-input": { + "tenant": "tenant1", + "network-name": "warhol", + "aic-cloud-region": "region1" + }, + "network-information": { + "network-type": "CAMPBELLS_TOMATO", + "network-id": "net123", + "from-preload": true + }, + "network-provided-allotted-resources": { + "network-provided-ar-id": [ + "ar123" + ] + } + } + }, + { + "network-id": "net125", + "network-data": { + "network-topology": { + "tenant": "tenant1", + "aic-cloud-region": "region1" + }, + "service-information": { + "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca", + "onap-model-information": { + "model-invariant-uuid": "abcdef12345", + "model-uuid": "abcdef12345" + } + }, + "network-request-input": { + "tenant": "tenant1", + "network-name": "popart", + "aic-cloud-region": "region1" + }, + "network-information": { + "network-type": "CAMPBELLS_TOMATO", + "network-id": "net125", + "from-preload": true + } + } + } + ] + }, "vnfs": { "vnf": [ { @@ -232,4 +340,4 @@ } } ] -}
\ No newline at end of file +} |