Skip to content

Commit 6f6343e

Browse files
authored
Merge pull request #14 from hmcts/feature/amp-148-root-endpoint
feature: api-148 add root endpoint to satisfy helm config which hits …
2 parents c95cd95 + 253e234 commit 6f6343e

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

src/apiTest/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ class ActuatorApiTest {
1616
private final RestTemplate http = new RestTemplate();
1717

1818
@Test
19-
void health_is_up() {
19+
void root_endpoint_should_be_ok() {
20+
final ResponseEntity<String> res = http.exchange(
21+
baseUrl + "/", HttpMethod.GET,
22+
new HttpEntity<>(new HttpHeaders()),
23+
String.class
24+
);
25+
assertThat(res.getStatusCode()).isEqualTo(HttpStatus.OK);
26+
assertThat(res.getBody()).contains("DEPRECATED root endpoint");
27+
}
28+
29+
@Test
30+
void health_endpoint_should_be_up() {
2031
final ResponseEntity<String> res = http.exchange(
2132
baseUrl + "/actuator/health", HttpMethod.GET,
2233
new HttpEntity<>(new HttpHeaders()),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package uk.gov.hmcts.cp.subscription.controllers;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
import static org.springframework.http.ResponseEntity.ok;
9+
10+
@RestController
11+
@Slf4j
12+
public class RootController {
13+
14+
/**
15+
* Root GET endpoint. Temp solution. The deployment helm charts are set to perform health checks using /
16+
* Once we understand the helm better we will amend tne halth checks to use /actuator/info
17+
*/
18+
@GetMapping("/")
19+
public ResponseEntity<String> root() {
20+
return ok("DEPRECATED root endpoint");
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package uk.gov.hmcts.cp.subscription.controllers;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.ExtendWith;
5+
import org.mockito.InjectMocks;
6+
import org.mockito.junit.jupiter.MockitoExtension;
7+
8+
import static org.assertj.core.api.Assertions.assertThat;
9+
10+
@ExtendWith(MockitoExtension.class)
11+
class RootControllerTest {
12+
13+
@InjectMocks
14+
RootController rootController;
15+
16+
@Test
17+
void update_controller_should_call_service() {
18+
var result = rootController.root();
19+
assertThat(result.getStatusCode().value()).isEqualTo(200);
20+
assertThat(result.getBody()).isEqualTo("DEPRECATED root endpoint");
21+
}
22+
}

0 commit comments

Comments
 (0)