Search in sources :

Example 1 with DeleteKeyFn

use of org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKeyFn in project beam by apache.

the class DatastoreV1Test method testDeleteKeys.

/**
   * Test that valid keys are transformed to delete mutations.
   */
@Test
public void testDeleteKeys() throws Exception {
    Key key = makeKey("bird", "finch").build();
    DeleteKeyFn deleteKeyFn = new DeleteKeyFn();
    Mutation exceptedMutation = makeDelete(key).build();
    assertEquals(deleteKeyFn.apply(key), exceptedMutation);
}
Also used : DeleteKeyFn(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKeyFn) Mutation(com.google.datastore.v1.Mutation) DeleteKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey) Key(com.google.datastore.v1.Key) DatastoreHelper.makeKey(com.google.datastore.v1.client.DatastoreHelper.makeKey) DatastoreV1.isValidKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey) Test(org.junit.Test)

Example 2 with DeleteKeyFn

use of org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKeyFn in project beam by apache.

the class DatastoreV1Test method testDeleteIncompleteKeys.

/**
   * Test that incomplete keys cannot be deleted.
   */
@Test
public void testDeleteIncompleteKeys() throws Exception {
    Key key = makeKey("bird").build();
    DeleteKeyFn deleteKeyFn = new DeleteKeyFn();
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Keys to be deleted from the Cloud Datastore must be complete");
    deleteKeyFn.apply(key);
}
Also used : DeleteKeyFn(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKeyFn) DeleteKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey) Key(com.google.datastore.v1.Key) DatastoreHelper.makeKey(com.google.datastore.v1.client.DatastoreHelper.makeKey) DatastoreV1.isValidKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey) Test(org.junit.Test)

Aggregations

Key (com.google.datastore.v1.Key)2 DatastoreHelper.makeKey (com.google.datastore.v1.client.DatastoreHelper.makeKey)2 DeleteKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey)2 DeleteKeyFn (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKeyFn)2 DatastoreV1.isValidKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey)2 Test (org.junit.Test)2 Mutation (com.google.datastore.v1.Mutation)1