Search in sources :

Example 11 with CommandResult

use of org.springframework.shell.core.CommandResult in project incubator-rya by apache.

the class MongoRyaShellIT method connectToInstance_noAuths.

@Test
public void connectToInstance_noAuths() throws IOException {
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Connect to the Mongo instance.
    String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
    shell.executeCommand(cmd);
    // Install an instance of rya.
    final String instanceName = "testInstance";
    final InstallConfiguration installConf = InstallConfiguration.builder().build();
    final ApplicationContext context = bootstrap.getApplicationContext();
    final InstallPrompt installPrompt = context.getBean(InstallPrompt.class);
    when(installPrompt.promptInstanceName()).thenReturn("testInstance");
    when(installPrompt.promptInstallConfiguration("testInstance")).thenReturn(installConf);
    when(installPrompt.promptVerified(instanceName, installConf)).thenReturn(true);
    CommandResult result = shell.executeCommand(RyaAdminCommands.INSTALL_CMD);
    assertTrue(result.isSuccess());
    // Connect to the instance that was just installed.
    cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance " + instanceName;
    result = shell.executeCommand(cmd);
    assertTrue(result.isSuccess());
    // Verify the shell state indicates it is connected to an instance.
    final SharedShellState sharedState = context.getBean(SharedShellState.class);
    final ShellState state = sharedState.getShellState();
    assertEquals(ConnectionState.CONNECTED_TO_INSTANCE, state.getConnectionState());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) ShellState(org.apache.rya.shell.SharedShellState.ShellState) Bootstrap(org.springframework.shell.Bootstrap) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 12 with CommandResult

use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.

the class SimpleCLIIntegrationTest method givenCommandConfig_whenExecutingWebSaveCommand_thenCorrectResult.

@Test
public void givenCommandConfig_whenExecutingWebSaveCommand_thenCorrectResult() {
    shell.executeCommand("admin-enable");
    final CommandResult result = shell.executeCommand("web-save --url https://www.google.com --out contents.txt");
    Assert.assertArrayEquals(new boolean[] { result.isSuccess(), new File("contents.txt").exists() }, new boolean[] { true, true });
}
Also used : File(java.io.File) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 13 with CommandResult

use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.

the class SimpleCLIIntegrationTest method givenCommandConfig_whenExecutingWebGetCommandWithDefaultArgument_thenCorrectResult.

@Test
public void givenCommandConfig_whenExecutingWebGetCommandWithDefaultArgument_thenCorrectResult() {
    final CommandResult result = shell.executeCommand("web-get https://www.google.com");
    Assert.assertEquals(result.isSuccess(), true);
}
Also used : CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 14 with CommandResult

use of org.springframework.shell.core.CommandResult in project tutorials by eugenp.

the class SimpleCLIIntegrationTest method givenCommandConfig_whenWebSaveCommandExecutedNoOutArgument_thenError.

@Test
public void givenCommandConfig_whenWebSaveCommandExecutedNoOutArgument_thenError() {
    shell.executeCommand("admin-enable");
    final CommandResult resultWebSave = shell.executeCommand("web-save --url https://www.google.com");
    Assert.assertEquals(resultWebSave.isSuccess(), false);
}
Also used : CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 15 with CommandResult

use of org.springframework.shell.core.CommandResult in project incubator-rya by apache.

the class MongoRyaShellIT method connectToInstance_instanceDoesNotExist.

@Test
public void connectToInstance_instanceDoesNotExist() throws IOException {
    final JLineShellComponent shell = getTestShell();
    // Connect to the Mongo instance.
    String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
    shell.executeCommand(cmd);
    // Try to connect to a non-existing instance.
    cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance doesNotExist";
    final CommandResult result = shell.executeCommand(cmd);
    assertFalse(result.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Aggregations

CommandResult (org.springframework.shell.core.CommandResult)22 Test (org.junit.Test)19 JLineShellComponent (org.springframework.shell.core.JLineShellComponent)14 Bootstrap (org.springframework.shell.Bootstrap)11 ApplicationContext (org.springframework.context.ApplicationContext)8 PasswordPrompt (org.apache.rya.shell.util.PasswordPrompt)7 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)6 LensClient (org.apache.lens.client.LensClient)3 JLineShell (org.springframework.shell.core.JLineShell)3 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)2 ShellState (org.apache.rya.shell.SharedShellState.ShellState)2 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)2 File (java.io.File)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1