### Question:
SecurityController { @RequestMapping(value="/security/haspermission", method=RequestMethod.GET) @ResponseBody public JsonResponse hasPermission( @RequestParam("targetId") long targetId, @RequestParam("targetType") String targetType, @RequestParam("permission") String permission) { if (permissionService.hasPermission(targetId, targetType, permission)) { return new JsonResponse(JsonResponseStatus.SUCCESS); } else { return new JsonResponse(JsonResponseStatus.FAIL); } } @Autowired  SecurityController(PermissionService permissionService); @RequestMapping(value="/security/haspermission", method=RequestMethod.GET) @ResponseBody JsonResponse hasPermission(
            @RequestParam("targetId") long targetId,
            @RequestParam("targetType") String targetType,
            @RequestParam("permission") String permission);  }### Answer:
@Test public void testHasPermissionPermissionGranted() { when(permissionService.hasPermission( anyLong(), anyString(), anyString())).thenReturn(true); JsonResponse response = securityController.hasPermission(0, null, null); assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS); }
@Test public void testHasPermissionPermissionNotGranted() { when(permissionService.hasPermission( anyLong(), anyString(), anyString())).thenReturn(false); JsonResponse response = securityController.hasPermission(0, null, null); assertEquals(response.getStatus(), JsonResponseStatus.FAIL); }