### Question:
SchemaNameAsAttribute implements SchemaAccessWriter { @Override public void validateSchema(final RecordSchema schema) throws SchemaNotFoundException { final SchemaIdentifier schemaId = schema.getIdentifier(); if (schemaId == null) { throw new SchemaNotFoundException("Cannot write Schema Name As Attribute because Schema Identifier is not known"); } if (!schemaId.getName().isPresent()) { throw new SchemaNotFoundException("Cannot write Schema Name As Attribute because the Schema Name is not known"); } }  @Override void writeHeader(final RecordSchema schema, final OutputStream out); @Override Map<String, String> getAttributes(final RecordSchema schema); @Override void validateSchema(final RecordSchema schema); @Override Set<SchemaField> getRequiredSchemaFields();  }### Answer:
@Test public void testValidateSchemaWhenValid() throws SchemaNotFoundException { final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().name("person").id(1L).build(); final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier); schemaAccessWriter.validateSchema(schema); }
@Test(expected = SchemaNotFoundException.class) public void testValidateSchemaWhenNoIdentifier() throws SchemaNotFoundException { final RecordSchema schema = new SimpleRecordSchema(fields, null); schemaAccessWriter.validateSchema(schema); }
@Test(expected = SchemaNotFoundException.class) public void testValidateSchemaWhenNoName() throws SchemaNotFoundException { final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().id(1L).build(); final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier); schemaAccessWriter.validateSchema(schema); }