Renamed CommandBuilder to LiteralArgumentBuilder
This commit is contained in:
@@ -7,7 +7,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import static net.minecraft.commands.builder.CommandBuilder.command;
|
||||
import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -22,13 +22,13 @@ public class CommandDispatcherTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testDuplicateCommand() throws Exception {
|
||||
subject.register(command("foo").executes(runnable));
|
||||
subject.register(command("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndExecuteCommand() throws Exception {
|
||||
subject.register(command("foo").executes(runnable));
|
||||
subject.register(literal("foo").executes(runnable));
|
||||
|
||||
subject.execute("foo");
|
||||
verify(runnable).run();
|
||||
|
||||
@@ -11,16 +11,11 @@ import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class ArgumentBuilderTest {
|
||||
ArgumentBuilder builder;
|
||||
TestableArgumentBuilder builder;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
builder = new ArgumentBuilder() {
|
||||
@Override
|
||||
public CommandNode build() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
builder = new TestableArgumentBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -32,4 +27,16 @@ public class ArgumentBuilderTest {
|
||||
assertThat(builder.getArguments(), hasSize(1));
|
||||
assertThat(builder.getArguments(), hasItems((ArgumentBuilder) argument));
|
||||
}
|
||||
|
||||
private static class TestableArgumentBuilder extends ArgumentBuilder<TestableArgumentBuilder> {
|
||||
@Override
|
||||
protected TestableArgumentBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandNode build() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-14
@@ -6,27 +6,16 @@ import org.junit.Test;
|
||||
|
||||
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
|
||||
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class CommandBuilderTest {
|
||||
CommandBuilder builder;
|
||||
public class LiteralArgumentBuilderTest {
|
||||
LiteralArgumentBuilder builder;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
builder = new CommandBuilder("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArguments() throws Exception {
|
||||
RequiredArgumentBuilder argument = argument("bar", integer());
|
||||
|
||||
builder.then(argument);
|
||||
|
||||
assertThat(builder.getArguments(), hasSize(1));
|
||||
assertThat(builder.getArguments(), hasItems((ArgumentBuilder) argument));
|
||||
builder = new LiteralArgumentBuilder("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -5,7 +5,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
|
||||
import static net.minecraft.commands.builder.CommandBuilder.command;
|
||||
import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
|
||||
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -15,7 +15,7 @@ public class LiteralCommandNodeTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
node = command("foo").build();
|
||||
node = literal("foo").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user