### Question:
InMapIndexRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherFieldSpec(FieldSpec otherFieldSpec) { List<Object> whiteList = new ArrayList<>(); for (int i = 0; i < underlyingList.list().size(); i++) { Object testingElement = underlyingList.list().get(i); if (otherFieldSpec.canCombineWithWhitelistValue(testingElement)) { whiteList.add(BigDecimal.valueOf(i)); } } return FieldSpecFactory.fromList(DistributedList.uniform(whiteList)).withNotNull(); } InMapIndexRelation(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 reduceToRelatedFieldSpec_whenAllValid_returnCompleteWhiteList() { FieldSpec parameter = FieldSpecFactory.fromType(FieldType.STRING); FieldSpec expected = FieldSpecFactory.fromList(DistributedList.uniform(Arrays.asList(0, 1))).withNotNull(); FieldSpec actual = testInstance.createModifierFromOtherFieldSpec(parameter); assertThat(actual, sameBeanAs(expected)); }
@Test void reduceToRelatedFieldSpec_whenSomeValid_returnReducedWhiteList() { FieldSpec parameter = FieldSpecFactory.fromRestriction(StringRestrictionsFactory.forStringContaining(Pattern.compile("^f.*"), false)); FieldSpec expected = FieldSpecFactory.fromList(DistributedList.uniform(Collections.singletonList(0))).withNotNull(); FieldSpec actual = testInstance.createModifierFromOtherFieldSpec(parameter); assertThat(actual, sameBeanAs(expected)); }