Search in sources :

Example 16 with Subparser

use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.

the class HostRegisterCommandTest method setUp.

@Before
public void setUp() {
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("register");
    command = new HostRegisterCommand(subparser);
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Before(org.junit.Before)

Example 17 with Subparser

use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.

the class JobCreateCommandTest method setUp.

@Before
public void setUp() {
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("create");
    final Supplier<Map<String, String>> envVarSupplier = new Supplier<Map<String, String>>() {

        @Override
        public Map<String, String> get() {
            return ImmutableMap.copyOf(envVars);
        }
    };
    command = new JobCreateCommand(subparser, envVarSupplier);
    when(client.createJob(argThat(matchesName(JOB_NAME)))).thenReturn(immediateFuture(new CreateJobResponse(CreateJobResponse.Status.OK, Collections.<String>emptyList(), "12345")));
}
Also used : CreateJobResponse(com.spotify.helios.common.protocol.CreateJobResponse) Subparser(net.sourceforge.argparse4j.inf.Subparser) Supplier(com.google.common.base.Supplier) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Before(org.junit.Before)

Example 18 with Subparser

use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.

the class HostListCommandTest method runCommand.

private int runCommand(String... commandArgs) throws ExecutionException, InterruptedException, ArgumentParserException {
    final String[] args = new String[1 + commandArgs.length];
    args[0] = "hosts";
    System.arraycopy(commandArgs, 0, args, 1, commandArgs.length);
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("hosts");
    final HostListCommand command = new HostListCommand(subparser);
    final Namespace options = parser.parseArgs(args);
    return command.run(options, client, out, false, null);
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Namespace(net.sourceforge.argparse4j.inf.Namespace)

Example 19 with Subparser

use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.

the class JobInspectCommandTest method setUp.

@Before
public void setUp() {
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("inspect");
    command = new JobInspectCommand(subparser, TimeZone.getTimeZone("UTC"));
    when(client.jobs(JOB_NAME_VERSION)).thenReturn(Futures.immediateFuture(jobs));
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Before(org.junit.Before)

Example 20 with Subparser

use of net.sourceforge.argparse4j.inf.Subparser in project helios by spotify.

the class JobStatusCommandTest method setUp.

@Before
public void setUp() {
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("list");
    command = new JobStatusCommand(subparser);
    // defaults for flags
    when(options.getString("job")).thenReturn(null);
    when(options.getString("host")).thenReturn("");
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Before(org.junit.Before)

Aggregations

Subparser (net.sourceforge.argparse4j.inf.Subparser)21 ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)10 Before (org.junit.Before)7 Namespace (net.sourceforge.argparse4j.inf.Namespace)5 ImmutableMap (com.google.common.collect.ImmutableMap)3 OptionMetadata (io.airlift.airline.model.OptionMetadata)3 List (java.util.List)3 Argument (net.sourceforge.argparse4j.inf.Argument)3 Configuration (io.dropwizard.Configuration)2 Bootstrap (io.dropwizard.setup.Bootstrap)2 ZoneOffset (java.time.ZoneOffset)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 Subparsers (net.sourceforge.argparse4j.inf.Subparsers)2 StringFormatter.dateString (org.apache.kafka.trogdor.common.StringFormatter.dateString)2 StringFormatter.durationString (org.apache.kafka.trogdor.common.StringFormatter.durationString)2 UptimeResponse (org.apache.kafka.trogdor.rest.UptimeResponse)2 TaskSpec (org.apache.kafka.trogdor.task.TaskSpec)2