diff --git a/src/test/java/net/minestom/server/command/GraphConversionExecutorTest.java b/src/test/java/net/minestom/server/command/GraphConversionExecutorTest.java index 55e5612f3..274744143 100644 --- a/src/test/java/net/minestom/server/command/GraphConversionExecutorTest.java +++ b/src/test/java/net/minestom/server/command/GraphConversionExecutorTest.java @@ -2,9 +2,12 @@ package net.minestom.server.command; import net.minestom.server.command.builder.Command; import net.minestom.server.command.builder.CommandContext; +import net.minestom.server.command.builder.arguments.ArgumentType; import net.minestom.server.command.builder.condition.CommandCondition; import org.junit.jupiter.api.Test; +import java.util.concurrent.atomic.AtomicBoolean; + import static net.minestom.server.command.builder.arguments.ArgumentType.Literal; import static org.junit.jupiter.api.Assertions.*; @@ -81,6 +84,24 @@ public class GraphConversionExecutorTest { assertFalse(condition.canUse(null, null)); } + + @Test + public void issue1326() { + final AtomicBoolean b = new AtomicBoolean(true); + var cmd = new Command("tp") {{ + addConditionalSyntax((s, c) -> b.getAndSet(false), null, ArgumentType.Entity("target"), + ArgumentType.Double("x"), ArgumentType.Double("y"), ArgumentType.Double("z")); + }}; + var graph = Graph.fromCommand(cmd); + final Graph.Node target = graph.root().next().get(0); + final Graph.Execution execution = target.execution(); + assertNotNull(execution); + final CommandCondition condition = execution.condition(); + assertNotNull(condition); + assertTrue(condition.canUse(null, null)); + assertFalse(b.get(), "Condition wasn't executed."); + } + private static void dummyExecutor(CommandSender sender, CommandContext context) { } } diff --git a/src/test/java/net/minestom/server/command/GraphConversionTest.java b/src/test/java/net/minestom/server/command/GraphConversionTest.java index d4eb79f14..2bea24622 100644 --- a/src/test/java/net/minestom/server/command/GraphConversionTest.java +++ b/src/test/java/net/minestom/server/command/GraphConversionTest.java @@ -2,8 +2,6 @@ package net.minestom.server.command; import net.minestom.server.command.builder.Command; import net.minestom.server.command.builder.CommandContext; -import net.minestom.server.command.builder.arguments.ArgumentType; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static net.minestom.server.command.builder.arguments.ArgumentType.Enum; @@ -117,24 +115,6 @@ public class GraphConversionTest { assertEqualsGraph(graph, main); } - @Test - //TODO See disable reason - @Disabled("Graphs' execution cannot be compared properly which makes this test pass when it shouldn't.") - public void issue1326() { - var cmd = new Command("tp") {{ - addConditionalSyntax((s, c) -> s instanceof ConsoleSender, null, ArgumentType.Entity("target"), - ArgumentType.Double("x"), ArgumentType.Double("y"), ArgumentType.Double("z")); - }}; - var graph = Graph.builder(ArgumentType.Literal("tp")) - .append(ArgumentType.Entity("target"), - new GraphImpl.ExecutionImpl(sender -> sender instanceof ConsoleSender, - null, null, null, null), b -> - b.append(ArgumentType.Double("x"), b1 -> - b1.append(ArgumentType.Double("y"), b2 -> - b2.append(ArgumentType.Double("z"))))).build(); - assertEqualsGraph(graph, cmd); - } - private static void assertEqualsGraph(Graph expected, Command command) { final Graph actual = Graph.fromCommand(command); assertTrue(expected.compare(actual, Graph.Comparator.TREE), () -> {