summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
authorMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-03-26 17:08:28 +0200
committerMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-03-27 17:56:13 +0200
commit25da75eacf48856824dd4e89b7ebd0da68fdef8a (patch)
tree5812664a19c4630cfc63e323901eddfa59d7f76e /src/test/java/org/onap
parent4b0d6728a146317a091b3e8b831e48bbd3fc9136 (diff)
Add initial sources
- Springboot application - Apache license 2.0 - Healthcheck Change-Id: I0dedfbe3348195f7be00ec8d27fbf25dfcda52b0 Issue-ID: EXTAPI-36 Signed-off-by: MatthieuGeerebaert <matthieu.geerebaert@orange.com>
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/nbi/apis/status/StatusTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/java/org/onap/nbi/apis/status/StatusTest.java b/src/test/java/org/onap/nbi/apis/status/StatusTest.java
new file mode 100644
index 0000000..d262e15
--- /dev/null
+++ b/src/test/java/org/onap/nbi/apis/status/StatusTest.java
@@ -0,0 +1,41 @@
+package org.onap.nbi.apis.status;
+
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.test.context.junit4.SpringRunner;
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class StatusTest {
+
+ @Autowired
+ StatusResource statusResource;
+
+ private MockHttpServletRequest request;
+
+ @Before
+ public void setup() {
+ request = new MockHttpServletRequest();
+ request.setRequestURI("/nbi/api/v1/status");
+ }
+
+ @Test
+ public void testHealthCheck() {
+ ResponseEntity<Object> response = statusResource.status(request);
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+ ObjectNode status = (ObjectNode) response.getBody();
+ assertThat(status.get("name").textValue()).isEqualTo("nbi");
+ assertThat(status.get("status").toString()).isEqualTo("OK");
+ assertThat(status.get("version").textValue()).isEqualTo("v1");
+ }
+}