### Question:
InMapRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { BigDecimal value = (BigDecimal) otherFieldGeneratedValue.getValue(); DistributedList<Object> newList = DistributedList.singleton(underlyingList.list().get(value.intValue())); return FieldSpecFactory.fromList(newList); } InMapRelation(Field main, Field other, DistributedList<Object> underlyingList); @Override FieldSpec createModifierFromOtherFieldSpec(FieldSpec otherFieldSpec); @Override FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue); @Override FieldSpecRelation inverse(); @Override Field main(); @Override Field other(); DistributedList<Object> getUnderlyingList(); @Override Constraint negate();  }### Answer:
@Test void reduceValueToFieldSpec_whenValidIndex_returnFieldSpec() { FieldSpec expected = FieldSpecFactory.fromList(DistributedList.singleton("bar")); FieldSpec actual = testInstance.createModifierFromOtherValue(new DataBagValue(BigDecimal.valueOf(1))); Assert.assertEquals(expected, actual); }
@Test void reduceValueToFieldSpec_whenInvalidIndex_throws() { assertThrows(IndexOutOfBoundsException.class, () -> testInstance.createModifierFromOtherValue(new DataBagValue(BigDecimal.valueOf(3)))); }
@Test void reduceValueToFieldSpec_whenInvalidIndexType_throws() { assertThrows(ClassCastException.class, () -> testInstance.createModifierFromOtherValue(new DataBagValue("bar"))); }