added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / test / java / org / oran / otf / api / tests / integration / services / HealthRouteIT.java
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 package org.oran.otf.api.tests.integration.services;\r
18 \r
19 import static org.hamcrest.CoreMatchers.equalTo;\r
20 \r
21 import org.oran.otf.api.Application;\r
22 import org.oran.otf.api.tests.shared.MemoryDatabase;\r
23 import io.restassured.RestAssured;\r
24 import org.junit.AfterClass;\r
25 import org.junit.Before;\r
26 import org.junit.BeforeClass;\r
27 import org.junit.Test;\r
28 import org.junit.runner.RunWith;\r
29 import org.springframework.boot.test.context.SpringBootTest;\r
30 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
31 import org.springframework.boot.web.server.LocalServerPort;\r
32 import org.springframework.test.context.ActiveProfiles;\r
33 import org.springframework.test.context.TestPropertySource;\r
34 import org.springframework.test.context.junit4.SpringRunner;\r
35 \r
36 @RunWith(SpringRunner.class)\r
37 @SpringBootTest(\r
38     webEnvironment = WebEnvironment.RANDOM_PORT,\r
39     classes = {\r
40         Application.class\r
41     })\r
42 @TestPropertySource("classpath:application-test.properties")\r
43 @ActiveProfiles("test")\r
44 public class HealthRouteIT {\r
45   @LocalServerPort\r
46   private int port;\r
47 \r
48 \r
49   @BeforeClass\r
50   public static void setup()throws Exception{\r
51     MemoryDatabase.setup();\r
52   }\r
53   @AfterClass\r
54   public static void cleanup(){\r
55     MemoryDatabase.cleanup();\r
56   }\r
57   @Before\r
58   public void setupRestAssured(){\r
59     RestAssured.port = port;\r
60     RestAssured.baseURI="https://localhost";\r
61     RestAssured.basePath="/otf/api";\r
62     RestAssured.urlEncodingEnabled =false;\r
63     RestAssured.useRelaxedHTTPSValidation();\r
64 \r
65   }\r
66   @Test\r
67   public void testHealthRouteRespondsWith200(){\r
68     RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().assertThat().statusCode(200);\r
69   }\r
70   @Test\r
71   public void testHealthRouteRespondsWithUp(){\r
72     RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().assertThat().body("message", equalTo("UP"));\r
73   }\r
74   @Test\r
75   public void testHealthRouteRespondsWithJson(){\r
76     RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().contentType("application/json");\r
77   }\r
78 \r
79 \r
80 }\r