expect(storageUtil.schedulerStore.fetchFrameworkId()).andReturn(Optional.of(frameworkId));
expect(storageUtil.lockStore.fetchLocks()).andReturn(ImmutableSet.of(lock));
String lockToken = "token";
expect(storageUtil.jobUpdateStore.fetchAllJobUpdateDetails())
.andReturn(ImmutableSet.of(
new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
new StoredJobUpdateDetails(updateDetails2.newBuilder(), null)));
expectDataWipe();
storageUtil.taskStore.saveTasks(tasks);
storageUtil.quotaStore.saveQuota("steve", ResourceAggregates.none());
expect(storageUtil.attributeStore.saveHostAttributes(attribute)).andReturn(true);
storageUtil.jobStore.saveAcceptedJob(
job.getJobManagerId(),
IJobConfiguration.build(job.getJobConfiguration()));
storageUtil.schedulerStore.saveFrameworkId(frameworkId);
storageUtil.lockStore.saveLock(lock);
storageUtil.jobUpdateStore.saveJobUpdate(
updateDetails1.getUpdate(), Optional.fromNullable(lockToken));
storageUtil.jobUpdateStore.saveJobUpdateEvent(
Iterables.getOnlyElement(updateDetails1.getUpdateEvents()),
updateId1);
storageUtil.jobUpdateStore.saveJobInstanceUpdateEvent(
Iterables.getOnlyElement(updateDetails1.getInstanceEvents()),
updateId1);
storageUtil.jobUpdateStore.saveJobUpdate(
updateDetails2.getUpdate(), Optional.<String>absent());
control.replay();
Snapshot expected = new Snapshot()
.setTimestamp(NOW)
.setTasks(IScheduledTask.toBuildersSet(tasks))
.setQuotaConfigurations(quotas)
.setHostAttributes(ImmutableSet.of(attribute.newBuilder(), legacyAttribute.newBuilder()))
.setJobs(ImmutableSet.of(job))
.setSchedulerMetadata(metadata)
.setLocks(ImmutableSet.of(lock.newBuilder()))
.setJobUpdateDetails(ImmutableSet.of(
new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
new StoredJobUpdateDetails(updateDetails2.newBuilder(), null)));
assertEquals(expected, snapshotStore.createSnapshot());
snapshotStore.applySnapshot(expected);
}