File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
apiTest/java/uk/gov/hmcts/cp/subscription/http
main/java/uk/gov/hmcts/cp/subscription/controllers
test/java/uk/gov/hmcts/cp/subscription/controllers Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff 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 ()),
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments