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();
}
}
Aggregations