diff --git a/build.gradle.kts b/build.gradle.kts index aba9cd1..fd91593 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("com.bakdata.release") version "1.4.0" id("com.bakdata.sonar") version "1.4.0" - id("com.bakdata.sonatype") version "1.4.0" + id("com.bakdata.sonatype") version "1.4.1" id("io.freefair.lombok") version "8.4" } @@ -16,6 +16,7 @@ allprojects { repositories { mavenCentral() maven(url = "https://packages.confluent.io/maven/") + maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots") } } diff --git a/error-handling-avro/build.gradle.kts b/error-handling-avro/build.gradle.kts index 5ca1286..3e8526e 100644 --- a/error-handling-avro/build.gradle.kts +++ b/error-handling-avro/build.gradle.kts @@ -21,7 +21,6 @@ dependencies { val junitVersion: String by project testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion) testImplementation(testFixtures(project(":error-handling-core"))) - testImplementation(group = "org.jooq", name = "jool", version = "0.9.14") val mockitoVersion: String by project testImplementation(group = "org.mockito", name = "mockito-junit-jupiter", version = mockitoVersion) val assertJVersion: String by project diff --git a/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterProcessorTest.java b/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterProcessorTest.java index 56b8d45..da3de55 100644 --- a/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterProcessorTest.java +++ b/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterProcessorTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ import java.time.Instant; import java.util.Arrays; import java.util.List; -import java.util.Properties; +import java.util.Map; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.Serdes; @@ -42,10 +42,10 @@ import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KeyValueMapper; import org.apache.kafka.streams.kstream.Produced; +import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.InjectSoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -81,8 +81,8 @@ protected void buildTopology(final StreamsBuilder builder) { } @Override - protected Properties getKafkaProperties() { - final Properties kafkaProperties = super.getKafkaProperties(); + protected Map getKafkaProperties() { + final Map kafkaProperties = super.getKafkaProperties(); kafkaProperties.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, SpecificAvroSerde.class); return kafkaProperties; } @@ -96,19 +96,20 @@ void shouldConvertAndSerializeAvroDeadLetter() { .add(1, "foo", 100) .add(2, "bar", 200); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(STRING_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(STRING_SERDE) .toList(); this.softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetter.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetter.class) .toList(); this.softly.assertThat(errors) .hasSize(2) - .allSatisfy(record -> this.softly.assertThat(record.timestamp()).isGreaterThan(startTimestamp)) + .allSatisfy(producerRecord -> this.softly.assertThat(producerRecord.timestamp()) + .isGreaterThan(startTimestamp)) .extracting(ProducerRecord::value).allSatisfy( deadLetter -> { this.softly.assertThat(deadLetter.getDescription()).isEqualTo(DEAD_LETTER_DESCRIPTION); @@ -117,7 +118,8 @@ void shouldConvertAndSerializeAvroDeadLetter() { .hasValue(RuntimeException.class.getCanonicalName()); // We don't check the exact stack trace, but only that it consists of multiple lines this.softly.assertThat(deadLetter.getCause().getStackTrace()).map(s -> Arrays.asList(s.split("\n"))) - .get().asList().hasSizeGreaterThan(1); + .get().asInstanceOf(InstanceOfAssertFactories.LIST) + .hasSizeGreaterThan(1); this.softly.assertThat(deadLetter.getTopic()).hasValue(INPUT_TOPIC); this.softly.assertThat(deadLetter.getPartition()).hasValue(0); } diff --git a/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterTransformerTest.java b/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterTransformerTest.java index 018e052..c99777c 100644 --- a/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterTransformerTest.java +++ b/error-handling-avro/src/test/java/com/bakdata/kafka/AvroDeadLetterTransformerTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde; import java.util.Arrays; import java.util.List; -import java.util.Properties; +import java.util.Map; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.Serdes; @@ -41,10 +41,10 @@ import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KeyValueMapper; import org.apache.kafka.streams.kstream.Produced; +import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.InjectSoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -81,8 +81,8 @@ protected void buildTopology(final StreamsBuilder builder) { } @Override - protected Properties getKafkaProperties() { - final Properties kafkaProperties = super.getKafkaProperties(); + protected Map getKafkaProperties() { + final Map kafkaProperties = super.getKafkaProperties(); kafkaProperties.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, SpecificAvroSerde.class); return kafkaProperties; } @@ -95,14 +95,14 @@ void shouldConvertAndSerializeAvroDeadLetter() { .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(STRING_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(STRING_SERDE) .toList(); this.softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetter.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetter.class) .toList(); this.softly.assertThat(errors) @@ -115,7 +115,8 @@ void shouldConvertAndSerializeAvroDeadLetter() { .hasValue(RuntimeException.class.getCanonicalName()); // We don't check the exact stack trace, but only that it consists of multiple lines this.softly.assertThat(deadLetter.getCause().getStackTrace()).map(s -> Arrays.asList(s.split("\n"))) - .get().asList().hasSizeGreaterThan(1); + .get().asInstanceOf(InstanceOfAssertFactories.LIST) + .hasSizeGreaterThan(1); this.softly.assertThat(deadLetter.getTopic()).hasValue(INPUT_TOPIC); this.softly.assertThat(deadLetter.getPartition()).hasValue(0); } diff --git a/error-handling-core/build.gradle.kts b/error-handling-core/build.gradle.kts index 96dd183..7518819 100644 --- a/error-handling-core/build.gradle.kts +++ b/error-handling-core/build.gradle.kts @@ -9,13 +9,13 @@ dependencies { api(group = "org.apache.kafka", name = "kafka-streams", version = kafkaVersion) val avroVersion: String by project implementation(group = "org.apache.avro", name = "avro", version = avroVersion) - implementation(group = "org.jooq", name = "jool", version = "0.9.14") - implementation(group = "org.apache.commons", name = "commons-lang3", version = "3.14.0") + implementation(group = "org.jooq", name = "jool", version = "0.9.15") + implementation(group = "org.apache.commons", name = "commons-lang3", version = "3.17.0") val junitVersion: String by project + testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion) testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-api", version = junitVersion) testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-params", version = junitVersion) - testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion) val assertJVersion: String by project testImplementation(group = "org.assertj", name = "assertj-core", version = assertJVersion) val mockitoVersion: String by project diff --git a/error-handling-core/src/main/java/com/bakdata/kafka/DeadLetterProcessor.java b/error-handling-core/src/main/java/com/bakdata/kafka/DeadLetterProcessor.java index dfaf72a..23d9285 100644 --- a/error-handling-core/src/main/java/com/bakdata/kafka/DeadLetterProcessor.java +++ b/error-handling-core/src/main/java/com/bakdata/kafka/DeadLetterProcessor.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -103,11 +103,11 @@ public void process(final FixedKeyRecord> inputRecord) { .inputTimestamp(Instant.ofEpochMilli(inputRecord.timestamp())) .build(); - final FixedKeyRecord record = inputRecord + final FixedKeyRecord outputRecord = inputRecord .withValue(this.deadLetterConverter.convert(deadLetterDescription)) .withTimestamp(this.context.currentSystemTimeMs()); - this.context.forward(record); + this.context.forward(outputRecord); } @Override diff --git a/error-handling-core/src/main/java/com/bakdata/kafka/ProcessingException.java b/error-handling-core/src/main/java/com/bakdata/kafka/ProcessingException.java index 2a5aca6..aed5a2b 100644 --- a/error-handling-core/src/main/java/com/bakdata/kafka/ProcessingException.java +++ b/error-handling-core/src/main/java/com/bakdata/kafka/ProcessingException.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +28,6 @@ * {@link Exception} thrown by error descriptors. The message contains information about input key and value. */ public class ProcessingException extends RuntimeException { - private static final long serialVersionUID = 6328000609687736610L; ProcessingException(final Object value, final Throwable cause) { super("Cannot process " + ErrorUtil.toString(value), cause); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatKeyValueMapperTopologyTest.java index 21181be..05c0f6d 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -100,16 +99,16 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -136,9 +135,9 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -148,14 +147,14 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .containsExactlyInAnyOrder(2L, 1L, 18L); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -179,9 +178,9 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -190,8 +189,8 @@ void shouldHandleNullInput(final SoftAssertions softly) { .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 3L); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -204,21 +203,21 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -241,20 +240,20 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatTransformerTopologyTest.java index 8370305..d9ff9d9 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -101,11 +100,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -118,7 +116,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -126,15 +124,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -144,11 +142,10 @@ public void close() { void shouldNotCaptureError(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -161,7 +158,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -199,7 +196,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -208,9 +205,9 @@ public void close() { .add(1, "foo") .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -219,14 +216,14 @@ public void close() { .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 1L, 18L, 4L, 5L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -248,6 +245,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -260,16 +258,16 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -277,8 +275,8 @@ public void close() { softly.assertThat(records) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 3L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -306,16 +304,16 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -323,8 +321,8 @@ public void close() { softly.assertThat(records) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 3L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -336,6 +334,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -348,27 +347,27 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -390,6 +389,7 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -402,26 +402,26 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -448,26 +448,26 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperTopologyTest.java index 084351a..565aac1 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -101,14 +100,14 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -134,22 +133,22 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(6L, 15L, 15L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -172,16 +171,16 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -194,19 +193,19 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -229,16 +228,16 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(5L, null, 2L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperWithKeyTopologyTest.java index 6aafc32..716adba 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -99,14 +98,14 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -132,22 +131,22 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 1L, 18L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -170,17 +169,17 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -193,19 +192,19 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -228,17 +227,17 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(5L, null, 2L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerTopologyTest.java index 7ac9e7d..dbac5df 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -96,11 +95,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -113,7 +111,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -121,14 +119,14 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -138,11 +136,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -155,7 +152,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -168,11 +165,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -188,7 +184,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -196,23 +192,23 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(6L, 15L, 15L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -234,6 +230,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -246,24 +243,24 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -275,6 +272,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -287,27 +285,27 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerWithKeyTopologyTest.java index c80b2c7..e7e42e7 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingFlatValueTransformerWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -99,11 +98,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -116,7 +114,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -124,14 +122,14 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -141,11 +139,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -158,7 +155,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -171,11 +168,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -191,7 +187,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -199,23 +195,23 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(6L, 15L, 15L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -237,6 +233,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -249,24 +246,24 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -278,6 +275,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -290,27 +288,27 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingKeyValueMapperTopologyTest.java index 5896a3f..e660206 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -100,15 +99,15 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -134,26 +133,26 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -176,20 +175,20 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -202,20 +201,20 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -238,19 +237,19 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingProcessorTopologyTest.java index f00f154..44e9c31 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.api.Record; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -100,11 +99,12 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -112,7 +112,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -120,16 +120,16 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -141,12 +141,13 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -154,7 +155,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -175,12 +176,12 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -188,7 +189,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -196,28 +197,28 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -244,9 +245,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -254,29 +255,29 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -287,12 +288,13 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -300,28 +302,28 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -348,9 +350,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(3.0).withValue(3L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(3.0).withValue(3L)); return; } throw new UnsupportedOperationException(); @@ -358,29 +360,29 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -397,13 +399,13 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } - if (3 == record.key() && "baz".equals(record.value())) { - this.context.forward(record.withKey(null).withValue(null)); + if (3 == inputRecord.key() && "baz".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(null).withValue(null)); return; } throw new UnsupportedOperationException(); @@ -411,7 +413,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -419,28 +421,28 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingTransformerTopologyTest.java index 911d39f..e458868 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -99,11 +98,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -116,7 +114,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -124,15 +122,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -142,11 +140,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -159,7 +156,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -196,7 +193,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -205,34 +202,34 @@ public void close() { .add(1, "foo") .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -254,6 +251,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -266,28 +264,28 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -299,6 +297,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -311,27 +310,27 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -368,28 +367,28 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -419,7 +418,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -427,27 +426,27 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -477,7 +476,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -485,27 +484,27 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperTopologyTest.java index df9f354..a62bc33 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -98,14 +97,14 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -131,25 +130,25 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -172,19 +171,19 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -197,19 +196,19 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -232,18 +231,18 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperWithKeyTopologyTest.java index 156a7f4..db230df 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -98,14 +97,14 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -131,25 +130,25 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -172,19 +171,19 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -197,19 +196,19 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -232,18 +231,18 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueProcessorTopologyTest.java index 53ba606..0c97fdd 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.api.FixedKeyRecord; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -100,11 +99,12 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -112,7 +112,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -120,15 +120,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -141,11 +141,12 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -153,7 +154,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -174,12 +175,12 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(2L)); + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -187,7 +188,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -195,28 +196,28 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -243,9 +244,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { - this.context.forward(record.withValue(2L)); + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -253,29 +254,29 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -287,11 +288,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -299,28 +301,28 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -347,9 +349,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(null)); + public void process(final FixedKeyRecord inputRecord) { + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(null)); return; } throw new UnsupportedOperationException(); @@ -357,28 +359,28 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); final List> errors = - Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerTopologyTest.java index 000de2f..cd15b61 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -93,11 +92,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -110,7 +108,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -118,14 +116,14 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -135,11 +133,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -152,7 +149,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -165,11 +162,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -185,7 +181,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -193,27 +189,27 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -235,6 +231,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -247,28 +244,28 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -280,6 +277,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -292,27 +290,27 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -331,11 +329,10 @@ public void close() { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -348,27 +345,27 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerWithKeyTopologyTest.java index a135717..c96f428 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorCapturingValueTransformerWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -96,11 +95,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -113,7 +111,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -121,14 +119,14 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -138,11 +136,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -155,7 +152,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -168,11 +165,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -188,7 +184,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -196,27 +192,27 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1)) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -238,6 +234,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -250,28 +247,28 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); @@ -283,6 +280,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -295,27 +293,27 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(DeadLetterDescription.class) .satisfies(deadLetter -> { @@ -334,11 +332,10 @@ public void close() { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -351,27 +348,27 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(DeadLetterDescription.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(DeadLetterDescription.class) .toList(); softly.assertThat(errors) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatKeyValueMapperTopologyTest.java index cabb395..9b03a99 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -101,9 +100,9 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -121,9 +120,9 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -142,11 +141,11 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -159,15 +158,15 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperTestTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperTestTopologyTest.java index da4880d..db03058 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperTestTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperTestTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -98,8 +97,8 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString("foo")) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) @@ -114,8 +113,8 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) @@ -133,8 +132,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString(null)) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -147,8 +146,8 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperWithKeyTopologyTest.java index 649559b..5eca42c 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingFlatValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -99,12 +98,12 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 1L, 18L); } @@ -116,12 +115,12 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); } @@ -135,10 +134,10 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -151,12 +150,12 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(5L, null, 2L); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingKeyValueMapperTopologyTest.java index b599787..3ddd052 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -99,15 +98,15 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -120,15 +119,15 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -143,11 +142,11 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -160,15 +159,15 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingProcessorTopologyTest.java index e5b6127..507dae1 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.api.Record; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -78,12 +77,13 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -107,12 +107,12 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -127,15 +127,15 @@ public void process(final Record record) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -153,9 +153,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -165,15 +165,15 @@ public void process(final Record record) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -185,12 +185,13 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -202,11 +203,11 @@ public void process(final Record record) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -223,9 +224,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(3.0).withValue(3L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(3.0).withValue(3L)); return; } throw new UnsupportedOperationException(); @@ -235,15 +236,15 @@ public void process(final Record record) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -261,13 +262,13 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } - if (3 == record.key() && "baz".equals(record.value())) { - this.context.forward(record.withKey(null).withValue(null)); + if (3 == inputRecord.key() && "baz".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(null).withValue(null)); return; } throw new UnsupportedOperationException(); @@ -278,22 +279,22 @@ public void process(final Record record) { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingTransformerTopologyTest.java index da2f4b3..c384d82 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -76,16 +75,15 @@ void shouldNotAllowNullTransformer(final SoftAssertions softly) { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -110,7 +108,7 @@ void shouldCaptureTransformerError(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override @@ -143,22 +141,22 @@ public KeyValue transform(final Integer key, final String value) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -171,11 +169,12 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -190,15 +189,15 @@ public KeyValue transform(final Integer key, final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -211,11 +210,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -232,11 +232,11 @@ public KeyValue transform(final Integer key, final String value) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -249,7 +249,7 @@ void shouldForwardOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override @@ -270,15 +270,15 @@ public KeyValue transform(final Integer key, final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -292,7 +292,7 @@ void shouldHandleReturnedNullKeyValue(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override @@ -317,21 +317,21 @@ public KeyValue transform(final Integer key, final String value) { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -345,7 +345,7 @@ void shouldHandleForwardedNullKeyValue(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override @@ -370,22 +370,22 @@ public KeyValue transform(final Integer key, final String value) { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperTopologyTest.java index 5fb82fc..08b59a1 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -96,14 +95,14 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString("foo")) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -116,14 +115,14 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -139,8 +138,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString(null)) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -153,14 +152,14 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperWithKeyTopologyTest.java index 335862c..d03920f 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -98,14 +97,14 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -118,14 +117,14 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -140,10 +139,10 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -156,14 +155,14 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueProcessorTopologyTest.java index eb7e65a..4e43a9a 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.api.FixedKeyRecord; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -76,16 +75,15 @@ void shouldNotAllowNullProcessor(final SoftAssertions softly) { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new FixedKeyProcessor<>() { - private FixedKeyProcessorContext context = null; @Override public void init(final FixedKeyProcessorContext context) { - this.context = context; + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -109,12 +107,12 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(2L)); + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -129,15 +127,15 @@ public void process(final FixedKeyRecord record) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -155,9 +153,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { - this.context.forward(record.withValue(2L)); + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -167,15 +165,15 @@ public void process(final FixedKeyRecord record) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -188,11 +186,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -204,11 +203,11 @@ public void process(final FixedKeyRecord record) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -225,9 +224,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(null)); + public void process(final FixedKeyRecord inputRecord) { + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(null)); return; } throw new UnsupportedOperationException(); @@ -237,15 +236,15 @@ public void process(final FixedKeyRecord record) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerTopologyTest.java index 9d50e9f..dbb5719 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,7 +39,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -75,16 +74,15 @@ void shouldNotAllowNullTransformer(final SoftAssertions softly) { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -105,16 +103,15 @@ public Long transform(final String value) { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -136,15 +133,15 @@ public Long transform(final String value) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString("foo")) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -157,11 +154,12 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -176,15 +174,15 @@ public Long transform(final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -197,11 +195,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -219,9 +218,9 @@ public Long transform(final String value) { .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process " + ErrorUtil.toString(null)) ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -230,16 +229,15 @@ public Long transform(final String value) { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -254,15 +252,15 @@ public Long transform(final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerWithKeyTopologyTest.java index b8a0591..1296374 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorDescribingValueTransformerWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,7 +39,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -75,16 +74,15 @@ void shouldNotAllowNullTransformer(final SoftAssertions softly) { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -105,16 +103,15 @@ public Long transform(final Integer key, final String value) { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -137,15 +134,15 @@ public Long transform(final Integer key, final String value) { .hasMessage( "Cannot process ('" + ErrorUtil.toString(1) + "', '" + ErrorUtil.toString("foo") + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -158,11 +155,12 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -177,15 +175,15 @@ public Long transform(final Integer key, final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -198,11 +196,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -219,11 +218,11 @@ public Long transform(final Integer key, final String value) { .add(null, null)) .satisfies(e -> softly.assertThat(e.getCause()) .hasMessage("Cannot process ('" + ErrorUtil.toString(null) + "', '" + ErrorUtil.toString(null) - + "')") + + "')") ); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -232,16 +231,15 @@ public Long transform(final Integer key, final String value) { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void close() { - + // do nothing } @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -256,15 +254,15 @@ public Long transform(final Integer key, final String value) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderProcessorTopologyTest.java index e1da34c..829bf9f 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -90,28 +89,28 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(1L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isEqualTo(2); - softly.assertThat(record.value()).isEqualTo("bar"); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isEqualTo(2); + softly.assertThat(producerRecord.value()).isEqualTo("bar"); }) .extracting(ProducerRecord::headers) .satisfies(headers -> { @@ -134,22 +133,22 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isNull(); - softly.assertThat(record.value()).isNull(); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isNull(); + softly.assertThat(producerRecord.value()).isNull(); }); } @@ -160,22 +159,22 @@ void shouldHandleExceptionWithoutMessage(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(1, "foo"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isEqualTo(1); - softly.assertThat(record.value()).isEqualTo("foo"); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isEqualTo(1); + softly.assertThat(producerRecord.value()).isEqualTo("foo"); }) .extracting(ProducerRecord::headers) .satisfies(headers -> softly.assertThat(getHeader(headers, ErrorHeaderProcessor.EXCEPTION_MESSAGE)) diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderTransformerTopologyTest.java index 3be8fe1..b087b01 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorHeaderTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -90,28 +89,28 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(1.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(1.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(1L)); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isEqualTo(2); - softly.assertThat(record.value()).isEqualTo("bar"); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isEqualTo(2); + softly.assertThat(producerRecord.value()).isEqualTo("bar"); }) .extracting(ProducerRecord::headers) .satisfies(headers -> { @@ -134,22 +133,22 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isNull(); - softly.assertThat(record.value()).isNull(); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isNull(); + softly.assertThat(producerRecord.value()).isNull(); }); } @@ -160,22 +159,22 @@ void shouldHandleExceptionWithoutMessage(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(1, "foo"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueSerde(Serdes.String())) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueSerde(Serdes.String()) .toList(); softly.assertThat(errors) .hasSize(1) .first() .isNotNull() - .satisfies(record -> { - softly.assertThat(record.key()).isEqualTo(1); - softly.assertThat(record.value()).isEqualTo("foo"); + .satisfies(producerRecord -> { + softly.assertThat(producerRecord.key()).isEqualTo(1); + softly.assertThat(producerRecord.value()).isEqualTo("foo"); }) .extracting(ProducerRecord::headers) .satisfies(headers -> softly.assertThat(getHeader(headers, ErrorHeaderTransformer.EXCEPTION_MESSAGE)) diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatKeyValueMapperTopologyTest.java index 2edc570..bbb3df6 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -93,9 +92,9 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -107,8 +106,8 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { when(this.mapper.apply(1, "foo")).thenThrow(throwable); this.createTopology(); softly.assertThatThrownBy(() -> this.topology.input() - .withValueSerde(STRING_SERDE) - .add(1, "foo")) + .withValueSerde(STRING_SERDE) + .add(1, "foo")) .isEqualTo(throwable); } @@ -122,9 +121,9 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -142,9 +141,9 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -161,9 +160,9 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -176,15 +175,15 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatTransformerTopologyTest.java index 548bb04..f775339 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -92,11 +91,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -109,7 +107,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -117,9 +115,9 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -129,11 +127,10 @@ public void close() { void shouldNotCaptureError(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -146,7 +143,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -159,11 +156,10 @@ public void close() { @Test void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -179,7 +175,7 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -187,9 +183,9 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -205,6 +201,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -217,16 +214,16 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .extracting(ProducerRecord::key) @@ -242,6 +239,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -254,16 +252,16 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -275,6 +273,7 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -287,22 +286,22 @@ public Iterable> transform(final Integer key, final Strin @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperTopologyTest.java index 187e889..0a1ee9b 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -92,8 +91,8 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -105,8 +104,8 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { when(this.mapper.apply("foo")).thenThrow(throwable); this.createTopology(); softly.assertThatThrownBy(() -> this.topology.input() - .withValueSerde(STRING_SERDE) - .add(1, "foo")) + .withValueSerde(STRING_SERDE) + .add(1, "foo")) .isEqualTo(throwable); } @@ -119,8 +118,8 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) @@ -135,8 +134,8 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) @@ -151,8 +150,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -165,8 +164,8 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperWithKeyTopologyTest.java index 684e9de..81c9c39 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -93,8 +92,8 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -120,12 +119,12 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 1L, 18L); } @@ -137,12 +136,12 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); } @@ -154,8 +153,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -168,12 +167,12 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(5L, null, 2L); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerTopologyTest.java index 24998c3..fb36651 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -90,11 +89,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -107,7 +105,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -115,8 +113,8 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -126,11 +124,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -143,7 +140,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -156,11 +153,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -176,7 +172,7 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -184,13 +180,13 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(6L, 15L, 15L); } @@ -201,6 +197,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -213,20 +210,20 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); } @@ -237,6 +234,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -249,16 +247,16 @@ public Iterable transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerWithKeyTopologyTest.java index cf20c32..240c469 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingFlatValueTransformerWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -92,11 +91,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -109,7 +107,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -117,8 +115,8 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -128,11 +126,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -145,7 +142,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -158,11 +155,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -178,7 +174,7 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -186,13 +182,13 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(3) - .allSatisfy(record -> softly.assertThat(record.key()).isEqualTo(2)) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(6L, 15L, 15L); } @@ -203,6 +199,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -215,20 +212,20 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) - .allSatisfy(record -> softly.assertThat(record.key()).isNull()) + .allSatisfy(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .containsExactlyInAnyOrder(2L, 5L); } @@ -239,6 +236,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -251,16 +249,16 @@ public Iterable transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingKeyValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingKeyValueMapperTopologyTest.java index eb7c21a..15f444c 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingKeyValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingKeyValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import org.apache.kafka.streams.kstream.Produced; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -93,9 +92,9 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -121,15 +120,15 @@ void shouldCaptureKeyValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -142,15 +141,15 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -163,9 +162,9 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -178,15 +177,15 @@ void shouldHandleNullKeyValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingProcessorTopologyTest.java index a804b9c..e66d78d 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.api.Record; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -92,11 +91,12 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -104,7 +104,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -112,9 +112,9 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -126,12 +126,13 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -139,7 +140,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -160,12 +161,12 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (1 == record.key() && "foo".equals(record.value())) { + public void process(final Record inputRecord) { + if (1 == inputRecord.key() && "foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -173,7 +174,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -181,15 +182,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -207,9 +208,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -217,22 +218,22 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -244,12 +245,13 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.mapper = new Processor<>() { @Override - public void init(final ProcessorContext context) { + public void init(final ProcessorContext context) { + // do nothing } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -257,16 +259,16 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -283,9 +285,9 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (record.key() == null && record.value() == null) { - this.context.forward(record.withKey(3.0).withValue(3L)); + public void process(final Record inputRecord) { + if (inputRecord.key() == null && inputRecord.value() == null) { + this.context.forward(inputRecord.withKey(3.0).withValue(3L)); return; } throw new UnsupportedOperationException(); @@ -293,22 +295,22 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -326,13 +328,13 @@ public void init(final ProcessorContext context) { } @Override - public void process(final Record record) { - if (2 == record.key() && "bar".equals(record.value())) { - this.context.forward(record.withKey(2.0).withValue(2L)); + public void process(final Record inputRecord) { + if (2 == inputRecord.key() && "bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(2.0).withValue(2L)); return; } - if (3 == record.key() && "baz".equals(record.value())) { - this.context.forward(record.withKey(null).withValue(null)); + if (3 == inputRecord.key() && "baz".equals(inputRecord.value())) { + this.context.forward(inputRecord.withKey(null).withValue(null)); return; } throw new UnsupportedOperationException(); @@ -340,7 +342,7 @@ public void process(final Record record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -348,22 +350,22 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingTransformerTopologyTest.java index 391c6a6..f704da3 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -90,11 +89,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -107,7 +105,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -115,9 +113,9 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -127,11 +125,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new Transformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -144,7 +141,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -181,7 +178,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -190,22 +187,22 @@ public void close() { .add(1, "foo") .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -218,6 +215,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -230,22 +228,22 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -258,6 +256,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -270,16 +269,16 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -306,22 +305,22 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -352,7 +351,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -360,21 +359,21 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(3.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(3.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(3L)) @@ -405,7 +404,7 @@ public KeyValue transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -413,22 +412,22 @@ public void close() { .withValueSerde(STRING_SERDE) .add(2, "bar") .add(3, "baz"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(DOUBLE_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(DOUBLE_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(2) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2.0)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2.0)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) ) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperTopologyTest.java index 2429a85..71394fe 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapper; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -91,8 +90,8 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -118,14 +117,14 @@ void shouldCaptureValueMapperError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -138,14 +137,14 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -158,8 +157,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -172,14 +171,14 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperWithKeyTopologyTest.java index 20f563e..1b89d91 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueMapperWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.kstream.ValueMapperWithKey; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -92,8 +91,8 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -119,14 +118,14 @@ void shouldCaptureValueMapperWithKeyError(final SoftAssertions softly) { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -139,14 +138,14 @@ void shouldHandleNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)); @@ -159,8 +158,8 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -173,14 +172,14 @@ void shouldHandleNullValue(final SoftAssertions softly) { this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .first() .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()); } diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueProcessorTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueProcessorTopologyTest.java index 285b045..3e40b1e 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueProcessorTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueProcessorTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,6 @@ import org.apache.kafka.streams.processor.api.FixedKeyRecord; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -94,11 +93,12 @@ void shouldForwardRecoverableException(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -106,7 +106,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -114,8 +114,8 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -128,11 +128,12 @@ void shouldNotCaptureThrowable(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw throwable; } throw new UnsupportedOperationException(); @@ -140,7 +141,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -161,12 +162,12 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("foo".equals(record.value())) { + public void process(final FixedKeyRecord inputRecord) { + if ("foo".equals(inputRecord.value())) { throw new RuntimeException("Cannot process"); } - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(2L)); + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -174,7 +175,7 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -182,15 +183,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -208,9 +209,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { - this.context.forward(record.withValue(2L)); + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { + this.context.forward(inputRecord.withValue(2L)); return; } throw new UnsupportedOperationException(); @@ -218,22 +219,22 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -246,11 +247,12 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final FixedKeyProcessorContext context) { + // do nothing } @Override - public void process(final FixedKeyRecord record) { - if (record.value() == null) { + public void process(final FixedKeyRecord inputRecord) { + if (inputRecord.value() == null) { throw new RuntimeException("Cannot process"); } throw new UnsupportedOperationException(); @@ -258,16 +260,16 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -284,9 +286,9 @@ public void init(final FixedKeyProcessorContext context) { } @Override - public void process(final FixedKeyRecord record) { - if ("bar".equals(record.value())) { - this.context.forward(record.withValue(null)); + public void process(final FixedKeyRecord inputRecord) { + if ("bar".equals(inputRecord.value())) { + this.context.forward(inputRecord.withValue(null)); return; } throw new UnsupportedOperationException(); @@ -294,22 +296,22 @@ public void process(final FixedKeyRecord record) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerTopologyTest.java index 96ab728..bb7a605 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -90,11 +89,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -107,7 +105,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -115,8 +113,8 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -126,11 +124,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -143,7 +140,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -156,11 +153,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -176,7 +172,7 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -184,15 +180,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -205,6 +201,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -217,22 +214,22 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -245,6 +242,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -257,16 +255,16 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -275,11 +273,10 @@ public void close() { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformer<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -292,22 +289,22 @@ public Long transform(final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerWithKeyTopologyTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerWithKeyTopologyTest.java index dbb6a60..65e7898 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerWithKeyTopologyTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ErrorLoggingValueTransformerWithKeyTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import org.apache.kafka.streams.processor.ProcessorContext; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -90,11 +89,10 @@ void shouldNotAllowNullFilter(final SoftAssertions softly) { void shouldForwardRecoverableException(final SoftAssertions softly) { final RuntimeException throwable = createRecoverableException(); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -107,7 +105,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -115,8 +113,8 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo")) .hasCause(throwable); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -126,11 +124,10 @@ public void close() { void shouldNotCaptureThrowable(final SoftAssertions softly) { final Error throwable = mock(Error.class); this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -143,7 +140,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -156,11 +153,10 @@ public void close() { @Test void shouldCaptureTransformerError(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -176,7 +172,7 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); @@ -184,15 +180,15 @@ public void close() { .withValueSerde(STRING_SERDE) .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -205,6 +201,7 @@ void shouldReturnOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -217,22 +214,22 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isNull()) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isNull()) .extracting(ProducerRecord::value) .isInstanceOf(Long.class) .satisfies(value -> softly.assertThat(value).isEqualTo(2L)) @@ -245,6 +242,7 @@ void shouldHandleErrorOnNullInput(final SoftAssertions softly) { @Override public void init(final ProcessorContext context) { + // do nothing } @Override @@ -257,16 +255,16 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(null, null); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .isEmpty(); @@ -275,11 +273,10 @@ public void close() { @Test void shouldHandleReturnedNullValue(final SoftAssertions softly) { this.mapper = new ValueTransformerWithKey<>() { - private ProcessorContext context = null; @Override public void init(final ProcessorContext context) { - this.context = context; + // do nothing } @Override @@ -292,22 +289,22 @@ public Long transform(final Integer key, final String value) { @Override public void close() { - + // do nothing } }; this.createTopology(); this.topology.input() .withValueSerde(STRING_SERDE) .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withKeySerde(INTEGER_SERDE) - .withValueSerde(LONG_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withKeySerde(INTEGER_SERDE) + .withValueSerde(LONG_SERDE) .toList(); softly.assertThat(records) .hasSize(1) .anySatisfy(r -> softly.assertThat(r) .isNotNull() - .satisfies(record -> softly.assertThat(record.key()).isEqualTo(2)) + .satisfies(producerRecord -> softly.assertThat(producerRecord.key()).isEqualTo(2)) .extracting(ProducerRecord::value) .satisfies(value -> softly.assertThat(value).isNull()) ); diff --git a/error-handling-core/src/test/java/com/bakdata/kafka/ProcessingErrorTest.java b/error-handling-core/src/test/java/com/bakdata/kafka/ProcessingErrorTest.java index 96a13cd..c3d9914 100644 --- a/error-handling-core/src/test/java/com/bakdata/kafka/ProcessingErrorTest.java +++ b/error-handling-core/src/test/java/com/bakdata/kafka/ProcessingErrorTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,11 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNullPointerException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; -import java.io.PrintWriter; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; diff --git a/error-handling-core/src/testFixtures/java/com/bakdata/kafka/ErrorCaptureTopologyTest.java b/error-handling-core/src/testFixtures/java/com/bakdata/kafka/ErrorCaptureTopologyTest.java index 842dd43..b225596 100644 --- a/error-handling-core/src/testFixtures/java/com/bakdata/kafka/ErrorCaptureTopologyTest.java +++ b/error-handling-core/src/testFixtures/java/com/bakdata/kafka/ErrorCaptureTopologyTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,8 @@ package com.bakdata.kafka; import com.bakdata.fluent_kafka_streams_tests.TestTopology; -import java.util.Properties; +import java.util.HashMap; +import java.util.Map; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.serialization.Serdes.IntegerSerde; @@ -48,20 +49,20 @@ void tearDown() { } } - protected Properties getKafkaProperties() { - final Properties kafkaConfig = new Properties(); + protected Map getKafkaProperties() { + final Map kafkaConfig = new HashMap<>(); // exactly once and order - kafkaConfig.setProperty(StreamsConfig.PROCESSING_GUARANTEE_CONFIG, StreamsConfig.EXACTLY_ONCE_V2); + kafkaConfig.put(StreamsConfig.PROCESSING_GUARANTEE_CONFIG, StreamsConfig.EXACTLY_ONCE_V2); kafkaConfig.put(StreamsConfig.producerPrefix(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION), 1); - kafkaConfig.setProperty(StreamsConfig.producerPrefix(ProducerConfig.ACKS_CONFIG), "all"); + kafkaConfig.put(StreamsConfig.producerPrefix(ProducerConfig.ACKS_CONFIG), "all"); // topology - kafkaConfig.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, "fake"); + kafkaConfig.put(StreamsConfig.APPLICATION_ID_CONFIG, "fake"); kafkaConfig.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, IntegerSerde.class); kafkaConfig.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, TestDeadLetterSerde.class); - kafkaConfig.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "fake"); + kafkaConfig.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "fake"); return kafkaConfig; } diff --git a/error-handling-proto/build.gradle.kts b/error-handling-proto/build.gradle.kts index c9de5b2..50e1967 100644 --- a/error-handling-proto/build.gradle.kts +++ b/error-handling-proto/build.gradle.kts @@ -1,7 +1,7 @@ description = "Transform dead letters in Kafka Streams applications to protobuf." plugins { - id("com.google.protobuf") version "0.9.1" + id("com.google.protobuf") version "0.9.4" } val protobufVersion: String by project @@ -11,7 +11,6 @@ dependencies { val junitVersion: String by project testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion) testImplementation(testFixtures(project(":error-handling-core"))) - testImplementation(group = "org.jooq", name = "jool", version = "0.9.14") val mockitoVersion: String by project testImplementation(group = "org.mockito", name = "mockito-junit-jupiter", version = mockitoVersion) val assertJVersion: String by project diff --git a/error-handling-proto/gradle.properties b/error-handling-proto/gradle.properties index 4441762..7837e83 100644 --- a/error-handling-proto/gradle.properties +++ b/error-handling-proto/gradle.properties @@ -1 +1 @@ -protobufVersion=3.21.12 +protobufVersion=3.25.5 diff --git a/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterProcessorTest.java b/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterProcessorTest.java index d6a0293..fc786c2 100644 --- a/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterProcessorTest.java +++ b/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterProcessorTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Properties; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.Serdes; @@ -54,10 +53,10 @@ import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KeyValueMapper; import org.apache.kafka.streams.kstream.Produced; +import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.InjectSoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -81,6 +80,10 @@ class ProtoDeadLetterProcessorTest extends ErrorCaptureTopologyTest { @Mock private KeyValueMapper> mapper; + private static Instant timestampToInstant(final Timestamp timestamp) { + return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()); + } + @Override protected void buildTopology(final StreamsBuilder builder) { final KStream input = builder.stream(INPUT_TOPIC, Consumed.with(null, STRING_SERDE)); @@ -94,9 +97,9 @@ protected void buildTopology(final StreamsBuilder builder) { } @Override - protected Properties getKafkaProperties() { - final Properties kafkaProperties = super.getKafkaProperties(); - kafkaProperties.setProperty( + protected Map getKafkaProperties() { + final Map kafkaProperties = super.getKafkaProperties(); + kafkaProperties.put( StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, KafkaProtobufSerde.class.getName()); kafkaProperties.put(KafkaProtobufDeserializerConfig.SPECIFIC_PROTOBUF_VALUE_TYPE, ProtoDeadLetter.class); @@ -108,7 +111,7 @@ protected void createTopology() { final StreamsBuilder builder = new StreamsBuilder(); this.buildTopology(builder); final Topology topology = builder.build(); - final Properties kafkaProperties = this.getKafkaProperties(); + final Map kafkaProperties = this.getKafkaProperties(); final SchemaRegistryMock schemaRegistryMock = new SchemaRegistryMock(List.of(new ProtobufSchemaProvider())); this.topology = new TestTopology(topology, kafkaProperties) .withSchemaRegistryMock(schemaRegistryMock); @@ -127,19 +130,20 @@ void shouldConvertAndSerializeProtoDeadLetter() { .add(1, "foo", 100) .add(2, "bar", 200); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(STRING_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(STRING_SERDE) .toList(); this.softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(ProtoDeadLetter.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(ProtoDeadLetter.class) .toList(); this.softly.assertThat(errors) .hasSize(2) - .allSatisfy(record -> this.softly.assertThat(record.timestamp()).isGreaterThan(startTimestamp)) + .allSatisfy(producerRecord -> this.softly.assertThat(producerRecord.timestamp()) + .isGreaterThan(startTimestamp)) .extracting(ProducerRecord::value).allSatisfy( deadLetter -> { this.softly.assertThat(deadLetter.getDescription()).isEqualTo(DEAD_LETTER_DESCRIPTION); @@ -149,7 +153,9 @@ void shouldConvertAndSerializeProtoDeadLetter() { .isEqualTo(RuntimeException.class.getCanonicalName()); // We don't check the exact stack trace, but only that it consists of multiple lines this.softly.assertThat(deadLetter.getCause().getStackTrace()).extracting(StringValue::getValue) - .extracting(s -> Arrays.asList(s.split("\n"))).asList().hasSizeGreaterThan(1); + .extracting(s -> Arrays.asList(s.split("\n"))) + .asInstanceOf(InstanceOfAssertFactories.LIST) + .hasSizeGreaterThan(1); this.softly.assertThat(deadLetter.getTopic()).extracting(StringValue::getValue) .isEqualTo(INPUT_TOPIC); this.softly.assertThat(deadLetter.getPartition()).extracting(Int32Value::getValue).isEqualTo(0); @@ -174,8 +180,4 @@ void shouldConvertAndSerializeProtoDeadLetter() { } ); } - - private static Instant timestampToInstant(final Timestamp timestamp) { - return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()); - } } diff --git a/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterTransformerTest.java b/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterTransformerTest.java index 652a01c..3781d39 100644 --- a/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterTransformerTest.java +++ b/error-handling-proto/src/test/java/com/bakdata/kafka/ProtoDeadLetterTransformerTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 bakdata + * Copyright (c) 2025 bakdata * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Properties; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.Serdes; @@ -52,10 +51,10 @@ import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.KeyValueMapper; import org.apache.kafka.streams.kstream.Produced; +import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.SoftAssertions; import org.assertj.core.api.junit.jupiter.InjectSoftAssertions; import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; -import org.jooq.lambda.Seq; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -92,9 +91,9 @@ protected void buildTopology(final StreamsBuilder builder) { } @Override - protected Properties getKafkaProperties() { - final Properties kafkaProperties = super.getKafkaProperties(); - kafkaProperties.setProperty( + protected Map getKafkaProperties() { + final Map kafkaProperties = super.getKafkaProperties(); + kafkaProperties.put( StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, KafkaProtobufSerde.class.getName()); kafkaProperties.put(KafkaProtobufDeserializerConfig.SPECIFIC_PROTOBUF_VALUE_TYPE, ProtoDeadLetter.class); @@ -106,7 +105,7 @@ protected void createTopology() { final StreamsBuilder builder = new StreamsBuilder(); this.buildTopology(builder); final Topology topology = builder.build(); - final Properties kafkaProperties = this.getKafkaProperties(); + final Map kafkaProperties = this.getKafkaProperties(); final SchemaRegistryMock schemaRegistryMock = new SchemaRegistryMock(List.of(new ProtobufSchemaProvider())); this.topology = new TestTopology(topology, kafkaProperties) .withSchemaRegistryMock(schemaRegistryMock); @@ -124,14 +123,14 @@ void shouldConvertAndSerializeProtoDeadLetter() { .add(1, "foo") .add(2, "bar"); - final List> records = Seq.seq(this.topology.streamOutput(OUTPUT_TOPIC) - .withValueSerde(STRING_SERDE)) + final List> records = this.topology.streamOutput(OUTPUT_TOPIC) + .withValueSerde(STRING_SERDE) .toList(); this.softly.assertThat(records) .isEmpty(); - final List> errors = Seq.seq(this.topology.streamOutput(ERROR_TOPIC) - .withValueType(ProtoDeadLetter.class)) + final List> errors = this.topology.streamOutput(ERROR_TOPIC) + .withValueType(ProtoDeadLetter.class) .toList(); this.softly.assertThat(errors) @@ -145,7 +144,9 @@ void shouldConvertAndSerializeProtoDeadLetter() { .isEqualTo(RuntimeException.class.getCanonicalName()); // We don't check the exact stack trace, but only that it consists of multiple lines this.softly.assertThat(deadLetter.getCause().getStackTrace()).extracting(StringValue::getValue) - .extracting(s -> Arrays.asList(s.split("\n"))).asList().hasSizeGreaterThan(1); + .extracting(s -> Arrays.asList(s.split("\n"))) + .asInstanceOf(InstanceOfAssertFactories.LIST) + .hasSizeGreaterThan(1); this.softly.assertThat(deadLetter.getTopic()).extracting(StringValue::getValue) .isEqualTo(INPUT_TOPIC); this.softly.assertThat(deadLetter.getPartition()).extracting(Int32Value::getValue).isEqualTo(0); diff --git a/gradle.properties b/gradle.properties index 7284ab2..bd19057 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ version=1.5.1-SNAPSHOT org.gradle.caching=true org.gradle.parallel=true org.gradle.jvmargs=-Xmx2048m -kafkaVersion=3.5.2 -avroVersion=1.11.3 -confluentVersion=7.5.1 -jacksonVersion=2.17.0 -junitVersion=5.10.2 -mockitoVersion=5.11.0 -log4jVersion=2.23.1 -kafkaStreamsTestsVersion=2.11.1 -assertJVersion=3.25.3 +kafkaVersion=3.8.1 +avroVersion=1.12.0 +confluentVersion=7.8.0 +jacksonVersion=2.18.2 +junitVersion=5.11.4 +mockitoVersion=5.15.2 +log4jVersion=2.24.3 +kafkaStreamsTestsVersion=2.16.0 +assertJVersion=3.27.2