Search in sources :

Example 1 with CreatePeriodicPCJ

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

the class RyaAdminCommandsTest method createPeriodicPCJ.

@Test
public void createPeriodicPCJ() throws InstanceDoesNotExistException, RyaClientException, IOException {
    // Mock the object that performs the create operation.
    final String instanceName = "unitTest";
    final String sparql = "SELECT * WHERE { ?person <http://isA> ?noun }";
    final String topic = "topic";
    final String brokers = "brokers";
    final String pcjId = "12341234";
    final CreatePeriodicPCJ mockCreatePCJ = mock(CreatePeriodicPCJ.class);
    when(mockCreatePCJ.createPeriodicPCJ(eq(instanceName), eq(sparql), eq(topic), eq(brokers))).thenReturn(pcjId);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getCreatePeriodicPCJ()).thenReturn(java.util.Optional.of(mockCreatePCJ));
    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.of(sparql));
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mockSparqlPrompt, mock(UninstallPrompt.class));
    final String message = commands.createPeriodicPcj(topic, brokers);
    // Verify the values that were provided to the command were passed through to CreatePCJ.
    verify(mockCreatePCJ).createPeriodicPCJ(eq(instanceName), eq(sparql), eq(topic), eq(brokers));
    // Verify a message is returned that explains what was created.
    final String expected = "The Periodic PCJ has been created. Its ID is '12341234'.";
    assertEquals(expected, message);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) CreatePeriodicPCJ(org.apache.rya.api.client.CreatePeriodicPCJ) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Aggregations

CreatePeriodicPCJ (org.apache.rya.api.client.CreatePeriodicPCJ)1 RyaClient (org.apache.rya.api.client.RyaClient)1 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)1 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)1 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)1 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)1 Test (org.junit.Test)1