From: Kai Moritz Date: Fri, 4 Nov 2022 07:25:08 +0000 (+0100) Subject: WIP:StringDeserializer X-Git-Tag: simple-consumer--json-DEPRECATED~15 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=1fdf265ee664c0b9396dbe01e4fa24942d996763;p=demos%2Fkafka%2Ftraining WIP:StringDeserializer --- diff --git a/src/main/java/de/juplo/kafka/Message.java b/src/main/java/de/juplo/kafka/Message.java deleted file mode 100644 index e4999b7..0000000 --- a/src/main/java/de/juplo/kafka/Message.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.juplo.kafka; - - -public abstract class Message -{ - public enum Type {ADD, CALC} - - public abstract Type getType(); -} diff --git a/src/main/java/de/juplo/kafka/MessageAddNumber.java b/src/main/java/de/juplo/kafka/MessageAddNumber.java deleted file mode 100644 index c024b65..0000000 --- a/src/main/java/de/juplo/kafka/MessageAddNumber.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.juplo.kafka; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.Data; - - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -public class MessageAddNumber extends Message -{ - private Integer next; - - - @Override - public Type getType() - { - return Type.ADD; - } -} diff --git a/src/main/java/de/juplo/kafka/MessageCalculateSum.java b/src/main/java/de/juplo/kafka/MessageCalculateSum.java deleted file mode 100644 index afc5a39..0000000 --- a/src/main/java/de/juplo/kafka/MessageCalculateSum.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.juplo.kafka; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.Data; - - -@Data -@JsonIgnoreProperties(ignoreUnknown = true) -public class MessageCalculateSum extends Message -{ - @Override - public Type getType() - { - return Type.CALC; - } -} diff --git a/src/test/java/de/juplo/kafka/MessageTest.java b/src/test/java/de/juplo/kafka/MessageTest.java deleted file mode 100644 index 52794ba..0000000 --- a/src/test/java/de/juplo/kafka/MessageTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.juplo.kafka; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.util.Arrays; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.*; - - -public class MessageTest -{ - ObjectMapper mapper = new ObjectMapper(); - - @Test - @DisplayName("Deserialize a MessageAddNumber message") - public void testDeserializeMessageAddNumber() - { - Assertions.assertDoesNotThrow(() -> mapper.readValue("{\"next\":42}", MessageAddNumber.class)); - Assertions.assertDoesNotThrow(() -> mapper.readValue("{\"number\":666,\"next\":42}", MessageAddNumber.class)); - } - - @Test - @DisplayName("Deserialize a MessageCalculateSum message") - public void testDeserializeMessageCalculateSum() throws JsonProcessingException - { - Assertions.assertDoesNotThrow(() -> mapper.readValue("{}", MessageCalculateSum.class)); - Assertions.assertDoesNotThrow(() -> mapper.readValue("{\"number\":666}", MessageCalculateSum.class)); - } -}