.withName(schemaNameAdjuster.adjust(envelopSchemaName)) .withRecord(valSchema) .withSource(sourceInfoSchema) .build();
.withName(schemaNameAdjuster.adjust(envelopSchemaName)) .withRecord(valSchema) .withSource(sourceInfoSchema) .build();
/** * Define the {@link Schema} used in the {@link FieldName#SOURCE} field. * * @param sourceSchema the schema of the {@link FieldName#SOURCE} field; may not be null * @return this builder so methods can be chained; never null */ default Builder withSource(Schema sourceSchema) { return withSchema(sourceSchema, FieldName.SOURCE); }
/** * Define the {@link Schema} used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields. * * @param schema the schema of the records, used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields; may * not be null * @return this builder so methods can be chained; never null */ default Builder withRecord(Schema schema) { return withSchema(schema, FieldName.BEFORE, FieldName.AFTER); }
@Test public void shouldBuildWithSimpleOptionalTypesForBeforeAndAfter() { Envelope env = Envelope.defineSchema() .withName("someName") .withRecord(Schema.OPTIONAL_STRING_SCHEMA) .withSource(Schema.OPTIONAL_INT64_SCHEMA) .build(); assertThat(env.schema()).isNotNull(); assertThat(env.schema().name()).isEqualTo("someName"); assertThat(env.schema().doc()).isNull(); assertThat(env.schema().version()).isNull(); assertOptionalField(env, Envelope.FieldName.AFTER, Schema.OPTIONAL_STRING_SCHEMA); assertOptionalField(env, Envelope.FieldName.BEFORE, Schema.OPTIONAL_STRING_SCHEMA); assertOptionalField(env, Envelope.FieldName.SOURCE, Schema.OPTIONAL_INT64_SCHEMA); assertRequiredField(env, Envelope.FieldName.OPERATION, Schema.STRING_SCHEMA); }
/** * Define the {@link Schema} used in the {@link FieldName#SOURCE} field. * * @param sourceSchema the schema of the {@link FieldName#SOURCE} field; may not be null * @return this builder so methods can be chained; never null */ default Builder withSource(Schema sourceSchema) { return withSchema(sourceSchema, FieldName.SOURCE); }
/** * Define the {@link Schema} used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields. * * @param schema the schema of the records, used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields; may * not be null * @return this builder so methods can be chained; never null */ default Builder withRecord(Schema schema) { return withSchema(schema, FieldName.BEFORE, FieldName.AFTER); }
private SourceRecord createDeleteRecord() { final Schema recordSchema = SchemaBuilder.struct().field("id", SchemaBuilder.int8()).build(); Envelope envelope = Envelope.defineSchema() .withName("dummy.Envelope") .withRecord(recordSchema) .withSource(SchemaBuilder.struct().build()) .build(); final Struct before = new Struct(recordSchema); before.put("id", (byte)1); final Struct payload = envelope.delete(before, null, System.nanoTime()); return new SourceRecord(new HashMap<>(), new HashMap<>(), "dummy", envelope.schema(), payload); }
private SourceRecord createCreateRecord() { final Schema recordSchema = SchemaBuilder.struct().field("id", SchemaBuilder.int8()).build(); Envelope envelope = Envelope.defineSchema() .withName("dummy.Envelope") .withRecord(recordSchema) .withSource(SchemaBuilder.struct().build()) .build(); final Struct before = new Struct(recordSchema); before.put("id", (byte)1); final Struct payload = envelope.create(before, null, System.nanoTime()); return new SourceRecord(new HashMap<>(), new HashMap<>(), "dummy", envelope.schema(), payload); }