From 5035a16930fd0df510d3b47ed72e419ca3ef72d2 Mon Sep 17 00:00:00 2001 From: djmil Date: Fri, 1 Sep 2023 16:58:43 +0200 Subject: [PATCH] SpringBoot: CordaClient: ResponseBody DAO --- .../cordaclient/dao/flow/ResponseBody.java | 11 +++++++ .../cordaclient/dao/flow/RequestBodyTest.java | 4 +-- .../dao/flow/ResponseBodyTest.java | 33 +++++++++++++++++++ .../dao/flow/ResponseBody-GameProposal.json | 9 +++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody.java create mode 100644 backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBodyTest.java create mode 100644 backend/src/test/resources/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody-GameProposal.json diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody.java new file mode 100644 index 0000000..f40e58a --- /dev/null +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody.java @@ -0,0 +1,11 @@ +package djmil.cordacheckers.cordaclient.dao.flow; + +public record ResponseBody( + String holdingIdentityShortHash, + String clientRequestId, + String flowId, + String flowStatus, + String flowResult, + String flowError, + String timestamp +) { } diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/RequestBodyTest.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/RequestBodyTest.java index 049d86e..de1ca2f 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/RequestBodyTest.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/RequestBodyTest.java @@ -15,7 +15,7 @@ import java.io.IOException; public class RequestBodyTest { @Autowired - private JacksonTester json; + private JacksonTester jTester; @Test void listFlowTest() throws IOException { @@ -26,6 +26,6 @@ public class RequestBodyTest { new Empty() ); - assertThat(json.write(requestBody)).isEqualToJson("requestBody/ListFlow.json"); + assertThat(jTester.write(requestBody)).isEqualToJson("requestBody/ListFlow.json"); } } diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBodyTest.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBodyTest.java new file mode 100644 index 0000000..8a4c817 --- /dev/null +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/dao/flow/ResponseBodyTest.java @@ -0,0 +1,33 @@ +package djmil.cordacheckers.cordaclient.dao.flow; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.test.json.JacksonTester; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; + +@JsonTest +public class ResponseBodyTest { + + @Autowired + private JacksonTester jTester; + + @Test + void GameProposalTest() throws IOException { + ResponseBody responseBody = new ResponseBody( + "804313813EED", + "game-proposal-11", + "ec913fe4-12cb-4867-acf0-4b8d24879362", + "COMPLETED", + "SHA-256D:67B08F2A94B1C38F6A42AC109FDCD6126B6B8F96FB2097DF81555956CC2AA7FB", + null, + "2023-08-29T14:41:05.600Z" + ); + + assertThat(jTester.write(responseBody)).isEqualToJson("ResponseBody-GameProposal.json"); + } +} + diff --git a/backend/src/test/resources/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody-GameProposal.json b/backend/src/test/resources/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody-GameProposal.json new file mode 100644 index 0000000..5fad7da --- /dev/null +++ b/backend/src/test/resources/djmil/cordacheckers/cordaclient/dao/flow/ResponseBody-GameProposal.json @@ -0,0 +1,9 @@ +{ + "holdingIdentityShortHash": "804313813EED", + "clientRequestId": "game-proposal-11", + "flowId": "ec913fe4-12cb-4867-acf0-4b8d24879362", + "flowStatus": "COMPLETED", + "flowResult": "SHA-256D:67B08F2A94B1C38F6A42AC109FDCD6126B6B8F96FB2097DF81555956CC2AA7FB", + "flowError": null, + "timestamp": "2023-08-29T14:41:05.600Z" + } \ No newline at end of file