### Question:
EncodingHelper implements Serializable { public static String decodeDoubleToCategory(final double doubleValue, final CategoricalValueSchema categoricalValueSchema) { final int index = (int) doubleValue; return Iterables.get(categoricalValueSchema.getNominalValues(), index); } EncodingHelper(final DatasetSchema schema); static SerializableEncoder encoderForField(final AbstractValueSchema abstractValueSchema); static String decodeDoubleToCategory(final double doubleValue,
                                                final CategoricalValueSchema categoricalValueSchema); static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema); Serializable encode(final Serializable value, final int index); int numberFields();  }### Answer:
@Test public void testDecodeCategorical() { final CategoricalValueSchema schema = new CategoricalValueSchema( true, ImmutableSet.of( "fraud", "genuine" ) ); assertThat(EncodingHelper.decodeDoubleToCategory(1.0, schema)) .as("Converting a valid index") .isEqualTo("genuine"); assertThatThrownBy(() -> EncodingHelper.decodeDoubleToCategory(2.0, schema)) .as("Converting an index too large") .isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> EncodingHelper.decodeDoubleToCategory(-3.0, schema)) .as("Converting a negative index") .isInstanceOf(IndexOutOfBoundsException.class); }