### Question:
SimpleRecordSchema implements RecordSchema { @Override public Optional<DataType> getDataType(final String fieldName) { final RecordField field = fieldMap.get(fieldName); if (field == null) { return Optional.empty(); } return Optional.of(field.getDataType()); } SimpleRecordSchema(final List<RecordField> fields);  SimpleRecordSchema(final List<RecordField> fields, final SchemaIdentifier id);  SimpleRecordSchema(final String text, final String schemaFormat, final SchemaIdentifier id);  SimpleRecordSchema(final List<RecordField> fields, final String text, final String schemaFormat, final SchemaIdentifier id); private  SimpleRecordSchema(final List<RecordField> fields, final String text, final String schemaFormat, final boolean textAvailable, final SchemaIdentifier id); private  SimpleRecordSchema(final String text, final String schemaFormat, final boolean textAvailable, final SchemaIdentifier id); @Override Optional<String> getSchemaText(); @Override Optional<String> getSchemaFormat(); @Override List<RecordField> getFields(); void setFields(final List<RecordField> fields); @Override int getFieldCount(); @Override RecordField getField(final int index); @Override List<DataType> getDataTypes(); @Override List<String> getFieldNames(); @Override Optional<DataType> getDataType(final String fieldName); @Override Optional<RecordField> getField(final String fieldName); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); @Override SchemaIdentifier getIdentifier();  }### Answer:
@Test public void testPreventsTwoFieldsWithSameAlias() { final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("hello", RecordFieldType.STRING.getDataType(), null, set("foo", "bar"))); fields.add(new RecordField("goodbye", RecordFieldType.STRING.getDataType(), null, set("baz", "bar"))); try { new SimpleRecordSchema(fields); Assert.fail("Was able to create two fields with same alias"); } catch (final IllegalArgumentException expected) { } }
@Test public void testPreventsTwoFieldsWithSameName() { final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("hello", RecordFieldType.STRING.getDataType(), null, set("foo", "bar"))); fields.add(new RecordField("hello", RecordFieldType.STRING.getDataType())); try { new SimpleRecordSchema(fields); Assert.fail("Was able to create two fields with same name"); } catch (final IllegalArgumentException expected) { } }
@Test public void testPreventsTwoFieldsWithConflictingNamesAliases() { final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("hello", RecordFieldType.STRING.getDataType(), null, set("foo", "bar"))); fields.add(new RecordField("bar", RecordFieldType.STRING.getDataType())); try { new SimpleRecordSchema(fields); Assert.fail("Was able to create two fields with conflicting names/aliases"); } catch (final IllegalArgumentException expected) { } }