use of io.airlift.airline.model.OptionMetadata in project atlasdb by palantir.
the class AtlasDbCliCommandTest method requiredIsSetOnArgument.
@Test
public void requiredIsSetOnArgument() {
boolean expectedRequired = true;
OptionMetadata metadata = new OptionMetadata(OptionType.COMMAND, ImmutableSet.of("arg"), "name", "description", 0, expectedRequired, false, ImmutableSet.of(), getOptionFields());
Argument argument = getArgumentMockFromAddOptionToParser(metadata, "arg");
verify(argument).required(expectedRequired);
}
use of io.airlift.airline.model.OptionMetadata in project atlasdb by palantir.
the class AtlasDbCliCommandTest method zeroArityConstantIsSetOnArgumentWhenThereArentAnyExpectedArguments.
@Test
public void zeroArityConstantIsSetOnArgumentWhenThereArentAnyExpectedArguments() {
OptionMetadata metadata = new OptionMetadata(OptionType.COMMAND, ImmutableSet.of("arg"), "name", "description", 0, false, false, ImmutableSet.of(), getOptionFields());
Argument argument = getArgumentMockFromAddOptionToParser(metadata, "arg");
verify(argument).action(Arguments.storeConst());
verify(argument).setConst(AtlasDbCommandUtils.ZERO_ARITY_ARG_CONSTANT);
}
use of io.airlift.airline.model.OptionMetadata in project atlasdb by palantir.
the class AtlasDbCliCommandTest method helpIsSetOnArgument.
@Test
public void helpIsSetOnArgument() {
String expectedDescription = "description";
OptionMetadata metadata = new OptionMetadata(OptionType.COMMAND, ImmutableSet.of("arg"), "name", expectedDescription, 0, false, false, ImmutableSet.of(), getOptionFields());
Argument argument = getArgumentMockFromAddOptionToParser(metadata, "arg");
verify(argument).help(expectedDescription);
}
use of io.airlift.airline.model.OptionMetadata in project atlasdb by palantir.
the class AtlasDbCliCommandTest method getArgumentMockFromAddOptionToParser.
private static Argument getArgumentMockFromAddOptionToParser(OptionMetadata metadata, String... argNames) {
Subparser parser = mock(Subparser.class);
Argument argument = mock(Argument.class, (Answer<Object>) (invocation) -> {
Object mock = invocation.getMock();
if (invocation.getMethod().getReturnType().isInstance(mock)) {
return mock;
} else {
return Mockito.RETURNS_DEFAULTS.answer(invocation);
}
});
when(parser.addArgument(argNames)).thenReturn(argument);
AtlasDbCliCommand.addOptionToParser(parser, metadata);
return argument;
}
Aggregations