aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java37
-rw-r--r--vid-app-common/src/test/resources/git.properties3
3 files changed, 35 insertions, 12 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
index 03dc8083e..12cc68e61 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
@@ -25,6 +25,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.dao.FnAppDoaImpl;
import org.onap.vid.model.GitRepositoryState;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,7 +47,6 @@ import java.util.Properties;
@RequestMapping("/")
public class HealthCheckController extends UnRestrictedBaseController {
-
/**
* The logger.
*/
@@ -58,6 +58,7 @@ public class HealthCheckController extends UnRestrictedBaseController {
final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
private static final String HEALTH_CHECK_PATH = "/healthCheck";
+ private static final String GIT_PROPERTIES_FILENAME = "git.properties";
/**
* Model for JSON response with health-check results.
@@ -193,10 +194,10 @@ public class HealthCheckController extends UnRestrictedBaseController {
return healthStatus;
}
- @RequestMapping(value = "/version", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public GitRepositoryState getCommitInfo() throws IOException {
Properties properties = new Properties();
- properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
+ properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME));
return new GitRepositoryState(properties);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
index ca7a163a8..6055bc390 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
@@ -1,18 +1,32 @@
package org.onap.vid.controllers;
+import org.apache.log4j.BasicConfigurator;
+import org.junit.Before;
import org.junit.Test;
-import org.onap.vid.controllers.HealthCheckController;
import org.onap.vid.controllers.HealthCheckController.HealthStatus;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
public class HealthCheckControllerTest {
- private HealthCheckController createTestSubject() {
- return new HealthCheckController();
+ private HealthCheckController testSubject;
+ private MockMvc mockMvc;
+
+ @Before
+ public void setUp() {
+ testSubject = new HealthCheckController();
+ BasicConfigurator.configure();
+ mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build();
}
@Test
public void testGetProfileCount() throws Exception {
- HealthCheckController testSubject;
String driver = "";
String URL = "";
String username = "";
@@ -20,29 +34,34 @@ public class HealthCheckControllerTest {
int result;
// default test
- testSubject = createTestSubject();
result = testSubject.getProfileCount(driver, URL, username, password);
}
@Test
public void testGethealthCheckStatusforIDNS() throws Exception {
- HealthCheckController testSubject;
HealthStatus result;
// default test
- testSubject = createTestSubject();
result = testSubject.gethealthCheckStatusforIDNS();
}
@Test
public void testGetHealthCheck() throws Exception {
- HealthCheckController testSubject;
String UserAgent = "";
String ECOMPRequestID = "";
HealthStatus result;
// default test
- testSubject = createTestSubject();
result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID);
}
+
+ @Test
+ public void testCommitInfoEndpoint() throws Exception {
+ mockMvc.perform(get("/commitInfo")
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.commitId").value("123987"))
+ .andExpect(jsonPath("$.commitMessageShort").value("Test short commit message"))
+ .andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200"));
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/git.properties b/vid-app-common/src/test/resources/git.properties
new file mode 100644
index 000000000..d504e3e88
--- /dev/null
+++ b/vid-app-common/src/test/resources/git.properties
@@ -0,0 +1,3 @@
+git.commit.id=123987
+git.commit.message.short=Test short commit message
+git.commit.time=1999-09-12T13\:48\:55+0200 \ No newline at end of file