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