+ public static void addSnapshotSavedLatch(String persistenceId) {
+ snapshotSavedLatches.put(persistenceId, new CountDownLatch(1));
+ }
+
+ public static void addSnapshotDeletedLatch(String persistenceId) {
+ snapshotDeletedLatches.put(persistenceId, new CountDownLatch(1));
+ }
+
+ public static <T> T waitForSavedSnapshot(String persistenceId, Class<T> type) {
+ if(!Uninterruptibles.awaitUninterruptibly(snapshotSavedLatches.get(persistenceId), 5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Snapshot was not saved");
+ }
+
+ return getSnapshots(persistenceId, type).get(0);
+ }
+
+ public static void waitForDeletedSnapshot(String persistenceId) {
+ if(!Uninterruptibles.awaitUninterruptibly(snapshotDeletedLatches.get(persistenceId), 5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Snapshot was not deleted");
+ }
+ }
+