From 4f5a6369092c6f2017b3e14840bad71764e7fa3b Mon Sep 17 00:00:00 2001 From: djmil Date: Mon, 4 Sep 2023 14:09:01 +0200 Subject: [PATCH] GameProposal Create test --- .../cordaclient/CordaClientTest.java | 29 +++++++++++++++++-- .../gameproposal/CreateFlow.java | 7 +++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/CordaClientTest.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/CordaClientTest.java index dfa83e7..7431ea0 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/CordaClientTest.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/CordaClientTest.java @@ -7,7 +7,9 @@ import org.springframework.boot.test.context.SpringBootTest; import com.fasterxml.jackson.core.JsonProcessingException; +import djmil.cordacheckers.cordaclient.dao.Color; import djmil.cordacheckers.cordaclient.dao.VirtualNode; +import djmil.cordacheckers.user.HoldingIdentityResolver; import static org.assertj.core.api.Assertions.assertThat; @@ -31,11 +33,34 @@ public class CordaClientTest { } @Test - void testListGameProposals() throws JsonProcessingException { + void testGameProposalList() throws JsonProcessingException { String resp = cordaClient.listGameProposals( - holdingIdentityResolver.getByCommonName("alice")); + holdingIdentityResolver.getByUsername("alice")); System.out.println("testListGameProposals "+ resp); } + @Test + void testGemeProposalCreate() { + final String gpSender = "alice"; + final String gpReceiver = "bob"; + final Color gpReceiverColor = Color.WHITE; + final String gpMessage = "GameProposal create test"; + + final String gpUuid = cordaClient.createGameProposal( + holdingIdentityResolver.getByUsername(gpSender), + holdingIdentityResolver.getByUsername(gpReceiver), + gpReceiverColor, + gpMessage + ); + + String listResSender = cordaClient.listGameProposals( + holdingIdentityResolver.getByUsername(gpSender)); + + String listResReceiver = cordaClient.listGameProposals( + holdingIdentityResolver.getByUsername(gpReceiver)); + + assertThat(listResSender).contains(gpUuid); + assertThat(listResReceiver).contains(gpUuid); + } } diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java b/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java index 47aebed..d346258 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java @@ -92,7 +92,7 @@ public class CreateFlow implements ClientStartableFlow{ return new GameProposalState( myInfo.getName(), opponentInfo.getName(), - GameProposalState.Color.valueOf(args.opponentColor), + opponentColor, args.message, UUID.randomUUID(), Arrays.asList(myInfo.getLedgerKeys().get(0), opponentInfo.getLedgerKeys().get(0)) @@ -120,6 +120,9 @@ public class CreateFlow implements ClientStartableFlow{ .finalize(signedTransaction, sessionsList) .getTransaction(); - return finalizedSignedTransaction.getId().toString(); + + // final String trxId = finalizedSignedTransaction.getId().toString(); + + return gameProposal.id.toString(); } }