1 package org.onap.vid.controllers;
3 import org.apache.log4j.BasicConfigurator;
4 import org.junit.Before;
6 import org.onap.vid.controllers.HealthCheckController.HealthStatus;
7 import org.springframework.http.MediaType;
8 import org.springframework.test.web.servlet.MockMvc;
9 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
11 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
12 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
13 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
16 public class HealthCheckControllerTest {
18 private HealthCheckController testSubject;
19 private MockMvc mockMvc;
23 testSubject = new HealthCheckController();
24 BasicConfigurator.configure();
25 mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build();
29 public void testGetProfileCount() throws Exception {
37 result = testSubject.getProfileCount(driver, URL, username, password);
41 public void testGethealthCheckStatusforIDNS() throws Exception {
45 result = testSubject.gethealthCheckStatusforIDNS();
49 public void testGetHealthCheck() throws Exception {
50 String UserAgent = "";
51 String ECOMPRequestID = "";
55 result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID);
59 public void testCommitInfoEndpoint() throws Exception {
60 mockMvc.perform(get("/commitInfo")
61 .accept(MediaType.APPLICATION_JSON))
62 .andExpect(status().isOk())
63 .andExpect(jsonPath("$.commitId").value("123987"))
64 .andExpect(jsonPath("$.commitMessageShort").value("Test short commit message"))
65 .andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200"));