@Test public void testCheckPermissions() { doNothing().when(commonPermissionCheckingUtils).checkPermissionForUserOnResources(any(), anyString(), any()); when(commonPermissionCheckingUtils.getParameter(any(), any(), any(), any())).thenReturn(Lists.newArrayList(USER_CRN, USER_CRN)); CheckPermissionByResourceCrnList rawMethodAnnotation = new CheckPermissionByResourceCrnList() { @Override public AuthorizationResourceAction action() { return AuthorizationResourceAction.EDIT_CREDENTIAL; } @Override public Class<? extends Annotation> annotationType() { return CheckPermissionByResourceCrnList.class; } }; underTest.checkPermissions(rawMethodAnnotation, USER_CRN, null, null, 0L); verify(commonPermissionCheckingUtils).getParameter(any(), any(), eq(ResourceCrnList.class), eq(Collection.class)); verify(commonPermissionCheckingUtils, times(0)).checkPermissionForUser(any(), anyString()); verify(commonPermissionCheckingUtils).checkPermissionForUserOnResources(eq(AuthorizationResourceAction.EDIT_CREDENTIAL), eq(USER_CRN), any()); }
@Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceCrnList methodAnnotation = (CheckPermissionByResourceCrnList) rawMethodAnnotation; Collection<String> resourceCrns = commonPermissionCheckingUtils .getParameter(proceedingJoinPoint, methodSignature, ResourceCrnList.class, Collection.class); AuthorizationResourceAction action = methodAnnotation.action(); commonPermissionCheckingUtils.checkPermissionForUserOnResources(action, userCrn, resourceCrns); }
ResourceCrnListPermissionChecker implements PermissionChecker<CheckPermissionByResourceCrnList> { @Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceCrnList methodAnnotation = (CheckPermissionByResourceCrnList) rawMethodAnnotation; Collection<String> resourceCrns = commonPermissionCheckingUtils .getParameter(proceedingJoinPoint, methodSignature, ResourceCrnList.class, Collection.class); AuthorizationResourceAction action = methodAnnotation.action(); commonPermissionCheckingUtils.checkPermissionForUserOnResources(action, userCrn, resourceCrns); } }
ResourceCrnListPermissionChecker implements PermissionChecker<CheckPermissionByResourceCrnList> { @Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceCrnList methodAnnotation = (CheckPermissionByResourceCrnList) rawMethodAnnotation; Collection<String> resourceCrns = commonPermissionCheckingUtils .getParameter(proceedingJoinPoint, methodSignature, ResourceCrnList.class, Collection.class); AuthorizationResourceAction action = methodAnnotation.action(); commonPermissionCheckingUtils.checkPermissionForUserOnResources(action, userCrn, resourceCrns); }  }
ResourceCrnListPermissionChecker implements PermissionChecker<CheckPermissionByResourceCrnList> { @Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceCrnList methodAnnotation = (CheckPermissionByResourceCrnList) rawMethodAnnotation; Collection<String> resourceCrns = commonPermissionCheckingUtils .getParameter(proceedingJoinPoint, methodSignature, ResourceCrnList.class, Collection.class); AuthorizationResourceAction action = methodAnnotation.action(); commonPermissionCheckingUtils.checkPermissionForUserOnResources(action, userCrn, resourceCrns); }  @Override void checkPermissions(T rawMethodAnnotation, String userCrn,
            ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); @Override Class<CheckPermissionByResourceCrnList> supportedAnnotation(); }
ResourceCrnListPermissionChecker implements PermissionChecker<CheckPermissionByResourceCrnList> { @Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceCrnList methodAnnotation = (CheckPermissionByResourceCrnList) rawMethodAnnotation; Collection<String> resourceCrns = commonPermissionCheckingUtils .getParameter(proceedingJoinPoint, methodSignature, ResourceCrnList.class, Collection.class); AuthorizationResourceAction action = methodAnnotation.action(); commonPermissionCheckingUtils.checkPermissionForUserOnResources(action, userCrn, resourceCrns); }  @Override void checkPermissions(T rawMethodAnnotation, String userCrn,
            ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); @Override Class<CheckPermissionByResourceCrnList> supportedAnnotation();  }