### Question:
PrivilegeValidator { public void validateReferralPrivilege(ReferralPrivilege referralPrivilege) throws EntitlementException { Set<String> referralPrivilegeRealms = referralPrivilege.getRealms(); realmValidator.validateRealms(referralPrivilegeRealms); } @Inject  PrivilegeValidator(RealmValidator realmValidator); void validatePrivilege(Privilege privilege); void validateReferralPrivilege(ReferralPrivilege referralPrivilege);  }### Answer:
@Test public void shouldErrorIfRealmWasNotValid() throws EntitlementException { doThrow(new EntitlementException(EntitlementException.INVALID_SEARCH_FILTER)) .when(mockValidator).validateRealms(ArgumentMatchers.<String>anyCollection()); try { validator.validateReferralPrivilege(createReferral("Badger")); fail(); } catch (EntitlementException e) { } }
@Test public void shouldErrorIfRealmWasNotValid() throws EntitlementException { doThrow(new EntitlementException(EntitlementException.INVALID_SEARCH_FILTER)) .when(mockValidator).validateRealms(anyListOf(String.class)); try { validator.validateReferralPrivilege(createReferral("Badger")); fail(); } catch (EntitlementException e) { } }