Search in sources :

Example 1 with InstallPrompt

use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method connectToInstance.

@Test
public void connectToInstance() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the correct password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("password".toCharArray());
    // Connect to the mini accumulo instance.
    String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    CommandResult result = shell.executeCommand(cmd);
    // Install an instance of rya.
    final String instanceName = "testInstance";
    final InstallConfiguration installConf = InstallConfiguration.builder().build();
    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);
    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) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) Bootstrap(org.springframework.shell.Bootstrap) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 2 with InstallPrompt

use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.

the class RyaAdminCommandsTest method install.

@Test
public void install() throws DuplicateInstanceNameException, RyaClientException, IOException {
    // Mock the object that performs the install operation.
    final Install mockInstall = mock(Install.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getInstall()).thenReturn(mockInstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    // Execute the command.
    final String instanceName = "unitTests";
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableGeoIndex(true).setEnablePcjIndex(true).build();
    final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
    when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
    when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
    when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
    final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.install();
    // Verify the values that were provided to the command were passed through to the Install.
    verify(mockInstall).install(eq(instanceName), eq(installConfig));
    // Verify a message is returned that indicates the success of the operation.
    final String expected = "The Rya instance named 'unitTests' has been installed.";
    assertEquals(expected, message);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 3 with InstallPrompt

use of org.apache.rya.shell.util.InstallPrompt 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 4 with InstallPrompt

use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.

the class RyaAdminCommandsTest method installWithMongoParameters.

@Test
public void installWithMongoParameters() throws DuplicateInstanceNameException, RyaClientException, IOException {
    // Mock the object that performs the install operation.
    final Install mockInstall = mock(Install.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getInstall()).thenReturn(mockInstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToMongo(mock(MongoConnectionDetails.class), mockCommands);
    final String instanceName = "unitTests";
    final boolean enableFreeTextIndex = false;
    final boolean enableTemporalIndex = false;
    final boolean enablePcjIndex = false;
    // Execute the command.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).build();
    final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
    when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
    when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
    when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
    final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.installWithMongoParameters(instanceName, enableFreeTextIndex, enableTemporalIndex, enablePcjIndex);
    // Verify the values that were provided to the command were passed through to the Install.
    verify(mockInstall).install(eq(instanceName), eq(installConfig));
    // Verify a message is returned that indicates the success of the operation.
    final String expected = "The Rya instance named 'unitTests' has been installed.";
    assertEquals(expected, message);
}
Also used : MongoConnectionDetails(org.apache.rya.api.client.mongo.MongoConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 5 with InstallPrompt

use of org.apache.rya.shell.util.InstallPrompt in project incubator-rya by apache.

the class RyaAdminCommandsTest method installWithAccumuloParameters.

@Test
public void installWithAccumuloParameters() throws DuplicateInstanceNameException, RyaClientException, IOException {
    // Mock the object that performs the install operation.
    final Install mockInstall = mock(Install.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getInstall()).thenReturn(mockInstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    final String instanceName = "unitTests";
    final boolean enableTableHashPrefix = false;
    final boolean enableEntityCentricIndex = true;
    final boolean enableFreeTextIndex = false;
    final boolean enableTemporalIndex = false;
    final boolean enablePcjIndex = true;
    final String fluoPcjAppName = instanceName + "pcj_updater";
    // Execute the command.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(enableTableHashPrefix).setEnableEntityCentricIndex(enableEntityCentricIndex).setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).setFluoPcjAppName(fluoPcjAppName).build();
    final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
    when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
    when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
    when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
    final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.installWithAccumuloParameters(instanceName, enableTableHashPrefix, enableEntityCentricIndex, enableFreeTextIndex, enableTemporalIndex, enablePcjIndex, fluoPcjAppName);
    // Verify the values that were provided to the command were passed through to the Install.
    verify(mockInstall).install(eq(instanceName), eq(installConfig));
    // Verify a message is returned that indicates the success of the operation.
    final String expected = "The Rya instance named 'unitTests' has been installed.";
    assertEquals(expected, message);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Aggregations

InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)6 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)6 Test (org.junit.Test)6 Install (org.apache.rya.api.client.Install)4 RyaClient (org.apache.rya.api.client.RyaClient)4 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)4 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)4 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)3 ShellState (org.apache.rya.shell.SharedShellState.ShellState)2 ApplicationContext (org.springframework.context.ApplicationContext)2 Bootstrap (org.springframework.shell.Bootstrap)2 CommandResult (org.springframework.shell.core.CommandResult)2 JLineShellComponent (org.springframework.shell.core.JLineShellComponent)2 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)1 MongoConnectionDetails (org.apache.rya.api.client.mongo.MongoConnectionDetails)1 PasswordPrompt (org.apache.rya.shell.util.PasswordPrompt)1