-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for JSON message deserialization
SVC-1398
- Loading branch information
1 parent
4c3f30f
commit 7d34f82
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...java/to/wetransform/hale/transformer/api/messaging/TransformationMessageConsumerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |