void validateAttributesField(Schema schema) {
    String attributesKeyName = getAttributesKeyName();
    if (!schema.hasField(attributesKeyName)) {
      return;
    }
    checkArgument(
        SchemaReflection.of(schema)
            .matchesAll(FieldMatcher.of(attributesKeyName, ATTRIBUTES_FIELD_TYPE)));
  }
@Test
  public void testValidateAttributesField() {
    PubsubRowToMessage pubsubRowToMessage = PubsubRowToMessage.builder().build();
    pubsubRowToMessage.validateAttributesField(ALL_DATA_TYPES_SCHEMA);
    pubsubRowToMessage.validateAttributesField(
        Schema.of(Field.of(DEFAULT_ATTRIBUTES_KEY_NAME, ATTRIBUTES_FIELD_TYPE)));

    assertThrows(
        IllegalArgumentException.class,
        () ->
            pubsubRowToMessage.validateAttributesField(
                Schema.of(Field.of(DEFAULT_ATTRIBUTES_KEY_NAME, FieldType.STRING))));

    assertThrows(
        IllegalArgumentException.class,
        () ->
            pubsubRowToMessage.validateAttributesField(
                Schema.of(
                    Field.of(
                        DEFAULT_ATTRIBUTES_KEY_NAME,
                        FieldType.map(FieldType.STRING, FieldType.BYTES)))));

    assertThrows(
        IllegalArgumentException.class,
        () ->
            pubsubRowToMessage.validateAttributesField(
                Schema.of(
                    Field.of(
                        DEFAULT_ATTRIBUTES_KEY_NAME,
                        FieldType.map(FieldType.BYTES, FieldType.STRING)))));

    assertThrows(
        IllegalArgumentException.class,
        () ->
            PubsubRowToMessage.builder().build().validateSerializableFields(ALL_DATA_TYPES_SCHEMA));
  }