### Question:
CategoryController { @ApiOperation(value = "根据ID查询", notes = "id") @GetMapping(value = "/{id}") public JsonData<CategoryDto> findCategoryByPrimaryKey(@PathVariable String id) { CategoryDto result = categoryService.findCategoryById(id); return JsonData.success(result); } CategoryController(CategoryService categoryService); @ApiOperation(value = "查询全部数据", notes = "id") @GetMapping JsonData<Page<CategoryDto>> findCategoryByCondition(CategoryDto categoryDto,
	                                                           @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable); @ApiOperation(value = "根据ID查询", notes = "id") @GetMapping(value = "/{id}") JsonData<CategoryDto> findCategoryByPrimaryKey(@PathVariable String id); @ApiOperation(value = "添加一条新的分类", notes = "id") @PostMapping @OptLog(operationType = OptLogType.ADD, operationName = "添加文章分类") JsonData<Void> insertCategory(@RequestBody @Validated CategoryDto categoryDto); @PutMapping @OptLog(operationType = OptLogType.MODIFY, operationName = "修改文章分类") @ApiOperation(value = "修改文章分类", notes = "id") JsonData<Void> updateByCategorySelective(@RequestBody @Validated CategoryDto categoryDto); @DeleteMapping // @OptLog(operationType = OptLogType.DELETE, operationName = "删除文章分类") @ApiOperation(value = "删除文章分类", notes = "id") JsonData<Void> deleteCategoryByIds(@RequestBody List<String> categoryIds);  }### Answer:
@Test void testFindCategoryByPrimaryKey() { when(categoryService.findCategoryById(anyString())).thenReturn(new CategoryDto()); JsonData<CategoryDto> result = categoryController.findCategoryByPrimaryKey("id"); Assertions.assertEquals(new JsonData<CategoryDto>(true, 0, "message", any()), result); }