### Question:
AuthToLocalBuilder implements Cloneable { public AuthToLocalBuilder addRule(String principal, String localUsername) { if (!StringUtils.isEmpty(principal) && !StringUtils.isEmpty(localUsername)) { Principal p = new Principal(principal); if (p.getRealm() == null) { throw new IllegalArgumentException( "Attempted to add a rule for a principal with no realm: " + principal); } Rule rule = createHostAgnosticRule(p, localUsername); setRules.add(rule); } return this; } AuthToLocalBuilder(String defaultRealm, String additionalRealms, boolean caseInsensitiveUserSupport);  AuthToLocalBuilder(String defaultRealm, Collection<String> additionalRealms, boolean caseInsensitiveUserSupport); @Override Object clone(); AuthToLocalBuilder addRules(String authToLocalRules); AuthToLocalBuilder addRule(String principal, String localUsername); String generate(); String generate(ConcatenationType concatenationType); static final ConcatenationType DEFAULT_CONCATENATION_TYPE; }### Answer:
@Test(expected = IllegalArgumentException.class) public void testAddNewRuleWithNoRealm() { AuthToLocalBuilder builder = new AuthToLocalBuilder("EXAMPLE.COM", Collections.emptyList(), false); builder.addRule("someUser", "hdfs"); }
@Test(expected = IllegalArgumentException.class) public void testAddNewRuleWithNoRealm2() { AuthToLocalBuilder builder = new AuthToLocalBuilder("EXAMPLE.COM", Collections.emptyList(), false); builder.addRule("someUser/someHost", "hdfs"); }