### Question:
Validators { public static Validator<String> inList( String[] validStrings ) { return value -> { if ( Arrays.stream( validStrings ).noneMatch( s -> s.equals( value ) ) ) { throw new IllegalArgumentException( "'" + value + "' found but must be one of: " + Arrays.toString( validStrings ) + "." ); } }; } private  Validators(); static Validator<String> inList( String[] validStrings ); static Validator<T[]> atLeast( final String key, final int length ); static Validator<T> emptyValidator(); static Validator<T> all( Validator<T>... validators ); static final Validator<File> REGEX_FILE_EXISTS; static final Validator<File> DIRECTORY_IS_WRITABLE; static final Validator<File> CONTAINS_NO_EXISTING_DATABASE; static final Validator<File> CONTAINS_EXISTING_DATABASE; }### Answer:
@Test public void shouldValidateInList() { try { Validators.inList(new String[] { "foo", "bar", "baz" }).validate( "qux" ); fail( "Should have failed to find item in list." ); } catch ( IllegalArgumentException e ) { assertThat( e.getMessage(), containsString( "'qux' found but must be one of: [foo, bar, baz]." ) ); } try { Validators.inList(new String[] { "foo", "bar", "baz" }).validate( "bar" ); } catch ( IllegalArgumentException e ) { fail( "Should have found item in list." ); } }