use of org.apache.rya.shell.util.SparqlPrompt in project incubator-rya by apache.
the class RyaStreamsCommandsTest method addQuery_insertQueryNotCorrectType.
@Test(expected = RuntimeException.class)
public void addQuery_insertQueryNotCorrectType() throws Exception {
// Mock the object that performs the rya streams operation.
final RyaStreamsClient mockClient = mock(RyaStreamsClient.class);
final AddQuery addQuery = mock(AddQuery.class);
when(mockClient.getAddQuery()).thenReturn(addQuery);
final String sparql = "SELECT * WHERE { ?a ?b ?c }";
final StreamsQuery addedQuery = new StreamsQuery(UUID.randomUUID(), sparql, true, true);
when(addQuery.addQuery(eq(sparql), eq(false), eq(true))).thenReturn(addedQuery);
// Mock a SPARQL prompt that a user entered a query through.
final SparqlPrompt prompt = mock(SparqlPrompt.class);
when(prompt.getSparql()).thenReturn(Optional.of(sparql));
// 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);
// Execute the command.
final RyaStreamsCommands commands = new RyaStreamsCommands(state, prompt, mock(ConsolePrinter.class));
commands.addQuery(true, true);
}
use of org.apache.rya.shell.util.SparqlPrompt in project incubator-rya by apache.
the class RyaAdminCommandsTest method createPCJ_cancelledPrompt.
@Test
public void createPCJ_cancelledPrompt() throws InstanceDoesNotExistException, RyaClientException, IOException {
// Mock the object that performs the create operation.
final String instanceName = "unitTest";
final RyaClient mockCommands = mock(RyaClient.class);
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.absent());
// Execute the command.
final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mockSparqlPrompt, mock(UninstallPrompt.class));
final String message = commands.createPcj(true, false);
// Verify a message is returned that explains what was created.
final String expected = "";
assertEquals(expected, message);
}
Aggregations