### Question:
Selectors { @SafeVarargs public static <Input, Output> SelectorFunction<Input, Output> firstAvailable(@NonNull final SelectorFunction<Input, Output> function, final SelectorFunction<Input, Output>... functions) { return new SelectorFunction<Input, Output>() { @SuppressWarnings("unchecked") @Override public Output select(Input input) { Output result = function.select(input); if (result != null) { return result; } for (SelectorFunction<Input, Output> selectorFunction : functions) { result = selectorFunction.select(input); if (result != null) { return result; } } return null; } }; }  @SafeVarargs static SelectorFunction<Input, Output> firstAvailable(@NonNull final SelectorFunction<Input, Output> function,
                                                         final SelectorFunction<Input, Output>... functions); static SelectorFunction<Collection<T>, T> filtered(@NonNull final SelectorFunction<Collection<T>, T> selector,
                                                   @NonNull final Predicate<T> predicate); static SelectorFunction<Collection<T>, T> single(final T preference); static SelectorFunction<Input, Output> nothing();  }### Answer:
@Test public void firstAvailable() throws Exception { List<String> options = asList("B", "C"); given(functionA.select(options)) .willReturn(null); given(functionB.select(options)) .willReturn("B"); String result = Selectors .firstAvailable( functionA, functionB ) .select(options); assertEquals("B", result); }