summaryrefslogtreecommitdiff
path: root/game-engine/src/test/java/org/luxons
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-07-05 09:35:27 +0200
committerJoffrey Bion <joffrey.bion@amadeus.com>2018-07-06 14:17:16 +0200
commitccfd6d1d3ba64eef7df1645c24d979c284fd99da (patch)
tree441bc4e931fc998d86f642390096af4d30e9b85f /game-engine/src/test/java/org/luxons
parentPrevent PICK_NEIGHBOUR_GUILD action if no guild to pick (diff)
downloadseven-wonders-ccfd6d1d3ba64eef7df1645c24d979c284fd99da.tar.gz
seven-wonders-ccfd6d1d3ba64eef7df1645c24d979c284fd99da.tar.bz2
seven-wonders-ccfd6d1d3ba64eef7df1645c24d979c284fd99da.zip
Kotlin mig: api package
Diffstat (limited to 'game-engine/src/test/java/org/luxons')
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java10
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java12
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java45
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/boards/ScienceTest.java26
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java24
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java4
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java14
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java28
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.java27
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java8
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java16
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java6
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java6
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java20
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java4
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java8
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java12
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java26
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java58
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.java13
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/resources/TradingRulesTest.java16
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java247
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java6
23 files changed, 195 insertions, 441 deletions
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java
index 02531cde..9beb44fd 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java
@@ -21,7 +21,7 @@ import org.luxons.sevenwonders.game.resources.BestPriceCalculator;
import org.luxons.sevenwonders.game.resources.ResourceTransaction;
import org.luxons.sevenwonders.game.resources.ResourceTransactions;
import org.luxons.sevenwonders.game.resources.Resources;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -48,7 +48,7 @@ public class GameTest {
}
private static Game createGame(int nbPlayers) {
- CustomizableSettings settings = TestUtils.createCustomizableSettings();
+ CustomizableSettings settings = TestUtilsKt.testCustomizableSettings();
return new GameDefinitionLoader().getGameDefinition().initGame(0, settings, nbPlayers);
}
@@ -99,11 +99,11 @@ public class GameTest {
for (HandCard handCard : turnInfo.getHand()) {
if (handCard.isPlayable()) {
Set<ResourceTransaction> resourcesToBuy = findResourcesToBuyFor(handCard, turnInfo);
- return TestUtils.createPlayerMove(handCard.getCard().getName(), MoveType.PLAY, resourcesToBuy);
+ return TestUtilsKt.createPlayerMove(MoveType.PLAY, handCard.getCard().getName(), resourcesToBuy);
}
}
HandCard firstCardInHand = turnInfo.getHand().get(0);
- return TestUtils.createPlayerMove(firstCardInHand.getCard().getName(), MoveType.DISCARD);
+ return TestUtilsKt.createPlayerMove(MoveType.DISCARD, firstCardInHand.getCard().getName());
}
private static Set<ResourceTransaction> findResourcesToBuyFor(HandCard handCard, PlayerTurnInfo turnInfo) {
@@ -122,6 +122,6 @@ public class GameTest {
assertNotNull(neighbourGuilds);
assertFalse(neighbourGuilds.isEmpty());
String cardName = neighbourGuilds.get(0).getName();
- return TestUtils.createPlayerMove(cardName, MoveType.COPY_GUILD);
+ return TestUtilsKt.createPlayerMove(MoveType.COPY_GUILD, cardName);
}
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java
index 93b6eb08..0dfa3a80 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java
@@ -8,7 +8,7 @@ import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
import org.luxons.sevenwonders.game.cards.Card;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -26,7 +26,7 @@ public class TableTest {
@Theory
public void getBoard_wrapLeft(int nbPlayers) {
assumeTrue(nbPlayers >= 2);
- Table table = TestUtils.createTable(nbPlayers);
+ Table table = TestUtilsKt.testTable(nbPlayers);
int last = nbPlayers - 1;
assertEquals(table.getBoard(last), table.getBoard(0, RelativeBoardPosition.LEFT));
assertEquals(table.getBoard(0), table.getBoard(0, RelativeBoardPosition.SELF));
@@ -36,7 +36,7 @@ public class TableTest {
@Theory
public void getBoard_wrapRight(int nbPlayers) {
assumeTrue(nbPlayers >= 2);
- Table table = TestUtils.createTable(nbPlayers);
+ Table table = TestUtilsKt.testTable(nbPlayers);
int last = nbPlayers - 1;
assertEquals(table.getBoard(last - 1), table.getBoard(last, RelativeBoardPosition.LEFT));
assertEquals(table.getBoard(last), table.getBoard(last, RelativeBoardPosition.SELF));
@@ -46,7 +46,7 @@ public class TableTest {
@Theory
public void getBoard_noWrap(int nbPlayers) {
assumeTrue(nbPlayers >= 3);
- Table table = TestUtils.createTable(nbPlayers);
+ Table table = TestUtilsKt.testTable(nbPlayers);
assertEquals(table.getBoard(0), table.getBoard(1, RelativeBoardPosition.LEFT));
assertEquals(table.getBoard(1), table.getBoard(1, RelativeBoardPosition.SELF));
assertEquals(table.getBoard(2), table.getBoard(1, RelativeBoardPosition.RIGHT));
@@ -55,8 +55,8 @@ public class TableTest {
@Theory
public void getNeighbourGuildCards(int nbPlayers) {
assumeTrue(nbPlayers >= 4);
- Table table = TestUtils.createTable(nbPlayers);
- List<Card> guildCards = TestUtils.createGuildCards(4);
+ Table table = TestUtilsKt.testTable(nbPlayers);
+ List<Card> guildCards = TestUtilsKt.createGuildCards(4);
table.getBoard(0).getPlayedCards().add(guildCards.get(0));
table.getBoard(0).getPlayedCards().add(guildCards.get(1));
table.getBoard(1).getPlayedCards().add(guildCards.get(2));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java
index c54ff0b2..4b373fa2 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java
@@ -25,7 +25,7 @@ import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.resources.Resources;
import org.luxons.sevenwonders.game.scoring.PlayerScore;
import org.luxons.sevenwonders.game.scoring.ScoreCategory;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -66,17 +66,16 @@ public class BoardTest {
@Theory
public void initialGold_respectsSettings(@FromDataPoints("gold") int goldAmountInSettings) {
- CustomizableSettings customSettings = TestUtils.createCustomizableSettings();
- customSettings.setInitialGold(goldAmountInSettings);
+ CustomizableSettings customSettings = TestUtilsKt.testCustomizableSettings(goldAmountInSettings);
Settings settings = new Settings(5, customSettings);
- Board board = new Board(TestUtils.createWonder(), 0, settings);
+ Board board = new Board(TestUtilsKt.testWonder(), 0, settings);
assertEquals(goldAmountInSettings, board.getGold());
}
@Theory
public void initialProduction_containsInitialResource(ResourceType type) {
- Board board = new Board(TestUtils.createWonder(type), 0, new Settings(5));
- Resources resources = TestUtils.createResources(type);
+ Board board = new Board(TestUtilsKt.testWonder(type), 0, new Settings(5));
+ Resources resources = TestUtilsKt.createResources(type);
assertTrue(board.getProduction().contains(resources));
assertTrue(board.getPublicProduction().contains(resources));
}
@@ -86,7 +85,7 @@ public class BoardTest {
@FromDataPoints("gold") int goldRemoved) {
assumeTrue(goldRemoved >= 0);
assumeTrue(initialGold >= goldRemoved);
- Board board = new Board(TestUtils.createWonder(), 0, new Settings(5));
+ Board board = new Board(TestUtilsKt.testWonder(), 0, new Settings(5));
board.setGold(initialGold);
board.removeGold(goldRemoved);
assertEquals(initialGold - goldRemoved, board.getGold());
@@ -98,7 +97,7 @@ public class BoardTest {
assumeTrue(goldRemoved >= 0);
assumeTrue(initialGold < goldRemoved);
thrown.expect(InsufficientFundsException.class);
- Board board = new Board(TestUtils.createWonder(), 0, new Settings(5));
+ Board board = new Board(TestUtilsKt.testWonder(), 0, new Settings(5));
board.setGold(initialGold);
board.removeGold(goldRemoved);
}
@@ -106,8 +105,8 @@ public class BoardTest {
@Theory
public void getNbCardsOfColor_properCount_singleColor(ResourceType type, @FromDataPoints("nbCards") int nbCards,
@FromDataPoints("nbCards") int nbOtherCards, Color color) {
- Board board = TestUtils.createBoard(type);
- TestUtils.addCards(board, nbCards, nbOtherCards, color);
+ Board board = TestUtilsKt.testBoard(type);
+ TestUtilsKt.addCards(board, nbCards, nbOtherCards, color);
assertEquals(nbCards, board.getNbCardsOfColor(Collections.singletonList(color)));
}
@@ -116,17 +115,17 @@ public class BoardTest {
@FromDataPoints("nbCards") int nbCards2,
@FromDataPoints("nbCards") int nbOtherCards, Color color1,
Color color2) {
- Board board = TestUtils.createBoard(type);
- TestUtils.addCards(board, nbCards1, color1);
- TestUtils.addCards(board, nbCards2, color2);
- TestUtils.addCards(board, nbOtherCards, TestUtils.getDifferentColorFrom(color1, color2));
+ Board board = TestUtilsKt.testBoard(type);
+ TestUtilsKt.addCards(board, nbCards1, color1);
+ TestUtilsKt.addCards(board, nbCards2, color2);
+ TestUtilsKt.addCards(board, nbOtherCards, TestUtilsKt.getDifferentColorFrom(color1, color2));
assertEquals(nbCards1 + nbCards2, board.getNbCardsOfColor(Arrays.asList(color1, color2)));
}
@Test
public void setCopiedGuild_succeedsOnPurpleCard() {
- Board board = TestUtils.createBoard(ResourceType.CLAY);
- Card card = TestUtils.createCard(Color.PURPLE);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY);
+ Card card = TestUtilsKt.testCard(Color.PURPLE);
board.setCopiedGuild(card);
assertSame(card, board.getCopiedGuild());
@@ -135,8 +134,8 @@ public class BoardTest {
@Theory
public void setCopiedGuild_failsOnNonPurpleCard(Color color) {
assumeTrue(color != Color.PURPLE);
- Board board = TestUtils.createBoard(ResourceType.CLAY);
- Card card = TestUtils.createCard(color);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY);
+ Card card = TestUtilsKt.testCard(color);
thrown.expect(IllegalArgumentException.class);
board.setCopiedGuild(card);
@@ -144,7 +143,7 @@ public class BoardTest {
@Theory
public void hasSpecial(SpecialAbility applied, SpecialAbility tested) {
- Board board = TestUtils.createBoard(ResourceType.CLAY);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY);
Table table = new Table(Collections.singletonList(board));
SpecialAbilityActivation special = new SpecialAbilityActivation(applied);
@@ -155,7 +154,7 @@ public class BoardTest {
@Test
public void canPlayFreeCard() {
- Board board = TestUtils.createBoard(ResourceType.CLAY);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY);
Table table = new Table(Collections.singletonList(board));
SpecialAbilityActivation special = new SpecialAbilityActivation(SpecialAbility.ONE_FREE_PER_AGE);
@@ -187,7 +186,7 @@ public class BoardTest {
@Theory
public void computePoints_gold(@FromDataPoints("gold") int gold) {
assumeTrue(gold >= 0);
- Board board = TestUtils.createBoard(ResourceType.WOOD);
+ Board board = TestUtilsKt.testBoard(ResourceType.WOOD);
Table table = new Table(Collections.singletonList(board));
board.setGold(gold);
@@ -199,12 +198,12 @@ public class BoardTest {
@Theory
public void computePoints_(@FromDataPoints("gold") int gold) {
assumeTrue(gold >= 0);
- Board board = TestUtils.createBoard(ResourceType.WOOD);
+ Board board = TestUtilsKt.testBoard(ResourceType.WOOD);
Table table = new Table(Collections.singletonList(board));
board.setGold(gold);
Effect effect = new RawPointsIncrease(5);
- TestUtils.playCardWithEffect(table, 0, Color.BLUE, effect);
+ TestUtilsKt.playCardWithEffect(table, 0, Color.BLUE, effect);
PlayerScore score = board.computePoints(table);
assertEquals(gold / 3, (int) score.getPoints(ScoreCategory.GOLD));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/ScienceTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/ScienceTest.java
index 24c63b31..b31da03b 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/ScienceTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/boards/ScienceTest.java
@@ -5,7 +5,7 @@ import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
@@ -27,7 +27,7 @@ public class ScienceTest {
@Test
public void addAll_empty() {
- Science initial = TestUtils.createScience(3, 4, 5, 1);
+ Science initial = TestUtilsKt.createScience(3, 4, 5, 1);
Science empty = new Science();
initial.addAll(empty);
assertEquals(3, initial.getQuantity(ScienceType.COMPASS));
@@ -38,8 +38,8 @@ public class ScienceTest {
@Test
public void addAll_noJoker() {
- Science initial = TestUtils.createScience(3, 4, 5, 1);
- Science other = TestUtils.createScience(1, 2, 3, 0);
+ Science initial = TestUtilsKt.createScience(3, 4, 5, 1);
+ Science other = TestUtilsKt.createScience(1, 2, 3, 0);
initial.addAll(other);
assertEquals(4, initial.getQuantity(ScienceType.COMPASS));
assertEquals(6, initial.getQuantity(ScienceType.WHEEL));
@@ -49,8 +49,8 @@ public class ScienceTest {
@Test
public void addAll_withJokers() {
- Science initial = TestUtils.createScience(3, 4, 5, 1);
- Science other = TestUtils.createScience(0, 0, 0, 3);
+ Science initial = TestUtilsKt.createScience(3, 4, 5, 1);
+ Science other = TestUtilsKt.createScience(0, 0, 0, 3);
initial.addAll(other);
assertEquals(3, initial.getQuantity(ScienceType.COMPASS));
assertEquals(4, initial.getQuantity(ScienceType.WHEEL));
@@ -60,8 +60,8 @@ public class ScienceTest {
@Test
public void addAll_mixed() {
- Science initial = TestUtils.createScience(3, 4, 5, 1);
- Science other = TestUtils.createScience(1, 2, 3, 4);
+ Science initial = TestUtilsKt.createScience(3, 4, 5, 1);
+ Science other = TestUtilsKt.createScience(1, 2, 3, 4);
initial.addAll(other);
assertEquals(4, initial.getQuantity(ScienceType.COMPASS));
assertEquals(6, initial.getQuantity(ScienceType.WHEEL));
@@ -71,31 +71,31 @@ public class ScienceTest {
@Theory
public void computePoints_compassesOnly_noJoker(int compasses) {
- Science science = TestUtils.createScience(compasses, 0, 0, 0);
+ Science science = TestUtilsKt.createScience(compasses, 0, 0, 0);
assertEquals(compasses * compasses, science.computePoints());
}
@Theory
public void computePoints_wheelsOnly_noJoker(int wheels) {
- Science science = TestUtils.createScience(0, wheels, 0, 0);
+ Science science = TestUtilsKt.createScience(0, wheels, 0, 0);
assertEquals(wheels * wheels, science.computePoints());
}
@Theory
public void computePoints_tabletsOnly_noJoker(int tablets) {
- Science science = TestUtils.createScience(0, 0, tablets, 0);
+ Science science = TestUtilsKt.createScience(0, 0, tablets, 0);
assertEquals(tablets * tablets, science.computePoints());
}
@Theory
public void computePoints_allSameNoJoker(int eachSymbol) {
- Science science = TestUtils.createScience(eachSymbol, eachSymbol, eachSymbol, 0);
+ Science science = TestUtilsKt.createScience(eachSymbol, eachSymbol, eachSymbol, 0);
assertEquals(3 * eachSymbol * eachSymbol + 7 * eachSymbol, science.computePoints());
}
@Theory
public void computePoints_expectation(int[] expectation) {
- Science science = TestUtils.createScience(expectation[0], expectation[1], expectation[2], expectation[3]);
+ Science science = TestUtilsKt.createScience(expectation[0], expectation[1], expectation[2], expectation[3]);
assertEquals(expectation[4], science.computePoints());
}
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
index 2a3b6806..b9681434 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
@@ -13,13 +13,13 @@ import org.luxons.sevenwonders.game.effects.Effect;
import org.luxons.sevenwonders.game.effects.ProductionIncrease;
import org.luxons.sevenwonders.game.resources.ResourceTransactions;
import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import org.luxons.sevenwonders.game.wonders.Wonder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
-import static org.luxons.sevenwonders.game.test.TestUtils.createCard;
public class CardTest {
@@ -61,14 +61,14 @@ public class CardTest {
@Test
public void equals_falseWhenNull() {
- Card card = createCard("TestCard");
+ Card card = TestUtilsKt.testCard("TestCard");
//noinspection ObjectEqualsNull
assertFalse(card.equals(null));
}
@Test
public void equals_falseWhenDifferentClass() {
- Card card = createCard("TestCard");
+ Card card = TestUtilsKt.testCard("TestCard");
Object object = new Object();
//noinspection EqualsBetweenInconvertibleTypes
assertFalse(card.equals(object));
@@ -76,35 +76,35 @@ public class CardTest {
@Test
public void equals_trueWhenSame() {
- Card card = createCard("TestCard");
+ Card card = TestUtilsKt.testCard("TestCard");
assertEquals(card, card);
}
@Test
public void equals_trueWhenSameContent() {
- Card card1 = createCard("TestCard");
- Card card2 = createCard("TestCard");
+ Card card1 = TestUtilsKt.testCard("TestCard");
+ Card card2 = TestUtilsKt.testCard("TestCard");
assertTrue(card1.equals(card2));
}
@Test
public void equals_falseWhenDifferentName() {
- Card card1 = createCard("TestCard1");
- Card card2 = createCard("TestCard2");
+ Card card1 = TestUtilsKt.testCard("TestCard1");
+ Card card2 = TestUtilsKt.testCard("TestCard2");
assertFalse(card1.equals(card2));
}
@Test
public void hashCode_sameWhenSameContent() {
- Card card1 = createCard("TestCard");
- Card card2 = createCard("TestCard");
+ Card card1 = TestUtilsKt.testCard("TestCard");
+ Card card2 = TestUtilsKt.testCard("TestCard");
assertEquals(card1.hashCode(), card2.hashCode());
}
@Test
public void hashCode_differentWhenDifferentName() {
- Card card1 = createCard("TestCard1");
- Card card2 = createCard("TestCard2");
+ Card card1 = TestUtilsKt.testCard("TestCard1");
+ Card card2 = TestUtilsKt.testCard("TestCard2");
assertNotEquals(card1.hashCode(), card2.hashCode());
}
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java
index 8adeb44d..f572c5ac 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/DecksTest.java
@@ -12,7 +12,7 @@ import org.junit.experimental.theories.Theory;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.cards.Decks.CardNotFoundException;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -34,7 +34,7 @@ public class DecksTest {
Map<Integer, List<Card>> cardsPerAge = new HashMap<>();
for (int age = 1; age <= nbAges; age++) {
int firstCardNumber = (age - 1) * nbCardsPerAge;
- cardsPerAge.put(age, TestUtils.createSampleCards(firstCardNumber, nbCardsPerAge));
+ cardsPerAge.put(age, TestUtilsKt.createSampleCards(firstCardNumber, nbCardsPerAge));
}
return new Decks(cardsPerAge);
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
index c20508e6..463dafcc 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/HandsTest.java
@@ -13,7 +13,7 @@ import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.api.HandCard;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.cards.Hands.PlayerIndexOutOfBoundsException;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -37,7 +37,7 @@ public class HandsTest {
Map<Integer, List<Card>> hands = new HashMap<>();
for (int p = 0; p < nbPlayers; p++) {
int firstCardNumber = (p - 1) * nbCardsPerPlayer;
- hands.put(p, TestUtils.createSampleCards(firstCardNumber, nbCardsPerPlayer));
+ hands.put(p, TestUtilsKt.createSampleCards(firstCardNumber, nbCardsPerPlayer));
}
return new Hands(hands, nbPlayers);
}
@@ -50,8 +50,8 @@ public class HandsTest {
@Test
public void get_retrievesCorrectCards() {
- List<Card> hand0 = TestUtils.createSampleCards(0, 5);
- List<Card> hand1 = TestUtils.createSampleCards(5, 10);
+ List<Card> hand0 = TestUtilsKt.createSampleCards(0, 5);
+ List<Card> hand1 = TestUtilsKt.createSampleCards(5, 10);
Map<Integer, List<Card>> handsMap = new HashMap<>();
handsMap.put(0, hand0);
handsMap.put(1, hand1);
@@ -126,14 +126,14 @@ public class HandsTest {
@Test
public void createHand_containsAllCards() {
- List<Card> hand0 = TestUtils.createSampleCards(0, 5);
- List<Card> hand1 = TestUtils.createSampleCards(5, 10);
+ List<Card> hand0 = TestUtilsKt.createSampleCards(0, 5);
+ List<Card> hand1 = TestUtilsKt.createSampleCards(5, 10);
Map<Integer, List<Card>> handsMap = new HashMap<>();
handsMap.put(0, hand0);
handsMap.put(1, hand1);
Hands hands = new Hands(handsMap, 2);
- Table table = TestUtils.createTable(2);
+ Table table = TestUtilsKt.testTable(2);
List<HandCard> hand = hands.createHand(table, 0);
for (HandCard handCard : hand) {
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java
index d2f505a4..6707dfab 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java
@@ -14,7 +14,7 @@ import org.luxons.sevenwonders.game.resources.Provider;
import org.luxons.sevenwonders.game.resources.ResourceTransactions;
import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.resources.Resources;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -54,7 +54,7 @@ public class RequirementsTest {
Requirements requirements = new Requirements();
requirements.setGold(requiredGold);
- Board board = TestUtils.createBoard(ResourceType.CLAY, boardGold);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY, boardGold);
Table table = new Table(Collections.singletonList(board));
assertEquals(boardGold >= requiredGold, requirements.areMetWithoutNeighboursBy(board));
@@ -64,9 +64,9 @@ public class RequirementsTest {
@Theory
public void resourceRequirement_initialResource(ResourceType initialResource, ResourceType requiredResource) {
- Requirements requirements = TestUtils.createRequirements(requiredResource);
+ Requirements requirements = TestUtilsKt.createRequirements(requiredResource);
- Board board = TestUtils.createBoard(initialResource, 0);
+ Board board = TestUtilsKt.testBoard(initialResource, 0);
Table table = new Table(Collections.singletonList(board));
assertEquals(initialResource == requiredResource, requirements.areMetWithoutNeighboursBy(board));
@@ -83,9 +83,9 @@ public class RequirementsTest {
ResourceType requiredResource) {
assumeTrue(initialResource != requiredResource);
- Requirements requirements = TestUtils.createRequirements(requiredResource);
+ Requirements requirements = TestUtilsKt.createRequirements(requiredResource);
- Board board = TestUtils.createBoard(initialResource, 0);
+ Board board = TestUtilsKt.testBoard(initialResource, 0);
board.getProduction().addFixedResource(producedResource, 1);
Table table = new Table(Collections.singletonList(board));
@@ -103,14 +103,14 @@ public class RequirementsTest {
ResourceType requiredResource) {
assumeTrue(initialResource != requiredResource);
- Requirements requirements = TestUtils.createRequirements(requiredResource);
+ Requirements requirements = TestUtilsKt.createRequirements(requiredResource);
- Board board = TestUtils.createBoard(initialResource, 2);
- Board neighbourBoard = TestUtils.createBoard(initialResource, 0);
+ Board board = TestUtilsKt.testBoard(initialResource, 2);
+ Board neighbourBoard = TestUtilsKt.testBoard(initialResource, 0);
neighbourBoard.getPublicProduction().addFixedResource(boughtResource, 1);
Table table = new Table(Arrays.asList(board, neighbourBoard));
- ResourceTransactions resources = TestUtils.createTransactions(Provider.RIGHT_PLAYER, boughtResource);
+ ResourceTransactions resources = TestUtilsKt.createTransactions(Provider.RIGHT_PLAYER, boughtResource);
assertFalse(requirements.areMetWithoutNeighboursBy(board));
assertEquals(boughtResource == requiredResource, requirements.areMetWithHelpBy(board, resources));
@@ -124,13 +124,13 @@ public class RequirementsTest {
public void pay_boughtResource(ResourceType initialResource, ResourceType requiredResource) {
assumeTrue(initialResource != requiredResource);
- Requirements requirements = TestUtils.createRequirements(requiredResource);
+ Requirements requirements = TestUtilsKt.createRequirements(requiredResource);
- Board board = TestUtils.createBoard(initialResource, 2);
- Board neighbourBoard = TestUtils.createBoard(requiredResource, 0);
+ Board board = TestUtilsKt.testBoard(initialResource, 2);
+ Board neighbourBoard = TestUtilsKt.testBoard(requiredResource, 0);
Table table = new Table(Arrays.asList(board, neighbourBoard));
- ResourceTransactions transactions = TestUtils.createTransactions(Provider.RIGHT_PLAYER,
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(Provider.RIGHT_PLAYER,
requiredResource);
assertFalse(requirements.areMetWithoutNeighboursBy(board));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.java
index 0387e198..517a4b1f 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializerTest.java
@@ -1,12 +1,13 @@
package org.luxons.sevenwonders.game.data.serializers;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import org.junit.Before;
import org.junit.Test;
import org.luxons.sevenwonders.game.boards.ScienceType;
import org.luxons.sevenwonders.game.effects.ScienceProgress;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -30,66 +31,66 @@ public class ScienceProgressSerializerTest {
@Test
public void serialize_emptyToNull() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 0, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 0, 0, 0);
String json = gson.toJson(progress);
assertEquals("null", json);
}
@Test
public void serialize_oneCompass() {
- ScienceProgress progress = TestUtils.createScienceProgress(1, 0, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(1, 0, 0, 0);
String json = gson.toJson(progress);
assertEquals(COMPASS_STR, json);
}
@Test
public void serialize_oneWheel() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 1, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 1, 0, 0);
String json = gson.toJson(progress);
assertEquals(WHEEL_STR, json);
}
@Test
public void serialize_oneTablet() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 0, 1, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 0, 1, 0);
String json = gson.toJson(progress);
assertEquals(TABLET_STR, json);
}
@Test
public void serialize_oneJoker() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 0, 0, 1);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 0, 0, 1);
String json = gson.toJson(progress);
assertEquals(JOKER_STR, json);
}
@Test(expected = UnsupportedOperationException.class)
public void serialize_failOnMultipleCompasses() {
- ScienceProgress progress = TestUtils.createScienceProgress(2, 0, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(2, 0, 0, 0);
gson.toJson(progress);
}
@Test(expected = UnsupportedOperationException.class)
public void serialize_failOnMultipleWheels() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 2, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 2, 0, 0);
gson.toJson(progress);
}
@Test(expected = UnsupportedOperationException.class)
public void serialize_failOnMultipleTablets() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 0, 2, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 0, 2, 0);
gson.toJson(progress);
}
@Test(expected = UnsupportedOperationException.class)
public void serialize_failOnMultipleJokers() {
- ScienceProgress progress = TestUtils.createScienceProgress(0, 0, 0, 2);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(0, 0, 0, 2);
gson.toJson(progress);
}
@Test(expected = UnsupportedOperationException.class)
public void serialize_failOnMixedElements() {
- ScienceProgress progress = TestUtils.createScienceProgress(1, 1, 0, 0);
+ ScienceProgress progress = TestUtilsKt.createScienceProgress(1, 1, 0, 0);
gson.toJson(progress);
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java
index bacea896..a32bc342 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java
@@ -14,7 +14,7 @@ import org.luxons.sevenwonders.game.boards.BoardElementType;
import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
import org.luxons.sevenwonders.game.cards.CardBack;
import org.luxons.sevenwonders.game.cards.Color;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
@@ -40,7 +40,7 @@ public class BonusPerBoardElementTest {
@Before
public void setUp() {
- table = TestUtils.createTable(4);
+ table = TestUtilsKt.testTable(4);
}
private static BonusPerBoardElement createBonus(BoardElementType type, int gold, int points, Color... colors) {
@@ -56,7 +56,7 @@ public class BonusPerBoardElementTest {
public void computePoints_countsCards(RelativeBoardPosition boardPosition, int nbCards, int nbOtherCards,
int points, int gold, Color color) {
Board board = table.getBoard(0, boardPosition);
- TestUtils.addCards(board, nbCards, nbOtherCards, color);
+ TestUtilsKt.addCards(board, nbCards, nbOtherCards, color);
BonusPerBoardElement bonus = createBonus(BoardElementType.CARD, gold, points, color);
bonus.setBoards(Collections.singletonList(boardPosition));
@@ -96,7 +96,7 @@ public class BonusPerBoardElementTest {
public void apply_countsCards(RelativeBoardPosition boardPosition, int nbCards, int nbOtherCards, int points,
int gold, Color color) {
Board board = table.getBoard(0, boardPosition);
- TestUtils.addCards(board, nbCards, nbOtherCards, color);
+ TestUtilsKt.addCards(board, nbCards, nbOtherCards, color);
BonusPerBoardElement bonus = createBonus(BoardElementType.CARD, gold, points, color);
bonus.setBoards(Collections.singletonList(boardPosition));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java
index 1de3a502..c13cec1b 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java
@@ -9,7 +9,7 @@ import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.resources.Provider;
import org.luxons.sevenwonders.game.resources.ResourceTransactions;
import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
@@ -33,14 +33,14 @@ public class DiscountTest {
@Theory
public void apply_givesDiscountedPrice(int discountedPrice, ResourceType discountedType, Provider provider) {
- Board board = TestUtils.createBoard(ResourceType.CLAY, 3);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY, 3);
Discount discount = new Discount();
discount.setDiscountedPrice(discountedPrice);
discount.getProviders().add(provider);
discount.getResourceTypes().add(discountedType);
discount.apply(board);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, discountedType);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, discountedType);
assertEquals(discountedPrice, board.getTradingRules().computeCost(transactions));
}
@@ -50,23 +50,23 @@ public class DiscountTest {
Assume.assumeTrue(otherProvider != provider);
Assume.assumeTrue(otherType != discountedType);
- Board board = TestUtils.createBoard(ResourceType.CLAY, 3);
+ Board board = TestUtilsKt.testBoard(ResourceType.CLAY, 3);
Discount discount = new Discount();
discount.setDiscountedPrice(discountedPrice);
discount.getProviders().add(provider);
discount.getResourceTypes().add(discountedType);
discount.apply(board);
- // this is the default in the settings used by TestUtils.createBoard()
+ // this is the default in the settings used by TestUtilsKt.testBoard()
int normalPrice = 2;
- ResourceTransactions fromOtherType = TestUtils.createTransactions(provider, otherType);
+ ResourceTransactions fromOtherType = TestUtilsKt.createTransactions(provider, otherType);
assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherType));
- ResourceTransactions fromOtherProvider = TestUtils.createTransactions(otherProvider, discountedType);
+ ResourceTransactions fromOtherProvider = TestUtilsKt.createTransactions(otherProvider, discountedType);
assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherProvider));
- ResourceTransactions fromOtherProviderAndType = TestUtils.createTransactions(otherProvider, otherType);
+ ResourceTransactions fromOtherProviderAndType = TestUtilsKt.createTransactions(otherProvider, otherType);
assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherProviderAndType));
}
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
index be124251..ffc506c0 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
@@ -7,7 +7,7 @@ import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -28,7 +28,7 @@ public class GoldIncreaseTest {
@Theory
public void apply_increaseGoldWithRightAmount(int initialAmount, int goldIncreaseAmount, ResourceType type) {
- Board board = TestUtils.createBoard(type, initialAmount);
+ Board board = TestUtilsKt.testBoard(type, initialAmount);
GoldIncrease goldIncrease = new GoldIncrease(goldIncreaseAmount);
goldIncrease.apply(board);
@@ -39,7 +39,7 @@ public class GoldIncreaseTest {
@Theory
public void computePoints_isAlwaysZero(int gold) {
GoldIncrease goldIncrease = new GoldIncrease(gold);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
assertEquals(0, goldIncrease.computePoints(table, 0));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
index 478af746..f5a25d98 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
@@ -7,7 +7,7 @@ import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -28,7 +28,7 @@ public class MilitaryReinforcementsTest {
@Theory
public void apply_increaseGoldWithRightAmount(int initialShields, int additionalShields, ResourceType type) {
- Board board = TestUtils.createBoard(type);
+ Board board = TestUtilsKt.testBoard(type);
board.getMilitary().addShields(initialShields);
MilitaryReinforcements reinforcements = new MilitaryReinforcements(additionalShields);
@@ -40,7 +40,7 @@ public class MilitaryReinforcementsTest {
@Theory
public void computePoints_isAlwaysZero(int shields) {
MilitaryReinforcements reinforcements = new MilitaryReinforcements(shields);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
assertEquals(0, reinforcements.computePoints(table, 0));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
index b6a47292..c39854e5 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
@@ -9,7 +9,7 @@ import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.resources.Production;
import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.resources.Resources;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -25,24 +25,24 @@ public class ProductionIncreaseTest {
private static ProductionIncrease createProductionIncrease(ResourceType... types) {
ProductionIncrease effect = new ProductionIncrease();
- effect.getProduction().addAll(TestUtils.createFixedProduction(types));
+ effect.getProduction().addAll(TestUtilsKt.fixedProduction(types));
return effect;
}
@Theory
public void apply_boardContainsAddedResourceType(ResourceType initialType, ResourceType addedType,
ResourceType extraType) {
- Board board = TestUtils.createBoard(initialType);
+ Board board = TestUtilsKt.testBoard(initialType);
ProductionIncrease effect = createProductionIncrease(addedType);
effect.setSellable(false);
effect.apply(board);
- Resources resources = TestUtils.createResources(initialType, addedType);
+ Resources resources = TestUtilsKt.createResources(initialType, addedType);
assertTrue(board.getProduction().contains(resources));
assertFalse(board.getPublicProduction().contains(resources));
- Resources moreResources = TestUtils.createResources(initialType, addedType, extraType);
+ Resources moreResources = TestUtilsKt.createResources(initialType, addedType, extraType);
assertFalse(board.getProduction().contains(moreResources));
assertFalse(board.getPublicProduction().contains(moreResources));
}
@@ -50,17 +50,17 @@ public class ProductionIncreaseTest {
@Theory
public void apply_boardContainsAddedResourceType_sellable(ResourceType initialType, ResourceType addedType,
ResourceType extraType) {
- Board board = TestUtils.createBoard(initialType);
+ Board board = TestUtilsKt.testBoard(initialType);
ProductionIncrease effect = createProductionIncrease(addedType);
effect.setSellable(true);
effect.apply(board);
- Resources resources = TestUtils.createResources(initialType, addedType);
+ Resources resources = TestUtilsKt.createResources(initialType, addedType);
assertTrue(board.getProduction().contains(resources));
assertTrue(board.getPublicProduction().contains(resources));
- Resources moreResources = TestUtils.createResources(initialType, addedType, extraType);
+ Resources moreResources = TestUtilsKt.createResources(initialType, addedType, extraType);
assertFalse(board.getProduction().contains(moreResources));
assertFalse(board.getPublicProduction().contains(moreResources));
}
@@ -68,7 +68,7 @@ public class ProductionIncreaseTest {
@Theory
public void computePoints_isAlwaysZero(ResourceType addedType) {
ProductionIncrease effect = createProductionIncrease(addedType);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
assertEquals(0, effect.computePoints(table, 0));
}
@@ -82,7 +82,7 @@ public class ProductionIncreaseTest {
@Theory
public void equals_falseWhenDifferentClass(ResourceType addedType) {
ProductionIncrease effect = createProductionIncrease(addedType);
- Production production = TestUtils.createFixedProduction(addedType);
+ Production production = TestUtilsKt.fixedProduction(addedType);
//noinspection EqualsBetweenInconvertibleTypes
assertFalse(effect.equals(production));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java
index 020eda73..dcf178f3 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java
@@ -5,7 +5,7 @@ import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -22,7 +22,7 @@ public class RawPointsIncreaseTest {
@Theory
public void computePoints_equalsNbOfPoints(int points) {
RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
assertEquals(points, rawPointsIncrease.computePoints(table, 0));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java
index b5402a7e..cecafad9 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java
@@ -8,7 +8,7 @@ import org.luxons.sevenwonders.game.boards.Board;
import org.luxons.sevenwonders.game.boards.Science;
import org.luxons.sevenwonders.game.boards.ScienceType;
import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
@@ -23,11 +23,11 @@ public class ScienceProgressTest {
@Theory
public void apply_initContainsAddedScience(int initCompasses, int initWheels, int initTablets, int initJokers,
int compasses, int wheels, int tablets, int jokers) {
- Board board = TestUtils.createBoard(ResourceType.ORE);
- Science initialScience = TestUtils.createScience(initCompasses, initWheels, initTablets, initJokers);
+ Board board = TestUtilsKt.testBoard(ResourceType.ORE);
+ Science initialScience = TestUtilsKt.createScience(initCompasses, initWheels, initTablets, initJokers);
board.getScience().addAll(initialScience);
- ScienceProgress effect = TestUtils.createScienceProgress(compasses, wheels, tablets, jokers);
+ ScienceProgress effect = TestUtilsKt.createScienceProgress(compasses, wheels, tablets, jokers);
effect.apply(board);
assertEquals(initCompasses + compasses, board.getScience().getQuantity(ScienceType.COMPASS));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java
index 0f30a3a5..021e8f7c 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java
@@ -14,7 +14,7 @@ import org.luxons.sevenwonders.game.boards.BoardElementType;
import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
import org.luxons.sevenwonders.game.cards.Card;
import org.luxons.sevenwonders.game.cards.Color;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -46,13 +46,13 @@ public class SpecialAbilityActivationTest {
Arrays.asList(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT));
bonus2.setPoints(1);
- return new Card[] {TestUtils.createGuildCard(1, bonus), TestUtils.createGuildCard(2, bonus2)};
+ return new Card[] {TestUtilsKt.createGuildCard(1, bonus), TestUtilsKt.createGuildCard(2, bonus2)};
}
@Theory
public void apply_addsAbility(SpecialAbility ability) {
SpecialAbilityActivation effect = new SpecialAbilityActivation(ability);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
effect.apply(table, 0);
@@ -65,7 +65,7 @@ public class SpecialAbilityActivationTest {
Assume.assumeTrue(ability != SpecialAbility.COPY_GUILD);
SpecialAbilityActivation effect = new SpecialAbilityActivation(ability);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
assertEquals(0, effect.computePoints(table, 0));
}
@@ -73,7 +73,7 @@ public class SpecialAbilityActivationTest {
@Theory
public void computePoints_copiedGuild(Card guildCard, RelativeBoardPosition neighbour) {
SpecialAbilityActivation effect = new SpecialAbilityActivation(SpecialAbility.COPY_GUILD);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
Board neighbourBoard = table.getBoard(0, neighbour);
neighbourBoard.addCard(guildCard);
@@ -88,7 +88,7 @@ public class SpecialAbilityActivationTest {
@Test(expected = IllegalStateException.class)
public void computePoints_copyGuild_failWhenNoChosenGuild() {
SpecialAbilityActivation effect = new SpecialAbilityActivation(SpecialAbility.COPY_GUILD);
- Table table = TestUtils.createTable(5);
+ Table table = TestUtilsKt.testTable(5);
effect.computePoints(table, 0);
}
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java
index 31e35edc..c58e1671 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import org.luxons.sevenwonders.game.Settings;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.cards.Card;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -16,19 +16,19 @@ public class BuildWonderMoveTest {
@Test(expected = InvalidMoveException.class)
public void validate_failsWhenCardNotInHand() {
- Table table = TestUtils.createTable(3);
- List<Card> hand = TestUtils.createSampleCards(0, 7);
- Card anotherCard = TestUtils.createCard("Card that is not in the hand");
- Move move = TestUtils.createMove(0, anotherCard, MoveType.UPGRADE_WONDER);
+ Table table = TestUtilsKt.testTable(3);
+ List<Card> hand = TestUtilsKt.createSampleCards(0, 7);
+ Card anotherCard = TestUtilsKt.testCard("Card that is not in the hand");
+ Move move = TestUtilsKt.createMove(0, anotherCard, MoveType.UPGRADE_WONDER);
move.validate(table, hand);
}
@Test(expected = InvalidMoveException.class)
public void validate_failsWhenWonderIsCompletelyBuilt() {
- Settings settings = TestUtils.createSettings(3);
- Table table = TestUtils.createTable(settings);
- List<Card> hand = TestUtils.createSampleCards(0, 7);
+ Settings settings = TestUtilsKt.testSettings(3);
+ Table table = TestUtilsKt.testTable(settings);
+ List<Card> hand = TestUtilsKt.createSampleCards(0, 7);
fillPlayerWonderLevels(settings, table, hand);
@@ -49,7 +49,7 @@ public class BuildWonderMoveTest {
private static void buildOneWonderLevel(Settings settings, Table table, List<Card> hand, int cardIndex) {
Card card = hand.get(cardIndex);
- Move move = TestUtils.createMove(0, card, MoveType.UPGRADE_WONDER);
+ Move move = TestUtilsKt.createMove(0, card, MoveType.UPGRADE_WONDER);
move.validate(table, hand);
move.place(table, Collections.emptyList(), settings);
move.activate(table, Collections.emptyList(), settings);
@@ -57,11 +57,11 @@ public class BuildWonderMoveTest {
@Test
public void place_increasesWonderLevel() {
- Settings settings = TestUtils.createSettings(3);
- Table table = TestUtils.createTable(settings);
- List<Card> hand = TestUtils.createSampleCards(0, 7);
+ Settings settings = TestUtilsKt.testSettings(3);
+ Table table = TestUtilsKt.testTable(settings);
+ List<Card> hand = TestUtilsKt.createSampleCards(0, 7);
Card cardToUse = hand.get(0);
- Move move = TestUtils.createMove(0, cardToUse, MoveType.UPGRADE_WONDER);
+ Move move = TestUtilsKt.createMove(0, cardToUse, MoveType.UPGRADE_WONDER);
move.validate(table, hand); // should not fail
int initialStage = table.getBoard(0).getWonder().getNbBuiltStages();
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java
index a5017097..bb0e757b 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java
@@ -5,7 +5,7 @@ import java.util.Arrays;
import org.junit.Test;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.luxons.sevenwonders.game.resources.Provider.LEFT_PLAYER;
@@ -20,7 +20,7 @@ public class BestPriceCalculatorTest {
@Test
public void bestPrice_0forEmptyResources() {
- Table table = TestUtils.createTable(3);
+ Table table = TestUtilsKt.testTable(3);
Resources resources = new Resources();
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 0));
assertEquals(new ResourceTransactions(), BestPriceCalculator.bestSolution(resources, table, 0));
@@ -28,22 +28,22 @@ public class BestPriceCalculatorTest {
@Test
public void bestPrice_fixedResources_defaultCost() {
- Board left = TestUtils.createBoard(STONE);
- Board main = TestUtils.createBoard(STONE);
- Board right = TestUtils.createBoard(WOOD);
+ Board left = TestUtilsKt.testBoard(STONE);
+ Board main = TestUtilsKt.testBoard(STONE);
+ Board right = TestUtilsKt.testBoard(WOOD);
Table table = new Table(Arrays.asList(main, right, left));
- Resources resources = TestUtils.createResources(STONE, STONE);
+ Resources resources = TestUtilsKt.createResources(STONE, STONE);
assertEquals(2, BestPriceCalculator.bestPrice(resources, table, 0));
assertEquals(4, BestPriceCalculator.bestPrice(resources, table, 1));
assertEquals(2, BestPriceCalculator.bestPrice(resources, table, 2));
- ResourceTransaction stoneLeftSingle = TestUtils.createTransaction(LEFT_PLAYER, STONE);
- ResourceTransaction stoneRightSingle = TestUtils.createTransaction(RIGHT_PLAYER, STONE);
+ ResourceTransaction stoneLeftSingle = TestUtilsKt.createTransaction(LEFT_PLAYER, STONE);
+ ResourceTransaction stoneRightSingle = TestUtilsKt.createTransaction(RIGHT_PLAYER, STONE);
- ResourceTransactions stoneLeft = TestUtils.createTransactions(stoneLeftSingle);
- ResourceTransactions stoneRight = TestUtils.createTransactions(stoneRightSingle);
- ResourceTransactions stoneLeftAndRight = TestUtils.createTransactions(stoneLeftSingle, stoneRightSingle);
+ ResourceTransactions stoneLeft = TestUtilsKt.createTransactions(stoneLeftSingle);
+ ResourceTransactions stoneRight = TestUtilsKt.createTransactions(stoneRightSingle);
+ ResourceTransactions stoneLeftAndRight = TestUtilsKt.createTransactions(stoneLeftSingle, stoneRightSingle);
assertEquals(stoneLeft, BestPriceCalculator.bestSolution(resources, table, 0));
assertEquals(stoneLeftAndRight, BestPriceCalculator.bestSolution(resources, table, 1));
@@ -52,22 +52,22 @@ public class BestPriceCalculatorTest {
@Test
public void bestPrice_fixedResources_overridenCost() {
- Board main = TestUtils.createBoard(STONE);
+ Board main = TestUtilsKt.testBoard(STONE);
main.getTradingRules().setCost(WOOD, RIGHT_PLAYER, 1);
- Board left = TestUtils.createBoard(WOOD);
- Board right = TestUtils.createBoard(WOOD);
- Board opposite = TestUtils.createBoard(GLASS);
+ Board left = TestUtilsKt.testBoard(WOOD);
+ Board right = TestUtilsKt.testBoard(WOOD);
+ Board opposite = TestUtilsKt.testBoard(GLASS);
Table table = new Table(Arrays.asList(main, right, opposite, left));
- Resources resources = TestUtils.createResources(WOOD);
+ Resources resources = TestUtilsKt.createResources(WOOD);
assertEquals(1, BestPriceCalculator.bestPrice(resources, table, 0));
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1));
assertEquals(2, BestPriceCalculator.bestPrice(resources, table, 2));
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 3));
- ResourceTransactions woodLeft = TestUtils.createTransactions(LEFT_PLAYER, WOOD);
- ResourceTransactions woodRight = TestUtils.createTransactions(RIGHT_PLAYER, WOOD);
+ ResourceTransactions woodLeft = TestUtilsKt.createTransactions(LEFT_PLAYER, WOOD);
+ ResourceTransactions woodRight = TestUtilsKt.createTransactions(RIGHT_PLAYER, WOOD);
assertEquals(woodRight, BestPriceCalculator.bestSolution(resources, table, 0));
assertEquals(new ResourceTransactions(), BestPriceCalculator.bestSolution(resources, table, 1));
assertEquals(woodLeft, BestPriceCalculator.bestSolution(resources, table, 2));
@@ -76,23 +76,23 @@ public class BestPriceCalculatorTest {
@Test
public void bestPrice_mixedResources_overridenCost() {
- Board left = TestUtils.createBoard(WOOD);
+ Board left = TestUtilsKt.testBoard(WOOD);
- Board main = TestUtils.createBoard(STONE);
+ Board main = TestUtilsKt.testBoard(STONE);
main.getTradingRules().setCost(WOOD, RIGHT_PLAYER, 1);
- Board right = TestUtils.createBoard(ORE);
+ Board right = TestUtilsKt.testBoard(ORE);
right.getProduction().addChoice(WOOD, CLAY);
right.getPublicProduction().addChoice(WOOD, CLAY);
Table table = new Table(Arrays.asList(main, right, left));
- Resources resources = TestUtils.createResources(WOOD);
+ Resources resources = TestUtilsKt.createResources(WOOD);
assertEquals(1, BestPriceCalculator.bestPrice(resources, table, 0));
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1));
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 2));
- ResourceTransactions woodRight = TestUtils.createTransactions(RIGHT_PLAYER, WOOD);
+ ResourceTransactions woodRight = TestUtilsKt.createTransactions(RIGHT_PLAYER, WOOD);
assertEquals(woodRight, BestPriceCalculator.bestSolution(resources, table, 0));
assertEquals(new ResourceTransactions(), BestPriceCalculator.bestSolution(resources, table, 1));
@@ -101,13 +101,13 @@ public class BestPriceCalculatorTest {
@Test
public void bestPrice_chooseCheapest() {
- Board left = TestUtils.createBoard(WOOD);
+ Board left = TestUtilsKt.testBoard(WOOD);
- Board main = TestUtils.createBoard(WOOD);
+ Board main = TestUtilsKt.testBoard(WOOD);
main.getProduction().addChoice(CLAY, ORE);
main.getTradingRules().setCost(CLAY, RIGHT_PLAYER, 1);
- Board right = TestUtils.createBoard(WOOD);
+ Board right = TestUtilsKt.testBoard(WOOD);
right.getProduction().addFixedResource(ORE, 1);
right.getProduction().addFixedResource(CLAY, 1);
right.getPublicProduction().addFixedResource(ORE, 1);
@@ -115,13 +115,13 @@ public class BestPriceCalculatorTest {
Table table = new Table(Arrays.asList(main, right, left));
- Resources resources = TestUtils.createResources(ORE, CLAY);
+ Resources resources = TestUtilsKt.createResources(ORE, CLAY);
assertEquals(1, BestPriceCalculator.bestPrice(resources, table, 0));
assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1));
assertEquals(4, BestPriceCalculator.bestPrice(resources, table, 2));
- ResourceTransactions oreAndClayLeft = TestUtils.createTransactions(LEFT_PLAYER, ORE, CLAY);
- ResourceTransactions clayRight = TestUtils.createTransactions(RIGHT_PLAYER, CLAY);
+ ResourceTransactions oreAndClayLeft = TestUtilsKt.createTransactions(LEFT_PLAYER, ORE, CLAY);
+ ResourceTransactions clayRight = TestUtilsKt.createTransactions(RIGHT_PLAYER, CLAY);
assertEquals(clayRight, BestPriceCalculator.bestSolution(resources, table, 0));
assertEquals(new ResourceTransactions(), BestPriceCalculator.bestSolution(resources, table, 1));
assertEquals(oreAndClayLeft, BestPriceCalculator.bestSolution(resources, table, 2));
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.java
index 68795053..775973b5 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/ResourceTransactionsTest.java
@@ -6,7 +6,7 @@ import java.util.List;
import java.util.Set;
import org.junit.Test;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
@@ -15,15 +15,16 @@ public class ResourceTransactionsTest {
@Test
public void toTransactions() {
List<ResourceTransaction> transactionList = new ArrayList<>();
- transactionList.add(TestUtils.createTransaction(Provider.LEFT_PLAYER, ResourceType.WOOD));
- transactionList.add(TestUtils.createTransaction(Provider.LEFT_PLAYER, ResourceType.CLAY));
- transactionList.add(TestUtils.createTransaction(Provider.RIGHT_PLAYER, ResourceType.WOOD));
+ transactionList.add(TestUtilsKt.createTransaction(Provider.LEFT_PLAYER, ResourceType.WOOD));
+ transactionList.add(TestUtilsKt.createTransaction(Provider.LEFT_PLAYER, ResourceType.CLAY));
+ transactionList.add(TestUtilsKt.createTransaction(Provider.RIGHT_PLAYER, ResourceType.WOOD));
ResourceTransactions transactions = new ResourceTransactions(transactionList);
Set<ResourceTransaction> expectedNormalized = new HashSet<>();
- expectedNormalized.add(TestUtils.createTransaction(Provider.LEFT_PLAYER, ResourceType.WOOD, ResourceType.CLAY));
- expectedNormalized.add(TestUtils.createTransaction(Provider.RIGHT_PLAYER, ResourceType.WOOD));
+ expectedNormalized.add(
+ TestUtilsKt.createTransaction(Provider.LEFT_PLAYER, ResourceType.WOOD, ResourceType.CLAY));
+ expectedNormalized.add(TestUtilsKt.createTransaction(Provider.RIGHT_PLAYER, ResourceType.WOOD));
assertEquals(expectedNormalized, new HashSet<>(transactions.toTransactions()));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/TradingRulesTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/TradingRulesTest.java
index d9f32c78..3c447753 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/TradingRulesTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/resources/TradingRulesTest.java
@@ -7,7 +7,7 @@ import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
@@ -52,14 +52,14 @@ public class TradingRulesTest {
@Theory
public void computeCost_defaultCostWhenNoOverride(int defaultCost, Provider provider, ResourceType type) {
TradingRules rules = new TradingRules(defaultCost);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, type);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, type);
assertEquals(defaultCost, rules.computeCost(transactions));
}
@Theory
public void computeCost_twiceDefaultFor2Resources(int defaultCost, Provider provider, ResourceType type) {
TradingRules rules = new TradingRules(defaultCost);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, type, type);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, type, type);
assertEquals(2 * defaultCost, rules.computeCost(transactions));
}
@@ -67,7 +67,7 @@ public class TradingRulesTest {
public void computeCost_overriddenCost(int defaultCost, int overriddenCost, Provider provider, ResourceType type) {
TradingRules rules = new TradingRules(defaultCost);
rules.setCost(type, provider, overriddenCost);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, type);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, type);
assertEquals(overriddenCost, rules.computeCost(transactions));
}
@@ -79,7 +79,7 @@ public class TradingRulesTest {
assumeTrue(overriddenProvider != provider || overriddenType != type);
TradingRules rules = new TradingRules(defaultCost);
rules.setCost(overriddenType, overriddenProvider, overriddenCost);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, type);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, type);
assertEquals(defaultCost, rules.computeCost(transactions));
}
@@ -90,7 +90,7 @@ public class TradingRulesTest {
assumeTrue(overriddenType != type);
TradingRules rules = new TradingRules(defaultCost);
rules.setCost(overriddenType, provider, overriddenCost);
- ResourceTransactions transactions = TestUtils.createTransactions(provider, overriddenType, type);
+ ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, overriddenType, type);
assertEquals(defaultCost + overriddenCost, rules.computeCost(transactions));
}
@@ -103,8 +103,8 @@ public class TradingRulesTest {
rules.setCost(type, overriddenProvider, overriddenCost);
List<ResourceTransaction> boughtResources = new ArrayList<>(2);
- boughtResources.add(TestUtils.createTransaction(provider, type));
- boughtResources.add(TestUtils.createTransaction(overriddenProvider, type));
+ boughtResources.add(TestUtilsKt.createTransaction(provider, type));
+ boughtResources.add(TestUtilsKt.createTransaction(overriddenProvider, type));
assertEquals(defaultCost + overriddenCost, rules.computeCost(new ResourceTransactions(boughtResources)));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
deleted file mode 100644
index 73a08a32..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.luxons.sevenwonders.game.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import org.luxons.sevenwonders.game.Settings;
-import org.luxons.sevenwonders.game.api.CustomizableSettings;
-import org.luxons.sevenwonders.game.api.PlayerMove;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.Science;
-import org.luxons.sevenwonders.game.boards.ScienceType;
-import org.luxons.sevenwonders.game.cards.Card;
-import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.cards.Color;
-import org.luxons.sevenwonders.game.cards.Requirements;
-import org.luxons.sevenwonders.game.effects.Effect;
-import org.luxons.sevenwonders.game.effects.ScienceProgress;
-import org.luxons.sevenwonders.game.moves.Move;
-import org.luxons.sevenwonders.game.moves.MoveType;
-import org.luxons.sevenwonders.game.resources.Production;
-import org.luxons.sevenwonders.game.resources.Provider;
-import org.luxons.sevenwonders.game.resources.ResourceTransaction;
-import org.luxons.sevenwonders.game.resources.ResourceTransactions;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.resources.Resources;
-import org.luxons.sevenwonders.game.wonders.Wonder;
-import org.luxons.sevenwonders.game.wonders.WonderStage;
-
-public class TestUtils {
-
- private static final long SEED = 42;
-
- public static CustomizableSettings createCustomizableSettings() {
- CustomizableSettings customizableSettings = new CustomizableSettings();
- customizableSettings.setRandomSeedForTests(SEED);
- return customizableSettings;
- }
-
- public static Settings createSettings(int nbPlayers) {
- return new Settings(nbPlayers, createCustomizableSettings());
- }
-
- public static Table createTable(int nbPlayers) {
- return createTable(createSettings(nbPlayers));
- }
-
- public static Table createTable(Settings settings) {
- return new Table(createBoards(settings.getNbPlayers(), settings));
- }
-
- private static List<Board> createBoards(int count, Settings settings) {
- List<Board> boards = new ArrayList<>(count);
- for (int i = 0; i < count; i++) {
- boards.add(createBoard(ResourceType.WOOD, settings));
- }
- return boards;
- }
-
- private static Board createBoard(ResourceType initialResource, Settings settings) {
- Wonder wonder = createWonder(initialResource);
- return new Board(wonder, 0, settings);
- }
-
- public static Board createBoard(ResourceType initialResource) {
- return createBoard(initialResource, createSettings(5));
- }
-
- private static Board createBoard(ResourceType initialResource, ResourceType... production) {
- Board board = createBoard(initialResource);
- board.getProduction().addAll(createFixedProduction(production));
- return board;
- }
-
- public static Board createBoard(ResourceType initialResource, int gold, ResourceType... production) {
- Board board = createBoard(initialResource, production);
- board.setGold(gold);
- return board;
- }
-
- public static Wonder createWonder() {
- return createWonder(ResourceType.WOOD);
- }
-
- public static Wonder createWonder(ResourceType initialResource) {
- WonderStage stage1 = createWonderStage();
- WonderStage stage2 = createWonderStage();
- WonderStage stage3 = createWonderStage();
- return new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource, stage1, stage2, stage3);
- }
-
- private static WonderStage createWonderStage(Effect... effects) {
- return new WonderStage(new Requirements(), Arrays.asList(effects));
- }
-
- public static Production createFixedProduction(ResourceType... producedTypes) {
- Production production = new Production();
- Resources fixedProducedResources = production.getFixedResources();
- fixedProducedResources.addAll(createResources(producedTypes));
- return production;
- }
-
- public static Resources createResources(ResourceType... types) {
- Resources resources = new Resources();
- for (ResourceType producedType : types) {
- resources.add(producedType, 1);
- }
- return resources;
- }
-
- public static ResourceTransactions createTransactions(Provider provider, ResourceType... resources) {
- ResourceTransaction transaction = createTransaction(provider, resources);
- return new ResourceTransactions(Collections.singletonList(transaction));
- }
-
- public static ResourceTransactions createTransactions(ResourceTransaction... transactions) {
- return new ResourceTransactions(Arrays.asList(transactions));
- }
-
- public static ResourceTransaction createTransaction(Provider provider, ResourceType... resources) {
- return new ResourceTransaction(provider, TestUtils.createResources(resources));
- }
-
- public static Requirements createRequirements(ResourceType... types) {
- Resources resources = createResources(types);
- Requirements requirements = new Requirements();
- requirements.setResources(resources);
- return requirements;
- }
-
- public static List<Card> createSampleCards(int fromIndex, int nbCards) {
- List<Card> sampleCards = new ArrayList<>();
- for (int i = fromIndex; i < fromIndex + nbCards; i++) {
- sampleCards.add(createCard(i, Color.BLUE));
- }
- return sampleCards;
- }
-
- public static Card createCard(String name) {
- return createCard(name, Color.BLUE);
- }
-
- public static Card createCard(Color color) {
- return createCard("Test Card", color);
- }
-
- public static Card createCard(Color color, Effect effect) {
- return createCard("Test Card", color, effect);
- }
-
- private static Card createCard(int num, Color color) {
- return createCard("Test Card " + num, color);
- }
-
- public static List<Card> createGuildCards(int count) {
- return IntStream.range(0, count).mapToObj(i -> TestUtils.createGuildCard(i)).collect(Collectors.toList());
- }
-
- public static Card createGuildCard(int num, Effect... effects) {
- return createCard("Test Guild " + num, Color.PURPLE, effects);
- }
-
- private static Card createCard(String name, Color color, Effect... effects) {
- Card card = new Card(name, color, new Requirements(), Arrays.asList(effects), null, null, "path/to/card/image");
- card.setBack(createCardBack());
- return card;
- }
-
- private static CardBack createCardBack() {
- return new CardBack("image-III");
- }
-
- public static void addCards(Board board, int nbCardsOfColor, int nbOtherCards, Color color) {
- addCards(board, nbCardsOfColor, color);
- Color otherColor = getDifferentColorFrom(color);
- addCards(board, nbOtherCards, otherColor);
- }
-
- public static void addCards(Board board, int nbCards, Color color) {
- for (int i = 0; i < nbCards; i++) {
- board.addCard(createCard(i, color));
- }
- }
-
- public static Color getDifferentColorFrom(Color... colors) {
- List<Color> forbiddenColors = Arrays.asList(colors);
- for (Color color : Color.values()) {
- if (!forbiddenColors.contains(color)) {
- return color;
- }
- }
- throw new IllegalArgumentException("All colors are forbidden!");
- }
-
- public static ScienceProgress createScienceProgress(int compasses, int wheels, int tablets, int jokers) {
- ScienceProgress progress = new ScienceProgress();
- progress.setScience(TestUtils.createScience(compasses, wheels, tablets, jokers));
- return progress;
- }
-
- public static Science createScience(int compasses, int wheels, int tablets, int jokers) {
- Science science = new Science();
- if (compasses > 0) {
- science.add(ScienceType.COMPASS, compasses);
- }
- if (wheels > 0) {
- science.add(ScienceType.WHEEL, wheels);
- }
- if (tablets > 0) {
- science.add(ScienceType.TABLET, tablets);
- }
- if (jokers > 0) {
- science.addJoker(jokers);
- }
- return science;
- }
-
- public static void playCardWithEffect(Table table, int playerIndex, Color color, Effect effect) {
- Card card = createCard(color, effect);
- Board board = table.getBoard(playerIndex);
- board.addCard(card);
- card.applyTo(table, playerIndex, new ResourceTransactions());
- }
-
- public static Move createMove(int playerIndex, Card card, MoveType type, ResourceTransaction... transactions) {
- PlayerMove playerMove = createPlayerMove(card.getName(), type, Arrays.asList(transactions));
- return type.resolve(playerIndex, card, playerMove);
- }
-
- public static PlayerMove createPlayerMove(String cardName, MoveType type) {
- return createPlayerMove(cardName, type, Collections.emptySet());
- }
-
- public static PlayerMove createPlayerMove(String cardName, MoveType type,
- Collection<ResourceTransaction> transactions) {
- PlayerMove playerMove = new PlayerMove();
- playerMove.setCardName(cardName);
- playerMove.setType(type);
- playerMove.setTransactions(transactions);
- return playerMove;
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java
index 5bf2affa..a7988f8a 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/wonders/WonderTest.java
@@ -2,7 +2,7 @@ package org.luxons.sevenwonders.game.wonders;
import org.junit.Test;
import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.test.TestUtils;
+import org.luxons.sevenwonders.game.test.TestUtilsKt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -11,7 +11,7 @@ public class WonderTest {
@Test
public void buildLevel_increasesNbBuiltStages() {
- Wonder wonder = TestUtils.createWonder();
+ Wonder wonder = TestUtilsKt.testWonder();
assertEquals(0, wonder.getNbBuiltStages());
wonder.buildLevel(new CardBack("img"));
assertEquals(1, wonder.getNbBuiltStages());
@@ -23,7 +23,7 @@ public class WonderTest {
@Test
public void buildLevel_failsIfFull() {
- Wonder wonder = TestUtils.createWonder();
+ Wonder wonder = TestUtilsKt.testWonder();
wonder.buildLevel(new CardBack("img"));
wonder.buildLevel(new CardBack("img"));
wonder.buildLevel(new CardBack("img"));
bgstack15