Group implements Iterable<AgentDirective> { @Nonnull public List<Directive> getDirectives() { return directives; } Group(@Nonnull Builder builder); @Nonnull List<Directive> getDirectives(); @Nonnull List<T> getDirectives(@Nonnull Class<T> directiveType); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Nonnull @Override String toString(); @Override Iterator<AgentDirective> iterator();  }
@Test public void givenGroupIsEmpty_whenGetDirectives_thenReturnsEmptyList() { Group group = new Group.Builder().build(); assertThat(group.getDirectives(), empty()); }
@Test public void givenGroupIsSingleton_whenGetDirectives_thenReturnsCollectionOfSizeOne() { Group group = new Group.Builder() .withDirective(new OtherDirective("key", "value")) .build(); assertThat(group.getDirectives(), hasSize(1)); }
@Test public void givenGroupContainsOtherDirective_whenGetOtherDirectives_thenReturnsCollectionOfSizeOne() { Group group = new Group.Builder() .withDirective(new OtherDirective("key", "value")) .build(); assertThat(group.getDirectives(OtherDirective.class), hasSize(1)); }