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' 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()); + } +}