Merge "Reorder modifiers"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / openecomp / mso / apihandlerinfra / GlobalHealthcheckHandlerTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.mso.apihandlerinfra;\r
22 \r
23 import static org.junit.Assert.*;\r
24 \r
25 import javax.ws.rs.core.Response;\r
26 \r
27 import org.apache.http.HttpStatus;\r
28 import org.junit.After;\r
29 import org.junit.Before;\r
30 import org.junit.Test;\r
31 import org.mockito.Mockito;\r
32 import org.openecomp.mso.HealthCheckUtils;\r
33 import org.openecomp.mso.MsoStatusUtil;\r
34 import org.openecomp.mso.logger.MsoLogger;\r
35 import org.openecomp.mso.properties.MsoJavaProperties;\r
36 import org.openecomp.mso.properties.MsoPropertiesFactory;\r
37 \r
38 public class GlobalHealthcheckHandlerTest {\r
39 \r
40         public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();\r
41         private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";\r
42         public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
43 \r
44         @Test\r
45         public final void testGlobalHealthcheck() {\r
46                 try {\r
47                         MsoStatusUtil statusUtil = Mockito.mock(MsoStatusUtil.class);\r
48                         HealthCheckUtils utils = Mockito.mock(HealthCheckUtils.class);\r
49                         Mockito.when(utils.verifyGlobalHealthCheck(true, null)).thenReturn(true);\r
50                         Mockito.when(statusUtil.getSiteStatus(Mockito.anyString())).thenReturn(true);\r
51                         GlobalHealthcheckHandler gh = Mockito.mock(GlobalHealthcheckHandler.class);\r
52                         Mockito.when(gh.globalHealthcheck(Mockito.anyBoolean())).thenReturn(HEALTH_CHECK_RESPONSE);\r
53                         Response resp = gh.globalHealthcheck(true);\r
54                         assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
55                 } catch (Exception e) {\r
56 \r
57                         e.printStackTrace();\r
58                 }\r
59         }\r
60 }\r