CustomerController { @PutMapping("{customerId}") public ResponseEntity<Customer> updateCustomer(@RequestBody Customer updateCustomerRequest, @PathVariable("customerId") Long customerId) throws EntityNotFoundException { log.info("Updating Customer {}", customerId); final Customer currentUser = this.customerService.getCustomer(customerId); if (currentUser.equals(updateCustomerRequest)) { return ResponseEntity.status(HttpStatus.NOT_MODIFIED).build(); } final Customer updatedCustomer = this.customerService.updateCustomer(updateCustomerRequest, customerId); return new ResponseEntity<>(updatedCustomer, HttpStatus.OK); }  @GetMapping ResponseEntity<List<Customer>> getCustomers(); @GetMapping(value = "{customerId}", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Customer> getCustomer(@PathVariable("customerId") @NotBlank Long customerId); @PostMapping ResponseEntity<Object> createCustomer(@Valid @RequestBody Customer customer, UriComponentsBuilder ucBuilder,
			Errors errors); @PutMapping("{customerId}") ResponseEntity<Customer> updateCustomer(@RequestBody Customer updateCustomerRequest,
			@PathVariable("customerId") Long customerId); @DeleteMapping("{customerId}") ResponseEntity<Customer> removeCustomer(@PathVariable("customerId") Long customerId); @DeleteMapping ResponseEntity<Customer> deleteAllUsers();  }
@Test void testUpdateCustomer() throws Exception { given(this.customerService.getCustomer(ArgumentMatchers.anyLong())) .willReturn(Customer.builder().firstName("firstName").build()); final Customer updateRequest = this.customer; final LocalDateTime dateOfBirth = LocalDateTime.now(); updateRequest.setDateOfBirth(dateOfBirth); given(this.customerService.updateCustomer(ArgumentMatchers.any(Customer.class), ArgumentMatchers.anyLong())) .willReturn(this.customer); this.mockMvc .perform(MockMvcRequestBuilders.put("/rest/customers/{customerId}", RandomUtils.nextLong()) .content(this.objectMapper.writeValueAsString(updateRequest)) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("firstName").value("firstName")) .andExpect(jsonPath("lastName").value("lastName")) .andExpect(jsonPath("dateOfBirth").value(dateOfBirth.toString())); }