public void testOversizedProperties() throws Exception {
String massiveString = makeMassiveString();
final List<String> movedProperties = Lists.newArrayList();
SlobId objectId = new SlobId(OBJECT_ID);
CheckedTransaction tx = datastore.beginTransaction();
MutationLog mutationLog =
new MutationLog(datastore,
ROOT_ENTITY_KIND, DELTA_ENTITY_KIND, SNAPSHOT_ENTITY_KIND,
new MutationLog.DefaultDeltaEntityConverter(),
tx, objectId, new TestModel(massiveString), new MutationLog.StateCache(1),
new OversizedPropertyMover.BlobWriteListener() {
@Override public void blobCreated(
Key entityKey, MovableProperty property, BlobKey blobKey) {
movedProperties.add(property.getPropertyName());
}
@Override public void blobDeleted(
Key entityKey, MovableProperty property, BlobKey blobKey) {
throw new AssertionError();
}
});
MutationLog.Appender appender = mutationLog.prepareAppender().getAppender();
ClientId clientId = new ClientId("fake-clientid");
// This will generate one snapshot.
appender.appendAll(
ImmutableList.of(
new ChangeData<String>(clientId, "delta 0 " + massiveString),
new ChangeData<String>(clientId, "delta 1 " + massiveString),
new ChangeData<String>(clientId, "delta 2 " + massiveString)));
// This will generate another snapshot.
appender.append(new ChangeData<String>(clientId, "delta 3 " + massiveString));
appender.finish();
tx.commit();
assertEquals(ImmutableList.of("op", "op", "op", "op", "Data", "Data"), movedProperties);
CheckedTransaction tx2 = datastore.beginTransaction();
MutationLog mutationLog2 =
// TODO: eliminate code duplication
new MutationLog(datastore,
ROOT_ENTITY_KIND, DELTA_ENTITY_KIND, SNAPSHOT_ENTITY_KIND,
new MutationLog.DefaultDeltaEntityConverter(),