Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/63 implement health endpoint #79

Merged
merged 9 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions power-pay-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
8 changes: 8 additions & 0 deletions power-pay-backend/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
management:
endpoints:
web:
exposure:
include: health, metrics
endpoint:
health:
show-details: always
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.adorsys.gis.powerpay.powerpaybackend;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;

@SpringBootTest
@AutoConfigureMockMvc
@ContextConfiguration(classes = { PowerPayBackendApplication.class })
class PowerPayBackendHealthTest {

@Autowired
private MockMvc mockMvc;

@Test
void healthEndpointTest() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/actuator/health"))
.andExpect(result -> {
if (result.getResponse().getStatus() == 200) {
MockMvcResultMatchers.status().isOk().match(result);
MockMvcResultMatchers.jsonPath("$.status").value("UP").match(result);
} else if (result.getResponse().getStatus() >= 500) {
MockMvcResultMatchers.status().is5xxServerError().match(result);
MockMvcResultMatchers.jsonPath("$.status").doesNotExist().match(result);
}
});
}
}
Loading