### Question:
Converters { public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } }  static StringArrayToEncodedArrayOfLimitedValues stringArrayToEncodedArrayOf(String... values); static StringToEncodedStringOfLimitedValuesConverter stringToEncodedStringOf(String... values); static StringToUnencodedStringOfLimitedValuesConverter stringToUnencodedStringOf(String... values); static Converter forType(String type, String... options); static final StringToStringConverter stringToString; static final ArrayToEncodedArrayConverter arrayToEncodedArray; static final HyperlinksConverter hyperlinks; static final DatableConverter datable; static final StringToEncodedStringOfLimitedValuesConverter gender; static final PersonNamesConverter personNames; static final StringToUnencodedStringOfLimitedValuesConverter stringOfYesNoUnknown; static final DefaultLocationNameConverter defaultLocationNameConverter; static final DefaultFullPersonNameConverter defaultFullPersonNameConverter; static final AltNamesConverter altNames; }### Answer:
@Test public void forTypeReturnsAConverterMatchingTheTypeName() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { assertThat(Converters.forType(PersonNamesConverter.TYPE), instanceOf(PersonNamesConverter.class)); assertThat(Converters.forType(DatableConverter.TYPE), instanceOf(DatableConverter.class)); assertThat(Converters.forType(StringToStringConverter.TYPE), instanceOf(StringToStringConverter.class)); assertThat(Converters.forType(HyperlinksConverter.TYPE), instanceOf(HyperlinksConverter.class)); assertThat(Converters.forType(DefaultFullPersonNameConverter.TYPE), instanceOf(DefaultFullPersonNameConverter.class)); assertThat(Converters.forType(ArrayToEncodedArrayConverter.TYPE), instanceOf(ArrayToEncodedArrayConverter.class)); assertThat(Converters.forType(AltNamesConverter.TYPE), instanceOf(AltNamesConverter.class)); }
@Test public void forTypeReturnsAConverterWithOptionsMatchingTheTypeName() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { final String[] options = {"a", "b"}; final Converter encodedString = Converters.forType(StringToEncodedStringOfLimitedValuesConverter.TYPE, options); final Converter encodedArray = Converters.forType(StringArrayToEncodedArrayOfLimitedValues.TYPE, options); final Converter unEncodedString = Converters.forType(StringToUnencodedStringOfLimitedValuesConverter.TYPE, options); assertThat(encodedString, instanceOf(StringToEncodedStringOfLimitedValuesConverter.class)); assertThat(encodedArray, instanceOf(StringArrayToEncodedArrayOfLimitedValues.class)); assertThat(unEncodedString, instanceOf(StringToUnencodedStringOfLimitedValuesConverter.class)); assertThat(((HasOptions) encodedString).getOptions(), contains("a", "b")); assertThat(((HasOptions) encodedArray).getOptions(), contains("a", "b")); assertThat(((HasOptions) unEncodedString).getOptions(), contains("a", "b")); }