Search in sources :

Example 1 with DeletePCJ

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

the class RyaAdminCommandsTest method deletePCJ.

@Test
public void deletePCJ() throws InstanceDoesNotExistException, RyaClientException {
    // Mock the object that performs the delete operation.
    final DeletePCJ mockDeletePCJ = mock(DeletePCJ.class);
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getDeletePCJ()).thenReturn(mockDeletePCJ);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    final String instanceName = "unitTests";
    state.connectedToInstance(instanceName);
    // Execute the command.
    final String pcjId = "123412342";
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.deletePcj(pcjId);
    // Verify the values that were provided to the command were passed through to the DeletePCJ.
    verify(mockDeletePCJ).deletePCJ(eq(instanceName), eq(pcjId));
    // Verify a message is returned that explains what was deleted.
    final String expected = "The PCJ has been deleted.";
    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) DeletePCJ(org.apache.rya.api.client.DeletePCJ) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 2 with DeletePCJ

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

the class AccumuloDeletePCJIT method deletePCJ.

@Test
public void deletePCJ() throws InstanceDoesNotExistException, RyaClientException, PCJStorageException, RepositoryException {
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = new AccumuloCreatePCJ(createConnectionDetails(), accumuloConn);
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(getRyaInstanceName(), sparql);
    // Verify a Query ID was added for the query within the Fluo app.
    List<String> fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
    assertEquals(1, fluoQueryIds.size());
    // Insert some statements into Rya.
    final ValueFactory vf = ryaRepo.getValueFactory();
    ryaConn.add(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    // Verify the correct results were exported.
    fluo.waitForObservers();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
        final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
        final MapBindingSet bob = new MapBindingSet();
        bob.addBinding("x", vf.createURI("http://Bob"));
        final MapBindingSet charlie = new MapBindingSet();
        charlie.addBinding("x", vf.createURI("http://Charlie"));
        final Set<BindingSet> expected = Sets.<BindingSet>newHashSet(bob, charlie);
        assertEquals(expected, results);
        // Delete the PCJ.
        final DeletePCJ deletePCJ = new AccumuloDeletePCJ(createConnectionDetails(), accumuloConn);
        deletePCJ.deletePCJ(getRyaInstanceName(), pcjId);
        // Ensure the PCJ's metadata has been removed from the storage.
        assertTrue(pcjStorage.listPcjs().isEmpty());
        // Ensure the PCJ has been removed from the Fluo application.
        fluo.waitForObservers();
        // Verify a Query ID was added for the query within the Fluo app.
        fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
        assertEquals(0, fluoQueryIds.size());
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) CreatePCJ(org.apache.rya.api.client.CreatePCJ) ValueFactory(org.openrdf.model.ValueFactory) ListQueryIds(org.apache.rya.indexing.pcj.fluo.api.ListQueryIds) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) MapBindingSet(org.openrdf.query.impl.MapBindingSet) DeletePCJ(org.apache.rya.api.client.DeletePCJ) Test(org.junit.Test)

Example 3 with DeletePCJ

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

the class AccumuloDeletePCJIT method deletePCJ_pcjDoesNotExist.

@Test(expected = RyaClientException.class)
public void deletePCJ_pcjDoesNotExist() throws InstanceDoesNotExistException, RyaClientException {
    // Delete the PCJ.
    final DeletePCJ deletePCJ = new AccumuloDeletePCJ(createConnectionDetails(), accumuloConn);
    deletePCJ.deletePCJ(getRyaInstanceName(), "randomID");
}
Also used : DeletePCJ(org.apache.rya.api.client.DeletePCJ) Test(org.junit.Test)

Example 4 with DeletePCJ

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

the class MongoDeletePCJIT method deletePCJ.

@Test
public void deletePCJ() throws Exception {
    final MongoConnectionDetails connectionDetails = getConnectionDetails();
    final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
    final Install installRya = ryaClient.getInstall();
    final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
    installRya.install(conf.getRyaInstanceName(), installConf);
    System.out.println(getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection("instance_details").find().first().toJson());
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
    final DeletePCJ deletePCJ = ryaClient.getDeletePCJ();
    deletePCJ.deletePCJ(conf.getRyaInstanceName(), pcjId);
    // Verify the RyaDetails were updated to include the new PCJ.
    final Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(conf.getRyaInstanceName());
    final ImmutableMap<String, PCJDetails> details = ryaDetails.get().getPCJIndexDetails().getPCJDetails();
    final PCJDetails pcjDetails = details.get(pcjId);
    assertNull(pcjDetails);
}
Also used : CreatePCJ(org.apache.rya.api.client.CreatePCJ) AccumuloCreatePCJ(org.apache.rya.api.client.accumulo.AccumuloCreatePCJ) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) DeletePCJ(org.apache.rya.api.client.DeletePCJ) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) Test(org.junit.Test)

Example 5 with DeletePCJ

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

the class AccumuloDeletePCJIT method deletePCJ_instanceDoesNotExist.

@Test(expected = InstanceDoesNotExistException.class)
public void deletePCJ_instanceDoesNotExist() throws InstanceDoesNotExistException, RyaClientException {
    // Delete a PCJ for a Rya instance that doesn't exist.
    final DeletePCJ deletePCJ = new AccumuloDeletePCJ(createConnectionDetails(), accumuloConn);
    deletePCJ.deletePCJ("doesNotExist", "randomID");
}
Also used : DeletePCJ(org.apache.rya.api.client.DeletePCJ) Test(org.junit.Test)

Aggregations

DeletePCJ (org.apache.rya.api.client.DeletePCJ)5 Test (org.junit.Test)5 CreatePCJ (org.apache.rya.api.client.CreatePCJ)2 RyaClient (org.apache.rya.api.client.RyaClient)2 Install (org.apache.rya.api.client.Install)1 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)1 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)1 AccumuloCreatePCJ (org.apache.rya.api.client.accumulo.AccumuloCreatePCJ)1 RyaDetails (org.apache.rya.api.instance.RyaDetails)1 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)1 ListQueryIds (org.apache.rya.indexing.pcj.fluo.api.ListQueryIds)1 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)1 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)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 ValueFactory (org.openrdf.model.ValueFactory)1 BindingSet (org.openrdf.query.BindingSet)1 MapBindingSet (org.openrdf.query.impl.MapBindingSet)1