Skip to content

Commit

Permalink
Have null changes be valid and fix IsolatedBlackContradicitonRule err…
Browse files Browse the repository at this point in the history
…or message (#561)

* Get Tests to be called

Revert "Create first cypress test template"

This reverts commit 3e50909.

First commit

Finish Lightup tests

* Add more tests

Update TestRunner.java

* Somehow ended up in the wrong spot

Fix Import

* Please let this be the fix

Update TreeTransition.java

Update TreeTransition.java

Update DirectRule.java

Check to see which is not correct

Update ElementController.java

Revert "maybe the null is making it think that it's not valid"

This reverts commit 7bf1de0d66ced6749ee37fbb9c252636b2fcdc79.

Just trying to change color

Revert "Just trying to change color"

This reverts commit ec44695ee578d664055d135a668927a0fd900f5d.

Revert "maybe the null is making it think that it's not valid"

This reverts commit 3f162fbdc32e6fbd23da321a14a6af96f0ff520d.

Check to see which is not correct

Revert "Check to see which is not correct"

This reverts commit 136b0a41b9d103e6f3e9a7f8cd5d970bf76b050b.

Update TreeTransition.java

Update TreeTransition.java

Revert "Update TreeTransition.java"

This reverts commit cde45bb9001cfbfa4f6e2a49b4e9990d2fa7ad33.

* Fix error with isolated Black

Fix error message with isolated black

* Removed excess whitespace and imports. Added short JavaDoc for `TestRunner.java`

---------

Co-authored-by: Charles Tian <[email protected]>
Co-authored-by: Bram van Heuveln <[email protected]>
Co-authored-by: Corppet <[email protected]>
  • Loading branch information
4 people authored Sep 29, 2023
1 parent f3dbafb commit bcb8629
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ public void executeCommand() {
}
else {
TreeTransitionView transitionView = (TreeTransitionView) firstSelectedView;
finalTreeElement = transitionView.getChildView().getTreeElement();
if (transitionView.getChildView() != null) {
finalTreeElement = transitionView.getChildView().getTreeElement();
}
else {
finalTreeElement = null;
}
}

if (finalTreeElement != null) {
puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(finalTreeElement));
}
puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(finalTreeElement));
puzzle.notifyTreeListeners(listener -> listener.onTreeSelectionChanged(newSelection));
}

Expand Down
14 changes: 4 additions & 10 deletions src/main/java/edu/rpi/legup/model/rules/DirectRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ public DirectRule(String ruleID, String ruleName, String description, String ima
*/
public String checkRule(TreeTransition transition) {
Board finalBoard = transition.getBoard();

if (!finalBoard.isModified()) {
return "State must be modified";
if (transition.getParents().size() != 1 ||
transition.getParents().get(0).getChildren().size() != 1) {
return "State must have only 1 parent and 1 child";
}
else {
if (transition.getParents().size() != 1 ||
transition.getParents().get(0).getChildren().size() != 1) {
return "State must have only 1 parent and 1 child";
}
else {
return checkRuleRaw(transition);
}
return checkRuleRaw(transition);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/test/java/legup/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import puzzles.nurikabe.rules.*;
import puzzles.treetent.rules.*;

/**
* This class runs all of the tests for the project without needing to run build scripts.
*/
public class TestRunner {
public static void main(String[] args) {
// Battleship Tests
Expand Down Expand Up @@ -103,6 +106,4 @@ private static void printTestResults(Result result) {
System.out.println("All tests passed: " + result.wasSuccessful());
System.out.println();
}


}
}
9 changes: 0 additions & 9 deletions src/test/java/legup/TestUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.save.InvalidFileFormatException;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import puzzles.battleship.rules.AdjacentShipsContradictionRuleTest;
import puzzles.battleship.rules.FinishWithShipsDirectRuleTests;

public final class TestUtilities {
public static void importTestBoard(String fileName, Puzzle puzzle) throws InvalidFileFormatException {
Expand All @@ -21,8 +16,4 @@ public static void importTestBoard(String fileName, Puzzle puzzle) throws Invali
TreeTransition transition = new TreeTransition(rootNode, board);
rootNode.getChildren().add(transition);
}


}


0 comments on commit bcb8629

Please sign in to comment.