}
@Test
public void testModifySnapshotBeforeCommit() throws Exception {
expect(snapshotStore.createSnapshot()).andReturn(SNAPSHOT1);
Snapshot modified = SNAPSHOT1.deepCopy().setTasks(ImmutableSet.of(TASK1));
Capture<MutateWork<Object, Exception>> transaction = createCapture();
expect(primaryStorage.write(capture(transaction))).andReturn(null);
distributedStore.persist(modified);
shutDownNow.execute();
control.replay();
clock.advance(INTERVAL);
storageBackup.createSnapshot();
String backup1 = storageBackup.createBackupName();
recovery.stage(backup1);
assertEquals(
IScheduledTask.setFromBuilders(SNAPSHOT1.getTasks()),
recovery.query(Query.unscoped()));
recovery.deleteTasks(Query.taskScoped(Tasks.id(TASK2)));
assertEquals(
IScheduledTask.setFromBuilders(modified.getTasks()),
recovery.query(Query.unscoped()));
recovery.commit();
transaction.getValue().apply(storeProvider);
}