Changed the Runnable to a Command
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.commands;
|
||||
|
||||
import net.minecraft.commands.context.CommandContext;
|
||||
import net.minecraft.commands.exceptions.UnknownCommandException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -8,12 +9,13 @@ import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CommandDispatcherTest {
|
||||
CommandDispatcher subject;
|
||||
@Mock Runnable runnable;
|
||||
@Mock Command command;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -22,16 +24,16 @@ public class CommandDispatcherTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testDuplicateCommand() throws Exception {
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(command));
|
||||
subject.register(literal("foo").executes(command));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndExecuteCommand() throws Exception {
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(command));
|
||||
|
||||
subject.execute("foo");
|
||||
verify(runnable).run();
|
||||
verify(command).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
@Test(expected = UnknownCommandException.class)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.Command;
|
||||
import net.minecraft.commands.tree.LiteralCommandNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -14,7 +15,7 @@ import static org.junit.Assert.assertThat;
|
||||
public class LiteralArgumentBuilderTest {
|
||||
LiteralArgumentBuilder builder;
|
||||
@Mock
|
||||
Runnable executor;
|
||||
Command command;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -30,10 +31,10 @@ public class LiteralArgumentBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testBuildWithExecutor() throws Exception {
|
||||
LiteralCommandNode node = builder.executes(executor).build();
|
||||
LiteralCommandNode node = builder.executes(command).build();
|
||||
|
||||
assertThat(node.getLiteral(), is("foo"));
|
||||
assertThat(node.getExecutor(), is(executor));
|
||||
assertThat(node.getCommand(), is(command));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.Command;
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
import net.minecraft.commands.tree.ArgumentCommandNode;
|
||||
import org.junit.Before;
|
||||
@@ -15,7 +16,8 @@ import static org.junit.Assert.assertThat;
|
||||
public class RequiredArgumentBuilderTest {
|
||||
@Mock CommandArgumentType<Integer> type;
|
||||
RequiredArgumentBuilder<Integer> builder;
|
||||
@Mock Runnable executor;
|
||||
@Mock
|
||||
Command command;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -32,11 +34,11 @@ public class RequiredArgumentBuilderTest {
|
||||
|
||||
@Test
|
||||
public void testBuildWithExecutor() throws Exception {
|
||||
ArgumentCommandNode<Integer> node = builder.executes(executor).build();
|
||||
ArgumentCommandNode<Integer> node = builder.executes(command).build();
|
||||
|
||||
assertThat(node.getName(), is("foo"));
|
||||
assertThat(node.getType(), is(type));
|
||||
assertThat(node.getExecutor(), is(executor));
|
||||
assertThat(node.getCommand(), is(command));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user