Merge "Increase tests coverage in backend"
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controllers / HealthCheckControllerTest.java
1 package org.onap.vid.controllers;
2
3 import org.apache.log4j.BasicConfigurator;
4 import org.junit.Before;
5 import org.junit.Test;
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;
10
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;
14
15
16 public class HealthCheckControllerTest {
17
18         private HealthCheckController testSubject;
19         private MockMvc mockMvc;
20
21         @Before
22         public void setUp() {
23                 testSubject = new HealthCheckController();
24                 BasicConfigurator.configure();
25                 mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build();
26         }
27
28         @Test
29         public void testGetProfileCount() throws Exception {
30                 String driver = "";
31                 String URL = "";
32                 String username = "";
33                 String password = "";
34                 int result;
35
36                 // default test
37                 result = testSubject.getProfileCount(driver, URL, username, password);
38         }
39
40         @Test
41         public void testGethealthCheckStatusforIDNS() throws Exception {
42                 HealthStatus result;
43
44                 // default test
45                 result = testSubject.gethealthCheckStatusforIDNS();
46         }
47
48         @Test
49         public void testGetHealthCheck() throws Exception {
50                 String UserAgent = "";
51                 String ECOMPRequestID = "";
52                 HealthStatus result;
53
54                 // default test
55                 result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID);
56         }
57
58         @Test
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"));
66         }
67 }