use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateFetchDataExtensionWithNullKeyAndNullHeaderValue.
@Test
public void shouldGenerateFetchDataExtensionWithNullKeyAndNullHeaderValue() {
byte[] build = KafkaFunctions.dataEx().typeId(0x01).fetch().timestamp(12345678L).partition(0, 0L).key(null).header("name", null).build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaDataExFW dataEx = new KafkaDataExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, dataEx.typeId());
assertEquals(KafkaApi.FETCH.value(), dataEx.kind());
final KafkaFetchDataExFW fetchDataEx = dataEx.fetch();
assertEquals(12345678L, fetchDataEx.timestamp());
final KafkaOffsetFW partition = fetchDataEx.partition();
assertEquals(0, partition.partitionId());
assertEquals(0L, partition.partitionOffset());
assertNull(fetchDataEx.key().value());
final MutableInteger headersCount = new MutableInteger();
fetchDataEx.headers().forEach(f -> headersCount.value++);
assertEquals(1, headersCount.value);
assertNotNull(fetchDataEx.headers().matchFirst(h -> "name".equals(h.name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && Objects.isNull(h.value())));
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateFetchDataExtension.
@Test
public void shouldGenerateFetchDataExtension() {
byte[] build = KafkaFunctions.dataEx().typeId(0x01).fetch().deferred(10).timestamp(12345678L).partition(0, 0L).key("match").header("name", "value").build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaDataExFW dataEx = new KafkaDataExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, dataEx.typeId());
assertEquals(KafkaApi.FETCH.value(), dataEx.kind());
final KafkaFetchDataExFW fetchDataEx = dataEx.fetch();
assertEquals(10, fetchDataEx.deferred());
assertEquals(12345678L, fetchDataEx.timestamp());
final KafkaOffsetFW partition = fetchDataEx.partition();
assertEquals(0, partition.partitionId());
assertEquals(0L, partition.partitionOffset());
assertEquals("match", fetchDataEx.key().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)));
final MutableInteger headersCount = new MutableInteger();
fetchDataEx.headers().forEach(f -> headersCount.value++);
assertEquals(1, headersCount.value);
assertNotNull(fetchDataEx.headers().matchFirst(h -> "name".equals(h.name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && "value".equals(h.value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null);
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateFetchDataExtensionWithLatestOffset.
@Test
public void shouldGenerateFetchDataExtensionWithLatestOffset() {
byte[] build = KafkaFunctions.dataEx().typeId(0x01).fetch().deferred(10).timestamp(12345678L).partition(0, 0L, 0L).key("match").header("name", "value").build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaDataExFW dataEx = new KafkaDataExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, dataEx.typeId());
assertEquals(KafkaApi.FETCH.value(), dataEx.kind());
final KafkaFetchDataExFW fetchDataEx = dataEx.fetch();
assertEquals(10, fetchDataEx.deferred());
assertEquals(12345678L, fetchDataEx.timestamp());
final KafkaOffsetFW partition = fetchDataEx.partition();
assertEquals(0, partition.partitionId());
assertEquals(0L, partition.partitionOffset());
assertEquals(0L, partition.latestOffset());
assertEquals("match", fetchDataEx.key().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)));
final MutableInteger headersCount = new MutableInteger();
fetchDataEx.headers().forEach(f -> headersCount.value++);
assertEquals(1, headersCount.value);
assertNotNull(fetchDataEx.headers().matchFirst(h -> "name".equals(h.name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && "value".equals(h.value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null);
}
Aggregations