Build stuff into nodes! They may not do anything, but it's node-tastic!

This commit is contained in:
Nathan Adams
2014-09-17 15:30:49 +02:00
parent 934ba3336f
commit 4f20d02a97
11 changed files with 161 additions and 1 deletions
@@ -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));
}
}