### Question:
SchemaNameAsAttribute implements SchemaAccessWriter { @Override public Map<String, String> getAttributes(final RecordSchema schema) { final Map<String,String> attributes = new HashMap<>(3); final SchemaIdentifier identifier = schema.getIdentifier(); final Optional<String> nameOption = identifier.getName(); if (nameOption.isPresent()) { attributes.put(SCHEMA_NAME_ATTRIBUTE, nameOption.get()); } final OptionalInt versionOption = identifier.getVersion(); if (versionOption.isPresent()) { attributes.put(SCHEMA_VERSION_ATTRIBUTE, String.valueOf(versionOption.getAsInt())); } final Optional<String> branchOption = identifier.getBranch(); if (branchOption.isPresent()) { attributes.put(SCHEMA_BRANCH_ATTRIBUTE, branchOption.get()); } return attributes; }  @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 testWriteNameBranchAndVersion() { final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder() .name("person").branch("master").version(1).id(1L).build(); final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier); final Map<String,String> attributes = schemaAccessWriter.getAttributes(schema); Assert.assertEquals(3, attributes.size()); Assert.assertEquals(schemaIdentifier.getName().get(), attributes.get(SchemaNameAsAttribute.SCHEMA_NAME_ATTRIBUTE)); Assert.assertEquals(schemaIdentifier.getBranch().get(), attributes.get(SchemaNameAsAttribute.SCHEMA_BRANCH_ATTRIBUTE)); Assert.assertEquals(String.valueOf(schemaIdentifier.getVersion().getAsInt()), attributes.get(SchemaNameAsAttribute.SCHEMA_VERSION_ATTRIBUTE)); }
@Test public void testWriteOnlyName() { final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().name("person").id(1L).build(); final RecordSchema schema = new SimpleRecordSchema(fields, schemaIdentifier); final Map<String,String> attributes = schemaAccessWriter.getAttributes(schema); Assert.assertEquals(1, attributes.size()); Assert.assertEquals(schemaIdentifier.getName().get(), attributes.get(SchemaNameAsAttribute.SCHEMA_NAME_ATTRIBUTE)); }