Search in sources :

Example 66 with RyaClient

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

the class RyaAdminCommandsTest method uninstall_no.

@Test
public void uninstall_no() throws Exception {
    // Mock the object that performs the Uninstall command.
    final Uninstall mockUninstall = mock(Uninstall.class);
    // Mock a prompt that says the user does want to uninstall it.
    final UninstallPrompt uninstallPrompt = mock(UninstallPrompt.class);
    when(uninstallPrompt.promptAreYouSure(eq("test_instance"))).thenReturn(false);
    final RyaClient mockClient = mock(RyaClient.class);
    when(mockClient.getUninstall()).thenReturn(mockUninstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockClient);
    state.connectedToInstance("test_instance");
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), uninstallPrompt);
    commands.uninstall();
    // Verify the request was forwarded to the client.
    verify(mockUninstall, never()).uninstall(eq("test_instance"));
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) Uninstall(org.apache.rya.api.client.Uninstall) RyaClient(org.apache.rya.api.client.RyaClient) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 67 with RyaClient

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

the class RyaAdminCommandsTest method uninstall_yes.

@Test
public void uninstall_yes() throws Exception {
    // Mock the object that performs the Uninstall command.
    final Uninstall mockUninstall = mock(Uninstall.class);
    // Mock a prompt that says the user does want to uninstall it.
    final UninstallPrompt uninstallPrompt = mock(UninstallPrompt.class);
    when(uninstallPrompt.promptAreYouSure(eq("test_instance"))).thenReturn(true);
    final RyaClient mockClient = mock(RyaClient.class);
    when(mockClient.getUninstall()).thenReturn(mockUninstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockClient);
    state.connectedToInstance("test_instance");
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), uninstallPrompt);
    commands.uninstall();
    // Verify the request was forwarded to the client.
    verify(mockUninstall).uninstall(eq("test_instance"));
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) Uninstall(org.apache.rya.api.client.Uninstall) RyaClient(org.apache.rya.api.client.RyaClient) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 68 with RyaClient

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

the class RyaAdminCommandsTest method addUser.

@Test
public void addUser() throws Exception {
    // Mock the object that performs the Add User command.
    final AddUser mockAddUser = mock(AddUser.class);
    final RyaClient mockClient = mock(RyaClient.class);
    when(mockClient.getAddUser()).thenReturn(java.util.Optional.of(mockAddUser));
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockClient);
    state.connectedToInstance("test_instance");
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    commands.addUser("alice");
    // Verify the add request was forwarded to the client.
    verify(mockAddUser).addUser(eq("test_instance"), eq("alice"));
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) AddUser(org.apache.rya.api.client.AddUser) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 69 with RyaClient

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

the class RyaAdminCommandsTest method installWithAccumuloParameters.

@Test
public void installWithAccumuloParameters() throws DuplicateInstanceNameException, RyaClientException, IOException {
    // Mock the object that performs the install operation.
    final Install mockInstall = mock(Install.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getInstall()).thenReturn(mockInstall);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    final String instanceName = "unitTests";
    final boolean enableTableHashPrefix = false;
    final boolean enableEntityCentricIndex = true;
    final boolean enableFreeTextIndex = false;
    final boolean enableTemporalIndex = false;
    final boolean enablePcjIndex = true;
    final String fluoPcjAppName = instanceName + "pcj_updater";
    // Execute the command.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(enableTableHashPrefix).setEnableEntityCentricIndex(enableEntityCentricIndex).setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).setFluoPcjAppName(fluoPcjAppName).build();
    final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
    when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
    when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
    when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
    final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.installWithAccumuloParameters(instanceName, enableTableHashPrefix, enableEntityCentricIndex, enableFreeTextIndex, enableTemporalIndex, enablePcjIndex, fluoPcjAppName);
    // Verify the values that were provided to the command were passed through to the Install.
    verify(mockInstall).install(eq(instanceName), eq(installConfig));
    // Verify a message is returned that indicates the success of the operation.
    final String expected = "The Rya instance named 'unitTests' has been installed.";
    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) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 70 with RyaClient

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

the class RyaAdminCommandsTest method getInstanceDetails.

@Test
public void getInstanceDetails() throws InstanceDoesNotExistException, RyaClientException {
    // This test is failed if the default timezone was not EST, so now it's fixed at EST.
    // If you get assert mismatch of EST!=EDT, try the deprecated getTimeZone("EST") instead.
    TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
    // Mock the object that performs the get operation.
    final GetInstanceDetails mockGetInstanceDetails = mock(GetInstanceDetails.class);
    final String instanceName = "test_instance";
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion("1.2.3.4").addUser("alice").addUser("bob").addUser("charlie").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(1252521351L))).addPCJDetails(PCJDetails.builder().setId("pcj 2").setUpdateStrategy(PCJUpdateStrategy.INCREMENTAL))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date(12525211L)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date(125221351L)))).build();
    when(mockGetInstanceDetails.getDetails(eq(instanceName))).thenReturn(Optional.of(details));
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getGetInstanceDetails()).thenReturn(mockGetInstanceDetails);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance(instanceName);
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.printInstanceDetails();
    // Verify the values that were provided to the command were passed through to the GetInstanceDetails.
    verify(mockGetInstanceDetails).getDetails(eq(instanceName));
    // Verify a message is returned that includes the details.
    final String expected = "General Metadata:\n" + "  Instance Name: test_instance\n" + "  RYA Version: 1.2.3.4\n" + "  Users: alice, bob, charlie\n" + "Secondary Indicies:\n" + "  Entity Centric Index:\n" + "    Enabled: true\n" + // RYA-215"    Enabled: true\n" +
    "  Free Text Index:\n" + "    Enabled: true\n" + "  Temporal Index:\n" + "    Enabled: true\n" + "  PCJ Index:\n" + "    Enabled: true\n" + "    Fluo App Name: test_instance_rya_pcj_updater\n" + "    PCJs:\n" + "      ID: pcj 1\n" + "        Update Strategy: BATCH\n" + "        Last Update Time: Thu Jan 15 06:55:21 EST 1970\n" + "      ID: pcj 2\n" + "        Update Strategy: INCREMENTAL\n" + "        Last Update Time: unavailable\n" + "Statistics:\n" + "  Prospector:\n" + "    Last Update Time: Wed Dec 31 22:28:45 EST 1969\n" + "  Join Selectivity:\n" + "    Last Updated Time: Fri Jan 02 05:47:01 EST 1970\n";
    assertEquals(expected, message);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) Test(org.junit.Test)

Aggregations

RyaClient (org.apache.rya.api.client.RyaClient)105 Test (org.junit.Test)76 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)41 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)29 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)26 CliCommand (org.springframework.shell.core.annotation.CliCommand)20 RyaClientException (org.apache.rya.api.client.RyaClientException)18 Install (org.apache.rya.api.client.Install)17 ShellState (org.apache.rya.shell.SharedShellState.ShellState)16 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)16 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)16 RyaDetails (org.apache.rya.api.instance.RyaDetails)14 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)13 IOException (java.io.IOException)11 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)9 Sail (org.openrdf.sail.Sail)9 ValueFactory (org.openrdf.model.ValueFactory)8 HashSet (java.util.HashSet)7 Connector (org.apache.accumulo.core.client.Connector)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7