Search in sources :

Example 11 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommandsTest method deletePCJ.

@Test
public void deletePCJ() throws InstanceDoesNotExistException, RyaClientException {
    // Mock the object that performs the delete operation.
    final DeletePCJ mockDeletePCJ = mock(DeletePCJ.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getDeletePCJ()).thenReturn(mockDeletePCJ);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    final String instanceName = "unitTests";
    state.connectedToInstance(instanceName);
    // Execute the command.
    final String pcjId = "123412342";
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.deletePcj(pcjId);
    // Verify the values that were provided to the command were passed through to the DeletePCJ.
    verify(mockDeletePCJ).deletePCJ(eq(instanceName), eq(pcjId));
    // Verify a message is returned that explains what was deleted.
    final String expected = "The PCJ has been deleted.";
    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) DeletePCJ(org.apache.rya.api.client.DeletePCJ) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 12 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommandsTest method createPeriodicPCJ.

@Test
public void createPeriodicPCJ() throws InstanceDoesNotExistException, RyaClientException, IOException {
    // Mock the object that performs the create operation.
    final String instanceName = "unitTest";
    final String sparql = "SELECT * WHERE { ?person <http://isA> ?noun }";
    final String topic = "topic";
    final String brokers = "brokers";
    final String pcjId = "12341234";
    final CreatePeriodicPCJ mockCreatePCJ = mock(CreatePeriodicPCJ.class);
    when(mockCreatePCJ.createPeriodicPCJ(eq(instanceName), eq(sparql), eq(topic), eq(brokers))).thenReturn(pcjId);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getCreatePeriodicPCJ()).thenReturn(java.util.Optional.of(mockCreatePCJ));
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance(instanceName);
    final SparqlPrompt mockSparqlPrompt = mock(SparqlPrompt.class);
    when(mockSparqlPrompt.getSparql()).thenReturn(Optional.of(sparql));
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mockSparqlPrompt, mock(UninstallPrompt.class));
    final String message = commands.createPeriodicPcj(topic, brokers);
    // Verify the values that were provided to the command were passed through to CreatePCJ.
    verify(mockCreatePCJ).createPeriodicPCJ(eq(instanceName), eq(sparql), eq(topic), eq(brokers));
    // Verify a message is returned that explains what was created.
    final String expected = "The Periodic PCJ has been created. Its ID is '12341234'.";
    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) CreatePeriodicPCJ(org.apache.rya.api.client.CreatePeriodicPCJ) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 13 with RyaClient

use of org.apache.rya.api.client.RyaClient 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 14 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class SharedShellStateTest method connectToStorageAgain.

@Test(expected = IllegalStateException.class)
public void connectToStorageAgain() {
    final SharedShellState state = new SharedShellState();
    // Connect to Accumulo.
    final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class);
    final RyaClient connectedCommands = mock(RyaClient.class);
    state.connectedToAccumulo(connectionDetails, connectedCommands);
    // Try to set the information again.
    state.connectedToAccumulo(connectionDetails, connectedCommands);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 15 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class SharedShellStateTest method connectedToRyaStreams.

@Test
public void connectedToRyaStreams() {
    // Create a shell state.
    final SharedShellState state = new SharedShellState();
    // Connect to Accumulo.
    final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class);
    final RyaClient connectedCommands = mock(RyaClient.class);
    state.connectedToAccumulo(connectionDetails, connectedCommands);
    // Connect to an Instance.
    state.connectedToInstance("instance");
    // Connect to Rya Streams for the instance.
    final RyaStreamsClient streamsClient = mock(RyaStreamsClient.class);
    state.connectedToRyaStreams(streamsClient);
    // Verify the state.
    assertEquals(streamsClient, state.getShellState().getRyaStreamsCommands().get());
}
Also used : RyaStreamsClient(org.apache.rya.streams.api.RyaStreamsClient) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Aggregations

RyaClient (org.apache.rya.api.client.RyaClient)105 Test (org.junit.Test)76 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)41 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)29 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)26 CliCommand (org.springframework.shell.core.annotation.CliCommand)20 RyaClientException (org.apache.rya.api.client.RyaClientException)18 Install (org.apache.rya.api.client.Install)17 ShellState (org.apache.rya.shell.SharedShellState.ShellState)16 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)16 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)16 RyaDetails (org.apache.rya.api.instance.RyaDetails)14 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)13 IOException (java.io.IOException)11 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)9 Sail (org.openrdf.sail.Sail)9 ValueFactory (org.openrdf.model.ValueFactory)8 HashSet (java.util.HashSet)7 Connector (org.apache.accumulo.core.client.Connector)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7