From 2ef63cf49428765161b0fba153a4a8b61af7237b Mon Sep 17 00:00:00 2001 From: djmil Date: Thu, 30 Nov 2023 11:47:31 +0100 Subject: [PATCH] backend: handle corda errors as HTTP_BAD_REQ --- .../cordacheckers/api/GameController.java | 130 ++++++++++-------- .../api/GameProposalController.java | 110 ++++++++------- .../api/LeaderboardController.java | 14 +- .../cordaclient/CordaClient.java | 29 ++-- .../cordaclient/dao/flow/arguments/Rsp.java | 7 +- .../flow/arguments/RspFailureException.java | 7 + .../cordaclient/GameBoardTests.java | 15 +- .../cordaclient/GameProposalTests.java | 9 +- .../cordaclient/GameStateTests.java | 5 +- .../cordaclient/RankingTests.java | 7 +- 10 files changed, 189 insertions(+), 144 deletions(-) create mode 100644 backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/RspFailureException.java diff --git a/backend/src/main/java/djmil/cordacheckers/api/GameController.java b/backend/src/main/java/djmil/cordacheckers/api/GameController.java index f6f6d9c..f4f2a46 100644 --- a/backend/src/main/java/djmil/cordacheckers/api/GameController.java +++ b/backend/src/main/java/djmil/cordacheckers/api/GameController.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; @@ -12,14 +13,15 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; import djmil.cordacheckers.cordaclient.CordaClient; import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameBoardMove; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.user.HoldingIdentityResolver; import djmil.cordacheckers.user.User; - @RestController @RequestMapping("api/game") public class GameController { @@ -32,83 +34,95 @@ public class GameController { @GetMapping public ResponseEntity> list( - @AuthenticationPrincipal User player - ) { - final List gsList = cordaClient.gameStateList(player.getHoldingIdentity()); + @AuthenticationPrincipal User player) { + try { + final List gsList = cordaClient.gameStateList( + player.getHoldingIdentity()); - return ResponseEntity.ok(gsList); + return ResponseEntity.ok(gsList); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/surrender") + @PutMapping("/{uuid}/surrender") public ResponseEntity surrender( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView finishedGame = cordaClient.gameBoardSurrender( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView finishedGame = cordaClient.gameBoardSurrender( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(finishedGame); + return ResponseEntity.ok(finishedGame); + + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/drawreq") + @PutMapping("/{uuid}/drawreq") public ResponseEntity drawRequest( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView drawReqGame = cordaClient.gameDrawRequest( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView drawReqGame = cordaClient.gameDrawRequest( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(drawReqGame); + return ResponseEntity.ok(drawReqGame); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/drawacc") + @PutMapping("/{uuid}/drawacc") public ResponseEntity drawAccept( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView drawAccGame = cordaClient.gameDrawAccept( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView drawAccGame = cordaClient.gameDrawAccept( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(drawAccGame); + return ResponseEntity.ok(drawAccGame); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/drawrej") + @PutMapping("/{uuid}/drawrej") public ResponseEntity drawReject( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView drawRejGame = cordaClient.gameDrawReject( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView drawRejGame = cordaClient.gameDrawReject( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(drawRejGame); + return ResponseEntity + .ok(drawRejGame); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/move") + @PutMapping("/{uuid}/move") public ResponseEntity move( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid, - @RequestBody ReqGameBoardMove request - ) { - final GameView movedGame = cordaClient.gameBoardMove( - issuer.getHoldingIdentity(), - uuid, - request.move(), - request.message() - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid, + @RequestBody ReqGameBoardMove request) { + try { + final GameView movedGame = cordaClient.gameBoardMove( + issuer.getHoldingIdentity(), + uuid, + request.move(), + request.message()); - return ResponseEntity - .ok(movedGame); + return ResponseEntity + .ok(movedGame); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } } diff --git a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java index f209746..5f7b3f5 100644 --- a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java +++ b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java @@ -4,6 +4,7 @@ import java.net.URI; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.PathVariable; @@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.core.JsonProcessingException; @@ -22,6 +24,7 @@ import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.HoldingIdentity; import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameProposalCreate; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.user.HoldingIdentityResolver; import djmil.cordacheckers.user.User; @@ -39,69 +42,78 @@ public class GameProposalController { public ResponseEntity create( @AuthenticationPrincipal User sender, @RequestBody ReqGameProposalCreate gpRequest, - UriComponentsBuilder ucb) throws JsonMappingException, JsonProcessingException - { - final HoldingIdentity gpSender = sender.getHoldingIdentity(); - final HoldingIdentity gpReceiver = holdingIdentityResolver.getByUsername(gpRequest.opponentName()); - final Stone.Color gpReceiverColor = gpRequest.opponentColor(); + UriComponentsBuilder ucb) throws JsonMappingException, JsonProcessingException { + try { + final HoldingIdentity gpSender = sender.getHoldingIdentity(); + final HoldingIdentity gpReceiver = holdingIdentityResolver.getByUsername(gpRequest.opponentName()); + final Stone.Color gpReceiverColor = gpRequest.opponentColor(); - // GiteaIssue #4: Exception handling - GameView gameStateView = cordaClient.gameProposalCreate( - gpSender, - gpReceiver, - gpReceiverColor, - gpRequest.board(), - gpRequest.message()); + // GiteaIssue #4: Exception handling + GameView gameStateView = cordaClient.gameProposalCreate( + gpSender, + gpReceiver, + gpReceiverColor, + gpRequest.board(), + gpRequest.message()); - URI locationOfNewGameProposal = ucb - .path("api/gameproposal/{id}") - .buildAndExpand(gameStateView.uuid()) - .toUri(); + URI locationOfNewGameProposal = ucb + .path("api/gameproposal/{id}") + .buildAndExpand(gameStateView.uuid()) + .toUri(); - return ResponseEntity - .created(locationOfNewGameProposal) - .body(gameStateView); + return ResponseEntity + .created(locationOfNewGameProposal) + .body(gameStateView); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/cancel") + @PutMapping("/{uuid}/cancel") public ResponseEntity cancel( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView canceledGameView = cordaClient.gameProposalCancel( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView canceledGameView = cordaClient.gameProposalCancel( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(canceledGameView); + return ResponseEntity + .ok(canceledGameView); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/reject") + @PutMapping("/{uuid}/reject") public ResponseEntity reject( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView rejectedGameView = cordaClient.gameProposalReject( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView rejectedGameView = cordaClient.gameProposalReject( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(rejectedGameView); + return ResponseEntity + .ok(rejectedGameView); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } - @PutMapping("/{uuid}/accept") + @PutMapping("/{uuid}/accept") public ResponseEntity accept( - @AuthenticationPrincipal User issuer, - @PathVariable UUID uuid - ) { - final GameView acceptedGameView = cordaClient.gameProposalAccept( - issuer.getHoldingIdentity(), - uuid - ); + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid) { + try { + final GameView acceptedGameView = cordaClient.gameProposalAccept( + issuer.getHoldingIdentity(), + uuid); - return ResponseEntity - .ok(acceptedGameView); + return ResponseEntity + .ok(acceptedGameView); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } } \ No newline at end of file diff --git a/backend/src/main/java/djmil/cordacheckers/api/LeaderboardController.java b/backend/src/main/java/djmil/cordacheckers/api/LeaderboardController.java index f6df567..f17ab49 100644 --- a/backend/src/main/java/djmil/cordacheckers/api/LeaderboardController.java +++ b/backend/src/main/java/djmil/cordacheckers/api/LeaderboardController.java @@ -3,13 +3,17 @@ package djmil.cordacheckers.api; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; import djmil.cordacheckers.cordaclient.CordaClient; import djmil.cordacheckers.cordaclient.dao.Rank; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.user.HoldingIdentityResolver; @@ -25,10 +29,14 @@ public class LeaderboardController { @GetMapping public ResponseEntity> getLeaderboard() { - final var hiCustodian = holdingIdentityResolver.getCustodian(); - final Map leaderboard = cordaClient.fetchRanking(hiCustodian); + try { + final var hiCustodian = holdingIdentityResolver.getCustodian(); + final Map leaderboard = cordaClient.fetchRanking(hiCustodian); - return ResponseEntity.ok(leaderboard); + return ResponseEntity.ok(leaderboard); + } catch (RspFailureException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } } } diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java index e9e8d6d..66af72a 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java @@ -28,6 +28,7 @@ import djmil.cordacheckers.cordaclient.dao.flow.RequestBody; import djmil.cordacheckers.cordaclient.dao.flow.ResponseBody; import djmil.cordacheckers.cordaclient.dao.flow.arguments.Req; import djmil.cordacheckers.cordaclient.dao.flow.arguments.Rsp; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameBoardMove; import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameProposalCreate; import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspGameState; @@ -67,7 +68,7 @@ public class CordaClient { } // use custodian holding identity to get ranking table of all players - public Map fetchRanking(HoldingIdentity holdingIdentity) { + public Map fetchRanking(HoldingIdentity holdingIdentity) throws RspFailureException { final RequestBody requestBody = new RequestBody( "ranking-" +UUID.randomUUID(), "djmil.cordacheckers.gameresult.RankingFlow", @@ -81,7 +82,7 @@ public class CordaClient { * @param holdingIdentity * @return list of unconsumed (active) GameStateViews */ - public List gameStateList(HoldingIdentity holdingIdentity) { + public List gameStateList(HoldingIdentity holdingIdentity) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gs.list-" + UUID.randomUUID(), "djmil.cordacheckers.gamestate.ListFlow", @@ -91,7 +92,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameStateGet(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameStateGet(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gs.get-" + UUID.randomUUID(), "djmil.cordacheckers.gamestate.GetFlow", @@ -102,13 +103,13 @@ public class CordaClient { } public GameView gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor, - String message) { + String message) throws RspFailureException { return gameProposalCreate(issuer, acquier, acquierColor, GameView.defaultGameBoard, message); } public GameView gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor, - Map board, String message) { + Map board, String message) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gp.create-" + UUID.randomUUID(), "djmil.cordacheckers.gameproposal.CreateFlow", @@ -122,7 +123,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameProposalReject(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameProposalReject(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gp.reject-" +UUID.randomUUID(), "djmil.cordacheckers.gameproposal.RejectFlow", @@ -132,7 +133,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameProposalCancel(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameProposalCancel(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gp.cancel-" +UUID.randomUUID(), "djmil.cordacheckers.gameproposal.CancelFlow", @@ -142,7 +143,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameProposalAccept(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameProposalAccept(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gp.accept-" +UUID.randomUUID(), "djmil.cordacheckers.gameproposal.AcceptFlow", @@ -152,18 +153,18 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameBoardSurrender(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameBoardSurrender(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gb.surrender-" +UUID.randomUUID(), "djmil.cordacheckers.gameboard.SurrenderFlow", gameUuid); - return cordaFlowExecute(holdingIdentity, requestBody, RspGameState.class) + return cordaFlowExecute(holdingIdentity, requestBody, RspGameState.class) .getResponce(requestBody); } public GameView gameBoardMove(HoldingIdentity holdingIdentity, UUID gameUuid, List move, - String message) { + String message) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gb.move-" +UUID.randomUUID(), "djmil.cordacheckers.gameboard.MoveFlow", @@ -174,7 +175,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameDrawRequest(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameDrawRequest(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gd.request-" +UUID.randomUUID(), "djmil.cordacheckers.gameboard.DrawRequestFlow", @@ -184,7 +185,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameDrawAccept(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameDrawAccept(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gd.accept-" +UUID.randomUUID(), "djmil.cordacheckers.gameboard.DrawAcceptFlow", @@ -194,7 +195,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameView gameDrawReject(HoldingIdentity holdingIdentity, UUID gameUuid) { + public GameView gameDrawReject(HoldingIdentity holdingIdentity, UUID gameUuid) throws RspFailureException { final RequestBody requestBody = new RequestBody( "gd.reject-" +UUID.randomUUID(), "djmil.cordacheckers.gameboard.DrawRejectFlow", diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/Rsp.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/Rsp.java index d884930..4e46aac 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/Rsp.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/Rsp.java @@ -7,7 +7,7 @@ public interface Rsp { public T successStatus(); public String failureStatus(); - public default T getResponce(RequestBody requestBody) { + public default T getResponce(RequestBody requestBody) throws RspFailureException { if (failureStatus() == null) { final var responce = successStatus(); final String gameUuid = (responce instanceof GameView) @@ -15,12 +15,11 @@ public interface Rsp { : ""; System.out.println(requestBody.clientRequestId() +" [OK] " +gameUuid); - return responce; } System.err.println(requestBody.clientRequestId() +" has failed: " +failureStatus()); - throw new RuntimeException(failureStatus()); + throw new RspFailureException(failureStatus()); } -} +} \ No newline at end of file diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/RspFailureException.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/RspFailureException.java new file mode 100644 index 0000000..4d83d89 --- /dev/null +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/RspFailureException.java @@ -0,0 +1,7 @@ +package djmil.cordacheckers.cordaclient.dao.flow.arguments; + +public class RspFailureException extends Exception { + public RspFailureException(String what) { + super(what); + } +} diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java index b7f43c5..571cbf8 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java @@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.GameView.Status; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.user.HoldingIdentityResolver; @@ -44,7 +45,7 @@ public class GameBoardTests { ); @Test - void testSurrender() { + void testSurrender() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -81,7 +82,7 @@ public class GameBoardTests { } @Test - void testMove() { + void testMove() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -193,7 +194,7 @@ public class GameBoardTests { } @Test - void testVictory_NoStones() { + void testVictory_NoStones() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -217,7 +218,7 @@ public class GameBoardTests { } @Test - void testVictory_StonesBlocked() { + void testVictory_StonesBlocked() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -241,7 +242,7 @@ public class GameBoardTests { } @Test - void testDrawRequest() { + void testDrawRequest() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -275,7 +276,7 @@ public class GameBoardTests { } @Test - void testDrawAccept() { + void testDrawAccept() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); @@ -311,7 +312,7 @@ public class GameBoardTests { } @Test - void testDrawReject() { + void testDrawReject() throws RspFailureException { final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName); final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName); diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java index 35e7f3b..5df9ddf 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java @@ -10,6 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.GameView.Status; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.user.HoldingIdentityResolver; @@ -26,7 +27,7 @@ public class GameProposalTests { final Stone.Color acquierColor = Stone.Color.WHITE; @Test - void testCreate() { + void testCreate() throws RspFailureException { final var hiIssuer = holdingIdentityResolver.getByUsername(issuer); final var hiAcquier = holdingIdentityResolver.getByUsername(acquier); final String message = "GameProposal CREATE test"; @@ -68,7 +69,7 @@ public class GameProposalTests { } @Test - void testReject() { + void testReject() throws RspFailureException { final var hiIssuer = holdingIdentityResolver.getByUsername(issuer); final var hiAcquier = holdingIdentityResolver.getByUsername(acquier); @@ -97,7 +98,7 @@ public class GameProposalTests { } @Test - void testCancel() { + void testCancel() throws RspFailureException { final var hiIssuer = holdingIdentityResolver.getByUsername(issuer); final var hiAcquier = holdingIdentityResolver.getByUsername(acquier); @@ -126,7 +127,7 @@ public class GameProposalTests { } @Test - void testAccept() { + void testAccept() throws RspFailureException { final var hiIssuer = holdingIdentityResolver.getByUsername(issuer); final var hiAcquier = holdingIdentityResolver.getByUsername(acquier); diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java index 8b30c51..e1345b5 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java @@ -12,6 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.Stone.Color; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.user.HoldingIdentityResolver; @SpringBootTest @@ -26,7 +27,7 @@ public class GameStateTests { final String player2 = "bobik"; @Test - void testList() { + void testList() throws RspFailureException { final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1); final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2); @@ -46,7 +47,7 @@ public class GameStateTests { } @Test - void testGet() { + void testGet() throws RspFailureException { final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1); final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2); diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java index 7e301ca..7310ddd 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java @@ -15,6 +15,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameView; import djmil.cordacheckers.cordaclient.dao.Rank; import djmil.cordacheckers.cordaclient.dao.Stone; +import djmil.cordacheckers.cordaclient.dao.flow.arguments.RspFailureException; import djmil.cordacheckers.user.HoldingIdentityResolver; @SpringBootTest @@ -39,7 +40,7 @@ public class RankingTests { ); @Test - void testSurrender() throws InvalidNameException { + void testSurrender() throws InvalidNameException, RspFailureException { final var hiCustodian = holdingIdentityResolver.getCustodian(); assertThat(hiCustodian).isNotNull(); @@ -68,7 +69,7 @@ public class RankingTests { } @Test - void testVictory() throws InvalidNameException { + void testVictory() throws InvalidNameException, RspFailureException { final var hiCustodian = holdingIdentityResolver.getCustodian(); assertThat(hiCustodian).isNotNull(); @@ -97,7 +98,7 @@ public class RankingTests { } @Test - void testDraw() throws InvalidNameException { + void testDraw() throws InvalidNameException, RspFailureException { final var hiCustodian = holdingIdentityResolver.getCustodian(); assertThat(hiCustodian).isNotNull(); -- 2.45.2