### Question:
ResourceNamePermissionChecker extends ResourcePermissionChecker<CheckPermissionByResourceName> { @Override public <T extends Annotation> void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime) { CheckPermissionByResourceName methodAnnotation = (CheckPermissionByResourceName) rawMethodAnnotation; AuthorizationResourceAction action = methodAnnotation.action(); String resourceName = getCommonPermissionCheckingUtils().getParameter(proceedingJoinPoint, methodSignature, ResourceName.class, String.class); ResourceBasedCrnProvider resourceBasedCrnProvider = getCommonPermissionCheckingUtils().getResourceBasedCrnProvider(action); String resourceCrn = resourceBasedCrnProvider.getResourceCrnByResourceName(resourceName); Map<String, AuthorizationResourceAction> authorizationActions = getAuthorizationActions(resourceCrn, action); getCommonPermissionCheckingUtils().checkPermissionForUserOnResource(authorizationActions, userCrn); }  @Override void checkPermissions(T rawMethodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint,
            MethodSignature methodSignature, long startTime); @Override Class<CheckPermissionByResourceName> supportedAnnotation();  }### Answer:
@Test public void testCheckPermissions() { when(commonPermissionCheckingUtils.getParameter(any(), any(), any(), any())).thenReturn("resource"); when(resourceBasedCrnProvider.getResourceCrnByResourceName(any())).thenReturn(USER_CRN); when(resourceBasedCrnProvider.getEnvironmentCrnByResourceCrn(anyString())).thenReturn(Optional.empty()); when(commonPermissionCheckingUtils.getResourceBasedCrnProvider(AuthorizationResourceAction.EDIT_CREDENTIAL)).thenReturn(resourceBasedCrnProvider); CheckPermissionByResourceName rawMethodAnnotation = new CheckPermissionByResourceName() { @Override public AuthorizationResourceAction action() { return AuthorizationResourceAction.EDIT_CREDENTIAL; } @Override public Class<? extends Annotation> annotationType() { return CheckPermissionByResourceName.class; } }; underTest.checkPermissions(rawMethodAnnotation, USER_CRN, null, null, 0L); verify(commonPermissionCheckingUtils).getParameter(any(), any(), eq(ResourceName.class), eq(String.class)); verify(commonPermissionCheckingUtils, times(0)).checkPermissionForUser(any(), anyString()); ArgumentCaptor<Map<String, AuthorizationResourceAction>> captor = ArgumentCaptor.forClass(Map.class); verify(commonPermissionCheckingUtils).checkPermissionForUserOnResource(captor.capture(), eq(USER_CRN)); Map<String, AuthorizationResourceAction> capturedActions = captor.getValue(); assertEquals(1, capturedActions.keySet().size()); assertThat(capturedActions, IsMapContaining.hasEntry(USER_CRN, AuthorizationResourceAction.EDIT_CREDENTIAL)); }