use of org.apache.rya.streams.api.interactor.StopQuery in project incubator-rya by apache.
the class RyaStreamsCommandsTest method stopQuery.
@Test
public void stopQuery() throws Exception {
// Mock the object that performs the rya streams operation.
final RyaStreamsClient mockClient = mock(RyaStreamsClient.class);
final StopQuery stopQuery = mock(StopQuery.class);
when(mockClient.getStopQuery()).thenReturn(stopQuery);
final GetQuery getQuery = mock(GetQuery.class);
when(mockClient.getGetQuery()).thenReturn(getQuery);
// Mock a shell state and connect it to a Rya instance.
final SharedShellState state = new SharedShellState();
state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mock(RyaClient.class));
state.connectedToInstance("unitTest");
state.connectedToRyaStreams(mockClient);
// Report the query as running.
final UUID queryId = UUID.randomUUID();
when(getQuery.getQuery(eq(queryId))).thenReturn(java.util.Optional.of(new StreamsQuery(queryId, "sparql", true, false)));
// Execute the command.
final RyaStreamsCommands commands = new RyaStreamsCommands(state, mock(SparqlPrompt.class), mock(ConsolePrinter.class));
final String message = commands.stopQuery(queryId.toString());
// Verify the interactor was invoked with the provided parameters.
verify(stopQuery).stop(queryId);
// Verify a message is printed to the user.
final String expected = "The query will no longer be processed by the Rya Streams subsystem.";
assertEquals(expected, message);
}
use of org.apache.rya.streams.api.interactor.StopQuery in project incubator-rya by apache.
the class RyaStreamsCommandsTest method stopQuery_alreadyStopped.
@Test
public void stopQuery_alreadyStopped() throws Exception {
// Mock the object that performs the rya streams operation.
final RyaStreamsClient mockClient = mock(RyaStreamsClient.class);
final StopQuery stopQuery = mock(StopQuery.class);
when(mockClient.getStopQuery()).thenReturn(stopQuery);
final GetQuery getQuery = mock(GetQuery.class);
when(mockClient.getGetQuery()).thenReturn(getQuery);
// Mock a shell state and connect it to a Rya instance.
final SharedShellState state = new SharedShellState();
state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mock(RyaClient.class));
state.connectedToInstance("unitTest");
state.connectedToRyaStreams(mockClient);
// Report the query as not running.
final UUID queryId = UUID.randomUUID();
when(getQuery.getQuery(eq(queryId))).thenReturn(java.util.Optional.of(new StreamsQuery(queryId, "sparql", false, false)));
// Execute the command.
final RyaStreamsCommands commands = new RyaStreamsCommands(state, mock(SparqlPrompt.class), mock(ConsolePrinter.class));
final String message = commands.stopQuery(queryId.toString());
// Verify the interactor was not invoked with the provided parameters.
verify(stopQuery, never()).stop(queryId);
// Verify a message is printed to the user.
final String expected = "That query is already stopped.";
assertEquals(expected, message);
}
Aggregations