summaryrefslogtreecommitdiffstats
path: root/sliapi/springboot/src/test/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-03-11 15:54:10 -0400
committerDan Timoney <dtimoney@att.com>2020-03-12 11:34:33 -0400
commit88f749277195998d150925e14e12021cc2e9292b (patch)
tree8e31b64b8e169cbd126d56d77cb0cb7cb7aef7d6 /sliapi/springboot/src/test/java
parentc46ebbb0f011a1587c3fe506c5029ce550b07ed2 (diff)
Add data persistence
Add code to persist MD-SAL data (test-results) Change-Id: I2c6d3e94e9e46ccbfad479c6d89507ec37939496 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'sliapi/springboot/src/test/java')
-rw-r--r--sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java
index a61a470ed..b4c629097 100644
--- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java
+++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java
@@ -118,6 +118,34 @@ public class RestconfApiControllerTest {
}
+ @Test
+ public void testTestResultAdd() throws Exception {
+ String url = "/restconf/config/SLI-API:test-results";
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn();
+
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ String jsonString = "{\n" +
+ " \"test-results\" : [\n" +
+ " {\n" +
+ " \"test-identifier\" : \"test-1\",\n" +
+ " \"results\" : [\"test result 1\"]\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString))
+ .andReturn();
+
+ assertEquals(200, mvcResult.getResponse().getStatus());
+
+ mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn();
+
+ assertEquals(200, mvcResult.getResponse().getStatus());
+ assertEquals(jsonString.replaceAll("\\s+",""), mvcResult.getResponse().getContentAsString().replaceAll("\\s+",""));
+ }
+
private String mapToJson(Object obj) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.writeValueAsString(obj);