### Question:
NameMapping implements Serializable { public static NameMapping of(MappedField... fields) { return new NameMapping(MappedFields.of(ImmutableList.copyOf(fields))); } NameMapping(MappedFields mapping); static NameMapping of(MappedField... fields); static NameMapping of(List<MappedField> fields); static NameMapping of(MappedFields fields); MappedField find(int id); MappedField find(String... names); MappedField find(List<String> names); MappedFields asMappedFields(); @Override String toString();  }### Answer:
@Test public void testFailsDuplicateName() { AssertHelpers.assertThrows("Should fail if names are reused", IllegalArgumentException.class, "Multiple entries with same key", () -> new NameMapping(MappedFields.of(MappedField.of(1, "x"), MappedField.of(2, "x")))); }
@Test public void testAllowsDuplicateNamesInSeparateContexts() { new NameMapping(MappedFields.of( MappedField.of(1, "x", MappedFields.of(MappedField.of(3, "x"))), MappedField.of(2, "y", MappedFields.of(MappedField.of(4, "x"))) )); }