### Question:
ColorTypeController { @GetMapping("/active") public ResponseEntity<?> getActiveColors() { DataResponse<ColorType> response = colorOperations.getActiveColors(); return new ResponseEntity<>(response, response.getHttpStatus()); } ColorTypeController(ColorTypeOperations colorOperations); @GetMapping("/active") ResponseEntity<?> getActiveColors(); @GetMapping ResponseEntity<?> getAllColors(); @PutMapping("/{color-id}/availability") ResponseEntity<?> colorTypeUpdateAvailability(@PathVariable("color-id") Integer colorId,
                                                  @RequestBody ColorTypeUpdateRequest dto); @GetMapping("/inactive") ResponseEntity<?> getInactiveColors();  }### Answer:
@Test public void getAllAvailableColors() throws Exception { ColorType color = new ColorType(1, "yellow"); List<ColorType> colorList = Arrays.asList(color); DataResponse<ColorType> expectedResponse = new DataResponse<ColorType>(); expectedResponse.setSuccess(true); expectedResponse.setMessage("Successfully returned print jobs by " + Status.ARCHIVED.getName() + " status"); expectedResponse.setData(colorList); expectedResponse.setHttpStatus(HttpStatus.ACCEPTED); Mockito.when(operations.getActiveColors()).thenReturn(expectedResponse); String jsonString = mockMvc.perform( MockMvcRequestBuilders.get("/api/colors/active") .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isAccepted()) .andReturn().getResponse().getContentAsString(); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); DataResponse<ColorType> actualResponse = mapper.readValue(jsonString, new TypeReference<DataResponse<ColorType>>() {}); verify(operations, times(1)).getActiveColors(); assertEquals(actualResponse.getMessage(), expectedResponse.getMessage()); }