Verify command merging in the dispatcher

This commit is contained in:
Nathan Adams
2014-09-26 10:39:50 +02:00
parent 82b576e38c
commit 4b6abf4084
@@ -13,6 +13,7 @@ import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument; import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
@@ -33,6 +34,16 @@ public class CommandDispatcherTest {
verify(command).run(any(CommandContext.class)); 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) @Test(expected = UnknownCommandException.class)
public void testExecuteUnknownCommand() throws Exception { public void testExecuteUnknownCommand() throws Exception {
subject.execute("foo"); subject.execute("foo");