added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / test / java / org / oran / otf / api / tests / integration / services / HealthRouteIT.java
diff --git a/otf-service-api/src/test/java/org/oran/otf/api/tests/integration/services/HealthRouteIT.java b/otf-service-api/src/test/java/org/oran/otf/api/tests/integration/services/HealthRouteIT.java
new file mode 100644 (file)
index 0000000..a04169e
--- /dev/null
@@ -0,0 +1,80 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.api.tests.integration.services;\r
+\r
+import static org.hamcrest.CoreMatchers.equalTo;\r
+\r
+import org.oran.otf.api.Application;\r
+import org.oran.otf.api.tests.shared.MemoryDatabase;\r
+import io.restassured.RestAssured;\r
+import org.junit.AfterClass;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;\r
+import org.springframework.boot.web.server.LocalServerPort;\r
+import org.springframework.test.context.ActiveProfiles;\r
+import org.springframework.test.context.TestPropertySource;\r
+import org.springframework.test.context.junit4.SpringRunner;\r
+\r
+@RunWith(SpringRunner.class)\r
+@SpringBootTest(\r
+    webEnvironment = WebEnvironment.RANDOM_PORT,\r
+    classes = {\r
+        Application.class\r
+    })\r
+@TestPropertySource("classpath:application-test.properties")\r
+@ActiveProfiles("test")\r
+public class HealthRouteIT {\r
+  @LocalServerPort\r
+  private int port;\r
+\r
+\r
+  @BeforeClass\r
+  public static void setup()throws Exception{\r
+    MemoryDatabase.setup();\r
+  }\r
+  @AfterClass\r
+  public static void cleanup(){\r
+    MemoryDatabase.cleanup();\r
+  }\r
+  @Before\r
+  public void setupRestAssured(){\r
+    RestAssured.port = port;\r
+    RestAssured.baseURI="https://localhost";\r
+    RestAssured.basePath="/otf/api";\r
+    RestAssured.urlEncodingEnabled =false;\r
+    RestAssured.useRelaxedHTTPSValidation();\r
+\r
+  }\r
+  @Test\r
+  public void testHealthRouteRespondsWith200(){\r
+    RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().assertThat().statusCode(200);\r
+  }\r
+  @Test\r
+  public void testHealthRouteRespondsWithUp(){\r
+    RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().assertThat().body("message", equalTo("UP"));\r
+  }\r
+  @Test\r
+  public void testHealthRouteRespondsWithJson(){\r
+    RestAssured.given().log().all().header("Accept", "application/json").get("/health/v1").then().contentType("application/json");\r
+  }\r
+\r
+\r
+}\r