### Question:
SearchController { @GetMapping(value = "/v1/search/categories") public ResponseEntity<Object> getSearchCategories(@RequestParam(name = "domain", required = false) String domain) { List<String> searchCategories = searchService.getSearchCategories(domain); return ResponseUtils.buildSucessResponse(searchCategories); }  @PostMapping(value = "/v1/search") ResponseEntity<Object> search(@RequestBody SearchCriteria criteria); @GetMapping(value = "/v1/search/categories") ResponseEntity<Object> getSearchCategories(@RequestParam(name = "domain", required = false) String domain);  }### Answer:
@Test public void testgetSearchCategories() throws Exception { when(service.getSearchCategories("domain")).thenReturn(Arrays.asList("cat1", "cat2")); ReflectionTestUtils.setField(controller, "searchService", service); ResponseEntity<Object> responseObj = controller.getSearchCategories("domain"); assertTrue(responseObj.getStatusCode() == HttpStatus.OK); assertTrue(((List<String>) (((Map<String, Object>) responseObj.getBody()).get("data"))).size() == 2); }