Spring Boot In Action Direct

@Test void shouldCreateUser() throws Exception { User user = new User("test@example.com"); given(userService.save(any())).willReturn(user); mockMvc.perform(post("/api/users") .contentType(MediaType.APPLICATION_JSON) .content("{\"email\":\"test@example.com\"}")) .andExpect(status().isCreated()) .andExpect(jsonPath("$.email").value("test@example.com")); }

@GetMapping("/{id}") public ResponseEntity<User> getById(@PathVariable Long id) { return userService.findById(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } spring boot in action

@Timed(value = "api.processing.time", percentiles = {0.5, 0.95, 0.99}) public void processRequest() { requestCounter.increment(); // processing logic } } Unit & Integration Tests @SpringBootTest @AutoConfigureMockMvc class UserControllerTest { @Autowired private MockMvc mockMvc; @Test void shouldCreateUser() throws Exception { User user