summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-22 01:54:00 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-22 01:54:00 +0200
commitea8a675cee038eba98de3eefc0f7f0d0290392d7 (patch)
tree5c1a65e52a0e1f4b9854c4fb51a75b38f95793fc /test/jrummikub/control
parent61a5d322ba22615a18198b5b0b663fca5b04bf5a (diff)
downloadJRummikub-ea8a675cee038eba98de3eefc0f7f0d0290392d7.tar
JRummikub-ea8a675cee038eba98de3eefc0f7f0d0290392d7.zip
Fix some warnings in tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@567 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/RoundControlTest.java42
-rw-r--r--test/jrummikub/control/network/NetworkRoundControlTest.java4
-rw-r--r--test/jrummikub/control/turn/TurnControlTest.java304
3 files changed, 140 insertions, 210 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index a6279ba..6b4cb23 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -6,6 +6,7 @@ import static org.junit.Assert.*;
import java.awt.Color;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
import jrummikub.control.turn.TurnMode;
import jrummikub.model.GameSettings;
@@ -223,12 +224,8 @@ public class RoundControlTest {
}
IHand hand = roundState.getActivePlayer().getHand();
- hand.drop(blueOne, new Position(0, 0));
- hand.drop(blueTwo, new Position(0, 0));
- hand.drop(blueThree, new Position(0, 0));
- hand.drop(blueTen, new Position(0, 0));
- hand.drop(redTen, new Position(0, 0));
- hand.drop(blueEleven, new Position(0, 0));
+ dropStonesOnHand(hand, Arrays.asList(blueOne, blueTwo, blueThree,
+ blueTen, redTen, blueEleven));
view.startTurnEvent.emit();
view.handPanel.stoneClickEvent.emit(blueOne, false);
@@ -255,6 +252,12 @@ public class RoundControlTest {
.getSize());
}
+ private void dropStonesOnHand(IHand hand, List<Stone> stones) {
+ for (int i = 0; i < stones.size(); i++) {
+ hand.drop(stones.get(i), new Position(0, 0));
+ }
+ }
+
/** Threshold=30 */
@Test
public void laidOutTooFewChangedTable() {
@@ -265,14 +268,8 @@ public class RoundControlTest {
}
// Fake Turn to put stones on the table
IHand hand = roundState.getActivePlayer().getHand();
- hand.drop(blueOne, new Position(0, 0));
- hand.drop(blueTwo, new Position(0, 0));
- hand.drop(blueThree, new Position(0, 0));
-
- hand.drop(redSeven, new Position(0, 0));
- hand.drop(blueSeven, new Position(0, 0));
- hand.drop(blackSeven, new Position(0, 0));
- hand.drop(orangeSeven, new Position(0, 0));
+ dropStonesOnHand(hand, Arrays.asList(blueOne, blueTwo, blueThree,
+ blueSeven, redSeven, blackSeven, orangeSeven));
view.startTurnEvent.emit();
view.handPanel.stoneClickEvent.emit(redSeven, false);
@@ -292,6 +289,7 @@ public class RoundControlTest {
assertEquals(2, roundState.getTable().getSize());
hand = roundState.getActivePlayer().getHand();
+ dropStonesOnHand(hand, Arrays.asList(redEight, redNine, redTen));
hand.drop(redEight, new Position(0, 0));
hand.drop(redNine, new Position(0, 0));
hand.drop(redTen, new Position(0, 0));
@@ -324,14 +322,8 @@ public class RoundControlTest {
}
// Fake Turn to put stones on the table
IHand hand = roundState.getActivePlayer().getHand();
- hand.drop(blueOne, new Position(0, 0));
- hand.drop(blueTwo, new Position(0, 0));
- hand.drop(blueThree, new Position(0, 0));
-
- hand.drop(redSeven, new Position(0, 0));
- hand.drop(blueSeven, new Position(0, 0));
- hand.drop(blackSeven, new Position(0, 0));
- hand.drop(orangeSeven, new Position(0, 0));
+ dropStonesOnHand(hand, Arrays.asList(blueOne, blueTwo, blueThree,
+ blueSeven, redSeven, blackSeven, orangeSeven));
view.startTurnEvent.emit();
view.handPanel.stoneClickEvent.emit(redSeven, false);
@@ -351,10 +343,8 @@ public class RoundControlTest {
assertEquals(2, roundState.getTable().getSize());
hand = roundState.getActivePlayer().getHand();
- hand.drop(redEight, new Position(0, 0));
- hand.drop(redNine, new Position(0, 0));
- hand.drop(redTen, new Position(0, 0));
- hand.drop(redEleven, new Position(0, 0));
+ dropStonesOnHand(hand,
+ Arrays.asList(redEight, redNine, redTen, redEleven));
view.startTurnEvent.emit();
view.tablePanel.stoneClickEvent.emit(redSeven, false);
diff --git a/test/jrummikub/control/network/NetworkRoundControlTest.java b/test/jrummikub/control/network/NetworkRoundControlTest.java
index 22daa44..acf1e84 100644
--- a/test/jrummikub/control/network/NetworkRoundControlTest.java
+++ b/test/jrummikub/control/network/NetworkRoundControlTest.java
@@ -21,6 +21,9 @@ import jrummikub.view.MockView;
import org.junit.Before;
import org.junit.Test;
+/**
+ * Tests for network round control
+ */
public class NetworkRoundControlTest {
private MockConnectionControl connectionControl;
private MockView view;
@@ -29,6 +32,7 @@ public class NetworkRoundControlTest {
private GameSettings gameSettings;
+ /** */
@Before
public void setup() {
AIControl.useBackgroundThread = false;
diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java
index ecd76ac..79baea1 100644
--- a/test/jrummikub/control/turn/TurnControlTest.java
+++ b/test/jrummikub/control/turn/TurnControlTest.java
@@ -99,11 +99,11 @@ public class TurnControlTest {
Stone blackJoker = new Stone(BLACK);
Stone orange10 = new Stone(10, StoneColor.ORANGE);
Stone blue4a = new Stone(4, StoneColor.BLUE);
- Stone black5 = new Stone(5, StoneColor.BLACK);
Stone orange13 = new Stone(13, StoneColor.ORANGE);
Stone red11 = new Stone(11, StoneColor.RED);
Stone black10 = new Stone(10, StoneColor.BLACK);
Stone black13 = new Stone(13, StoneColor.BLACK);
+ Stone orangeOne = new Stone(1, StoneColor.ORANGE);
private void checkTableDisplay(ITable table) {
Iterator<Pair<StoneSet, Position>> stoneSetsView = mockView.tablePanel.stoneSets
@@ -220,7 +220,8 @@ public class TurnControlTest {
testControl.getEndOfTurnEvent().add(
new IListener2<IRoundState, RoundControl.InvalidTurnInfo>() {
@Override
- public void handle(IRoundState value1, InvalidTurnInfo value2) {
+ public void handle(IRoundState value1,
+ InvalidTurnInfo value2) {
eventFired = true;
}
});
@@ -304,8 +305,8 @@ public class TurnControlTest {
mockView.handPanel.stoneClickEvent.emit(redJoker, true);
mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(blackJoker,
- true);
+ mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(
+ blackJoker, true);
assertCollection(Arrays.asList(redJoker, blackJoker));
}
@@ -321,7 +322,8 @@ public class TurnControlTest {
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker,
true);
- mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, true);
+ mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker,
+ true);
assertCollection(new ArrayList<Stone>());
}
@@ -419,8 +421,8 @@ public class TurnControlTest {
testControl.startTurn();
Stone stone4 = new Stone(4, StoneColor.RED);
- StoneSet set1 = new StoneSet(
- Arrays.asList(redOne, redTwo, redThree, stone4));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree,
+ stone4));
mockTable.findStoneSet.put(redOne, set1);
mockTable.findStoneSet.put(redThree, set1);
@@ -591,10 +593,10 @@ public class TurnControlTest {
mockHand.drop(blueThree, new Position(0, 0));
mockHand.drop(blueFour, new Position(0, 0));
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
@@ -606,31 +608,19 @@ public class TurnControlTest {
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
mockView.tablePanel.leftConnectorClickEvent.emit(oldSet1);
+
// handcheck
assertEquals(1, mockHand.getSize());
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
// tablecheck
assertEquals(2, table.getSize());
- StoneSet newSet1, newSet2;
- if (table.getSetArray()[0].getSize() == 3) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
- assertSame(oldSet2, newSet2);
+ Pair<StoneSet, StoneSet> newSets = assignNewSets(table, 3);
+ assertSame(oldSet2, newSets.getSecond());
// setcheck
- assertEquals(9, newSet1.getSize());
- assertSame(newSet1.get(0), blueThree);
- assertSame(newSet1.get(1), redOne);
- assertSame(newSet1.get(2), redThree);
- assertSame(newSet1.get(3), blueOne);
- assertSame(newSet1.get(4), blackOne);
- assertSame(newSet1.get(5), redTwo);
- assertSame(newSet1.get(6), redFour);
- assertSame(newSet1.get(7), blackTwo);
- assertSame(newSet1.get(8), blackThree);
+ assertEquals(9, newSets.getFirst().getSize());
+ assertions(newSets.getFirst(), Arrays.asList(blueThree, redOne,
+ redThree, blueOne, blackOne, redTwo, redFour, blackTwo,
+ blackThree));
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
@@ -640,55 +630,49 @@ public class TurnControlTest {
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
// tablecheck
assertEquals(2, table.getSize());
- if (table.getSetArray()[0].getSize() == 5) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
+ newSets = assignNewSets(table, 5);
// setcheck1
- assertEquals(7, newSet1.getSize());
- assertSame(newSet1.get(0), blueThree);
- assertSame(newSet1.get(1), blueOne);
- assertSame(newSet1.get(2), blackOne);
- assertSame(newSet1.get(3), redTwo);
- assertSame(newSet1.get(4), redFour);
- assertSame(newSet1.get(5), blackTwo);
- assertSame(newSet1.get(6), blackThree);
+ assertEquals(7, newSets.getFirst().getSize());
+ assertions(newSets.getFirst(), Arrays.asList(blueThree, blueOne,
+ blackOne, redTwo, redFour, blackTwo, blackThree));
// setcheck2
- assertEquals(5, newSet2.getSize());
- assertSame(newSet2.get(0), redOne);
- assertSame(newSet2.get(1), redThree);
- assertSame(newSet2.get(2), blueTwo);
- assertSame(newSet2.get(3), blackFour);
- assertSame(newSet2.get(4), blackFive);
+ assertEquals(5, newSets.getSecond().getSize());
+ assertions(newSets.getSecond(),
+ Arrays.asList(redOne, redThree, blueTwo, blackFour, blackFive));
// versuche, links was wegzunehmen und wieder anzuhängen
mockView.handPanel.stoneClickEvent.emit(blueFour, false);
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
- mockView.tablePanel.leftConnectorClickEvent.emit(newSet2);
+ mockView.tablePanel.leftConnectorClickEvent.emit(newSets.getSecond());
// handcheck
assertEquals(0, mockHand.getSize());
// tablecheck
assertEquals(2, table.getSize());
- if (table.getSetArray()[0].getSize() == 6) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
+ newSets = assignNewSets(table, 6);
// setcheck1
- assertEquals(7, newSet1.getSize());
+ assertEquals(7, newSets.getFirst().getSize());
// setcheck2
- assertEquals(6, newSet2.getSize());
- assertSame(newSet2.get(0), blueFour);
- assertSame(newSet2.get(1), redOne);
- assertSame(newSet2.get(2), redThree);
- assertSame(newSet2.get(3), blueTwo);
- assertSame(newSet2.get(4), blackFour);
- assertSame(newSet2.get(5), blackFive);
+ assertEquals(6, newSets.getSecond().getSize());
+ assertions(newSets.getSecond(), Arrays.asList(blueFour, redOne,
+ redThree, blueTwo, blackFour, blackFive));
+ }
+
+ private Pair<StoneSet, StoneSet> assignNewSets(AccessibleTable table, int i) {
+ StoneSet set1, set2;
+ if (table.getSetArray()[0].getSize() == i) {
+ set2 = table.getSetArray()[0];
+ set1 = table.getSetArray()[1];
+ } else {
+ set1 = table.getSetArray()[0];
+ set2 = table.getSetArray()[1];
+ }
+ return new Pair<StoneSet, StoneSet>(set1, set2);
+ }
+
+ private void assertions(StoneSet set, List<Stone> stones) {
+ for (int i = 0; i < stones.size(); i++) {
+ assertSame(set.get(i), stones.get(i));
+ }
}
/** */
@@ -698,18 +682,17 @@ public class TurnControlTest {
mockTable.clonedTable = table;
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
mockHand.drop(blueThree, new Position(0, 0));
mockHand.drop(blueFour, new Position(0, 0));
- turnControl.setup(
- new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN, false),
- new GameSettings(), mockView);
+ turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN,
+ false), new GameSettings(), mockView);
turnControl.startTurn();
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
@@ -721,26 +704,13 @@ public class TurnControlTest {
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
// tablecheck
assertEquals(2, table.getSize());
- StoneSet newSet1, newSet2;
- if (table.getSetArray()[0].getSize() == 3) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
- assertSame(oldSet2, newSet2);
+
+ Pair <StoneSet, StoneSet> newSets = assignNewSets(table, 3);
+ assertSame(oldSet2, newSets.getSecond());
// setcheck
- assertEquals(9, newSet1.getSize());
- assertSame(newSet1.get(0), blueOne);
- assertSame(newSet1.get(1), blackOne);
- assertSame(newSet1.get(2), redTwo);
- assertSame(newSet1.get(3), redFour);
- assertSame(newSet1.get(4), blackTwo);
- assertSame(newSet1.get(5), blackThree);
- assertSame(newSet1.get(6), blueThree);
- assertSame(newSet1.get(7), redOne);
- assertSame(newSet1.get(8), redThree);
+ assertEquals(9, newSets.getFirst().getSize());
+ assertions(newSets.getFirst(), Arrays.asList(blueOne, blackOne, redTwo, redFour,
+ blackTwo, blackThree, blueThree, redOne, redThree));
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
@@ -750,55 +720,31 @@ public class TurnControlTest {
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
// tablecheck
assertEquals(2, table.getSize());
- if (table.getSetArray()[0].getSize() == 5) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
+ newSets = assignNewSets(table, 5);
// setcheck1
- assertEquals(7, newSet1.getSize());
- assertSame(newSet1.get(0), blueOne);
- assertSame(newSet1.get(1), blackOne);
- assertSame(newSet1.get(2), redTwo);
- assertSame(newSet1.get(3), redFour);
- assertSame(newSet1.get(4), blackTwo);
- assertSame(newSet1.get(5), blackThree);
- assertSame(newSet1.get(6), blueThree);
+ assertEquals(7, newSets.getFirst().getSize());
+ assertions(newSets.getFirst(), Arrays.asList(blueOne, blackOne, redTwo, redFour,
+ blackTwo, blackThree, blueThree));
// setcheck2
- assertEquals(5, newSet2.getSize());
- assertSame(newSet2.get(0), blueTwo);
- assertSame(newSet2.get(1), blackFour);
- assertSame(newSet2.get(2), blackFive);
- assertSame(newSet2.get(3), redOne);
- assertSame(newSet2.get(4), redThree);
+ assertEquals(5, newSets.getSecond().getSize());
+ assertions(newSets.getSecond(),
+ Arrays.asList(blueTwo, blackFour, blackFive, redOne, redThree));
// versuche, rechts was wegzunehmen und wieder anzuhängen
mockView.handPanel.stoneClickEvent.emit(blueFour, false);
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
- mockView.tablePanel.rightConnectorClickEvent.emit(newSet2);
+ mockView.tablePanel.rightConnectorClickEvent.emit(newSets.getSecond());
// handcheck
assertEquals(0, mockHand.getSize());
// tablecheck
assertEquals(2, table.getSize());
- if (table.getSetArray()[0].getSize() == 6) {
- newSet2 = table.getSetArray()[0];
- newSet1 = table.getSetArray()[1];
- } else {
- newSet1 = table.getSetArray()[0];
- newSet2 = table.getSetArray()[1];
- }
+ newSets = assignNewSets(table, 6);
// setcheck1
- assertEquals(7, newSet1.getSize());
+ assertEquals(7, newSets.getFirst().getSize());
// setcheck2
- assertEquals(6, newSet2.getSize());
- assertSame(newSet2.get(0), blueTwo);
- assertSame(newSet2.get(1), blackFour);
- assertSame(newSet2.get(2), blackFive);
- assertSame(newSet2.get(3), redOne);
- assertSame(newSet2.get(4), blueFour);
- assertSame(newSet2.get(5), redThree);
+ assertEquals(6, newSets.getSecond().getSize());
+ assertions(newSets.getSecond(), Arrays.asList(blueTwo, blackFour, blackFive,
+ redOne, blueFour, redThree));
}
/** */
@@ -806,19 +752,18 @@ public class TurnControlTest {
public void testAddNewSet() {
AccessibleTable table = new AccessibleTable();
mockTable.clonedTable = table;
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- redTwo, redThree, redFour, blackTwo, blackThree));
- StoneSet oldSet2 = new StoneSet(
- Arrays.asList(blueTwo, blackFour, blackFive));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
table.drop(oldSet1, new Position(0, 0));
table.drop(oldSet2, new Position(0, 0));
mockHand.drop(blueThree, new Position(0, 0));
mockHand.drop(blueFour, new Position(0, 0));
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(
- new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN, false),
- new GameSettings(), mockView);
+ turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN,
+ false), new GameSettings(), mockView);
turnControl.startTurn();
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
@@ -863,22 +808,14 @@ public class TurnControlTest {
// setcheck1
assertEquals(6, newSet1.getSize());
- assertSame(newSet1.get(0), blueOne);
- assertSame(newSet1.get(1), blackOne);
- assertSame(newSet1.get(2), redTwo);
- assertSame(newSet1.get(3), redFour);
- assertSame(newSet1.get(4), blackTwo);
- assertSame(newSet1.get(5), blackThree);
+ assertions(newSet1, Arrays.asList(blueOne, blackOne, redTwo, redFour,
+ blackTwo, blackThree));
// setcheck2
assertEquals(2, newSet2.getSize());
- assertSame(newSet2.get(0), blackFour);
- assertSame(newSet2.get(1), blackFive);
+ assertions(newSet2, Arrays.asList(blackFour, blackFive));
// setcheck1
assertEquals(4, newSet3.getSize());
- assertSame(newSet3.get(0), blueThree);
- assertSame(newSet3.get(1), redOne);
- assertSame(newSet3.get(2), redThree);
- assertSame(newSet3.get(3), blueTwo);
+ assertions(newSet3, Arrays.asList(blueThree, redOne, redThree, blueTwo));
checkTableDisplay(table);
checkHandDisplay(mockHand);
@@ -898,7 +835,7 @@ public class TurnControlTest {
mockHand.drop(blueFour, new Position(0, 0));
mockHand.drop(blue4a, new Position(0, 0));
mockHand.drop(blackJoker, new Position(0, 0));
- mockHand.drop(black5, new Position(0, 0));
+ mockHand.drop(blackFive, new Position(0, 0));
mockHand.drop(orange13, new Position(0, 0));
mockHand.drop(red11, new Position(0, 0));
mockHand.drop(black10, new Position(0, 0));
@@ -907,8 +844,8 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
@@ -923,7 +860,7 @@ public class TurnControlTest {
|| stones.get(5).getFirst() == blue4a);
assertSame(stones.get(6).getFirst(), redFour);
- assertSame(stones.get(7).getFirst(), black5);
+ assertSame(stones.get(7).getFirst(), blackFive);
assertSame(stones.get(8).getFirst(), black10);
assertSame(stones.get(9).getFirst(), orange10);
assertSame(stones.get(10).getFirst(), red11);
@@ -947,7 +884,7 @@ public class TurnControlTest {
mockHand.drop(blueFour, new Position(0, 0));
mockHand.drop(blue4a, new Position(0, 0));
mockHand.drop(blackJoker, new Position(0, 0));
- mockHand.drop(black5, new Position(0, 0));
+ mockHand.drop(blackFive, new Position(0, 0));
mockHand.drop(orange13, new Position(0, 0));
mockHand.drop(red11, new Position(0, 0));
mockHand.drop(black10, new Position(0, 0));
@@ -956,12 +893,12 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
- assertSame(stones.get(0).getFirst(), black5);
+ assertSame(stones.get(0).getFirst(), blackFive);
assertSame(stones.get(1).getFirst(), black10);
assertSame(stones.get(2).getFirst(), orange10);
assertSame(stones.get(3).getFirst(), orange13);
@@ -997,8 +934,8 @@ public class TurnControlTest {
assertCollection(new ArrayList<Stone>());
- Set<Stone> expected = new HashSet<Stone>(
- Arrays.asList(redJoker, blackJoker));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ blackJoker));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();
@@ -1025,7 +962,8 @@ public class TurnControlTest {
assertCollection(Arrays.asList(blackJoker));
- Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker, black13));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ black13));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();
@@ -1041,12 +979,15 @@ public class TurnControlTest {
public void testTableDifference() {
MockTable oldTable = new MockTable();
MockTable newTable = new MockTable();
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne));
+ StoneSet oldSet1 = new StoneSet(
+ Arrays.asList(blueOne, redOne, blackOne));
StoneSet oldSet2 = new StoneSet(blueTwo);
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
- StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour));
- StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree));
+ StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo,
+ blueFour));
+ StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne,
+ blueThree));
newTable.drop(newSet1, new Position(0, 0));
newTable.drop(newSet2, new Position(0, 0));
@@ -1054,7 +995,8 @@ public class TurnControlTest {
expectedStones.add(blueThree);
expectedStones.add(blueFour);
- Set<Stone> stones = AbstractTurnControl.tableDifference(oldTable, newTable);
+ Set<Stone> stones = AbstractTurnControl.tableDifference(oldTable,
+ newTable);
assertTrue(expectedStones.containsAll(stones));
assertTrue(stones.containsAll(expectedStones));
@@ -1064,21 +1006,15 @@ public class TurnControlTest {
@Test
public void testTableSetDifference() {
ITable oldTable = new AccessibleTable();
- Stone blueOne = new Stone(1, BLUE);
- Stone redOne = new Stone(1, RED);
- Stone blackOne = new Stone(1, BLACK);
- Stone orangeOne = new Stone(1, ORANGE);
- Stone blueTwo = new Stone(2, BLUE);
- Stone blueThree = new Stone(3, BLUE);
- Stone blueFour = new Stone(4, BLUE);
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- orangeOne));
- StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, orangeOne));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree,
+ blueFour));
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
ITable newTable = (Table) oldTable.clone();
- List<StoneSet> newSets = AbstractTurnControl.tableSetDifference(oldTable,
- newTable);
+ List<StoneSet> newSets = AbstractTurnControl.tableSetDifference(
+ oldTable, newTable);
List<StoneSet> vanishedSets = AbstractTurnControl.tableSetDifference(
newTable, oldTable);
@@ -1086,24 +1022,24 @@ public class TurnControlTest {
assertTrue(vanishedSets.isEmpty());
newTable.pickUp(oldSet2);
- newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position(
- 0, 0));
+ newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))),
+ new Position(0, 0));
newSets = AbstractTurnControl.tableSetDifference(oldTable, newTable);
- vanishedSets = AbstractTurnControl.tableSetDifference(newTable, oldTable);
+ vanishedSets = AbstractTurnControl.tableSetDifference(newTable,
+ oldTable);
assertFalse(newSets.isEmpty());
assertFalse(vanishedSets.isEmpty());
assertEquals(1, newSets.size());
assertEquals(1, vanishedSets.size());
- Stone redTwo = new Stone(2, RED);
- Stone redThree = new Stone(3, RED);
- Stone redFour = new Stone(4, RED);
- StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour));
+ StoneSet oldSet3 = new StoneSet(
+ Arrays.asList(redTwo, redThree, redFour));
ITable newTable2 = (Table) oldTable.clone();
newTable2.drop(oldSet3, new Position(0, 0));
newSets = AbstractTurnControl.tableSetDifference(oldTable, newTable2);
- vanishedSets = AbstractTurnControl.tableSetDifference(newTable2, oldTable);
+ vanishedSets = AbstractTurnControl.tableSetDifference(newTable2,
+ oldTable);
assertFalse(newSets.isEmpty());
assertTrue(vanishedSets.isEmpty());