From 4b6abf408445f1f6281a7ee32cd4a357ab173680 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 26 Sep 2014 10:39:50 +0200 Subject: [PATCH] Verify command merging in the dispatcher --- .../net/minecraft/commands/CommandDispatcherTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/net/minecraft/commands/CommandDispatcherTest.java b/src/test/java/net/minecraft/commands/CommandDispatcherTest.java index 33002cf..96f7c0b 100644 --- a/src/test/java/net/minecraft/commands/CommandDispatcherTest.java +++ b/src/test/java/net/minecraft/commands/CommandDispatcherTest.java @@ -13,6 +13,7 @@ import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal; import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -33,6 +34,16 @@ public class CommandDispatcherTest { verify(command).run(any(CommandContext.class)); } + @Test + public void testCreateAndMergeCommands() throws Exception { + subject.register(literal("base").then(literal("foo")).executes(command)); + subject.register(literal("base").then(literal("bar")).executes(command)); + + subject.execute("base foo"); + subject.execute("base bar"); + verify(command, times(2)).run(any(CommandContext.class)); + } + @Test(expected = UnknownCommandException.class) public void testExecuteUnknownCommand() throws Exception { subject.execute("foo");