From 6986a3d8379055f04a118cc688ae63de68882ab8 Mon Sep 17 00:00:00 2001
From: Charles Tian <46334090+charlestian23@users.noreply.github.com>
Date: Tue, 17 Oct 2023 16:35:32 -0400
Subject: [PATCH 1/2] Atomic Direct Rule Test (#651)
* Initial setup
* Working initial test
* Added another test
* Added more tests
* Added another test
* Added comments, removed useless imports, added 1 more test
* Reformatting
* Removed useless import
---------
Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com>
---
.../rules/AtomicDirectRuleTest.java | 188 ++++++++++++++++++
.../rules/DirectRuleAtomicTest.java | 6 -
.../rules/AtomicDirectRule/Empty | 13 ++
.../rules/AtomicDirectRule/FalseA | 14 ++
.../rules/AtomicDirectRule/TrueB | 14 ++
5 files changed, 229 insertions(+), 6 deletions(-)
create mode 100644 src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java
delete mode 100644 src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA
create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB
diff --git a/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java b/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java
new file mode 100644
index 000000000..51aa213c6
--- /dev/null
+++ b/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java
@@ -0,0 +1,188 @@
+package puzzles.shorttruthtable.rules;
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell;
+import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType;
+import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.DirectRuleAtomic;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AtomicDirectRuleTest {
+ private static final DirectRuleAtomic RULE = new DirectRuleAtomic();
+ private static ShortTruthTable stt;
+
+ @BeforeClass
+ public static void setup() {
+ MockGameBoardFacade.getInstance();
+ stt = new ShortTruthTable();
+ }
+
+ /**
+ * Given two statements:
+ * A
+ * A
+ * where the first A is set to false.
+ *
+ * This test sets the second A to false and then asserts that this
+ * is a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void MatchingFalseTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(cell);
+
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given two statements:
+ * A
+ * A
+ * where the first A is set to false.
+ *
+ * This test sets the second A to true and then asserts that this
+ * is not a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void MismatchingFalseTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(cell);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given two statements:
+ * B
+ * B
+ * where the first B is set to true.
+ *
+ * This test sets the second B to true and then asserts that this
+ * is a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void MatchingTrueTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(cell);
+
+ Assert.assertNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given two statements:
+ * B
+ * B
+ * where the first B is set to true.
+ *
+ * This test sets the second B to false and then asserts that this
+ * is not a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void MismatchingTrueTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(cell);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given two statements:
+ * C
+ * C
+ * where neither statement is set to anything.
+ *
+ * This test sets the second C to false and then asserts that this
+ * is not a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void NothingPreviouslyMarkedTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/Empty", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.FALSE);
+ board.addModifiedData(cell);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+
+ /**
+ * Given two statements:
+ * C
+ * C
+ * where neither statement is set to anything.
+ *
+ * This test sets the second C to true and then asserts that this
+ * is not a valid application of the rule.
+ *
+ * @throws InvalidFileFormatException
+ */
+ @Test
+ public void NothingPreviouslyMarkedTest2() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/Empty", stt);
+ TreeNode rootNode = stt.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard();
+
+ ShortTruthTableCell cell = board.getCell(0, 2);
+ cell.setData(ShortTruthTableCellType.TRUE);
+ board.addModifiedData(cell);
+
+ Assert.assertNotNull(RULE.checkRule(transition));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java b/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java
deleted file mode 100644
index 81991fa46..000000000
--- a/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package puzzles.shorttruthtable.rules;
-
-class DirectRuleAtomicTest {
-
-
-}
\ No newline at end of file
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty
new file mode 100644
index 000000000..6a6effadf
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA
new file mode 100644
index 000000000..8c5ddc7b9
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB
new file mode 100644
index 000000000..46a1beb2d
--- /dev/null
+++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
From 535a825f6968464c98d1a9b8d1dce73cd919db5a Mon Sep 17 00:00:00 2001
From: Charles Tian <46334090+charlestian23@users.noreply.github.com>
Date: Tue, 17 Oct 2023 16:49:30 -0400
Subject: [PATCH 2/2] Gradle fixes + removed build files (#648)
* Removed build files
These shouldn't be here
* Removed legup-update and legup Gradle projects
---------
Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com>
---
build.gradle | 1 -
.../BlockInVerticalPath | 11 -----------
.../CannotFillMiddle | 0
.../LightInHorizontalPath | 10 ----------
.../LightInVerticalPath | 10 ----------
.../CannotFillCorners | 13 -------------
.../CannotFillMiddle | 11 -----------
.../TooFewBulbsContradictionRule/BlockEnclosed | 13 -------------
.../CompleteBoardBlockEnclosed | 15 ---------------
.../CornerBlockEnclosed | 11 -----------
.../ManyBlocksEnclosed | 17 -----------------
.../TooManyBulbsContradictionRule/BlockEnclosed | 13 -------------
.../CompleteBoardBlockEnclosed | 15 ---------------
.../CornerBlockEnclosed | 11 -----------
.../ManyBlocksEnclosed | 17 -----------------
settings.gradle | 2 --
16 files changed, 170 deletions(-)
delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath
delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle
delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath
delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath
delete mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners
delete mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed
delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed
diff --git a/build.gradle b/build.gradle
index fafa54cac..1ba7ea006 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,6 @@ dependencies {
implementation 'org.jetbrains:annotations:20.1.0'
implementation 'org.jetbrains:annotations:20.1.0'
implementation 'com.formdev:flatlaf:3.0'
- implementation project(':legup-update')
implementation 'com.google.firebase:firebase-admin:6.3.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.1'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath
deleted file mode 100644
index 5f27b3ec8..000000000
--- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle
deleted file mode 100644
index e69de29bb..000000000
diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath
deleted file mode 100644
index 633ccc80b..000000000
--- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath
deleted file mode 100644
index 70419c40c..000000000
--- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners
deleted file mode 100644
index 38b52f04d..000000000
--- a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle
deleted file mode 100644
index 44086f145..000000000
--- a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed
deleted file mode 100644
index a57a2473e..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed
deleted file mode 100644
index f48d240f0..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed
deleted file mode 100644
index 1a9cd60d9..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed
deleted file mode 100644
index 32200d831..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed
deleted file mode 100644
index c5760aede..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed
deleted file mode 100644
index 88fb0a8f1..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed
deleted file mode 100644
index a9a8dc5a0..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed
deleted file mode 100644
index e743862eb..000000000
--- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 936e82b6f..f9f593d2b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,4 +1,2 @@
rootProject.name = 'Legup'
-include ':legup'
-include ':legup-update'