From 789fd1d0726f2456a1338edbefa8f97095d3236e Mon Sep 17 00:00:00 2001 From: Florian Esser Date: Wed, 28 Feb 2024 13:45:37 +0100 Subject: [PATCH 1/2] build: add test logger plugin Add a Gradle test logger plugin that display which JUnit tests were executed during the build. SVC-1398 --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index d1f0c61..33eec43 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ plugins { id 'io.spring.dependency-management' version '1.1.4' id 'com.diffplug.spotless' version '6.25.0' id 'com.bmuschko.docker-spring-boot-application' version '9.4.0' + id 'com.adarshr.test-logger' version '4.0.0' } group = 'to.wetransform.hale' From 51bdaba6819f4a194f7b0bfa317c1fcbd4496d5c Mon Sep 17 00:00:00 2001 From: Florian Esser Date: Wed, 28 Feb 2024 13:46:17 +0100 Subject: [PATCH 2/2] test: add test for JSON message deserialization SVC-1398 --- .../TransformationMessageConsumerTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/java/to/wetransform/hale/transformer/api/messaging/TransformationMessageConsumerTest.java diff --git a/src/test/java/to/wetransform/hale/transformer/api/messaging/TransformationMessageConsumerTest.java b/src/test/java/to/wetransform/hale/transformer/api/messaging/TransformationMessageConsumerTest.java new file mode 100644 index 0000000..4e81982 --- /dev/null +++ b/src/test/java/to/wetransform/hale/transformer/api/messaging/TransformationMessageConsumerTest.java @@ -0,0 +1,30 @@ +package to.wetransform.hale.transformer.api.messaging; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +class TransformationMessageConsumerTest { + + @Test + void testDeserializeTransformationMessage() throws Exception { + // Mock the received message + byte[] messageBody = + "{\"projectUrl\": \"https://example.org/example.halez\", \"sourceDataUrl\": \"https://example.org/example.gml\", \"targetFileName\": \"result.gml\", \"s3Region\": \"eu-west-1\", \"s3BucketName\": \"example-bucket\", \"s3AccessKey\": \"ACCESSKEY\", \"s3SecretKey\": \"SECRETKEY\"}" + .getBytes(); + + ObjectMapper mapper = new ObjectMapper(); + TransformationMessageConsumer.TransformationMessage transformationMessage = + mapper.readValue(messageBody, TransformationMessageConsumer.TransformationMessage.class); + + assertEquals("https://example.org/example.halez", transformationMessage.projectUrl()); + assertEquals("https://example.org/example.gml", transformationMessage.sourceDataUrl()); + assertEquals("result.gml", transformationMessage.targetFileName()); + assertEquals("eu-west-1", transformationMessage.s3Region()); + assertEquals("example-bucket", transformationMessage.s3BucketName()); + assertEquals("ACCESSKEY", transformationMessage.s3AccessKey()); + assertEquals("SECRETKEY", transformationMessage.s3SecretKey()); + } +}