Skip to content

Instantly share code, notes, and snippets.

@hugmanrique
Created April 3, 2021 19:13
Show Gist options
  • Save hugmanrique/38a46adb8a812bb2e2d692a277e03c7b to your computer and use it in GitHub Desktop.
Save hugmanrique/38a46adb8a812bb2e2d692a277e03c7b to your computer and use it in GitHub Desktop.
// Paste in src/test/java/com/mojang/brigadier/CommandDispatcherTest.java
@SuppressWarnings("unchecked")
@Test
public void testExecuteAmbiguousArgumentImpermissibleLiteral() throws Exception {
final Command<Object> command = mock(Command.class);
when(command.run(any())).thenReturn(100);
subject.register(literal("foo")
.then(
literal("bar")
.requires(source -> false)
)
.then(
argument("argument", StringArgumentType.word())
.executes(command)
)
);
assertThat(subject.execute("foo bar", source), is(100));
verify(command).run(any(CommandContext.class));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment