Search in sources :

Example 1 with SetRyaStreamsConfiguration

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

the class RyaStreamsCommandsTest method configureRyaStreams.

@Test
public void configureRyaStreams() throws Exception {
    // Mock the object that performs the configure operation.
    final RyaClient mockCommands = mock(RyaClient.class);
    final SetRyaStreamsConfiguration setStreams = mock(SetRyaStreamsConfiguration.class);
    when(mockCommands.getSetRyaStreamsConfiguration()).thenReturn(setStreams);
    // Mock a shell state and connect it to a Rya instance.
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance("unitTest");
    // Verify that no Rya Streams Client is set to the state.
    assertFalse(state.getShellState().getRyaStreamsCommands().isPresent());
    try {
        // Execute the command.
        final RyaStreamsCommands commands = new RyaStreamsCommands(state, mock(SparqlPrompt.class), mock(ConsolePrinter.class));
        final String message = commands.configureRyaStreams("localhost", 6);
        // Verify the request was forwarded to the mocked interactor.
        final RyaStreamsDetails expectedDetails = new RyaStreamsDetails("localhost", 6);
        verify(setStreams).setRyaStreamsConfiguration(eq("unitTest"), eq(expectedDetails));
        // Verify a RyaStreamsClient was created and added to the state.
        assertTrue(state.getShellState().getRyaStreamsCommands().isPresent());
        // Verify the correct message is reported.
        final String expected = "The Rya Instance has been updated to use the provided Rya Streams subsystem. " + "Rya Streams commands are now avaiable while connected to this instance.";
        assertEquals(expected, message);
    } finally {
        state.getShellState().getRyaStreamsCommands().get().close();
    }
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) ConsolePrinter(org.apache.rya.shell.util.ConsolePrinter) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) SetRyaStreamsConfiguration(org.apache.rya.api.client.SetRyaStreamsConfiguration) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Aggregations

RyaClient (org.apache.rya.api.client.RyaClient)1 SetRyaStreamsConfiguration (org.apache.rya.api.client.SetRyaStreamsConfiguration)1 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)1 RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)1 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)1 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)1 Test (org.junit.Test)1