diff --git a/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java
new file mode 100644
index 000000000..785e1afd7
--- /dev/null
+++ b/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java
@@ -0,0 +1,174 @@
+package puzzles.starbattle.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.starbattle.StarBattle;
+import edu.rpi.legup.puzzle.starbattle.StarBattleBoard;
+import edu.rpi.legup.puzzle.starbattle.StarBattleCell;
+import edu.rpi.legup.puzzle.starbattle.StarBattleCellType;
+import edu.rpi.legup.puzzle.starbattle.rules.EmptyAdjacentDirectRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import java.awt.*;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class EmptyAdjacentDirectRuleTest {
+
+ private static final EmptyAdjacentDirectRule RULE = new EmptyAdjacentDirectRule();
+ private static StarBattle starbattle;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ starbattle = new StarBattle();
+ }
+
+ @Test
+ public void EmptyAdjacentDirectRule_OneLeft() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft", starbattle);
+ TreeNode rootNode = starbattle.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ StarBattleBoard board = (StarBattleBoard) transition.getBoard();
+ StarBattleCell cell1 = board.getCell(1,1);
+ cell1.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell2 = board.getCell(2,1);
+ cell2.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell3 = board.getCell(3,1);
+ cell3.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell4 = board.getCell(1,3);
+ cell4.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell5 = board.getCell(2,3);
+ cell5.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell6 = board.getCell(3,3);
+ cell6.setData(StarBattleCellType.BLACK.value);
+
+ board.addModifiedData(cell1);
+ board.addModifiedData(cell2);
+ board.addModifiedData(cell3);
+ board.addModifiedData(cell4);
+ board.addModifiedData(cell5);
+ board.addModifiedData(cell6);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); ++i) {
+ for (int j = 0; j < board.getWidth(); ++j) {
+ Point point = new Point(j,i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
+ point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) ||
+ point.equals(cell5.getLocation()) || point.equals(cell6.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ }
+ }
+ }
+
+ @Test
+ public void EmptyAdjacentDirectRule_TwoLeft() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft", starbattle);
+ TreeNode rootNode = starbattle.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ StarBattleBoard board = (StarBattleBoard) transition.getBoard();
+ StarBattleCell cell1 = board.getCell(1,1);
+ cell1.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell2 = board.getCell(2,1);
+ cell2.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell3 = board.getCell(1,3);
+ cell3.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell4 = board.getCell(2,3);
+ cell4.setData(StarBattleCellType.BLACK.value);
+
+ board.addModifiedData(cell1);
+ board.addModifiedData(cell2);
+ board.addModifiedData(cell3);
+ board.addModifiedData(cell4);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); ++i) {
+ for (int j = 0; j < board.getWidth(); ++j) {
+ Point point = new Point(j,i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
+ point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ }
+ }
+ }
+
+ @Test
+ public void EmptyAdjacentDirectRule_ThreeLeft()
+ throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft", starbattle);
+ TreeNode rootNode = starbattle.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ StarBattleBoard board = (StarBattleBoard) transition.getBoard();
+ StarBattleCell cell1 = board.getCell(1,1);
+ cell1.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell2 = board.getCell(2,1);
+ cell2.setData(StarBattleCellType.BLACK.value);
+
+ board.addModifiedData(cell1);
+ board.addModifiedData(cell2);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); ++i) {
+ for (int j = 0; j < board.getWidth(); ++j) {
+ Point point = new Point(j,i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ }
+ }
+ }
+
+ @Test
+ public void EmptyAdjacentDirectRule_ImproperUseFourLeft() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft", starbattle);
+ TreeNode rootNode = starbattle.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ StarBattleBoard board = (StarBattleBoard) transition.getBoard();
+ StarBattleCell cell1 = board.getCell(1,1);
+ cell1.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell2 = board.getCell(2,1);
+ cell2.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell3 = board.getCell(1,3);
+ cell3.setData(StarBattleCellType.BLACK.value);
+ StarBattleCell cell4 = board.getCell(2,3);
+ cell4.setData(StarBattleCellType.BLACK.value);
+
+ board.addModifiedData(cell1);
+ board.addModifiedData(cell2);
+ board.addModifiedData(cell3);
+ board.addModifiedData(cell4);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); ++i) {
+ for (int j = 0; j < board.getWidth(); ++j) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
+ }
+ }
+ }
+}
diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft
new file mode 100644
index 000000000..782c1d37d
--- /dev/null
+++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft
new file mode 100644
index 000000000..29005798d
--- /dev/null
+++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft
new file mode 100644
index 000000000..ab6f4b178
--- /dev/null
+++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft
new file mode 100644
index 000000000..5e8d71fbb
--- /dev/null
+++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
\ No newline at end of file