forked from ADORSYS-GIS/e2e-banking-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ADORSYS-GIS#63 implement health endpoint (ADORSYS-GIS#79)
* feat: configure the health and metrics endpoints * feat: implement unit test for the health endpoint * Update pom.xml * updated: pom.xml file * fix: remove unneccessary file * Update PowerPayBackendHealthTest.java Fix failing test * Add test case for handling server failures in health endpoint * fix test --------- Co-authored-by: mbunwe-victor <mbunwevicki@gmail.com> Co-authored-by: chendi <lumblessingc@gmail.com>
- Loading branch information
1 parent
68087a2
commit f67af3c
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...end/src/test/java/com/adorsys/gis/powerpay/powerpaybackend/PowerPayBackendHealthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
} | ||
} |