Search in sources :

Example 46 with IntegerSerializer

use of org.apache.kafka.common.serialization.IntegerSerializer in project AD482-apps by RedHatTraining.

the class StreamTopologyBuilderTest method setup.

@BeforeEach
public void setup() {
    // TODO: create the test driver
    StreamTopologyBuilder builder = new StreamTopologyBuilder();
    testDriver = new TopologyTestDriver(builder.buildTopology());
    // TODO: Create test topics
    wattsStream = testDriver.createInputTopic("turbine-generated-watts", new IntegerSerializer(), new IntegerSerializer());
    ObjectMapperSerde<MWattsMeasurement> measurementSerde = new ObjectMapperSerde<>(MWattsMeasurement.class);
    measurementsStream = testDriver.createOutputTopic("turbine-generated-mwatts", new IntegerDeserializer(), measurementSerde.deserializer());
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) MWattsMeasurement(com.redhat.energy.records.MWattsMeasurement) TopologyTestDriver(org.apache.kafka.streams.TopologyTestDriver) ObjectMapperSerde(io.quarkus.kafka.client.serialization.ObjectMapperSerde) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 47 with IntegerSerializer

use of org.apache.kafka.common.serialization.IntegerSerializer in project AD482-apps by RedHatTraining.

the class MovementTrackerTopologyTest method setup.

@BeforeEach
public void setup() {
    // TODO: pass the VehicleMovementTracker topology to the test driver
    tracker = new VehicleMovementTracker();
    testDriver = new TopologyTestDriver(tracker.buildTopology());
    // TODO: Create test input topics
    vehicleRegisteredSerde = new ObjectMapperSerde<>(VehicleRegistered.class);
    vehicleMovedSerde = new ObjectMapperSerde<>(VehicleMoved.class);
    vehicleRegisteredTopic = testDriver.createInputTopic("vehicle-registered", new IntegerSerializer(), vehicleRegisteredSerde.serializer());
    vehicleMovedTopic = testDriver.createInputTopic("vehicle-moved", new IntegerSerializer(), vehicleMovedSerde.serializer());
    // TODO: Create test stores
    vehiclesStore = testDriver.getKeyValueStore("vehicles-store");
    vehicleMetricsStore = testDriver.getKeyValueStore("vehicle-metrics-store");
    // TODO: Create test output topic
    vehicleStatusSerde = new ObjectMapperSerde<>(VehicleStatus.class);
    vehicleStatusTopic = testDriver.createOutputTopic("vehicle-status", new IntegerDeserializer(), vehicleStatusSerde.deserializer());
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) VehicleRegistered(com.redhat.vehicles.events.VehicleRegistered) VehicleMoved(com.redhat.vehicles.events.VehicleMoved) TopologyTestDriver(org.apache.kafka.streams.TopologyTestDriver) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 48 with IntegerSerializer

use of org.apache.kafka.common.serialization.IntegerSerializer in project quarkus-quickstarts by quarkusio.

the class AggregatorTest method setUp.

@BeforeEach
public void setUp() {
    temperatureProducer = new KafkaProducer(producerProps(), new IntegerSerializer(), new StringSerializer());
    weatherStationsProducer = new KafkaProducer(producerProps(), new IntegerSerializer(), new ObjectMapperSerializer());
    weatherStationsConsumer = new KafkaConsumer(consumerProps(), new IntegerDeserializer(), new ObjectMapperDeserializer<>(Aggregation.class));
}
Also used : KafkaProducer(org.apache.kafka.clients.producer.KafkaProducer) IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) ObjectMapperDeserializer(io.quarkus.kafka.client.serialization.ObjectMapperDeserializer) ObjectMapperSerializer(io.quarkus.kafka.client.serialization.ObjectMapperSerializer) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) StringSerializer(org.apache.kafka.common.serialization.StringSerializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 49 with IntegerSerializer

use of org.apache.kafka.common.serialization.IntegerSerializer in project apache-kafka-on-k8s by banzaicloud.

the class GlobalStateTaskTest method shouldProcessRecordsForOtherTopic.

@Test
public void shouldProcessRecordsForOtherTopic() {
    final byte[] integerBytes = new IntegerSerializer().serialize("foo", 1);
    globalStateTask.initialize();
    globalStateTask.update(new ConsumerRecord<>(topic2, 1, 1, integerBytes, integerBytes));
    assertEquals(1, sourceTwo.numReceived);
    assertEquals(0, sourceOne.numReceived);
}
Also used : IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) Test(org.junit.Test)

Example 50 with IntegerSerializer

use of org.apache.kafka.common.serialization.IntegerSerializer in project apache-kafka-on-k8s by banzaicloud.

the class GlobalStateTaskTest method shouldThrowStreamsExceptionWhenKeyDeserializationFails.

@Test
public void shouldThrowStreamsExceptionWhenKeyDeserializationFails() throws Exception {
    final byte[] key = new LongSerializer().serialize(topic2, 1L);
    final byte[] recordValue = new IntegerSerializer().serialize(topic2, 10);
    maybeDeserialize(globalStateTask, key, recordValue, true);
}
Also used : LongSerializer(org.apache.kafka.common.serialization.LongSerializer) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) Test(org.junit.Test)

Aggregations

IntegerSerializer (org.apache.kafka.common.serialization.IntegerSerializer)106 StringSerializer (org.apache.kafka.common.serialization.StringSerializer)75 Test (org.junit.Test)74 TopologyTestDriver (org.apache.kafka.streams.TopologyTestDriver)72 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)58 MockApiProcessorSupplier (org.apache.kafka.test.MockApiProcessorSupplier)46 Properties (java.util.Properties)22 IntegerDeserializer (org.apache.kafka.common.serialization.IntegerDeserializer)16 KeyValueTimestamp (org.apache.kafka.streams.KeyValueTimestamp)13 HashSet (java.util.HashSet)11 Set (java.util.Set)11 KeyValue (org.apache.kafka.streams.KeyValue)10 LongSerializer (org.apache.kafka.common.serialization.LongSerializer)9 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)9 Serdes (org.apache.kafka.common.serialization.Serdes)8 TestInputTopic (org.apache.kafka.streams.TestInputTopic)8 Consumed (org.apache.kafka.streams.kstream.Consumed)8 KStream (org.apache.kafka.streams.kstream.KStream)8 StreamsTestUtils (org.apache.kafka.test.StreamsTestUtils)8 Duration (java.time.Duration)6