use of org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.UpsertFn in project beam by apache.
the class DatastoreV1Test method testAddEntities.
@Test
public /**
* Test that entities with valid keys are transformed to upsert mutations.
*/
void testAddEntities() throws Exception {
Key key = makeKey("bird", "finch").build();
Entity entity = Entity.newBuilder().setKey(key).build();
UpsertFn upsertFn = new UpsertFn();
Mutation expectedMutation = makeUpsert(entity).build();
assertEquals(expectedMutation, upsertFn.apply(entity));
}
use of org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.UpsertFn in project beam by apache.
the class DatastoreV1Test method testAddEntitiesWithIncompleteKeys.
/**
* Test that entities with incomplete keys cannot be updated.
*/
@Test
public void testAddEntitiesWithIncompleteKeys() throws Exception {
Key key = makeKey("bird").build();
Entity entity = Entity.newBuilder().setKey(key).build();
UpsertFn upsertFn = new UpsertFn();
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Entities to be written to the Cloud Datastore must have complete keys");
upsertFn.apply(entity);
}
Aggregations