CustomerController { @GetMapping(value = "{customerId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Customer> getCustomer(@PathVariable("customerId") @NotBlank Long customerId) throws EntityNotFoundException { log.info("Fetching Customer with id {}", customerId); final Customer user = this.customerService.getCustomer(customerId); return new ResponseEntity<>(user, 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 testGetCustomer() throws Exception { given(this.customerService.getCustomer(ArgumentMatchers.anyLong())).willReturn(this.customer); this.mockMvc.perform(MockMvcRequestBuilders.get("/rest/customers/{customerId}", RandomUtils.nextLong())) .andExpect(status().isOk()).andExpect(jsonPath("firstName").value("firstName")) .andExpect(jsonPath("lastName").value("lastName")); }
@Test void testUpdateSameCustomer() throws Exception { given(this.customerService.getCustomer(ArgumentMatchers.anyLong())).willReturn(this.customer); this.mockMvc.perform(MockMvcRequestBuilders.put("/rest/customers/{customerId}", this.customer.getId()) .content(this.objectMapper.writeValueAsString(this.customer)).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotModified()); }