### Question:
UmsAccountAuthorizationService { public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; }  void checkRightOfUser(String userCrn, AuthorizationResourceAction action); Boolean hasRightOfUser(String userCrn, String action); void checkCallerIsSelfOrHasRight(String actorCrnStr, String targetUserCrnStr, AuthorizationResourceAction action);  }### Answer:
@Test public void testHasRightOfUserWithValidResourceTypeAndAction() { when(umsClient.checkRight(anyString(), anyString(), anyString(), any())).thenReturn(true); assertTrue(ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "datalake/read"))); when(umsClient.checkRight(anyString(), anyString(), anyString(), any())).thenReturn(false); assertFalse(ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "datalake/read"))); }
@Test public void testHasRightOfUserWithInvalidAction() { thrown.expect(BadRequestException.class); thrown.expectMessage("Action cannot be found by request!"); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "invalid")); verifyZeroInteractions(umsClient); }