Made every CommandNode support an executor

This commit is contained in:
Nathan Adams
2014-09-24 12:04:33 +02:00
parent 3ef22ef317
commit d13587a4df
6 changed files with 34 additions and 8 deletions
@@ -3,6 +3,7 @@ package net.minecraft.commands.builder;
import net.minecraft.commands.tree.LiteralCommandNode;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
@@ -12,6 +13,8 @@ import static org.junit.Assert.assertThat;
public class LiteralArgumentBuilderTest {
LiteralArgumentBuilder builder;
@Mock
Runnable executor;
@Before
public void setUp() throws Exception {
@@ -25,6 +28,14 @@ public class LiteralArgumentBuilderTest {
assertThat(node.getLiteral(), is("foo"));
}
@Test
public void testBuildWithExecutor() throws Exception {
LiteralCommandNode node = builder.executes(executor).build();
assertThat(node.getLiteral(), is("foo"));
assertThat(node.getExecutor(), is(executor));
}
@Test
public void testBuildWithChildren() throws Exception {
builder.then(argument("bar", integer()));
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertThat;
public class RequiredArgumentBuilderTest {
@Mock CommandArgumentType<Integer> type;
RequiredArgumentBuilder<Integer> builder;
@Mock Runnable executor;
@Before
public void setUp() throws Exception {
@@ -29,6 +30,15 @@ public class RequiredArgumentBuilderTest {
assertThat(node.getType(), is(type));
}
@Test
public void testBuildWithExecutor() throws Exception {
ArgumentCommandNode<Integer> node = builder.executes(executor).build();
assertThat(node.getName(), is("foo"));
assertThat(node.getType(), is(type));
assertThat(node.getExecutor(), is(executor));
}
@Test
public void testBuildWithChildren() throws Exception {
builder.then(argument("bar", integer()));