use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateFetchBeginExtensionWithNullKeyAndNullHeaderValue.
@Test
public void shouldGenerateFetchBeginExtensionWithNullKeyAndNullHeaderValue() {
byte[] build = KafkaFunctions.beginEx().typeId(0x01).fetch().topic("topic").partition(0, 0L).filter().key(null).build().filter().header("name", null).build().build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaBeginExFW beginEx = new KafkaBeginExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, beginEx.typeId());
assertEquals(KafkaApi.FETCH.value(), beginEx.kind());
final KafkaFetchBeginExFW fetchBeginEx = beginEx.fetch();
assertEquals("topic", fetchBeginEx.topic().asString());
final KafkaOffsetFW partition = fetchBeginEx.partition();
assertEquals(0, partition.partitionId());
assertEquals(0L, partition.partitionOffset());
final MutableInteger filterCount = new MutableInteger();
fetchBeginEx.filters().forEach(f -> filterCount.value++);
assertEquals(2, filterCount.value);
assertNotNull(fetchBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == KEY.value() && Objects.isNull(c.key().value())) != null));
assertNotNull(fetchBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == HEADER.value() && "name".equals(c.header().name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && Objects.isNull(c.header().value())) != null));
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateProduceBeginExtension.
@Test
public void shouldGenerateProduceBeginExtension() {
byte[] build = KafkaFunctions.beginEx().typeId(0x01).produce().transaction("transaction").topic("topic").partition(1, 0).build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaBeginExFW beginEx = new KafkaBeginExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, beginEx.typeId());
assertEquals(KafkaApi.PRODUCE.value(), beginEx.kind());
final KafkaProduceBeginExFW produceBeginEx = beginEx.produce();
assertEquals("transaction", produceBeginEx.transaction().asString());
assertEquals(1, produceBeginEx.partition().partitionId());
assertEquals("topic", produceBeginEx.topic().asString());
assertEquals(0, produceBeginEx.partition().partitionOffset());
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateMergedBeginExtensionWithHeaderNotEqualsFilter.
@Test
public void shouldGenerateMergedBeginExtensionWithHeaderNotEqualsFilter() {
byte[] build = KafkaFunctions.beginEx().typeId(0x01).merged().topic("topic").partition(0, 1L).filter().key("match").build().filter().headerNot("name", "value").build().build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaBeginExFW beginEx = new KafkaBeginExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, beginEx.typeId());
assertEquals(KafkaApi.MERGED.value(), beginEx.kind());
final KafkaMergedBeginExFW mergedBeginEx = beginEx.merged();
assertEquals("topic", mergedBeginEx.topic().asString());
assertNotNull(mergedBeginEx.partitions().matchFirst(p -> p.partitionId() == 0 && p.partitionOffset() == 1L));
final MutableInteger filterCount = new MutableInteger();
mergedBeginEx.filters().forEach(f -> filterCount.value++);
assertEquals(2, filterCount.value);
assertNotNull(mergedBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == KEY.value() && "match".equals(c.key().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
assertNotNull(mergedBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == NOT.value() && c.not().condition().kind() == HEADER.value() && "name".equals(c.not().condition().header().name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && "value".equals(c.not().condition().header().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateMetaBeginExtension.
@Test
public void shouldGenerateMetaBeginExtension() {
byte[] build = KafkaFunctions.beginEx().typeId(0x01).meta().topic("topic").build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaBeginExFW beginEx = new KafkaBeginExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, beginEx.typeId());
assertEquals(KafkaApi.META.value(), beginEx.kind());
final KafkaMetaBeginExFW metaBeginEx = beginEx.meta();
assertEquals("topic", metaBeginEx.topic().asString());
}
use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW in project zilla by aklivity.
the class KafkaFunctionsTest method shouldGenerateMergedBeginExtensionWithKeyNotEqualsFilter.
@Test
public void shouldGenerateMergedBeginExtensionWithKeyNotEqualsFilter() {
byte[] build = KafkaFunctions.beginEx().typeId(0x01).merged().topic("topic").partition(0, 1L).filter().keyNot("match").build().filter().header("name", "value").build().build().build();
DirectBuffer buffer = new UnsafeBuffer(build);
KafkaBeginExFW beginEx = new KafkaBeginExFW().wrap(buffer, 0, buffer.capacity());
assertEquals(0x01, beginEx.typeId());
assertEquals(KafkaApi.MERGED.value(), beginEx.kind());
final KafkaMergedBeginExFW mergedBeginEx = beginEx.merged();
assertEquals("topic", mergedBeginEx.topic().asString());
assertNotNull(mergedBeginEx.partitions().matchFirst(p -> p.partitionId() == 0 && p.partitionOffset() == 1L));
final MutableInteger filterCount = new MutableInteger();
mergedBeginEx.filters().forEach(f -> filterCount.value++);
assertEquals(2, filterCount.value);
assertNotNull(mergedBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == NOT.value() && c.not().condition().kind() == KEY.value() && "match".equals(c.not().condition().key().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
assertNotNull(mergedBeginEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == HEADER.value() && "name".equals(c.header().name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && "value".equals(c.header().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
}
Aggregations