-
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.
Merge pull request #4 from everymeals/chore/project-setting
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
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
16 changes: 16 additions & 0 deletions
16
src/main/java/everymeal/server/infra/HealthCheckController.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,16 @@ | ||
package everymeal.server.infra; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/health-check") | ||
public class HealthCheckController { | ||
|
||
@GetMapping | ||
public String healthCheck() { | ||
return "Server is Up!"; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/everymeal/server/infra/HealthCheckControllerTest.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,32 @@ | ||
package everymeal.server.infra; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import everymeal.server.infra.HealthCheckController; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
@WebMvcTest(HealthCheckController.class) | ||
class HealthCheckControllerTest { | ||
|
||
@Autowired | ||
MockMvc mvc; | ||
|
||
@Test | ||
@DisplayName("health-check") | ||
void healthCheck() throws Exception { | ||
//given | ||
String hello = "Server is Up!"; | ||
//when | ||
|
||
//then | ||
mvc.perform(get("/health-check")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(hello)); | ||
} | ||
} |