RyaStreamsCommands implements CommandMarker { @CliCommand(value = STREAM_QUERIES_DELETE_CMD, help = "Delete a SPARQL query from the Rya Streams subsystem.") public String deleteQuery( @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to remove.") final String queryId) { final RyaStreamsClient streamsClient = state.getShellState().getRyaStreamsCommands().get(); final UUID id = UUID.fromString(queryId); try { streamsClient.getDeleteQuery().delete(id); } catch (final RyaStreamsException e) { throw new RuntimeException("Could not delete the query from the Rya Streams subsystem.", e); } return "The query has been deleted."; } @Autowired  RyaStreamsCommands(
            final SharedShellState state,
            final SparqlPrompt sparqlPrompt,
            final ConsolePrinter consolePrinter); @CliAvailabilityIndicator({ STREAMS_CONFIGURE_CMD, STREAMS_DETAILS_CMD}) boolean areConfigCommandsAvailable(); @CliAvailabilityIndicator({ STREAM_QUERIES_ADD_CMD, STREAM_QUERIES_DELETE_CMD, STREAM_QUERIES_START_CMD, STREAM_QUERIES_STOP_CMD, STREAM_QUERIES_LIST_CMD, STREAM_QUERIES_DETAILS_CMD}) boolean areQueriesCommandsAvailable(); @CliCommand(value = STREAMS_CONFIGURE_CMD, help = "Connect a Rya Streams subsystem to a Rya Instance.") String configureRyaStreams(
            @CliOption(key = {"kafkaHostname"}, mandatory = true, help = "The hostname of the Kafka Broker.")
            final String kafkaHostname,
            @CliOption(key = {"kafkaPort"}, mandatory = true, help = "The port of the Kafka Broker.")
            final int kafkaPort); @CliCommand(value = STREAMS_DETAILS_CMD, help = "Print information about which Rya Streams subsystem the Rya instance is connected to.") String printRyaStreamsDetails(); @CliCommand(value = STREAM_QUERIES_ADD_CMD, help = "Add a SPARQL query to the Rya Streams subsystem.") String addQuery(
            @CliOption(key = {"inactive"}, mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
                       help = "Setting this flag will add the query, but not run it. (default: false)")
            final boolean inactive,
            @CliOption(key = {"insert"}, mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
                       help = "Setting this flag will insert the query's results back into Rya. (default: false)")
            final boolean isInsert); @CliCommand(value = STREAM_QUERIES_DELETE_CMD, help = "Delete a SPARQL query from the Rya Streams subsystem.") String deleteQuery(
            @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to remove.")
            final String queryId); @CliCommand(value = STREAM_QUERIES_START_CMD, help = "Start processing a SPARQL query using the Rya Streams subsystem.") String startQuery(
            @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to start processing.")
            final String queryId); @CliCommand(value = STREAM_QUERIES_STOP_CMD, help = "Stop processing a SPARQL query using the Rya Streams subsystem.") String stopQuery(
            @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to stop processing.")
            final String queryId); @CliCommand(value = STREAM_QUERIES_LIST_CMD, help = "List the queries that are being managed by the configured Rya Streams subsystem.") String listQueries(); @CliCommand(value = STREAM_QUERIES_DETAILS_CMD, help = "Print detailed information about a specific query managed by the Rya Streams subsystem.") String printQueryDetails(
            @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query whose details will be printed.")
            final String queryId); static final String STREAMS_CONFIGURE_CMD; static final String STREAMS_DETAILS_CMD; static final String STREAM_QUERIES_ADD_CMD; static final String STREAM_QUERIES_DELETE_CMD; static final String STREAM_QUERIES_START_CMD; static final String STREAM_QUERIES_STOP_CMD; static final String STREAM_QUERIES_LIST_CMD; static final String STREAM_QUERIES_DETAILS_CMD; }
@Test public void deleteQuery() throws Exception { final RyaStreamsClient mockClient = mock(RyaStreamsClient.class); final DeleteQuery deleteQuery = mock(DeleteQuery.class); when(mockClient.getDeleteQuery()).thenReturn(deleteQuery); final SharedShellState state = new SharedShellState(); state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mock(RyaClient.class)); state.connectedToInstance("unitTest"); state.connectedToRyaStreams(mockClient); final RyaStreamsCommands commands = new RyaStreamsCommands(state, mock(SparqlPrompt.class), mock(ConsolePrinter.class)); final UUID queryId = UUID.randomUUID(); final String message = commands.deleteQuery(queryId.toString()); verify(deleteQuery).delete(eq(queryId)); final String expected = "The query has been deleted."; assertEquals(expected, message); }