summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-02-27 14:54:42 -0500
committerDan Timoney <dtimoney@att.com>2020-02-27 15:00:10 -0500
commitc1c724e3d3db47b40db0a98670a2caa5ee2b2a9f (patch)
tree5fab7dfab304e96372549e247651233073d1a5cd
parentec7aa8b8c9fbe23f7628eb61bea93c0136cff6c5 (diff)
Fixed junit testing
Fixed junit testing (was incorrectly mocking the class to be tested) Change-Id: I275a6aca53b9a14fb151b020d1b7287f3e234417 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java33
-rw-r--r--sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java6
2 files changed, 12 insertions, 27 deletions
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java
index e2cd864d..7c4717da 100644
--- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java
@@ -1,27 +1,10 @@
package org.onap.ccsdk.sli.core.sliapi.springboot;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.*;
-import org.onap.ccsdk.sli.core.sli.ConfigurationException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
-import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
+import org.onap.ccsdk.sli.core.sli.*;
+import org.onap.ccsdk.sli.core.sli.provider.base.*;
import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput;
import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields;
import org.slf4j.Logger;
@@ -30,7 +13,13 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00")
@@ -75,7 +64,7 @@ public class RestconfApiController implements RestconfApi {
return;
}
- String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
+ String serviceLogicDirectory = System.getProperty("serviceLogicDirectory", "src/main/resources");
System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, store);
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 af55a518..701cb3eb 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
@@ -9,7 +9,6 @@ import org.onap.ccsdk.sli.core.sliapi.model.ExecutegraphinputInput;
import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
@@ -25,8 +24,6 @@ public class RestconfApiControllerTest {
@Autowired
private MockMvc mvc;
- @MockBean
- private RestconfApiController restconfApiController;
@Test
public void testHealthcheck() throws Exception {
@@ -82,8 +79,7 @@ public class RestconfApiControllerTest {
MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn();
- // Note: this really should return 401 (and truly does), but mockito always returns a 200.
- assertEquals(200, mvcResult.getResponse().getStatus());
+ assertEquals(401, mvcResult.getResponse().getStatus());
}