### Question:
Rules implements Iterable<Rule> { public void register(Object... rules) { Objects.requireNonNull(rules); for (Object rule : rules) { Objects.requireNonNull(rule); this.rules.add(RuleProxy.asRule(rule)); } } Rules(Set<Rule> rules);  Rules(Rule... rules);  Rules(Object... rules); void register(Object... rules); void unregister(Object... rules); void unregister(final String ruleName); boolean isEmpty(); void clear(); int size(); @Override Iterator<Rule> iterator();  }### Answer:
@Test public void register() { rules.register(new DummyRule()); assertThat(rules).hasSize(1); }
@Test public void sort() { Rule r1 = new BasicRule("rule", "", 1); Rule r2 = new BasicRule("rule", "", Integer.MAX_VALUE); DummyRule r3 = new DummyRule(); rules.register(r3); rules.register(r1); rules.register(r2); assertThat(rules).startsWith(r1).endsWith(r2); }
@Test(expected = NullPointerException.class) public void whenRegisterNullRule_thenShouldThrowNullPointerException() { rules.register(null); }