### Question:
CommonPermissionCheckingUtils { public void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn) { Set<String> removableDefaultResourceCrns = Sets.newHashSet(); for (Map.Entry<String, AuthorizationResourceAction> resourceAndAction : resourcesWithActions.entrySet()) { String resourceCrn = resourceAndAction.getKey(); AuthorizationResourceAction action = resourceAndAction.getValue(); DefaultResourceChecker defaultResourceChecker = defaultResourceCheckerMap.get(umsRightProvider.getResourceType(action)); if (defaultResourceChecker != null && defaultResourceChecker.isDefault(resourceCrn)) { throwAccessDeniedIfActionNotAllowed(action, List.of(resourceCrn), defaultResourceChecker); removableDefaultResourceCrns.add(resourceCrn); } } removableDefaultResourceCrns.stream().forEach(resourceCrn -> resourcesWithActions.remove(resourceCrn)); if (!resourcesWithActions.isEmpty()) { umsResourceAuthorizationService.checkIfUserHasAtLeastOneRight(userCrn, resourcesWithActions); } }  @PostConstruct void init(); boolean legacyAuthorizationNeeded(); ResourceBasedCrnProvider getResourceBasedCrnProvider(AuthorizationResourceAction action); void checkPermissionForUser(AuthorizationResourceAction action, String userCrn); void checkPermissionForUserOnResource(Map<String, AuthorizationResourceAction> resourcesWithActions, String userCrn); void checkPermissionForUserOnResource(AuthorizationResourceAction action, String userCrn, String resourceCrn); void checkPermissionForUserOnResources(AuthorizationResourceAction action,
            String userCrn, Collection<String> resourceCrns); Map<String, Boolean> getPermissionsForUserOnResources(AuthorizationResourceAction action,
            String userCrn, List<String> resourceCrns); Object proceed(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, long startTime); boolean isAuthorizationDisabled(ProceedingJoinPoint proceedingJoinPoint); boolean isInternalOnly(ProceedingJoinPoint proceedingJoinPoint); T getParameter(ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature, Class annotation, Class<T> target);  }### Answer:
@Test public void testCheckPermissionForUserOnDefaultResource() { underTest.checkPermissionForUserOnResource(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG, USER_CRN, DEFAULT_RESOURCE_CRN); verify(defaultResourceChecker).isDefault(DEFAULT_RESOURCE_CRN); verify(defaultResourceChecker).isAllowedAction(AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG); verifyZeroInteractions(umsResourceAuthorizationService); }
@Test public void testCheckPermissionFailForUserOnDefaultResource() { AccessDeniedException exception = Assert.assertThrows(AccessDeniedException.class, () -> { underTest.checkPermissionForUserOnResource(AuthorizationResourceAction.DELETE_IMAGE_CATALOG, USER_CRN, DEFAULT_RESOURCE_CRN); }); assertEquals(exception.getMessage(), "You have no right to perform environments/deleteImageCatalog on resources [DEFAULT_RESOURCE_CRN]"); verify(defaultResourceChecker).isDefault(DEFAULT_RESOURCE_CRN); verify(defaultResourceChecker).isAllowedAction(AuthorizationResourceAction.DELETE_IMAGE_CATALOG); verifyZeroInteractions(umsResourceAuthorizationService); }
@Test public void testCheckPermissionForUserOnNotDefaultResource() { underTest.checkPermissionForUserOnResource(AuthorizationResourceAction.DELETE_IMAGE_CATALOG, USER_CRN, RESOURCE_CRN); verify(defaultResourceChecker).isDefault(RESOURCE_CRN); verify(umsResourceAuthorizationService).checkRightOfUserOnResource(USER_CRN, AuthorizationResourceAction.DELETE_IMAGE_CATALOG, RESOURCE_CRN); verify(defaultResourceChecker, times(0)).isAllowedAction(any()); }