Build stuff into nodes! They may not do anything, but it's node-tastic!
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.commands;
|
||||
|
||||
import net.minecraft.commands.tree.CommandNode;
|
||||
|
||||
public class CommandNodeTest {
|
||||
CommandNode node;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.tree.CommandNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -14,7 +15,12 @@ public class ArgumentBuilderTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
builder = new ArgumentBuilder() {};
|
||||
builder = new ArgumentBuilder() {
|
||||
@Override
|
||||
public CommandNode build() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.tree.LiteralCommandNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -7,6 +8,7 @@ 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 {
|
||||
@@ -26,4 +28,20 @@ public class CommandBuilderTest {
|
||||
assertThat(builder.getArguments(), hasSize(1));
|
||||
assertThat(builder.getArguments(), hasItems((ArgumentBuilder) argument));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuild() throws Exception {
|
||||
LiteralCommandNode node = builder.build();
|
||||
|
||||
assertThat(node.getLiteral(), is("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildWithChildren() throws Exception {
|
||||
builder.then(argument("bar", integer()));
|
||||
builder.then(argument("baz", integer()));
|
||||
LiteralCommandNode node = builder.build();
|
||||
|
||||
assertThat(node.getChildren(), hasSize(2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.minecraft.commands.builder;
|
||||
|
||||
import net.minecraft.commands.arguments.CommandArgumentType;
|
||||
import net.minecraft.commands.tree.ArgumentCommandNode;
|
||||
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;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class RequiredArgumentBuilderTest {
|
||||
@Mock CommandArgumentType type;
|
||||
RequiredArgumentBuilder builder;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
builder = argument("foo", type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuild() throws Exception {
|
||||
ArgumentCommandNode node = builder.build();
|
||||
|
||||
assertThat(node.getName(), is("foo"));
|
||||
assertThat(node.getType(), is(type));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildWithChildren() throws Exception {
|
||||
builder.then(argument("bar", integer()));
|
||||
builder.then(argument("baz", integer()));
|
||||
ArgumentCommandNode node = builder.build();
|
||||
|
||||
assertThat(node.getChildren(), hasSize(2));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user