### Question:
UmsResourceAuthorizationService { public void checkRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, Collection<String> resourceCrns) { if (!umsClient.isAuthorizationEntitlementRegistered(userCrn, ThreadBasedUserCrnProvider.getAccountId())) { checkRightOfUserOnResource(userCrn, action, null); return; } String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resources [%s]", right, Joiner.on(",").join(resourceCrns)); checkRightOfUserOnResources(userCrn, right, resourceCrns, unauthorizedMessage); }  void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn); Map<String, Boolean> getRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, List<String> resourceCrns); void checkRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, Collection<String> resourceCrns); void checkIfUserHasAtLeastOneRight(String userCrn, Map<String, AuthorizationResourceAction> checkedRightsForResources);  }### Answer:
@Test public void testCheckRightOnResourcesFailure() { when(umsClient.hasRights(anyString(), anyString(), anyList(), anyString(), any())).thenReturn(hasRightsResultMap()); thrown.expect(AccessDeniedException.class); thrown.expectMessage("You have no right to perform environments/describeEnvironment on resources [" + RESOURCE_CRN + "," + RESOURCE_CRN2 + "]"); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest. checkRightOfUserOnResources(USER_CRN, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT, Lists.newArrayList(RESOURCE_CRN, RESOURCE_CRN2))); }
@Test public void testCheckRightOnResources() { Map<String, Boolean> resultMap = hasRightsResultMap(); resultMap.put(RESOURCE_CRN2, Boolean.TRUE); when(umsClient.hasRights(anyString(), anyString(), anyList(), anyString(), any())).thenReturn(resultMap); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest. checkRightOfUserOnResources(USER_CRN, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT, Lists.newArrayList(RESOURCE_CRN, RESOURCE_CRN2))); }