Initialize HemHub project foundation
This commit is contained in:
18
backend/src/main/java/se/rubble/hemhub/HealthController.java
Normal file
18
backend/src/main/java/se/rubble/hemhub/HealthController.java
Normal file
@ -0,0 +1,18 @@
|
||||
package se.rubble.hemhub;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class HealthController {
|
||||
|
||||
@GetMapping("/health")
|
||||
public Map<String, String> health() {
|
||||
return Map.of("status", "UP");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package se.rubble.hemhub;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class HemHubApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(HemHubApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package se.rubble.hemhub;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
class HealthControllerTest {
|
||||
|
||||
private final MockMvc mockMvc =
|
||||
MockMvcBuilders.standaloneSetup(new HealthController()).build();
|
||||
|
||||
@Test
|
||||
void healthReturnsUp() throws Exception {
|
||||
mockMvc.perform(get("/api/health"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.status").value("UP"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user