springboot: rename GameState to GameView
- update tests to use myColor instead of opponentColor
This commit is contained in:
parent
5f23c4c766
commit
b3d7ab3e75
@ -1,4 +0,0 @@
|
|||||||
package djmil.cordacheckers;
|
|
||||||
|
|
||||||
public record Joke(String joke) {
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package djmil.cordacheckers.gameproposal;
|
package djmil.cordacheckers.api;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,7 +17,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.CordaClient;
|
import djmil.cordacheckers.cordaclient.CordaClient;
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.HoldingIdentity;
|
import djmil.cordacheckers.cordaclient.dao.HoldingIdentity;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone;
|
import djmil.cordacheckers.cordaclient.dao.Stone;
|
||||||
import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameProposalCreate;
|
import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameProposalCreate;
|
||||||
@ -26,7 +26,7 @@ import djmil.cordacheckers.user.User;
|
|||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("gameproposal")
|
@RequestMapping("api/gameproposal")
|
||||||
public class GameProposalController {
|
public class GameProposalController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -34,21 +34,6 @@ public class GameProposalController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HoldingIdentityResolver holdingIdentityResolver;
|
HoldingIdentityResolver holdingIdentityResolver;
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public ResponseEntity<String> findAllUnconsumed(
|
|
||||||
@AuthenticationPrincipal User player
|
|
||||||
) {
|
|
||||||
List<GameState> gsList = cordaClient.gameStateList(player.getHoldingIdentity());
|
|
||||||
|
|
||||||
return ResponseEntity.ok(gsList.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// @PostMapping()
|
|
||||||
// public ResponseEntity<String> gameproposalSend(@AuthenticationPrincipal ApiUserDetails user) {
|
|
||||||
|
|
||||||
// return ResponseEntity.ok("");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public ResponseEntity<Void> createGameProposal(
|
public ResponseEntity<Void> createGameProposal(
|
||||||
@ -62,7 +47,7 @@ public class GameProposalController {
|
|||||||
final Stone.Color gpReceiverColor = gpRequest.opponentColor();
|
final Stone.Color gpReceiverColor = gpRequest.opponentColor();
|
||||||
|
|
||||||
// TODO handle expectionns here
|
// TODO handle expectionns here
|
||||||
GameState gameStateView = cordaClient.gameProposalCreate(
|
GameView gameStateView = cordaClient.gameProposalCreate(
|
||||||
gpSender,
|
gpSender,
|
||||||
gpReceiver,
|
gpReceiver,
|
||||||
gpReceiverColor,
|
gpReceiverColor,
|
||||||
@ -70,7 +55,7 @@ public class GameProposalController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
URI locationOfNewGameProposal = ucb
|
URI locationOfNewGameProposal = ucb
|
||||||
.path("gameproposal/{id}")
|
.path("api/gameproposal/{id}")
|
||||||
.buildAndExpand(gameStateView)
|
.buildAndExpand(gameStateView)
|
||||||
.toUri();
|
.toUri();
|
||||||
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.CordaClient;
|
import djmil.cordacheckers.cordaclient.CordaClient;
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||||
import djmil.cordacheckers.user.User;
|
import djmil.cordacheckers.user.User;
|
||||||
|
|
||||||
@ -26,10 +26,10 @@ public class GameStateController {
|
|||||||
HoldingIdentityResolver holdingIdentityResolver;
|
HoldingIdentityResolver holdingIdentityResolver;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<GameState>> gameStateList(
|
public ResponseEntity<List<GameView>> gameStateList(
|
||||||
@AuthenticationPrincipal User player
|
@AuthenticationPrincipal User player
|
||||||
) {
|
) {
|
||||||
final List<GameState> gsList = cordaClient.gameStateList(player.getHoldingIdentity());
|
final List<GameView> gsList = cordaClient.gameStateList(player.getHoldingIdentity());
|
||||||
|
|
||||||
return ResponseEntity.ok(gsList);
|
return ResponseEntity.ok(gsList);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.HoldingIdentity;
|
import djmil.cordacheckers.cordaclient.dao.HoldingIdentity;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone;
|
import djmil.cordacheckers.cordaclient.dao.Stone;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Rank;
|
import djmil.cordacheckers.cordaclient.dao.Rank;
|
||||||
@ -81,7 +81,7 @@ public class CordaClient {
|
|||||||
* @param holdingIdentity
|
* @param holdingIdentity
|
||||||
* @return list of unconsumed (active) GameStateViews
|
* @return list of unconsumed (active) GameStateViews
|
||||||
*/
|
*/
|
||||||
public List<GameState> gameStateList(HoldingIdentity holdingIdentity) {
|
public List<GameView> gameStateList(HoldingIdentity holdingIdentity) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gs.list-" + UUID.randomUUID(),
|
"gs.list-" + UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gamestate.ListFlow",
|
"djmil.cordacheckers.gamestate.ListFlow",
|
||||||
@ -91,7 +91,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameStateGet(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameStateGet(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gs.get-" + UUID.randomUUID(),
|
"gs.get-" + UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gamestate.GetFlow",
|
"djmil.cordacheckers.gamestate.GetFlow",
|
||||||
@ -101,13 +101,13 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor,
|
public GameView gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor,
|
||||||
String message) {
|
String message) {
|
||||||
|
|
||||||
return gameProposalCreate(issuer, acquier, acquierColor, GameState.defaultGameBoard, message);
|
return gameProposalCreate(issuer, acquier, acquierColor, GameView.defaultGameBoard, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor,
|
public GameView gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor,
|
||||||
Map<Integer, Stone> board, String message) {
|
Map<Integer, Stone> board, String message) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gp.create-" + UUID.randomUUID(),
|
"gp.create-" + UUID.randomUUID(),
|
||||||
@ -122,7 +122,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameProposalReject(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameProposalReject(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gp.reject-" +UUID.randomUUID(),
|
"gp.reject-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameproposal.RejectFlow",
|
"djmil.cordacheckers.gameproposal.RejectFlow",
|
||||||
@ -132,7 +132,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameProposalCancel(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameProposalCancel(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gp.reject-" +UUID.randomUUID(),
|
"gp.reject-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameproposal.CancelFlow",
|
"djmil.cordacheckers.gameproposal.CancelFlow",
|
||||||
@ -142,7 +142,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameProposalAccept(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameProposalAccept(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gp.accept-" +UUID.randomUUID(),
|
"gp.accept-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameproposal.AcceptFlow",
|
"djmil.cordacheckers.gameproposal.AcceptFlow",
|
||||||
@ -152,7 +152,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameBoardSurrender(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameBoardSurrender(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gb.surrender-" +UUID.randomUUID(),
|
"gb.surrender-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameboard.SurrenderFlow",
|
"djmil.cordacheckers.gameboard.SurrenderFlow",
|
||||||
@ -162,7 +162,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameBoardMove(HoldingIdentity holdingIdentity, UUID gameUuid, List<Integer> move,
|
public GameView gameBoardMove(HoldingIdentity holdingIdentity, UUID gameUuid, List<Integer> move,
|
||||||
String message) {
|
String message) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gb.move-" +UUID.randomUUID(),
|
"gb.move-" +UUID.randomUUID(),
|
||||||
@ -174,7 +174,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameDrawRequest(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameDrawRequest(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gd.request-" +UUID.randomUUID(),
|
"gd.request-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameboard.DrawRequestFlow",
|
"djmil.cordacheckers.gameboard.DrawRequestFlow",
|
||||||
@ -184,7 +184,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameDrawAccept(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameDrawAccept(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gd.accept-" +UUID.randomUUID(),
|
"gd.accept-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameboard.DrawAcceptFlow",
|
"djmil.cordacheckers.gameboard.DrawAcceptFlow",
|
||||||
@ -194,7 +194,7 @@ public class CordaClient {
|
|||||||
.getResponce(requestBody);
|
.getResponce(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState gameDrawReject(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
public GameView gameDrawReject(HoldingIdentity holdingIdentity, UUID gameUuid) {
|
||||||
final RequestBody requestBody = new RequestBody(
|
final RequestBody requestBody = new RequestBody(
|
||||||
"gd.reject-" +UUID.randomUUID(),
|
"gd.reject-" +UUID.randomUUID(),
|
||||||
"djmil.cordacheckers.gameboard.DrawRejectFlow",
|
"djmil.cordacheckers.gameboard.DrawRejectFlow",
|
||||||
|
@ -4,10 +4,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record GameState(
|
public record GameView(
|
||||||
Status status,
|
Status status,
|
||||||
|
|
||||||
|
Stone.Color myColor,
|
||||||
String opponentName,
|
String opponentName,
|
||||||
Stone.Color opponentColor,
|
|
||||||
|
|
||||||
Map<Integer, Stone> board,
|
Map<Integer, Stone> board,
|
||||||
Integer moveNumber,
|
Integer moveNumber,
|
@ -1,6 +1,6 @@
|
|||||||
package djmil.cordacheckers.cordaclient.dao.flow.arguments;
|
package djmil.cordacheckers.cordaclient.dao.flow.arguments;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.flow.RequestBody;
|
import djmil.cordacheckers.cordaclient.dao.flow.RequestBody;
|
||||||
|
|
||||||
public interface Rsp <T> {
|
public interface Rsp <T> {
|
||||||
@ -10,8 +10,8 @@ public interface Rsp <T> {
|
|||||||
public default T getResponce(RequestBody requestBody) {
|
public default T getResponce(RequestBody requestBody) {
|
||||||
if (failureStatus() == null) {
|
if (failureStatus() == null) {
|
||||||
final var responce = successStatus();
|
final var responce = successStatus();
|
||||||
final String gameUuid = (responce instanceof GameState)
|
final String gameUuid = (responce instanceof GameView)
|
||||||
? "GameUUID " +((GameState)responce).uuid().toString()
|
? "GameUUID " +((GameView)responce).uuid().toString()
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
System.out.println(requestBody.clientRequestId() +" [OK] " +gameUuid);
|
System.out.println(requestBody.clientRequestId() +" [OK] " +gameUuid);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package djmil.cordacheckers.cordaclient.dao.flow.arguments;
|
package djmil.cordacheckers.cordaclient.dao.flow.arguments;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
|
|
||||||
public record RspGameState(
|
public record RspGameState(
|
||||||
GameState successStatus,
|
GameView successStatus,
|
||||||
String transactionId,
|
String transactionId,
|
||||||
String failureStatus) implements Rsp<GameState> {
|
String failureStatus) implements Rsp<GameView> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package djmil.cordacheckers.cordaclient.dao.flow.arguments;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
|
|
||||||
public record RspGameStateList(
|
public record RspGameStateList(
|
||||||
List<GameState> successStatus,
|
List<GameView> successStatus,
|
||||||
String failureStatus) implements Rsp<List<GameState>> {
|
String failureStatus) implements Rsp<List<GameView>> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState.Status;
|
import djmil.cordacheckers.cordaclient.dao.GameView.Status;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone;
|
import djmil.cordacheckers.cordaclient.dao.Stone;
|
||||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||||
|
|
||||||
@ -48,21 +48,21 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(
|
final GameView game = cordaClient.gameProposalCreate(
|
||||||
hiWhite, hiBlack, Stone.Color.BLACK, "GameBoard SURRENDER test");
|
hiWhite, hiBlack, Stone.Color.BLACK, "GameBoard SURRENDER test");
|
||||||
|
|
||||||
final GameState acceptedGameBlackView = cordaClient.gameProposalAccept(
|
final GameView acceptedGameBlackView = cordaClient.gameProposalAccept(
|
||||||
hiBlack, game.uuid());
|
hiBlack, game.uuid());
|
||||||
|
|
||||||
assertThat(acceptedGameBlackView.opponentColor()).isEqualByComparingTo(Stone.Color.WHITE);
|
assertThat(acceptedGameBlackView.myColor()).isEqualByComparingTo(Stone.Color.BLACK);
|
||||||
assertThat(acceptedGameBlackView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
assertThat(acceptedGameBlackView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
// Black shall be able to surrender, even if it is not his turn
|
// Black shall be able to surrender, even if it is not his turn
|
||||||
final GameState surrendererGameView = cordaClient.gameBoardSurrender(
|
final GameView surrendererGameView = cordaClient.gameBoardSurrender(
|
||||||
hiBlack, game.uuid());
|
hiBlack, game.uuid());
|
||||||
|
|
||||||
|
assertThat(surrendererGameView.myColor()).isEqualByComparingTo(Stone.Color.BLACK);
|
||||||
assertThat(surrendererGameView.opponentName()).isEqualToIgnoringCase(whitePlayerName);
|
assertThat(surrendererGameView.opponentName()).isEqualToIgnoringCase(whitePlayerName);
|
||||||
assertThat(surrendererGameView.opponentColor()).isEqualByComparingTo(Stone.Color.WHITE);
|
|
||||||
assertThat(surrendererGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_LOOSE);
|
assertThat(surrendererGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_LOOSE);
|
||||||
assertThat(surrendererGameView.moveNumber() == 0);
|
assertThat(surrendererGameView.moveNumber() == 0);
|
||||||
|
|
||||||
@ -71,11 +71,11 @@ public class GameBoardTests {
|
|||||||
hiWhite, game.uuid());
|
hiWhite, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState winnerGameView = cordaClient.gameStateGet(
|
final GameView winnerGameView = cordaClient.gameStateGet(
|
||||||
hiWhite, game.uuid());
|
hiWhite, game.uuid());
|
||||||
|
|
||||||
|
assertThat(winnerGameView.myColor()).isEqualByComparingTo(Stone.Color.WHITE);
|
||||||
assertThat(winnerGameView.opponentName()).isEqualToIgnoringCase(blackPlayerName);
|
assertThat(winnerGameView.opponentName()).isEqualToIgnoringCase(blackPlayerName);
|
||||||
assertThat(winnerGameView.opponentColor()).isEqualByComparingTo(Stone.Color.BLACK);
|
|
||||||
assertThat(winnerGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_WON);
|
assertThat(winnerGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_WON);
|
||||||
assertThat(winnerGameView.moveNumber() == 0);
|
assertThat(winnerGameView.moveNumber() == 0);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(
|
final GameView game = cordaClient.gameProposalCreate(
|
||||||
hiWhite, hiBlack, Stone.Color.BLACK, "GameBoard MOVE test");
|
hiWhite, hiBlack, Stone.Color.BLACK, "GameBoard MOVE test");
|
||||||
|
|
||||||
final var m0 = cordaClient.gameProposalAccept(hiBlack, game.uuid());
|
final var m0 = cordaClient.gameProposalAccept(hiBlack, game.uuid());
|
||||||
@ -197,10 +197,10 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiBlack, hiWhite, Stone.Color.WHITE,
|
final GameView game = cordaClient.gameProposalCreate(hiBlack, hiWhite, Stone.Color.WHITE,
|
||||||
victoryTestBoard1, "GameBoard Vitcory test 1");
|
victoryTestBoard1, "GameBoard Vitcory test 1");
|
||||||
|
|
||||||
final GameState m0 = cordaClient.gameProposalAccept(hiWhite, game.uuid());
|
final GameView m0 = cordaClient.gameProposalAccept(hiWhite, game.uuid());
|
||||||
assertThat(m0.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
assertThat(m0.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
||||||
assertThat(m0.board()).containsAllEntriesOf(victoryTestBoard1);
|
assertThat(m0.board()).containsAllEntriesOf(victoryTestBoard1);
|
||||||
|
|
||||||
@ -221,10 +221,10 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
final GameView game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
||||||
victoryTestBoard2, "GameBoard Vitcory test 2");
|
victoryTestBoard2, "GameBoard Vitcory test 2");
|
||||||
|
|
||||||
final GameState m0 = cordaClient.gameProposalAccept(hiBlack, game.uuid());
|
final GameView m0 = cordaClient.gameProposalAccept(hiBlack, game.uuid());
|
||||||
assertThat(m0.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
assertThat(m0.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
||||||
assertThat(m0.board()).containsAllEntriesOf(victoryTestBoard2);
|
assertThat(m0.board()).containsAllEntriesOf(victoryTestBoard2);
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
final GameView game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
||||||
"Test draw request");
|
"Test draw request");
|
||||||
|
|
||||||
assertThat(cordaClient.gameProposalAccept(hiBlack, game.uuid())
|
assertThat(cordaClient.gameProposalAccept(hiBlack, game.uuid())
|
||||||
@ -255,10 +255,10 @@ public class GameBoardTests {
|
|||||||
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
final GameView drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
||||||
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
final GameState drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
final GameView drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
||||||
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
||||||
|
|
||||||
assertThat(drawReqAcquierView.board()).containsAllEntriesOf(drawReqIssuerView.board());
|
assertThat(drawReqAcquierView.board()).containsAllEntriesOf(drawReqIssuerView.board());
|
||||||
@ -279,7 +279,7 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiBlack, hiWhite, Stone.Color.WHITE,
|
final GameView game = cordaClient.gameProposalCreate(hiBlack, hiWhite, Stone.Color.WHITE,
|
||||||
"Draw ACCEPT test");
|
"Draw ACCEPT test");
|
||||||
|
|
||||||
assertThat(cordaClient.gameProposalAccept(hiWhite, game.uuid())
|
assertThat(cordaClient.gameProposalAccept(hiWhite, game.uuid())
|
||||||
@ -289,24 +289,24 @@ public class GameBoardTests {
|
|||||||
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
final GameView drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
||||||
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // White shall not be able to accept own Draw Request
|
assertThatThrownBy(() -> { // White shall not be able to accept own Draw Request
|
||||||
cordaClient.gameDrawAccept(hiWhite, game.uuid());
|
cordaClient.gameDrawAccept(hiWhite, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
final GameView drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
||||||
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // Black shall not be able to send counter Draw Request
|
assertThatThrownBy(() -> { // Black shall not be able to send counter Draw Request
|
||||||
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawAcceptBlackView = cordaClient.gameDrawAccept(hiBlack, game.uuid());
|
final GameView drawAcceptBlackView = cordaClient.gameDrawAccept(hiBlack, game.uuid());
|
||||||
assertThat(drawAcceptBlackView.status()).isEqualByComparingTo(Status.GAME_RESULT_DRAW);
|
assertThat(drawAcceptBlackView.status()).isEqualByComparingTo(Status.GAME_RESULT_DRAW);
|
||||||
|
|
||||||
final GameState drawAcceptWhiteView = cordaClient.gameStateGet(hiWhite, game.uuid());
|
final GameView drawAcceptWhiteView = cordaClient.gameStateGet(hiWhite, game.uuid());
|
||||||
assertThat(drawAcceptWhiteView.status()).isEqualByComparingTo(Status.GAME_RESULT_DRAW);
|
assertThat(drawAcceptWhiteView.status()).isEqualByComparingTo(Status.GAME_RESULT_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,30 +315,30 @@ public class GameBoardTests {
|
|||||||
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
final var hiWhite = holdingIdentityResolver.getByUsername(whitePlayerName);
|
||||||
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
final var hiBlack = holdingIdentityResolver.getByUsername(blackPlayerName);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
final GameView game = cordaClient.gameProposalCreate(hiWhite, hiBlack, Stone.Color.BLACK,
|
||||||
"Draw REJECT test");
|
"Draw REJECT test");
|
||||||
|
|
||||||
assertThat(cordaClient.gameProposalAccept(hiBlack, game.uuid())
|
assertThat(cordaClient.gameProposalAccept(hiBlack, game.uuid())
|
||||||
.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
final GameState drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
final GameView drawReqIssuerView = cordaClient.gameDrawRequest(hiWhite, game.uuid());
|
||||||
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
assertThat(drawReqIssuerView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // White shall not be able to reject own Draw Request
|
assertThatThrownBy(() -> { // White shall not be able to reject own Draw Request
|
||||||
cordaClient.gameDrawReject(hiWhite, game.uuid());
|
cordaClient.gameDrawReject(hiWhite, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
final GameView drawReqAcquierView = cordaClient.gameStateGet(hiBlack, game.uuid());
|
||||||
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
assertThat(drawReqAcquierView.status()).isEqualByComparingTo(Status.DRAW_REQUEST_WAIT_FOR_YOU);
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // Black shall not be able to send counter Draw Request
|
assertThatThrownBy(() -> { // Black shall not be able to send counter Draw Request
|
||||||
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
cordaClient.gameDrawRequest(hiBlack, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState drawRejectBlackView = cordaClient.gameDrawReject(hiBlack, game.uuid());
|
final GameView drawRejectBlackView = cordaClient.gameDrawReject(hiBlack, game.uuid());
|
||||||
assertThat(drawRejectBlackView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
assertThat(drawRejectBlackView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
||||||
|
|
||||||
final GameState drawRejectWhiteView = cordaClient.gameStateGet(hiWhite, game.uuid());
|
final GameView drawRejectWhiteView = cordaClient.gameStateGet(hiWhite, game.uuid());
|
||||||
assertThat(drawRejectWhiteView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
assertThat(drawRejectWhiteView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState.Status;
|
import djmil.cordacheckers.cordaclient.dao.GameView.Status;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone;
|
import djmil.cordacheckers.cordaclient.dao.Stone;
|
||||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||||
|
|
||||||
@ -31,16 +31,16 @@ public class GameProposalTests {
|
|||||||
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
||||||
final String message = "GameProposal CREATE test";
|
final String message = "GameProposal CREATE test";
|
||||||
|
|
||||||
final GameState issuerGameView = cordaClient.gameProposalCreate(
|
final GameView issuerGameView = cordaClient.gameProposalCreate(
|
||||||
hiIssuer, hiAcquier, acquierColor, message);
|
hiIssuer, hiAcquier, acquierColor, message);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Issuers perspective on a newly created GameProposal
|
* Issuers perspective on a newly created GameProposal
|
||||||
*/
|
*/
|
||||||
assertThat(issuerGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_OPPONENT);
|
assertThat(issuerGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_OPPONENT);
|
||||||
|
assertThat(issuerGameView.myColor()).isEqualByComparingTo(acquierColor.opposite());
|
||||||
assertThat(issuerGameView.opponentName()).isEqualToIgnoringCase(acquier);
|
assertThat(issuerGameView.opponentName()).isEqualToIgnoringCase(acquier);
|
||||||
assertThat(issuerGameView.opponentColor()).isEqualByComparingTo(acquierColor);
|
assertThat(issuerGameView.board()).containsAllEntriesOf(GameView.defaultGameBoard);
|
||||||
assertThat(issuerGameView.board()).containsAllEntriesOf(GameState.defaultGameBoard);
|
|
||||||
assertThat(issuerGameView.previousMove()).isNull();
|
assertThat(issuerGameView.previousMove()).isNull();
|
||||||
assertThat(issuerGameView.moveNumber() == 0);
|
assertThat(issuerGameView.moveNumber() == 0);
|
||||||
assertThat(issuerGameView.message()).isEqualToIgnoringCase(message);
|
assertThat(issuerGameView.message()).isEqualToIgnoringCase(message);
|
||||||
@ -49,7 +49,7 @@ public class GameProposalTests {
|
|||||||
/*
|
/*
|
||||||
* Acquier shall be able to find newly created GameProposal
|
* Acquier shall be able to find newly created GameProposal
|
||||||
*/
|
*/
|
||||||
GameState acquierGameView = assertDoesNotThrow( () -> {
|
GameView acquierGameView = assertDoesNotThrow( () -> {
|
||||||
return cordaClient.gameStateList(hiAcquier)
|
return cordaClient.gameStateList(hiAcquier)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(gameView -> gameView.uuid().compareTo(issuerGameView.uuid()) == 0)
|
.filter(gameView -> gameView.uuid().compareTo(issuerGameView.uuid()) == 0)
|
||||||
@ -58,9 +58,9 @@ public class GameProposalTests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
assertThat(acquierGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_YOU);
|
assertThat(acquierGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_YOU);
|
||||||
|
assertThat(acquierGameView.myColor()).isEqualByComparingTo(acquierColor);
|
||||||
assertThat(acquierGameView.opponentName()).isEqualToIgnoringCase(issuer);
|
assertThat(acquierGameView.opponentName()).isEqualToIgnoringCase(issuer);
|
||||||
assertThat(acquierGameView.opponentColor()).isEqualByComparingTo(acquierColor.opposite());
|
assertThat(acquierGameView.board()).containsAllEntriesOf(GameView.defaultGameBoard);
|
||||||
assertThat(acquierGameView.board()).containsAllEntriesOf(GameState.defaultGameBoard);
|
|
||||||
assertThat(acquierGameView.previousMove()).isNull();
|
assertThat(acquierGameView.previousMove()).isNull();
|
||||||
assertThat(acquierGameView.moveNumber() == 0);
|
assertThat(acquierGameView.moveNumber() == 0);
|
||||||
assertThat(acquierGameView.message()).isEqualToIgnoringCase(message);
|
assertThat(acquierGameView.message()).isEqualToIgnoringCase(message);
|
||||||
@ -72,7 +72,7 @@ public class GameProposalTests {
|
|||||||
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
||||||
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(
|
final GameView game = cordaClient.gameProposalCreate(
|
||||||
hiIssuer, hiAcquier, acquierColor, "GameProposal REJECT test");
|
hiIssuer, hiAcquier, acquierColor, "GameProposal REJECT test");
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // Issuer can not reject
|
assertThatThrownBy(() -> { // Issuer can not reject
|
||||||
@ -80,12 +80,12 @@ public class GameProposalTests {
|
|||||||
hiIssuer, game.uuid());
|
hiIssuer, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState pendingGameView = cordaClient.gameStateGet(
|
final GameView pendingGameView = cordaClient.gameStateGet(
|
||||||
hiAcquier, game.uuid());
|
hiAcquier, game.uuid());
|
||||||
assertThat(pendingGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_YOU);
|
assertThat(pendingGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_YOU);
|
||||||
assertThat(pendingGameView.uuid()).isEqualByComparingTo(game.uuid());
|
assertThat(pendingGameView.uuid()).isEqualByComparingTo(game.uuid());
|
||||||
|
|
||||||
final GameState rejectedGameView = cordaClient.gameProposalReject(
|
final GameView rejectedGameView = cordaClient.gameProposalReject(
|
||||||
hiAcquier, game.uuid());
|
hiAcquier, game.uuid());
|
||||||
assertThat(rejectedGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_REJECTED);
|
assertThat(rejectedGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_REJECTED);
|
||||||
assertThat(rejectedGameView.uuid()).isEqualByComparingTo(game.uuid());
|
assertThat(rejectedGameView.uuid()).isEqualByComparingTo(game.uuid());
|
||||||
@ -101,7 +101,7 @@ public class GameProposalTests {
|
|||||||
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
||||||
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(
|
final GameView game = cordaClient.gameProposalCreate(
|
||||||
hiIssuer, hiAcquier, acquierColor, "GameProposal CANCEL test");
|
hiIssuer, hiAcquier, acquierColor, "GameProposal CANCEL test");
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // Acquier can not cancel
|
assertThatThrownBy(() -> { // Acquier can not cancel
|
||||||
@ -109,12 +109,12 @@ public class GameProposalTests {
|
|||||||
hiAcquier, game.uuid());
|
hiAcquier, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState pendingGameView = cordaClient.gameStateGet(
|
final GameView pendingGameView = cordaClient.gameStateGet(
|
||||||
hiIssuer, game.uuid());
|
hiIssuer, game.uuid());
|
||||||
assertThat(pendingGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_OPPONENT);
|
assertThat(pendingGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_WAIT_FOR_OPPONENT);
|
||||||
assertThat(pendingGameView.uuid()).isEqualByComparingTo(game.uuid());
|
assertThat(pendingGameView.uuid()).isEqualByComparingTo(game.uuid());
|
||||||
|
|
||||||
final GameState canceledGameView = cordaClient.gameProposalCancel(
|
final GameView canceledGameView = cordaClient.gameProposalCancel(
|
||||||
hiIssuer, game.uuid());
|
hiIssuer, game.uuid());
|
||||||
assertThat(canceledGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_CANCELED);
|
assertThat(canceledGameView.status()).isEqualByComparingTo(Status.GAME_PROPOSAL_CANCELED);
|
||||||
assertThat(canceledGameView.uuid()).isEqualByComparingTo(game.uuid());
|
assertThat(canceledGameView.uuid()).isEqualByComparingTo(game.uuid());
|
||||||
@ -130,19 +130,19 @@ public class GameProposalTests {
|
|||||||
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
final var hiIssuer = holdingIdentityResolver.getByUsername(issuer);
|
||||||
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
final var hiAcquier = holdingIdentityResolver.getByUsername(acquier);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(
|
final GameView game = cordaClient.gameProposalCreate(
|
||||||
hiIssuer, hiAcquier, acquierColor, "GameProposal ACCEPT test");
|
hiIssuer, hiAcquier, acquierColor, "GameProposal ACCEPT test");
|
||||||
|
|
||||||
assertThatThrownBy(() -> { // Issuer can not accept
|
assertThatThrownBy(() -> { // Issuer can not accept
|
||||||
cordaClient.gameProposalAccept(hiIssuer, game.uuid());
|
cordaClient.gameProposalAccept(hiIssuer, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState acceptedGameAcquierView = cordaClient.gameProposalAccept(
|
final GameView acceptedGameAcquierView = cordaClient.gameProposalAccept(
|
||||||
hiAcquier, game.uuid());
|
hiAcquier, game.uuid());
|
||||||
|
|
||||||
|
assertThat(acceptedGameAcquierView.myColor()).isEqualByComparingTo(acquierColor);
|
||||||
assertThat(acceptedGameAcquierView.opponentName()).isEqualToIgnoringCase(issuer);
|
assertThat(acceptedGameAcquierView.opponentName()).isEqualToIgnoringCase(issuer);
|
||||||
assertThat(acceptedGameAcquierView.opponentColor()).isEqualByComparingTo(acquierColor.opposite());
|
assertThat(acceptedGameAcquierView.board()).containsAllEntriesOf(GameView.defaultGameBoard);
|
||||||
assertThat(acceptedGameAcquierView.board()).containsAllEntriesOf(GameState.defaultGameBoard);
|
|
||||||
assertThat(acceptedGameAcquierView.previousMove()).isNull();
|
assertThat(acceptedGameAcquierView.previousMove()).isNull();
|
||||||
assertThat(acceptedGameAcquierView.moveNumber() == 0);
|
assertThat(acceptedGameAcquierView.moveNumber() == 0);
|
||||||
assertThat(acceptedGameAcquierView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
assertThat(acceptedGameAcquierView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_YOU);
|
||||||
@ -153,12 +153,12 @@ public class GameProposalTests {
|
|||||||
hiIssuer, game.uuid());
|
hiIssuer, game.uuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState acceptedGameIssuerView = cordaClient.gameStateGet(
|
final GameView acceptedGameIssuerView = cordaClient.gameStateGet(
|
||||||
hiIssuer, game.uuid());
|
hiIssuer, game.uuid());
|
||||||
|
|
||||||
|
assertThat(acceptedGameIssuerView.myColor()).isEqualByComparingTo(acquierColor.opposite());
|
||||||
assertThat(acceptedGameIssuerView.opponentName()).isEqualToIgnoringCase(acquier);
|
assertThat(acceptedGameIssuerView.opponentName()).isEqualToIgnoringCase(acquier);
|
||||||
assertThat(acceptedGameIssuerView.opponentColor()).isEqualByComparingTo(acquierColor);
|
assertThat(acceptedGameIssuerView.board()).containsAllEntriesOf(GameView.defaultGameBoard);
|
||||||
assertThat(acceptedGameIssuerView.board()).containsAllEntriesOf(GameState.defaultGameBoard);
|
|
||||||
assertThat(acceptedGameIssuerView.previousMove()).isNull();
|
assertThat(acceptedGameIssuerView.previousMove()).isNull();
|
||||||
assertThat(acceptedGameIssuerView.moveNumber() == 0);
|
assertThat(acceptedGameIssuerView.moveNumber() == 0);
|
||||||
assertThat(acceptedGameIssuerView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
assertThat(acceptedGameIssuerView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT);
|
||||||
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone.Color;
|
import djmil.cordacheckers.cordaclient.dao.Stone.Color;
|
||||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class GameStateTests {
|
|||||||
final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1);
|
final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1);
|
||||||
final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2);
|
final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2);
|
||||||
|
|
||||||
final GameState p1GameView = cordaClient.gameProposalCreate(
|
final GameView p1GameView = cordaClient.gameProposalCreate(
|
||||||
hiPlayer1, hiPlayer2, Color.BLACK, "GameState List test");
|
hiPlayer1, hiPlayer2, Color.BLACK, "GameState List test");
|
||||||
|
|
||||||
final UUID gameUuid = p1GameView.uuid();
|
final UUID gameUuid = p1GameView.uuid();
|
||||||
@ -38,8 +38,8 @@ public class GameStateTests {
|
|||||||
/*
|
/*
|
||||||
* Both players shall be able to find newly created GameProposal within GameList
|
* Both players shall be able to find newly created GameProposal within GameList
|
||||||
*/
|
*/
|
||||||
final List<GameState> p1GameList = cordaClient.gameStateList(hiPlayer1);
|
final List<GameView> p1GameList = cordaClient.gameStateList(hiPlayer1);
|
||||||
final List<GameState> p2GameList = cordaClient.gameStateList(hiPlayer2);
|
final List<GameView> p2GameList = cordaClient.gameStateList(hiPlayer2);
|
||||||
|
|
||||||
assertThat(findGameStateById(p1GameList, gameUuid)).isNotNull();
|
assertThat(findGameStateById(p1GameList, gameUuid)).isNotNull();
|
||||||
assertThat(findGameStateById(p2GameList, gameUuid)).isNotNull();
|
assertThat(findGameStateById(p2GameList, gameUuid)).isNotNull();
|
||||||
@ -56,17 +56,17 @@ public class GameStateTests {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
final GameState p1GameView = cordaClient.gameProposalCreate(
|
final GameView p1GameView = cordaClient.gameProposalCreate(
|
||||||
hiPlayer1, hiPlayer2, Color.WHITE, "GameState Get test");
|
hiPlayer1, hiPlayer2, Color.WHITE, "GameState Get test");
|
||||||
|
|
||||||
final UUID gameUuid = p1GameView.uuid();
|
final UUID gameUuid = p1GameView.uuid();
|
||||||
|
|
||||||
final GameState p2GameView = cordaClient.gameStateGet(hiPlayer2, gameUuid);
|
final GameView p2GameView = cordaClient.gameStateGet(hiPlayer2, gameUuid);
|
||||||
|
|
||||||
assertThat(p1GameView.message()).isEqualTo(p2GameView.message());
|
assertThat(p1GameView.message()).isEqualTo(p2GameView.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState findGameStateById(List<GameState> gameStateList, UUID gameUuid) {
|
GameView findGameStateById(List<GameView> gameStateList, UUID gameUuid) {
|
||||||
return gameStateList
|
return gameStateList
|
||||||
.stream()
|
.stream()
|
||||||
.filter(gameView -> gameView.uuid().compareTo(gameUuid) == 0)
|
.filter(gameView -> gameView.uuid().compareTo(gameUuid) == 0)
|
||||||
|
@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
import djmil.cordacheckers.cordaclient.dao.GameView;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Rank;
|
import djmil.cordacheckers.cordaclient.dao.Rank;
|
||||||
import djmil.cordacheckers.cordaclient.dao.Stone;
|
import djmil.cordacheckers.cordaclient.dao.Stone;
|
||||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||||
@ -50,7 +50,7 @@ public class RankingTests {
|
|||||||
final var winnerName = hiWinner.getName();
|
final var winnerName = hiWinner.getName();
|
||||||
final var losserName = hiLooser.getName();
|
final var losserName = hiLooser.getName();
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiWinner, hiLooser, Stone.Color.WHITE,
|
final GameView game = cordaClient.gameProposalCreate(hiWinner, hiLooser, Stone.Color.WHITE,
|
||||||
"GameBoard GLOBAL_RANKING surrender test");
|
"GameBoard GLOBAL_RANKING surrender test");
|
||||||
|
|
||||||
cordaClient.gameProposalAccept(hiLooser, game.uuid());
|
cordaClient.gameProposalAccept(hiLooser, game.uuid());
|
||||||
@ -79,7 +79,7 @@ public class RankingTests {
|
|||||||
final var winnerName = hiWinner.getName();
|
final var winnerName = hiWinner.getName();
|
||||||
final var losserName = hiLooser.getName();
|
final var losserName = hiLooser.getName();
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiWinner, hiLooser, Stone.Color.BLACK,
|
final GameView game = cordaClient.gameProposalCreate(hiWinner, hiLooser, Stone.Color.BLACK,
|
||||||
board1, "GameBoard GLOBAL_RANKING victory test");
|
board1, "GameBoard GLOBAL_RANKING victory test");
|
||||||
|
|
||||||
cordaClient.gameProposalAccept(hiLooser, game.uuid());
|
cordaClient.gameProposalAccept(hiLooser, game.uuid());
|
||||||
@ -104,7 +104,7 @@ public class RankingTests {
|
|||||||
final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1);
|
final var hiPlayer1 = holdingIdentityResolver.getByUsername(player1);
|
||||||
final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2);
|
final var hiPlayer2 = holdingIdentityResolver.getByUsername(player2);
|
||||||
|
|
||||||
final GameState game = cordaClient.gameProposalCreate(hiPlayer1, hiPlayer2, Stone.Color.WHITE,
|
final GameView game = cordaClient.gameProposalCreate(hiPlayer1, hiPlayer2, Stone.Color.WHITE,
|
||||||
"GameBoard GLOBAL_RANKING draw test");
|
"GameBoard GLOBAL_RANKING draw test");
|
||||||
|
|
||||||
cordaClient.gameProposalAccept(hiPlayer2, game.uuid());
|
cordaClient.gameProposalAccept(hiPlayer2, game.uuid());
|
||||||
|
Loading…
Reference in New Issue
Block a user