summaryrefslogtreecommitdiff
path: root/backend/src
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2017-05-25 10:04:10 +0200
committerjbion <joffrey.bion@amadeus.com>2017-05-25 10:07:09 +0200
commitf9948aefa464d3cca9a96dc3dd7b04b9552b3db7 (patch)
tree8203cf724c5af6f35b7c859a8d0959a716a6dd03 /backend/src
parentAdd missing serialized fields (diff)
downloadseven-wonders-f9948aefa464d3cca9a96dc3dd7b04b9552b3db7.tar.gz
seven-wonders-f9948aefa464d3cca9a96dc3dd7b04b9552b3db7.tar.bz2
seven-wonders-f9948aefa464d3cca9a96dc3dd7b04b9552b3db7.zip
Add deserializable API objects for Java SevenWonders client
Diffstat (limited to 'backend/src')
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiBoard.java166
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCard.java100
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCardBack.java14
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiEffect.java4
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiHandCard.java48
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiLobby.java65
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiMilitary.java34
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayer.java20
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayerTurnInfo.java98
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiProduction.java29
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiScience.java28
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTable.java73
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTradingRules.java19
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonder.java18
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonderStage.java37
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/api/SevenWondersSession.java35
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/test/client/JackstompSession.java3
17 files changed, 779 insertions, 12 deletions
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiBoard.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiBoard.java
new file mode 100644
index 00000000..56a67482
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiBoard.java
@@ -0,0 +1,166 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.luxons.sevenwonders.game.cards.Card;
+import org.luxons.sevenwonders.game.effects.SpecialAbility;
+
+public class ApiBoard {
+
+ private ApiWonder wonder;
+
+ private int playerIndex;
+
+ private List<ApiCard> playedCards;
+
+ private ApiProduction production;
+
+ private ApiProduction publicProduction;
+
+ private ApiScience science;
+
+ private ApiTradingRules tradingRules;
+
+ private ApiMilitary military;
+
+ private Set<SpecialAbility> specialAbilities;
+
+ private Map<Integer, Boolean> consumedFreeCards;
+
+ private Card copiedGuild;
+
+ private int gold;
+
+ private int pointsPer3Gold;
+
+ public ApiWonder getWonder() {
+ return wonder;
+ }
+
+ public void setWonder(ApiWonder wonder) {
+ this.wonder = wonder;
+ }
+
+ public int getPlayerIndex() {
+ return playerIndex;
+ }
+
+ public void setPlayerIndex(int playerIndex) {
+ this.playerIndex = playerIndex;
+ }
+
+ public List<ApiCard> getPlayedCards() {
+ return playedCards;
+ }
+
+ public void setPlayedCards(List<ApiCard> playedCards) {
+ this.playedCards = playedCards;
+ }
+
+ public ApiProduction getProduction() {
+ return production;
+ }
+
+ public void setProduction(ApiProduction production) {
+ this.production = production;
+ }
+
+ public ApiProduction getPublicProduction() {
+ return publicProduction;
+ }
+
+ public void setPublicProduction(ApiProduction publicProduction) {
+ this.publicProduction = publicProduction;
+ }
+
+ public ApiScience getScience() {
+ return science;
+ }
+
+ public void setScience(ApiScience science) {
+ this.science = science;
+ }
+
+ public ApiTradingRules getTradingRules() {
+ return tradingRules;
+ }
+
+ public void setTradingRules(ApiTradingRules tradingRules) {
+ this.tradingRules = tradingRules;
+ }
+
+ public ApiMilitary getMilitary() {
+ return military;
+ }
+
+ public void setMilitary(ApiMilitary military) {
+ this.military = military;
+ }
+
+ public Set<SpecialAbility> getSpecialAbilities() {
+ return specialAbilities;
+ }
+
+ public void setSpecialAbilities(Set<SpecialAbility> specialAbilities) {
+ this.specialAbilities = specialAbilities;
+ }
+
+ public Map<Integer, Boolean> getConsumedFreeCards() {
+ return consumedFreeCards;
+ }
+
+ public void setConsumedFreeCards(Map<Integer, Boolean> consumedFreeCards) {
+ this.consumedFreeCards = consumedFreeCards;
+ }
+
+ public Card getCopiedGuild() {
+ return copiedGuild;
+ }
+
+ public void setCopiedGuild(Card copiedGuild) {
+ this.copiedGuild = copiedGuild;
+ }
+
+ public int getGold() {
+ return gold;
+ }
+
+ public void setGold(int gold) {
+ this.gold = gold;
+ }
+
+ public int getPointsPer3Gold() {
+ return pointsPer3Gold;
+ }
+
+ public void setPointsPer3Gold(int pointsPer3Gold) {
+ this.pointsPer3Gold = pointsPer3Gold;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiBoard apiBoard = (ApiBoard) o;
+ return playerIndex == apiBoard.playerIndex && gold == apiBoard.gold && pointsPer3Gold == apiBoard.pointsPer3Gold
+ && Objects.equals(wonder, apiBoard.wonder) && Objects.equals(playedCards, apiBoard.playedCards)
+ && Objects.equals(production, apiBoard.production) && Objects.equals(publicProduction,
+ apiBoard.publicProduction) && Objects.equals(science, apiBoard.science) && Objects.equals(tradingRules,
+ apiBoard.tradingRules) && Objects.equals(military, apiBoard.military) && Objects.equals(
+ specialAbilities, apiBoard.specialAbilities) && Objects.equals(consumedFreeCards,
+ apiBoard.consumedFreeCards) && Objects.equals(copiedGuild, apiBoard.copiedGuild);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(wonder, playerIndex, playedCards, production, publicProduction, science, tradingRules,
+ military, specialAbilities, consumedFreeCards, copiedGuild, gold, pointsPer3Gold);
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCard.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCard.java
new file mode 100644
index 00000000..f927dd4c
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCard.java
@@ -0,0 +1,100 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.luxons.sevenwonders.game.cards.Color;
+import org.luxons.sevenwonders.game.cards.Requirements;
+
+public class ApiCard {
+
+ private String name;
+
+ private Color color;
+
+ private Requirements requirements;
+
+ private String chainParent;
+
+ private List<String> chainChildren;
+
+ private String image;
+
+ private ApiCardBack back;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ public Requirements getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(Requirements requirements) {
+ this.requirements = requirements;
+ }
+
+ public String getChainParent() {
+ return chainParent;
+ }
+
+ public void setChainParent(String chainParent) {
+ this.chainParent = chainParent;
+ }
+
+ public List<String> getChainChildren() {
+ return chainChildren;
+ }
+
+ public void setChainChildren(List<String> chainChildren) {
+ this.chainChildren = chainChildren;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public ApiCardBack getBack() {
+ return back;
+ }
+
+ public void setBack(ApiCardBack back) {
+ this.back = back;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiCard apiCard = (ApiCard) o;
+ return Objects.equals(name, apiCard.name) && color == apiCard.color && Objects.equals(requirements,
+ apiCard.requirements) && Objects.equals(chainParent, apiCard.chainParent) && Objects.equals(
+ chainChildren, apiCard.chainChildren) && Objects.equals(image, apiCard.image) && Objects.equals(back,
+ apiCard.back);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, color, requirements, chainParent, chainChildren, image, back);
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCardBack.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCardBack.java
new file mode 100644
index 00000000..e0f5a50e
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiCardBack.java
@@ -0,0 +1,14 @@
+package org.luxons.sevenwonders.test.api;
+
+public class ApiCardBack {
+
+ private String image;
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiEffect.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiEffect.java
new file mode 100644
index 00000000..df71365d
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiEffect.java
@@ -0,0 +1,4 @@
+package org.luxons.sevenwonders.test.api;
+
+public class ApiEffect {
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiHandCard.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiHandCard.java
new file mode 100644
index 00000000..0cb143c1
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiHandCard.java
@@ -0,0 +1,48 @@
+package org.luxons.sevenwonders.test.api;
+
+/**
+ * A card with contextual information relative to the hand it is sitting in. The extra information is especially
+ * useful because it frees the client from a painful business logic implementation.
+ */
+public class ApiHandCard {
+
+ private ApiCard card;
+
+ private boolean chainable;
+
+ private boolean free;
+
+ private boolean playable;
+
+ public ApiCard getCard() {
+ return card;
+ }
+
+ public void setCard(ApiCard card) {
+ this.card = card;
+ }
+
+ public boolean isChainable() {
+ return chainable;
+ }
+
+ public void setChainable(boolean chainable) {
+ this.chainable = chainable;
+ }
+
+ public boolean isFree() {
+ return free;
+ }
+
+ public void setFree(boolean free) {
+ this.free = free;
+ }
+
+ public boolean isPlayable() {
+ return playable;
+ }
+
+ public void setPlayable(boolean playable) {
+ this.playable = playable;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiLobby.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiLobby.java
index 9ce9a5d7..e068ea86 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiLobby.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiLobby.java
@@ -1,11 +1,25 @@
package org.luxons.sevenwonders.test.api;
+import java.util.List;
+import java.util.Objects;
+
+import org.luxons.sevenwonders.game.api.CustomizableSettings;
+import org.luxons.sevenwonders.lobby.State;
+
public class ApiLobby {
private long id;
private String name;
+ private ApiPlayer owner;
+
+ private List<ApiPlayer> players;
+
+ private CustomizableSettings settings;
+
+ private State state;
+
public long getId() {
return id;
}
@@ -21,4 +35,55 @@ public class ApiLobby {
public void setName(String name) {
this.name = name;
}
+
+ public ApiPlayer getOwner() {
+ return owner;
+ }
+
+ public void setOwner(ApiPlayer owner) {
+ this.owner = owner;
+ }
+
+ public List<ApiPlayer> getPlayers() {
+ return players;
+ }
+
+ public void setPlayers(List<ApiPlayer> players) {
+ this.players = players;
+ }
+
+ public CustomizableSettings getSettings() {
+ return settings;
+ }
+
+ public void setSettings(CustomizableSettings settings) {
+ this.settings = settings;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiLobby apiLobby = (ApiLobby) o;
+ return id == apiLobby.id && Objects.equals(name, apiLobby.name) && Objects.equals(owner, apiLobby.owner)
+ && Objects.equals(players, apiLobby.players) && Objects.equals(settings, apiLobby.settings)
+ && state == apiLobby.state;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, name, owner, players, settings, state);
+ }
}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiMilitary.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiMilitary.java
new file mode 100644
index 00000000..11ba2b1c
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiMilitary.java
@@ -0,0 +1,34 @@
+package org.luxons.sevenwonders.test.api;
+
+public class ApiMilitary {
+
+ private int nbShields = 0;
+
+ private int totalPoints = 0;
+
+ private int nbDefeatTokens = 0;
+
+ public int getNbShields() {
+ return nbShields;
+ }
+
+ public void setNbShields(int nbShields) {
+ this.nbShields = nbShields;
+ }
+
+ public int getTotalPoints() {
+ return totalPoints;
+ }
+
+ public void setTotalPoints(int totalPoints) {
+ this.totalPoints = totalPoints;
+ }
+
+ public int getNbDefeatTokens() {
+ return nbDefeatTokens;
+ }
+
+ public void setNbDefeatTokens(int nbDefeatTokens) {
+ this.nbDefeatTokens = nbDefeatTokens;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayer.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayer.java
index dcf7ec03..940e410b 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayer.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayer.java
@@ -1,5 +1,7 @@
package org.luxons.sevenwonders.test.api;
+import java.util.Objects;
+
public class ApiPlayer {
private String username;
@@ -27,4 +29,22 @@ public class ApiPlayer {
public void setIndex(int index) {
this.index = index;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiPlayer apiPlayer = (ApiPlayer) o;
+ return index == apiPlayer.index && Objects.equals(username, apiPlayer.username) && Objects.equals(displayName,
+ apiPlayer.displayName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(username, displayName, index);
+ }
}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayerTurnInfo.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayerTurnInfo.java
new file mode 100644
index 00000000..ae4d06ad
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiPlayerTurnInfo.java
@@ -0,0 +1,98 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.luxons.sevenwonders.game.api.Action;
+
+public class ApiPlayerTurnInfo {
+
+ private int playerIndex;
+
+ private ApiTable table;
+
+ private int currentAge;
+
+ private Action action;
+
+ private List<ApiHandCard> hand;
+
+ private List<ApiCard> neighbourGuildCards;
+
+ private String message;
+
+ public int getPlayerIndex() {
+ return playerIndex;
+ }
+
+ public void setPlayerIndex(int playerIndex) {
+ this.playerIndex = playerIndex;
+ }
+
+ public ApiTable getTable() {
+ return table;
+ }
+
+ public void setTable(ApiTable table) {
+ this.table = table;
+ }
+
+ public int getCurrentAge() {
+ return currentAge;
+ }
+
+ public void setCurrentAge(int currentAge) {
+ this.currentAge = currentAge;
+ }
+
+ public List<ApiHandCard> getHand() {
+ return hand;
+ }
+
+ public void setHand(List<ApiHandCard> hand) {
+ this.hand = hand;
+ }
+
+ public List<ApiCard> getNeighbourGuildCards() {
+ return neighbourGuildCards;
+ }
+
+ public void setNeighbourGuildCards(List<ApiCard> neighbourGuildCards) {
+ this.neighbourGuildCards = neighbourGuildCards;
+ }
+
+ public Action getAction() {
+ return action;
+ }
+
+ public void setAction(Action action) {
+ this.action = action;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiPlayerTurnInfo that = (ApiPlayerTurnInfo) o;
+ return playerIndex == that.playerIndex && currentAge == that.currentAge && Objects.equals(table, that.table)
+ && action == that.action && Objects.equals(hand, that.hand) && Objects.equals(neighbourGuildCards,
+ that.neighbourGuildCards) && Objects.equals(message, that.message);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(playerIndex, table, currentAge, action, hand, neighbourGuildCards, message);
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiProduction.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiProduction.java
new file mode 100644
index 00000000..0c3bf8b3
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiProduction.java
@@ -0,0 +1,29 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.Set;
+
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.resources.Resources;
+
+public class ApiProduction {
+
+ private Resources fixedResources;
+
+ private Set<Set<ResourceType>> alternativeResources;
+
+ public Resources getFixedResources() {
+ return fixedResources;
+ }
+
+ public void setFixedResources(Resources fixedResources) {
+ this.fixedResources = fixedResources;
+ }
+
+ public Set<Set<ResourceType>> getAlternativeResources() {
+ return alternativeResources;
+ }
+
+ public void setAlternativeResources(Set<Set<ResourceType>> alternativeResources) {
+ this.alternativeResources = alternativeResources;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiScience.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiScience.java
new file mode 100644
index 00000000..b2808c83
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiScience.java
@@ -0,0 +1,28 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.Map;
+
+import org.luxons.sevenwonders.game.boards.ScienceType;
+
+public class ApiScience {
+
+ private Map<ScienceType, Integer> quantities;
+
+ private int jokers;
+
+ public Map<ScienceType, Integer> getQuantities() {
+ return quantities;
+ }
+
+ public void setQuantities(Map<ScienceType, Integer> quantities) {
+ this.quantities = quantities;
+ }
+
+ public int getJokers() {
+ return jokers;
+ }
+
+ public void setJokers(int jokers) {
+ this.jokers = jokers;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTable.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTable.java
new file mode 100644
index 00000000..d0d991aa
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTable.java
@@ -0,0 +1,73 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.List;
+
+import org.luxons.sevenwonders.game.cards.HandRotationDirection;
+import org.luxons.sevenwonders.game.moves.Move;
+
+public class ApiTable {
+
+ private int nbPlayers;
+
+ private List<ApiBoard> boards;
+
+ private int currentAge = 0;
+
+ private HandRotationDirection handRotationDirection;
+
+ private List<Move> lastPlayedMoves;
+
+ private List<ApiCard> neighbourGuildCards;
+
+ public int getNbPlayers() {
+ return nbPlayers;
+ }
+
+ public void setNbPlayers(int nbPlayers) {
+ this.nbPlayers = nbPlayers;
+ }
+
+ public List<ApiBoard> getBoards() {
+ return boards;
+ }
+
+ public void setBoards(List<ApiBoard> boards) {
+ this.boards = boards;
+ }
+
+ public int getCurrentAge() {
+ return currentAge;
+ }
+
+ public void setCurrentAge(int currentAge) {
+ this.currentAge = currentAge;
+ }
+
+ public HandRotationDirection getHandRotationDirection() {
+ return handRotationDirection;
+ }
+
+ public void setHandRotationDirection(HandRotationDirection handRotationDirection) {
+ this.handRotationDirection = handRotationDirection;
+ }
+
+ public List<Move> getLastPlayedMoves() {
+ return lastPlayedMoves;
+ }
+
+ public void setLastPlayedMoves(List<Move> lastPlayedMoves) {
+ this.lastPlayedMoves = lastPlayedMoves;
+ }
+
+ public void increaseCurrentAge() {
+ this.currentAge++;
+ }
+
+ public List<ApiCard> getNeighbourGuildCards() {
+ return neighbourGuildCards;
+ }
+
+ public void setNeighbourGuildCards(List<ApiCard> neighbourGuildCards) {
+ this.neighbourGuildCards = neighbourGuildCards;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTradingRules.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTradingRules.java
new file mode 100644
index 00000000..324b7d0e
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiTradingRules.java
@@ -0,0 +1,19 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.Map;
+
+import org.luxons.sevenwonders.game.resources.Provider;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+
+public class ApiTradingRules {
+
+ private Map<ResourceType, Map<Provider, Integer>> costs;
+
+ public Map<ResourceType, Map<Provider, Integer>> getCosts() {
+ return costs;
+ }
+
+ public void setCosts(Map<ResourceType, Map<Provider, Integer>> costs) {
+ this.costs = costs;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonder.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonder.java
new file mode 100644
index 00000000..d671b2f7
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonder.java
@@ -0,0 +1,18 @@
+package org.luxons.sevenwonders.test.api;
+
+import java.util.List;
+
+import org.luxons.sevenwonders.game.resources.ResourceType;
+
+public class ApiWonder {
+
+ private String name;
+
+ private ResourceType initialResource;
+
+ private List<ApiWonderStage> stages;
+
+ private String image;
+
+ private int nbBbuiltStages;
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonderStage.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonderStage.java
new file mode 100644
index 00000000..6a6e0884
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/ApiWonderStage.java
@@ -0,0 +1,37 @@
+package org.luxons.sevenwonders.test.api;
+
+import org.luxons.sevenwonders.game.cards.CardBack;
+import org.luxons.sevenwonders.game.cards.Requirements;
+
+public class ApiWonderStage {
+
+ private Requirements requirements;
+
+ private CardBack cardBack;
+
+ private boolean built;
+
+ public Requirements getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(Requirements requirements) {
+ this.requirements = requirements;
+ }
+
+ public CardBack getCardBack() {
+ return cardBack;
+ }
+
+ public void setCardBack(CardBack cardBack) {
+ this.cardBack = cardBack;
+ }
+
+ public boolean isBuilt() {
+ return built;
+ }
+
+ public void setBuilt(boolean built) {
+ this.built = built;
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/api/SevenWondersSession.java b/backend/src/test/java/org/luxons/sevenwonders/test/api/SevenWondersSession.java
index ad8e41ba..093d391a 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/test/api/SevenWondersSession.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/api/SevenWondersSession.java
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.test.api;
import org.luxons.sevenwonders.actions.ChooseNameAction;
import org.luxons.sevenwonders.actions.CreateGameAction;
import org.luxons.sevenwonders.actions.JoinGameAction;
+import org.luxons.sevenwonders.test.client.Channel;
import org.luxons.sevenwonders.test.client.JackstompSession;
import static org.junit.Assert.assertEquals;
@@ -21,25 +22,21 @@ public class SevenWondersSession {
session.disconnect();
}
- public ApiPlayer chooseName(String displayName) throws Exception {
+ public ApiPlayer chooseName(String displayName) throws InterruptedException {
ChooseNameAction action = new ChooseNameAction();
action.setPlayerName(displayName);
+ return session.request(action, ApiPlayer.class, "/app/chooseName", "/user/queue/nameChoice");
+ }
- ApiPlayer player = session.request(action, ApiPlayer.class, "/app/chooseName", "/user/queue/nameChoice");
- assertNotNull(player);
- assertEquals(displayName, player.getDisplayName());
-
- return player;
+ public Channel<ApiLobby[]> watchGames() {
+ return session.subscribe("/topic/games", ApiLobby[].class);
}
public ApiLobby createGame(String gameName) throws InterruptedException {
CreateGameAction action = new CreateGameAction();
action.setGameName(gameName);
- ApiLobby lobby = session.request(action, ApiLobby.class, "/app/lobby/create", "/user/queue/lobby/joined");
- assertNotNull(lobby);
- assertEquals(gameName, lobby.getName());
- return lobby;
+ return session.request(action, ApiLobby.class, "/app/lobby/create", "/user/queue/lobby/joined");
}
public ApiLobby joinGame(long gameId) throws InterruptedException {
@@ -52,10 +49,26 @@ public class SevenWondersSession {
return lobby;
}
+ public Channel<ApiLobby> watchLobbyUpdates(long gameId) {
+ return session.subscribe("/topic/lobby/" + gameId + "/updated", ApiLobby.class);
+ }
+
+ public Channel<ApiLobby> watchLobbyStart(long gameId) {
+ return session.subscribe("/topic/lobby/" + gameId + "/started", ApiLobby.class);
+ }
+
public void startGame(long gameId) throws InterruptedException {
String sendDestination = "/app/lobby/startGame";
String receiveDestination = "/topic/lobby/" + gameId + "/started";
- boolean received = session.request(sendDestination, null, receiveDestination);
+ boolean received = session.request(null, sendDestination, receiveDestination);
assertTrue(received);
}
+
+ public void sayReady() {
+ session.send("/app/game/sayReady", null);
+ }
+
+ public Channel<ApiPlayerTurnInfo> watchTurns() {
+ return session.subscribe("/user/queue/game/turn", ApiPlayerTurnInfo.class);
+ }
}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/test/client/JackstompSession.java b/backend/src/test/java/org/luxons/sevenwonders/test/client/JackstompSession.java
index 6ab7fb7d..12ab0adc 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/test/client/JackstompSession.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/test/client/JackstompSession.java
@@ -48,6 +48,7 @@ public class JackstompSession implements StompSession {
Subscription sub = stompSession.subscribe(destination, frameHandler);
return new Channel<>(sub, blockingQueue);
}
+
@Override
public Receiptable acknowledge(String messageId, boolean consumed) {
return stompSession.acknowledge(messageId, consumed);
@@ -82,7 +83,7 @@ public class JackstompSession implements StompSession {
return msg;
}
- public boolean request(String requestDestination, Object payload, String responseDestination)
+ public boolean request(Object payload, String requestDestination, String responseDestination)
throws InterruptedException {
Channel<Object> channel = subscribeEmptyMsgs(responseDestination);
send(requestDestination, payload);
bgstack15