GroupSet implements UsableGroupManager<SelectedGroup<T>> { @Override public SelectedGroup<T> useGroup(final String group) { Objects.requireNonNull(group, "group must not be null"); return new SelectedGroup<>(find(group)); } GroupSet(final Set<T> all, final Map<String, Set<T>> groups, final Set<T> defaults); SelectedGroup<T> useAll(); @Override SelectedGroup<T> useDefaultGroup(); @Override SelectedGroup<T> useGroup(final String group); @Override SelectedGroup<T> useOptionalGroup(final Optional<String> group); Set<GroupMember<T>> inspectAll(); static GroupSet<T> build(
        Collection<T> configured, Optional<List<String>> defaultBackends
    );  }
@Test public void useGroupTest() { assertEquals(ImmutableSet.of(a, b, c), g.useDefaultGroup().getMembers()); assertEquals(ImmutableSet.of(a, b, c), g.useOptionalGroup(Optional.empty()).getMembers()); assertEquals(ImmutableSet.of(a, b), g.useGroup("foo").getMembers()); assertEquals(ImmutableSet.of(b, c), g.useGroup("bar").getMembers()); }
@Test public void useMissingGroupTest() { assertEquals(ImmutableSet.of(), g.useGroup("baz").getMembers()); }
@Test(expected = NullPointerException.class) public void useNullFailureTest() { assertEquals(ImmutableSet.of(), g.useGroup(null).getMembers()); }