diff options
author | Dan Timoney <dtimoney@att.com> | 2020-11-05 10:25:30 -0500 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2020-11-05 10:25:47 -0500 |
commit | 8478c087e47ab2b56d5fb5bd8fba8f91f2f7e108 (patch) | |
tree | 5205fe7bbf1167c47bd449bbcd90cd000a87aac5 /ms/generic-resource-api/src/test | |
parent | b2ec6199c755d31701a75361cb8b73722027c646 (diff) |
Update to avoid dup module names
Update GRA microservice to use updated swagger which no longer
duplicates module names in config URLs.
Change-Id: Iad63f356d4854c7cefdde46215a1b448b281e2ca
Issue-ID: SDNC-1406
Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'ms/generic-resource-api/src/test')
3 files changed, 59 insertions, 65 deletions
diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java index 5b0a8e6..95226f7 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java @@ -1,12 +1,17 @@ package org.onap.sdnc.apps.ms.gra.controllers; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -17,13 +22,6 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.transaction.annotation.Transactional; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static org.junit.Assert.assertEquals; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request; - @RunWith(SpringRunner.class) @SpringBootTest(classes={GenericResourceMsApp.class}) @AutoConfigureMockMvc @@ -31,7 +29,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. public class ConfigApiPreloadControllerTest { private final static String CONFIG_PRELOAD_URL = "/config/GENERIC-RESOURCE-API:preload-information/"; - private final static String CONFIG_PRELOAD_LIST_URL = "/config/GENERIC-RESOURCE-API:preload-information/GENERIC-RESOURCE-API:preload-list/"; + private final static String CONFIG_PRELOAD_LIST_URL = "/config/GENERIC-RESOURCE-API:preload-information/preload-list/"; @Autowired @@ -254,7 +252,7 @@ public class ConfigApiPreloadControllerTest { // Test with data loadData(CONFIG_PRELOAD_URL, "src/test/resources/preload1-net-model-info.json"); assert(configPreloadDataRepository.count() > 0); - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); assertEquals(1, configPreloadDataRepository.count()); @@ -262,7 +260,7 @@ public class ConfigApiPreloadControllerTest { // Test without data configPreloadDataRepository.deleteAll(); assertEquals(0, configPreloadDataRepository.count()); - mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configPreloadDataRepository.count()); @@ -278,13 +276,13 @@ public class ConfigApiPreloadControllerTest { 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/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").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/GENERIC-RESOURCE-API:preload-data").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); } @@ -298,7 +296,7 @@ public class ConfigApiPreloadControllerTest { // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configPreloadDataRepository.count()); @@ -321,7 +319,7 @@ public class ConfigApiPreloadControllerTest { configPreloadDataRepository.save(preloadData); // Test with bad file content - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(badContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(badContent)) .andReturn(); assertEquals(400, mvcResult.getResponse().getStatus()); assertEquals(1, configPreloadDataRepository.count()); @@ -344,7 +342,7 @@ public class ConfigApiPreloadControllerTest { // Test with no existing preload data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); @@ -365,7 +363,7 @@ public class ConfigApiPreloadControllerTest { // Test with existing preload dat - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(409, mvcResult.getResponse().getStatus()); assertEquals(1, configPreloadDataRepository.count()); @@ -381,7 +379,7 @@ public class ConfigApiPreloadControllerTest { // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configPreloadDataRepository.count()); @@ -402,7 +400,7 @@ public class ConfigApiPreloadControllerTest { configPreloadDataRepository.save(preloadData); // Test with bad file content - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(badContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(badContent)) .andReturn(); assertEquals(400, mvcResult.getResponse().getStatus()); assertEquals(1, configPreloadDataRepository.count()); @@ -425,7 +423,7 @@ public class ConfigApiPreloadControllerTest { // Test with no existing preload data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); @@ -446,7 +444,7 @@ public class ConfigApiPreloadControllerTest { // Test with existing preload dat - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/GENERIC-RESOURCE-API:preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_PRELOAD_LIST_URL+"preload1/network/preload-data/").contentType(MediaType.APPLICATION_JSON).content(goodContent)) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); assertEquals(1, configPreloadDataRepository.count()); diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java index e9a5c8b..609e780 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java @@ -1,16 +1,22 @@ package org.onap.sdnc.apps.ms.gra.controllers; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; import org.onap.sdnc.apps.ms.gra.data.ConfigServices; import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceModelInfrastructure; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicemodelinfrastructureService; +import org.onap.sdnc.apps.ms.gra.swagger.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -21,15 +27,6 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.transaction.annotation.Transactional; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request; - @RunWith(SpringRunner.class) @SpringBootTest(classes={GenericResourceMsApp.class}) @AutoConfigureMockMvc @@ -37,7 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. public class ConfigApiServicesControllerTest { 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/GENERIC-RESOURCE-API:service/"; + private final static String CONFIG_SERVICES_SERVICE_URL = "/config/GENERIC-RESOURCE-API:services/service/"; @Autowired private MockMvc mvc; @@ -241,7 +238,7 @@ public class ConfigApiServicesControllerTest { configServicesRepository.deleteAll(); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -251,7 +248,7 @@ public class ConfigApiServicesControllerTest { assertEquals(1, configServicesRepository.count()); // Test with data - mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -271,13 +268,13 @@ public class ConfigApiServicesControllerTest { loadServicesData("src/test/resources/service1.json"); assert(configServicesRepository.count() > 0); - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(200, mvcResult.getResponse().getStatus()); // Test with no data configServicesRepository.deleteAll(); - mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); } @@ -290,7 +287,7 @@ public class ConfigApiServicesControllerTest { String content = readFileContent("src/test/resources/service1-servicedata.json"); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -300,7 +297,7 @@ public class ConfigApiServicesControllerTest { service.setSvcInstanceId("service1"); configServicesRepository.save(service); assertEquals(1, configServicesRepository.count()); - mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -309,7 +306,7 @@ public class ConfigApiServicesControllerTest { assertNotEquals(null, updatedService.get(0).getSvcData()); // Test with existing data - should return 409 - mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(409, mvcResult.getResponse().getStatus()); @@ -325,7 +322,7 @@ public class ConfigApiServicesControllerTest { String content = readFileContent("src/test/resources/service1-servicedata.json"); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -334,7 +331,7 @@ public class ConfigApiServicesControllerTest { ConfigServices service = new ConfigServices(); service.setSvcInstanceId("service1"); configServicesRepository.save(service); - mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -343,7 +340,7 @@ public class ConfigApiServicesControllerTest { assertNotEquals(null, updatedService.get(0).getSvcData()); // Test with existing data - should return 204 - mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-data/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); @@ -357,7 +354,7 @@ public class ConfigApiServicesControllerTest { configServicesRepository.deleteAll(); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -367,7 +364,7 @@ public class ConfigApiServicesControllerTest { assertEquals(1, configServicesRepository.count()); // Test with data - mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -385,13 +382,13 @@ public class ConfigApiServicesControllerTest { loadServicesData("src/test/resources/service1.json"); assert(configServicesRepository.count() > 0); - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content("")) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(200, mvcResult.getResponse().getStatus()); // Test with no data configServicesRepository.deleteAll(); - mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content("")) + mvcResult = mvc.perform(MockMvcRequestBuilders.get(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content("")) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); } @@ -404,7 +401,7 @@ public class ConfigApiServicesControllerTest { String content = readFileContent("src/test/resources/service1-servicestatus.json"); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -413,7 +410,7 @@ public class ConfigApiServicesControllerTest { ConfigServices service = new ConfigServices(); service.setSvcInstanceId("service1"); configServicesRepository.save(service); - mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -422,7 +419,7 @@ public class ConfigApiServicesControllerTest { assertNotEquals(null, updatedService.get(0).getServiceStatus()); // Test with existing data - should return 409 - mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.post(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(409, mvcResult.getResponse().getStatus()); @@ -438,7 +435,7 @@ public class ConfigApiServicesControllerTest { String content = readFileContent("src/test/resources/service1-servicestatus.json"); // Test with no data - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(404, mvcResult.getResponse().getStatus()); assertEquals(0, configServicesRepository.count()); @@ -447,7 +444,7 @@ public class ConfigApiServicesControllerTest { ConfigServices service = new ConfigServices(); service.setSvcInstanceId("service1"); configServicesRepository.save(service); - mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(201, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); @@ -456,7 +453,7 @@ public class ConfigApiServicesControllerTest { assertNotEquals(null, updatedService.get(0).getServiceStatus()); // Test with existing data - should return 204 - mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/GENERIC-RESOURCE-API:service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) + mvcResult = mvc.perform(MockMvcRequestBuilders.put(CONFIG_SERVICES_SERVICE_URL+"service1/service-status/").contentType(MediaType.APPLICATION_JSON).content(content)) .andReturn(); assertEquals(204, mvcResult.getResponse().getStatus()); diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java index b285d9e..0a5e8a8 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java @@ -1,5 +1,13 @@ package org.onap.sdnc.apps.ms.gra.controllers; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -8,8 +16,7 @@ import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; import org.onap.sdnc.apps.ms.gra.data.ConfigServices; import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; import org.onap.sdnc.apps.ms.gra.data.OperationalServicesRepository; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceModelInfrastructure; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicemodelinfrastructureService; +import org.onap.sdnc.apps.ms.gra.swagger.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -20,14 +27,6 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.transaction.annotation.Transactional; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import static org.junit.Assert.*; - @RunWith(SpringRunner.class) @SpringBootTest(classes={GenericResourceMsApp.class}) @AutoConfigureMockMvc |