aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [1/3] aurora git commit: Convert test sources to use lambdas throughout.
Date Thu, 10 Dec 2015 18:11:43 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 8613f7b40 -> d5d5a73c4


http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStoreTest.java
index 9d5468c..d035513 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbJobUpdateStoreTest.java
@@ -17,7 +17,6 @@ package org.apache.aurora.scheduler.storage.db;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -49,10 +48,8 @@ import org.apache.aurora.gen.storage.StoredJobUpdateDetails;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.Storage.StorageException;
-import org.apache.aurora.scheduler.storage.Storage.Work.Quiet;
 import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
@@ -122,15 +119,12 @@ public class DbJobUpdateStoreTest {
         instructions.getDesiredState().getInstances(),
         instructions.getSettings().getUpdateOnlyTheseInstances())
         .flatMap(Set::stream)
-        .forEach(new Consumer<Range>() {
-          @Override
-          public void accept(Range range) {
-            if (range.getFirst() == 0) {
-              range.setFirst(1);
-            }
-            if (range.getLast() == 0) {
-              range.setLast(1);
-            }
+        .forEach(range -> {
+          if (range.getFirst() == 0) {
+            range.setFirst(1);
+          }
+          if (range.getLast() == 0) {
+            range.setLast(1);
           }
         });
     return IJobUpdate.build(builder);
@@ -384,14 +378,11 @@ public class DbJobUpdateStoreTest {
 
   @Test
   public void testSaveJobUpdateWithoutEventFailsSelect() {
-    final IJobUpdateKey updateId = makeKey("u3");
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        IJobUpdate update = makeJobUpdate(updateId);
-        storeProvider.getLockStore().saveLock(makeLock(update, "lock1"));
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock1"));
-      }
+    IJobUpdateKey updateId = makeKey("u3");
+    storage.write((NoResult.Quiet) storeProvider -> {
+      IJobUpdate update = makeJobUpdate(updateId);
+      storeProvider.getLockStore().saveLock(makeLock(update, "lock1"));
+      storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock1"));
     });
     assertEquals(Optional.absent(), getUpdateDetails(updateId));
   }
@@ -591,33 +582,29 @@ public class DbJobUpdateStoreTest {
 
   @Test(expected = StorageException.class)
   public void testSaveUpdateWithoutLock() {
-    final IJobUpdate update = makeJobUpdate(makeKey("updateId"));
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock"));
-      }
-    });
+    IJobUpdate update = makeJobUpdate(makeKey("updateId"));
+    storage.write((NoResult.Quiet) storeProvider ->
+        storeProvider.getJobUpdateStore().saveJobUpdate(update, Optional.of("lock")));
   }
 
   @Test(expected = StorageException.class)
   public void testSaveTwoUpdatesForOneJob() {
-    final IJobUpdate update = makeJobUpdate(makeKey("updateId"));
+    IJobUpdate update = makeJobUpdate(makeKey("updateId"));
     saveUpdate(update, Optional.of("lock1"));
     saveUpdate(update, Optional.of("lock2"));
   }
 
   @Test(expected = StorageException.class)
   public void testSaveTwoUpdatesSameJobKey() {
-    final IJobUpdate update1 = makeJobUpdate(makeKey("update1"));
-    final IJobUpdate update2 = makeJobUpdate(makeKey("update2"));
+    IJobUpdate update1 = makeJobUpdate(makeKey("update1"));
+    IJobUpdate update2 = makeJobUpdate(makeKey("update2"));
     saveUpdate(update1, Optional.of("lock1"));
     saveUpdate(update2, Optional.of("lock1"));
   }
 
   @Test
   public void testLockCleared() {
-    final IJobUpdate update = makeJobUpdate(makeKey("update1"));
+    IJobUpdate update = makeJobUpdate(makeKey("update1"));
     saveUpdate(update, Optional.of("lock1"));
 
     removeLock(update, "lock1");
@@ -644,35 +631,32 @@ public class DbJobUpdateStoreTest {
 
   @Test
   public void testGetLockToken() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        final IJobUpdate update1 = makeJobUpdate(UPDATE1);
-        final IJobUpdate update2 = makeJobUpdate(UPDATE2);
-        saveUpdate(update1, Optional.of("lock1"));
-        assertEquals(
-            Optional.of("lock1"),
-            storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
-        assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
-
-        saveUpdate(update2, Optional.of("lock2"));
-        assertEquals(
-            Optional.of("lock1"),
-            storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
-        assertEquals(
-            Optional.of("lock2"),
-            storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
-
-        storeProvider.getLockStore().removeLock(makeLock(update1, "lock1").getKey());
-        assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
-        assertEquals(
-            Optional.of("lock2"),
-            storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
-
-        storeProvider.getLockStore().removeLock(makeLock(update2, "lock2").getKey());
-        assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
-        assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      IJobUpdate update1 = makeJobUpdate(UPDATE1);
+      IJobUpdate update2 = makeJobUpdate(UPDATE2);
+      saveUpdate(update1, Optional.of("lock1"));
+      assertEquals(
+          Optional.of("lock1"),
+          storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
+      assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
+
+      saveUpdate(update2, Optional.of("lock2"));
+      assertEquals(
+          Optional.of("lock1"),
+          storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
+      assertEquals(
+          Optional.of("lock2"),
+          storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
+
+      storeProvider.getLockStore().removeLock(makeLock(update1, "lock1").getKey());
+      assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
+      assertEquals(
+          Optional.of("lock2"),
+          storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
+
+      storeProvider.getLockStore().removeLock(makeLock(update2, "lock2").getKey());
+      assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE1));
+      assertEquals(NO_TOKEN, storeProvider.getJobUpdateStore().getLockToken(UPDATE2));
     });
   }
 
@@ -848,69 +832,38 @@ public class DbJobUpdateStoreTest {
     assertEquals(getUpdateInstructions(key).get(), expected.getInstructions());
   }
 
-  private Optional<IJobUpdate> getUpdate(final IJobUpdateKey key) {
-    return storage.read(new Quiet<Optional<IJobUpdate>>() {
-      @Override
-      public Optional<IJobUpdate> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdate(key);
-      }
-    });
+  private Optional<IJobUpdate> getUpdate(IJobUpdateKey key) {
+    return storage.read(storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdate(key));
   }
 
-  private List<IJobInstanceUpdateEvent> getInstanceEvents(final IJobUpdateKey key, final int id) {
-    return storage.read(new Quiet<List<IJobInstanceUpdateEvent>>() {
-      @Override
-      public List<IJobInstanceUpdateEvent> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchInstanceEvents(key, id);
-      }
-    });
+  private List<IJobInstanceUpdateEvent> getInstanceEvents(IJobUpdateKey key, int id) {
+    return storage.read(
+        storeProvider -> storeProvider.getJobUpdateStore().fetchInstanceEvents(key, id));
   }
 
-  private Optional<IJobUpdateInstructions> getUpdateInstructions(final IJobUpdateKey key) {
-    return storage.read(new Quiet<Optional<IJobUpdateInstructions>>() {
-      @Override
-      public Optional<IJobUpdateInstructions> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdateInstructions(key);
-      }
-    });
+  private Optional<IJobUpdateInstructions> getUpdateInstructions(IJobUpdateKey key) {
+    return storage.read(
+        storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdateInstructions(key));
   }
 
-  private Optional<IJobUpdateDetails> getUpdateDetails(final IJobUpdateKey key) {
-    return storage.read(new Quiet<Optional<IJobUpdateDetails>>() {
-      @Override
-      public Optional<IJobUpdateDetails> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdateDetails(key);
-      }
-    });
+  private Optional<IJobUpdateDetails> getUpdateDetails(IJobUpdateKey key) {
+    return storage.read(
+        storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdateDetails(key));
   }
 
   private Set<StoredJobUpdateDetails> getAllUpdateDetails() {
-    return storage.read(new Quiet<Set<StoredJobUpdateDetails>>() {
-      @Override
-      public Set<StoredJobUpdateDetails> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchAllJobUpdateDetails();
-      }
-    });
+    return storage.read(
+        storeProvider -> storeProvider.getJobUpdateStore().fetchAllJobUpdateDetails());
   }
 
-  private List<IJobUpdateDetails> queryDetails(final JobUpdateQuery query) {
-    return storage.read(new Quiet<List<IJobUpdateDetails>>() {
-      @Override
-      public List<IJobUpdateDetails> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdateDetails(
-            IJobUpdateQuery.build(query));
-      }
-    });
+  private List<IJobUpdateDetails> queryDetails(JobUpdateQuery query) {
+    return storage.read(storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdateDetails(
+        IJobUpdateQuery.build(query)));
   }
 
-  private List<IJobUpdateSummary> getSummaries(final JobUpdateQuery query) {
-    return storage.read(new Quiet<List<IJobUpdateSummary>>() {
-      @Override
-      public List<IJobUpdateSummary> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdateSummaries(
-            IJobUpdateQuery.build(query));
-      }
-    });
+  private List<IJobUpdateSummary> getSummaries(JobUpdateQuery query) {
+    return storage.read(storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdateSummaries(
+        IJobUpdateQuery.build(query)));
   }
 
   private static ILock makeLock(IJobUpdate update, String lockToken) {
@@ -921,80 +874,54 @@ public class DbJobUpdateStoreTest {
         .setUser("fake user"));
   }
 
-  private IJobUpdate saveUpdate(final IJobUpdate update, final Optional<String> lockToken) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        if (lockToken.isPresent()) {
-          storeProvider.getLockStore().saveLock(makeLock(update, lockToken.get()));
-        }
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, lockToken);
-        storeProvider.getJobUpdateStore().saveJobUpdateEvent(
-            update.getSummary().getKey(),
-            FIRST_EVENT);
+  private IJobUpdate saveUpdate(IJobUpdate update, Optional<String> lockToken) {
+    storage.write((NoResult.Quiet) storeProvider -> {
+      if (lockToken.isPresent()) {
+        storeProvider.getLockStore().saveLock(makeLock(update, lockToken.get()));
       }
+      storeProvider.getJobUpdateStore().saveJobUpdate(update, lockToken);
+      storeProvider.getJobUpdateStore().saveJobUpdateEvent(
+          update.getSummary().getKey(),
+          FIRST_EVENT);
     });
 
     return update;
   }
 
-  private IJobUpdate saveUpdateNoEvent(final IJobUpdate update, final Optional<String> lockToken) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        if (lockToken.isPresent()) {
-          storeProvider.getLockStore().saveLock(makeLock(update, lockToken.get()));
-        }
-        storeProvider.getJobUpdateStore().saveJobUpdate(update, lockToken);
+  private IJobUpdate saveUpdateNoEvent(IJobUpdate update, Optional<String> lockToken) {
+    storage.write((NoResult.Quiet) storeProvider -> {
+      if (lockToken.isPresent()) {
+        storeProvider.getLockStore().saveLock(makeLock(update, lockToken.get()));
       }
+      storeProvider.getJobUpdateStore().saveJobUpdate(update, lockToken);
     });
 
     return update;
   }
 
-  private void saveJobEvent(final IJobUpdateEvent event, final IJobUpdateKey key) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().saveJobUpdateEvent(key, event);
-      }
-    });
+  private void saveJobEvent(IJobUpdateEvent event, IJobUpdateKey key) {
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getJobUpdateStore().saveJobUpdateEvent(key, event));
   }
 
-  private void saveJobInstanceEvent(final IJobInstanceUpdateEvent event, final IJobUpdateKey key) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().saveJobInstanceUpdateEvent(key, event);
-      }
-    });
+  private void saveJobInstanceEvent(IJobInstanceUpdateEvent event, IJobUpdateKey key) {
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getJobUpdateStore().saveJobInstanceUpdateEvent(key, event));
   }
 
   private void truncateUpdates() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents();
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents());
   }
 
-  private Set<IJobUpdateKey> pruneHistory(final int retainCount, final long pruningThresholdMs) {
-    return storage.write(new MutateWork.Quiet<Set<IJobUpdateKey>>() {
-      @Override
-      public Set<IJobUpdateKey> apply(MutableStoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().pruneHistory(retainCount, pruningThresholdMs);
-      }
-    });
+  private Set<IJobUpdateKey> pruneHistory(int retainCount, long pruningThresholdMs) {
+    return storage.write(storeProvider ->
+        storeProvider.getJobUpdateStore().pruneHistory(retainCount, pruningThresholdMs));
   }
 
-  private void removeLock(final IJobUpdate update, final String lockToken) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getLockStore().removeLock(makeLock(update, lockToken).getKey());
-      }
-    });
+  private void removeLock(IJobUpdate update, String lockToken) {
+    storage.write((NoResult.Quiet) storeProvider ->
+        storeProvider.getLockStore().removeLock(makeLock(update, lockToken).getKey()));
   }
 
   private IJobUpdate populateExpected(IJobUpdate update) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbLockStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbLockStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbLockStoreTest.java
index 400e99f..8ed58e0 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbLockStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbLockStoreTest.java
@@ -15,7 +15,6 @@ package org.apache.aurora.scheduler.storage.db;
 
 import java.io.IOException;
 import java.util.Optional;
-import java.util.Set;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -24,11 +23,7 @@ import org.apache.aurora.gen.Lock;
 import org.apache.aurora.gen.LockKey;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork;
 import org.apache.aurora.scheduler.storage.Storage.StorageException;
-import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.Work.Quiet;
 import org.apache.aurora.scheduler.storage.entities.ILock;
 import org.apache.aurora.scheduler.storage.entities.ILockKey;
 import org.apache.aurora.scheduler.storage.testing.StorageEntityUtil;
@@ -42,47 +37,31 @@ public class DbLockStoreTest {
 
   private Storage storage;
 
-  private void assertLocks(final ILock... expected) {
+  private void assertLocks(ILock... expected) {
     assertEquals(
         ImmutableSet.<ILock>builder().add(expected).build(),
-        storage.read(new Quiet<Set<ILock>>() {
-          @Override
-          public Set<ILock> apply(Storage.StoreProvider storeProvider) {
-            return storeProvider.getLockStore().fetchLocks();
-          }
-        }));
+        storage.read(storeProvider -> storeProvider.getLockStore().fetchLocks()));
   }
 
-  private Optional<ILock> getLock(final ILockKey key) {
-    return storage.read(new Quiet<Optional<ILock>>() {
-      @Override
-      public Optional<ILock> apply(StoreProvider storeProvider) {
-        return storeProvider.getLockStore().fetchLock(key);
-      }
-    });
+  private Optional<ILock> getLock(ILockKey key) {
+    return storage.read(storeProvider -> storeProvider.getLockStore().fetchLock(key));
   }
 
-  private void saveLocks(final ILock... locks) {
-    storage.write(new MutateWork.Quiet<Void>() {
-      @Override
-      public Void apply(MutableStoreProvider storeProvider) {
-        for (ILock lock : locks) {
-          storeProvider.getLockStore().saveLock(lock);
-        }
-        return null;
+  private void saveLocks(ILock... locks) {
+    storage.write(storeProvider -> {
+      for (ILock lock : locks) {
+        storeProvider.getLockStore().saveLock(lock);
       }
+      return null;
     });
   }
 
-  private void removeLocks(final ILock... locks) {
-    storage.write(new MutateWork.Quiet<Void>() {
-      @Override
-      public Void apply(MutableStoreProvider storeProvider) {
-        for (ILock lock : locks) {
-          storeProvider.getLockStore().removeLock(lock.getKey());
-        }
-        return null;
+  private void removeLocks(ILock... locks) {
+    storage.write(storeProvider -> {
+      for (ILock lock : locks) {
+        storeProvider.getLockStore().removeLock(lock.getKey());
       }
+      return null;
     });
   }
 
@@ -196,12 +175,9 @@ public class DbLockStoreTest {
     saveLocks(lock1, lock2);
     assertLocks(lock1, lock2);
 
-    storage.write(new MutateWork.Quiet<Void>() {
-      @Override
-      public Void apply(MutableStoreProvider storeProvider) {
-        storeProvider.getLockStore().deleteLocks();
-        return null;
-      }
+    storage.write(storeProvider -> {
+      storeProvider.getLockStore().deleteLocks();
+      return null;
     });
 
     assertLocks();

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbQuotaStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbQuotaStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbQuotaStoreTest.java
index ff7afcf..e0ec995 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbQuotaStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbQuotaStoreTest.java
@@ -21,10 +21,7 @@ import com.google.common.collect.ImmutableMap;
 
 import org.apache.aurora.gen.ResourceAggregate;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork;
-import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.Work;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
 import org.apache.aurora.scheduler.storage.testing.StorageEntityUtil;
 import org.junit.Before;
@@ -88,51 +85,28 @@ public class DbQuotaStoreTest {
     assertQuotas(ImmutableMap.of(ROLE_A, QUOTA_B));
   }
 
-  private void save(final String role, final IResourceAggregate quota) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getQuotaStore().saveQuota(role, quota);
-      }
-    });
+  private void save(String role, IResourceAggregate quota) {
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getQuotaStore().saveQuota(role, quota));
   }
 
-  private Optional<IResourceAggregate> select(final String role) {
-    return storage.read(new Work.Quiet<Optional<IResourceAggregate>>() {
-      @Override
-      public Optional<IResourceAggregate> apply(StoreProvider storeProvider) {
-        return storeProvider.getQuotaStore().fetchQuota(role);
-      }
-    });
+  private Optional<IResourceAggregate> select(String role) {
+    return storage.read(storeProvider -> storeProvider.getQuotaStore().fetchQuota(role));
   }
 
   private void assertQuotas(Map<String, IResourceAggregate> quotas) {
     assertEquals(
         quotas,
-        storage.read(new Work.Quiet<Map<String, IResourceAggregate>>() {
-          @Override
-          public Map<String, IResourceAggregate> apply(StoreProvider storeProvider) {
-            return storeProvider.getQuotaStore().fetchQuotas();
-          }
-        })
+        storage.read(storeProvider -> storeProvider.getQuotaStore().fetchQuotas())
     );
   }
 
-  private void delete(final String role) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getQuotaStore().removeQuota(role);
-      }
-    });
+  private void delete(String role) {
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getQuotaStore().removeQuota(role));
   }
 
   private void deleteAll() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getQuotaStore().deleteQuotas();
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider -> storeProvider.getQuotaStore().deleteQuotas());
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStoreTest.java
index 36ff3a5..a6320bf 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbSchedulerStoreTest.java
@@ -18,10 +18,7 @@ import java.io.IOException;
 import com.google.common.base.Optional;
 
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork;
-import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.Work;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -45,21 +42,12 @@ public class DbSchedulerStoreTest {
     assertEquals(Optional.of("b"), select());
   }
 
-  private void save(final String id) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getSchedulerStore().saveFrameworkId(id);
-      }
-    });
+  private void save(String id) {
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getSchedulerStore().saveFrameworkId(id));
   }
 
   private Optional<String> select() {
-    return storage.read(new Work.Quiet<Optional<String>>() {
-      @Override
-      public Optional<String> apply(StoreProvider storeProvider) {
-        return storeProvider.getSchedulerStore().fetchFrameworkId();
-      }
-    });
+    return storage.read(storeProvider -> storeProvider.getSchedulerStore().fetchFrameworkId());
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
index a0bd34b..214e287 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
@@ -22,8 +22,8 @@ import org.apache.aurora.scheduler.storage.JobUpdateStore;
 import org.apache.aurora.scheduler.storage.LockStore;
 import org.apache.aurora.scheduler.storage.QuotaStore;
 import org.apache.aurora.scheduler.storage.SchedulerStore;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.Storage.StorageException;
 import org.apache.aurora.scheduler.storage.Storage.Work;
 import org.apache.aurora.scheduler.storage.TaskStore;
@@ -31,7 +31,6 @@ import org.apache.ibatis.exceptions.PersistenceException;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
@@ -93,12 +92,9 @@ public class DbStorageTest extends EasyMockTest {
 
   private IExpectationSetters<?> expectGateClosed() throws Exception {
     return expect(gatedWorkQueue.closeDuring(EasyMock.anyObject()))
-        .andAnswer(new IAnswer<Object>() {
-          @Override
-          public Object answer() throws Throwable {
-            GatedOperation<?, ?> op = (GatedOperation<?, ?>) EasyMock.getCurrentArguments()[0];
-            return op.doWithGateClosed();
-          }
+        .andAnswer(() -> {
+          GatedOperation<?, ?> op = (GatedOperation<?, ?>) EasyMock.getCurrentArguments()[0];
+          return op.doWithGateClosed();
         });
   }
 
@@ -134,20 +130,12 @@ public class DbStorageTest extends EasyMockTest {
 
     control.replay();
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        noopWrite();
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider -> noopWrite());
   }
 
   private void noopWrite() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        // No-op.
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      // No-op.
     });
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/log/LogManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/LogManagerTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/LogManagerTest.java
index 36900a8..9cae0c4 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/LogManagerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/LogManagerTest.java
@@ -76,14 +76,11 @@ public class LogManagerTest extends EasyMockTest {
   private static final Amount<Integer, Data> NO_FRAMES_EVER_SIZE =
       Amount.of(Integer.MAX_VALUE, Data.GB);
 
-  private static final Function<LogEntry, byte[]> ENCODE = new Function<LogEntry, byte[]>() {
-    @Override
-    public byte[] apply(LogEntry entry) {
-      try {
-        return encode(entry);
-      } catch (CodingException e) {
-        throw new RuntimeException(e);
-      }
+  private static final Function<LogEntry, byte[]> ENCODE = entry -> {
+    try {
+      return encode(entry);
+    } catch (CodingException e) {
+      throw new RuntimeException(e);
     }
   };
 
@@ -298,12 +295,7 @@ public class LogManagerTest extends EasyMockTest {
       this.chunkSize = chunkSize;
       this.header = LogEntry.frame(header);
       this.chunks = ImmutableList.copyOf(Iterables.transform(chunks,
-          new Function<Frame, LogEntry>() {
-            @Override
-            public LogEntry apply(Frame frame) {
-              return LogEntry.frame(frame);
-            }
-          }));
+          LogEntry::frame));
     }
   }
 
@@ -533,12 +525,7 @@ public class LogManagerTest extends EasyMockTest {
 
   private SaveTasks createSaveTasks(String... taskIds) {
     return new SaveTasks(ImmutableSet.copyOf(Iterables.transform(ImmutableList.copyOf(taskIds),
-        new Function<String, ScheduledTask>() {
-          @Override
-          public ScheduledTask apply(String taskId) {
-            return new ScheduledTask().setAssignedTask(new AssignedTask().setTaskId(taskId));
-          }
-        })));
+        taskId -> new ScheduledTask().setAssignedTask(new AssignedTask().setTaskId(taskId)))));
   }
 
   private RemoveTasks createRemoveTasks(String... taskIds) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
index cc777b2..6f31206 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/LogStorageTest.java
@@ -87,10 +87,10 @@ import org.apache.aurora.scheduler.log.Log.Position;
 import org.apache.aurora.scheduler.log.Log.Stream;
 import org.apache.aurora.scheduler.storage.AttributeStore;
 import org.apache.aurora.scheduler.storage.SnapshotStore;
-import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult.Quiet;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent;
@@ -109,7 +109,6 @@ import org.apache.aurora.scheduler.storage.log.testing.LogOpMatcher.StreamMatche
 import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -146,20 +145,17 @@ public class LogStorageTest extends EasyMockTest {
     log = createMock(Log.class);
     snapshotDeduplicator = createMock(SnapshotDeduplicator.class);
 
-    StreamManagerFactory streamManagerFactory = new StreamManagerFactory() {
-      @Override
-      public StreamManager create(Stream logStream) {
-        HashFunction md5 = Hashing.md5();
-        return new StreamManagerImpl(
-            logStream,
-            new EntrySerializer.EntrySerializerImpl(
-                Amount.of(1, Data.GB),
-                md5),
-            false,
-            md5,
-            snapshotDeduplicator,
-            false);
-      }
+    StreamManagerFactory streamManagerFactory = logStream -> {
+      HashFunction md5 = Hashing.md5();
+      return new StreamManagerImpl(
+          logStream,
+          new EntrySerializer.EntrySerializerImpl(
+              Amount.of(1, Data.GB),
+              md5),
+          false,
+          md5,
+          snapshotDeduplicator,
+          false);
     };
     LogManager logManager = new LogManager(log, streamManagerFactory);
 
@@ -199,43 +195,31 @@ public class LogStorageTest extends EasyMockTest {
     // Our start should recover the log and then forward to the underlying storage start of the
     // supplied initialization logic.
     final AtomicBoolean initialized = new AtomicBoolean(false);
-    MutateWork.NoResult.Quiet initializationLogic = new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider provider) {
-        // Creating a mock and expecting apply(storeProvider) does not work here for whatever
-        // reason.
-        initialized.set(true);
-      }
+    MutateWork.NoResult.Quiet initializationLogic = provider -> {
+      // Creating a mock and expecting apply(storeProvider) does not work here for whatever
+      // reason.
+      initialized.set(true);
     };
 
     final Capture<MutateWork.NoResult.Quiet> recoverAndInitializeWork = createCapture();
     storageUtil.storage.write(capture(recoverAndInitializeWork));
-    expectLastCall().andAnswer(new IAnswer<Void>() {
-      @Override
-      public Void answer() throws Throwable {
-        recoverAndInitializeWork.getValue().apply(storageUtil.mutableStoreProvider);
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      recoverAndInitializeWork.getValue().apply(storageUtil.mutableStoreProvider);
+      return null;
     });
 
     final Capture<MutateWork<Void, RuntimeException>> recoveryWork = createCapture();
     expect(storageUtil.storage.write(capture(recoveryWork))).andAnswer(
-        new IAnswer<Void>() {
-          @Override
-          public Void answer() {
-            recoveryWork.getValue().apply(storageUtil.mutableStoreProvider);
-            return null;
-          }
+        () -> {
+          recoveryWork.getValue().apply(storageUtil.mutableStoreProvider);
+          return null;
         });
 
     final Capture<MutateWork<Void, RuntimeException>> initializationWork = createCapture();
     expect(storageUtil.storage.write(capture(initializationWork))).andAnswer(
-        new IAnswer<Void>() {
-          @Override
-          public Void answer() {
-            initializationWork.getValue().apply(storageUtil.mutableStoreProvider);
-            return null;
-          }
+        () -> {
+          initializationWork.getValue().apply(storageUtil.mutableStoreProvider);
+          return null;
         });
 
     // We should perform a snapshot when the snapshot thread runs.
@@ -252,12 +236,9 @@ public class LogStorageTest extends EasyMockTest {
     stream.truncateBefore(position);
     final Capture<MutateWork<Void, RuntimeException>> snapshotWork = createCapture();
     expect(storageUtil.storage.write(capture(snapshotWork))).andAnswer(
-        new IAnswer<Void>() {
-          @Override
-          public Void answer() {
-            snapshotWork.getValue().apply(storageUtil.mutableStoreProvider);
-            return null;
-          }
+        () -> {
+          snapshotWork.getValue().apply(storageUtil.mutableStoreProvider);
+          return null;
         }).anyTimes();
 
     // Populate all LogEntry types.
@@ -390,13 +371,10 @@ public class LogStorageTest extends EasyMockTest {
     }
 
     storageUtil.storage.bulkLoad(EasyMock.anyObject());
-    expectLastCall().andAnswer(new IAnswer<MutateWork.NoResult<?>>() {
-      @Override
-      public NoResult<?> answer() throws Throwable {
-        MutateWork.NoResult work = (MutateWork.NoResult<?>) EasyMock.getCurrentArguments()[0];
-        work.apply(storageUtil.mutableStoreProvider);
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      NoResult work = (NoResult<?>) EasyMock.getCurrentArguments()[0];
+      work.apply(storageUtil.mutableStoreProvider);
+      return null;
     });
     expect(stream.readAll()).andReturn(entryBuilder.build().iterator());
   }
@@ -426,41 +404,29 @@ public class LogStorageTest extends EasyMockTest {
       // Simulate NOOP initialization work
       // Creating a mock and expecting apply(storeProvider) does not work here for whatever
       // reason.
-      MutateWork.NoResult.Quiet initializationLogic = new NoResult.Quiet() {
-        @Override
-        public void execute(Storage.MutableStoreProvider storeProvider) {
-          // No-op.
-        }
+      MutateWork.NoResult.Quiet initializationLogic = storeProvider -> {
+        // No-op.
       };
 
       final Capture<MutateWork.NoResult.Quiet> recoverAndInitializeWork = createCapture();
       storageUtil.storage.write(capture(recoverAndInitializeWork));
-      expectLastCall().andAnswer(new IAnswer<Void>() {
-        @Override
-        public Void answer() throws Throwable {
-          recoverAndInitializeWork.getValue().apply(storageUtil.mutableStoreProvider);
-          return null;
-        }
+      expectLastCall().andAnswer(() -> {
+        recoverAndInitializeWork.getValue().apply(storageUtil.mutableStoreProvider);
+        return null;
       });
 
       storageUtil.storage.bulkLoad(EasyMock.anyObject());
-      expectLastCall().andAnswer(new IAnswer<MutateWork.NoResult<?>>() {
-        @Override
-        public NoResult<?> answer() throws Throwable {
-          MutateWork.NoResult work = (MutateWork.NoResult<?>) EasyMock.getCurrentArguments()[0];
-          work.apply(storageUtil.mutableStoreProvider);
-          return null;
-        }
+      expectLastCall().andAnswer(() -> {
+        NoResult work = (NoResult<?>) EasyMock.getCurrentArguments()[0];
+        work.apply(storageUtil.mutableStoreProvider);
+        return null;
       });
       expect(stream.readAll()).andReturn(Iterators.emptyIterator());
       final Capture<MutateWork<Void, RuntimeException>> recoveryWork = createCapture();
       expect(storageUtil.storage.write(capture(recoveryWork))).andAnswer(
-          new IAnswer<Void>() {
-            @Override
-            public Void answer() {
-              recoveryWork.getValue().apply(storageUtil.mutableStoreProvider);
-              return null;
-            }
+          () -> {
+            recoveryWork.getValue().apply(storageUtil.mutableStoreProvider);
+            return null;
           });
 
       // Schedule snapshots.
@@ -489,12 +455,7 @@ public class LogStorageTest extends EasyMockTest {
   abstract class MutationFixture extends StorageTestFixture {
     @Override
     protected void runTest() {
-      logStorage.write(new MutateWork.NoResult.Quiet() {
-        @Override
-        public void execute(MutableStoreProvider storeProvider) {
-          performMutations(storeProvider);
-        }
-      });
+      logStorage.write((Quiet) MutationFixture.this::performMutations);
     }
 
     protected abstract void performMutations(MutableStoreProvider storeProvider);
@@ -653,22 +614,18 @@ public class LogStorageTest extends EasyMockTest {
       protected void performMutations(MutableStoreProvider storeProvider) {
         assertEquals(mutated, storeProvider.getUnsafeTaskStore().mutateTasks(query, mutation));
 
-        logStorage.write(new MutateWork.NoResult.Quiet() {
-          @Override
-          public void execute(MutableStoreProvider innerProvider) {
-            innerProvider.getUnsafeTaskStore().deleteTasks(tasksToRemove);
-          }
-        });
+        logStorage.write((NoResult.Quiet)
+            innerProvider -> innerProvider.getUnsafeTaskStore().deleteTasks(tasksToRemove));
       }
     }.run();
   }
 
   @Test
   public void testSaveAndMutateTasks() throws Exception {
-    final Query.Builder query = Query.taskScoped("fred");
-    final Function<IScheduledTask, IScheduledTask> mutation = Functions.identity();
-    final Set<IScheduledTask> saved = ImmutableSet.of(task("a", ScheduleStatus.INIT));
-    final ImmutableSet<IScheduledTask> mutated = ImmutableSet.of(task("a", ScheduleStatus.PENDING));
+    Query.Builder query = Query.taskScoped("fred");
+    Function<IScheduledTask, IScheduledTask> mutation = Functions.identity();
+    Set<IScheduledTask> saved = ImmutableSet.of(task("a", ScheduleStatus.INIT));
+    ImmutableSet<IScheduledTask> mutated = ImmutableSet.of(task("a", ScheduleStatus.PENDING));
 
     new MutationFixture() {
       @Override
@@ -695,10 +652,10 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveAndMutateTasksNoCoalesceUniqueIds() throws Exception {
-    final Query.Builder query = Query.taskScoped("fred");
-    final Function<IScheduledTask, IScheduledTask> mutation = Functions.identity();
-    final Set<IScheduledTask> saved = ImmutableSet.of(task("b", ScheduleStatus.INIT));
-    final ImmutableSet<IScheduledTask> mutated = ImmutableSet.of(task("a", ScheduleStatus.PENDING));
+    Query.Builder query = Query.taskScoped("fred");
+    Function<IScheduledTask, IScheduledTask> mutation = Functions.identity();
+    Set<IScheduledTask> saved = ImmutableSet.of(task("b", ScheduleStatus.INIT));
+    ImmutableSet<IScheduledTask> mutated = ImmutableSet.of(task("a", ScheduleStatus.PENDING));
 
     new MutationFixture() {
       @Override
@@ -729,8 +686,8 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testRemoveTasksQuery() throws Exception {
-    final IScheduledTask task = task("a", ScheduleStatus.FINISHED);
-    final Set<String> taskIds = Tasks.ids(task);
+    IScheduledTask task = task("a", ScheduleStatus.FINISHED);
+    Set<String> taskIds = Tasks.ids(task);
     new MutationFixture() {
       @Override
       protected void setupExpectations() throws Exception {
@@ -749,7 +706,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testRemoveTasksIds() throws Exception {
-    final Set<String> taskIds = ImmutableSet.of("42");
+    Set<String> taskIds = ImmutableSet.of("42");
     new MutationFixture() {
       @Override
       protected void setupExpectations() throws Exception {
@@ -768,9 +725,8 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveQuota() throws Exception {
-    final String role = "role";
-    final IResourceAggregate quota =
-        IResourceAggregate.build(new ResourceAggregate(1.0, 128L, 1024L));
+    String role = "role";
+    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate(1.0, 128L, 1024L));
 
     new MutationFixture() {
       @Override
@@ -790,7 +746,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testRemoveQuota() throws Exception {
-    final String role = "role";
+    String role = "role";
     new MutationFixture() {
       @Override
       protected void setupExpectations() throws Exception {
@@ -808,7 +764,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveLock() throws Exception {
-    final ILock lock = ILock.build(new Lock()
+    ILock lock = ILock.build(new Lock()
         .setKey(LockKey.job(JOB_KEY.newBuilder()))
         .setToken("testLockId")
         .setUser("testUser")
@@ -831,8 +787,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testRemoveLock() throws Exception {
-    final ILockKey lockKey =
-        ILockKey.build(LockKey.job(JOB_KEY.newBuilder()));
+    ILockKey lockKey = ILockKey.build(LockKey.job(JOB_KEY.newBuilder()));
     new MutationFixture() {
       @Override
       protected void setupExpectations() throws Exception {
@@ -851,10 +806,10 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveHostAttributes() throws Exception {
-    final String host = "hostname";
-    final Set<Attribute> attributes =
+    String host = "hostname";
+    Set<Attribute> attributes =
         ImmutableSet.of(new Attribute().setName("attr").setValues(ImmutableSet.of("value")));
-    final Optional<IHostAttributes> hostAttributes = Optional.of(
+    Optional<IHostAttributes> hostAttributes = Optional.of(
         IHostAttributes.build(new HostAttributes()
             .setHost(host)
             .setAttributes(attributes)));
@@ -906,10 +861,8 @@ public class LogStorageTest extends EasyMockTest {
     saveAndAssertJobUpdate(Optional.absent());
   }
 
-  private void saveAndAssertJobUpdate(final Optional<String> lockToken)
-      throws Exception {
-
-    final IJobUpdate update = IJobUpdate.build(new JobUpdate()
+  private void saveAndAssertJobUpdate(Optional<String> lockToken) throws Exception {
+    IJobUpdate update = IJobUpdate.build(new JobUpdate()
         .setSummary(new JobUpdateSummary()
             .setKey(UPDATE_ID.newBuilder())
             .setUser("user"))
@@ -941,7 +894,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveJobUpdateEvent() throws Exception {
-    final IJobUpdateEvent event = IJobUpdateEvent.build(new JobUpdateEvent()
+    IJobUpdateEvent event = IJobUpdateEvent.build(new JobUpdateEvent()
         .setStatus(JobUpdateStatus.ROLLING_BACK)
         .setTimestampMs(12345L));
 
@@ -964,7 +917,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testSaveJobInstanceUpdateEvent() throws Exception {
-    final IJobInstanceUpdateEvent event = IJobInstanceUpdateEvent.build(new JobInstanceUpdateEvent()
+    IJobInstanceUpdateEvent event = IJobInstanceUpdateEvent.build(new JobInstanceUpdateEvent()
         .setAction(JobUpdateAction.INSTANCE_ROLLING_BACK)
         .setTimestampMs(12345L)
         .setInstanceId(0));
@@ -990,7 +943,7 @@ public class LogStorageTest extends EasyMockTest {
 
   @Test
   public void testPruneHistory() throws Exception {
-    final PruneJobUpdateHistory pruneHistory = new PruneJobUpdateHistory()
+    PruneJobUpdateHistory pruneHistory = new PruneJobUpdateHistory()
         .setHistoryPruneThresholdMs(1L)
         .setPerJobRetainCount(1);
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/mem/InMemTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/InMemTaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/InMemTaskStoreTest.java
index a39f690..d18ce20 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/InMemTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/InMemTaskStoreTest.java
@@ -22,14 +22,13 @@ import com.google.inject.util.Modules;
 import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.storage.AbstractTaskStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.TaskStore;
 import org.apache.aurora.scheduler.storage.db.DbModule;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.junit.Test;
 
 import static org.apache.aurora.common.inject.Bindings.KeyFactory.PLAIN;
-
 import static org.junit.Assert.assertEquals;
 
 public class InMemTaskStoreTest extends AbstractTaskStoreTest {
@@ -52,14 +51,11 @@ public class InMemTaskStoreTest extends AbstractTaskStoreTest {
   @Test
   public void testSecondaryIndexConsistency() {
     // Test for regression of AURORA-1305.
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        TaskStore.Mutable taskStore = storeProvider.getUnsafeTaskStore();
-        taskStore.saveTasks(ImmutableSet.of(TASK_A));
-        taskStore.deleteTasks(Tasks.ids(TASK_A));
-        assertEquals(0L, statsProvider.getLongValue(MemTaskStore.getIndexSizeStatName("job")));
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      TaskStore.Mutable taskStore = storeProvider.getUnsafeTaskStore();
+      taskStore.saveTasks(ImmutableSet.of(TASK_A));
+      taskStore.deleteTasks(Tasks.ids(TASK_A));
+      assertEquals(0L, statsProvider.getLongValue(MemTaskStore.getIndexSizeStatName("job")));
     });
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/mem/StorageTransactionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/StorageTransactionTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/StorageTransactionTest.java
index d40e75a..ba5969a 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/StorageTransactionTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/StorageTransactionTest.java
@@ -14,7 +14,6 @@
 package org.apache.aurora.scheduler.storage.mem;
 
 import java.util.Set;
-import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -33,10 +32,8 @@ import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork;
-import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.Work;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
@@ -67,35 +64,22 @@ public class StorageTransactionTest extends TearDownTestCase {
   public void testConcurrentReaders() throws Exception {
     // Validate that a slow read does not block another read.
 
-    final CountDownLatch slowReadStarted = new CountDownLatch(1);
-    final CountDownLatch slowReadFinished = new CountDownLatch(1);
-
-    Future<String> future = executor.submit(new Callable<String>() {
-      @Override
-      public String call() throws Exception {
-        return storage.read(new Work.Quiet<String>() {
-          @Override
-          public String apply(StoreProvider storeProvider) {
-            slowReadStarted.countDown();
-            try {
-              slowReadFinished.await();
-            } catch (InterruptedException e) {
-              fail(e.getMessage());
-            }
-            return "slowResult";
-          }
-        });
+    CountDownLatch slowReadStarted = new CountDownLatch(1);
+    CountDownLatch slowReadFinished = new CountDownLatch(1);
+
+    Future<String> future = executor.submit(() -> storage.read(storeProvider -> {
+      slowReadStarted.countDown();
+      try {
+        slowReadFinished.await();
+      } catch (InterruptedException e) {
+        fail(e.getMessage());
       }
-    });
+      return "slowResult";
+    }));
 
     slowReadStarted.await();
 
-    String fastResult = storage.read(new Work.Quiet<String>() {
-      @Override
-      public String apply(StoreProvider storeProvider) {
-        return "fastResult";
-      }
-    });
+    String fastResult = storage.read(storeProvider -> "fastResult");
     assertEquals("fastResult", fastResult);
     slowReadFinished.countDown();
     assertEquals("slowResult", future.get());
@@ -117,129 +101,87 @@ public class StorageTransactionTest extends TearDownTestCase {
     }
   }
 
-  private void expectTasks(final String... taskIds) {
-    storage.read(new Work.Quiet<Void>() {
-      @Override
-      public Void apply(StoreProvider storeProvider) {
-        Query.Builder query = Query.unscoped();
-        Set<String> ids = FluentIterable.from(storeProvider.getTaskStore().fetchTasks(query))
-            .transform(Tasks::id)
-            .toSet();
-        assertEquals(ImmutableSet.<String>builder().add(taskIds).build(), ids);
-        return null;
-      }
+  private void expectTasks(String... taskIds) {
+    storage.read(storeProvider -> {
+      Query.Builder query = Query.unscoped();
+      Set<String> ids = FluentIterable.from(storeProvider.getTaskStore().fetchTasks(query))
+          .transform(Tasks::id)
+          .toSet();
+      assertEquals(ImmutableSet.<String>builder().add(taskIds).build(), ids);
+      return null;
     });
   }
 
   @Test
   public void testWritesUnderTransaction() {
-    final IResourceAggregate quota = IResourceAggregate
-            .build(new ResourceAggregate().setDiskMb(100).setNumCpus(2.0).setRamMb(512));
+    IResourceAggregate quota = IResourceAggregate
+        .build(new ResourceAggregate().setDiskMb(100).setNumCpus(2.0).setRamMb(512));
 
     try {
-      storage.write(new MutateWork.NoResult.Quiet() {
-        @Override
-        public void execute(MutableStoreProvider storeProvider) {
-          storeProvider.getQuotaStore().saveQuota("a", quota);
-          throw new CustomException();
-        }
+      storage.write(storeProvider -> {
+        storeProvider.getQuotaStore().saveQuota("a", quota);
+        throw new CustomException();
       });
       fail("Expected CustomException to be thrown.");
     } catch (CustomException e) {
       // Expected
     }
 
-    storage.read(new Work.Quiet<Void>() {
-      @Override
-      public Void apply(StoreProvider storeProvider) {
-        // If the previous write was under a transaction then there would be no quota records.
-        assertEquals(ImmutableMap.of(),
-            storeProvider.getQuotaStore().fetchQuotas());
-        return null;
-      }
+    storage.read(storeProvider -> {
+      // If the previous write was under a transaction then there would be no quota records.
+      assertEquals(ImmutableMap.of(),
+          storeProvider.getQuotaStore().fetchQuotas());
+      return null;
     });
   }
 
   @Test
   public void testOperations() {
-    expectWriteFail(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a"), makeTask("b")));
-        throw new CustomException();
-      }
+    expectWriteFail(storeProvider -> {
+      storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a"), makeTask("b")));
+      throw new CustomException();
     });
     expectTasks();
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a"), makeTask("b")));
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider ->
+        storeProvider.getUnsafeTaskStore().saveTasks(
+            ImmutableSet.of(makeTask("a"), makeTask("b"))));
     expectTasks("a", "b");
 
-    expectWriteFail(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().deleteAllTasks();
-        throw new CustomException();
-      }
+    expectWriteFail(storeProvider -> {
+      storeProvider.getUnsafeTaskStore().deleteAllTasks();
+      throw new CustomException();
     });
     expectTasks("a", "b");
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().deleteAllTasks();
-      }
-    });
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getUnsafeTaskStore().deleteAllTasks());
 
-    expectWriteFail(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a")));
-        throw new CustomException();
-      }
+    expectWriteFail(storeProvider -> {
+      storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a")));
+      throw new CustomException();
     });
     expectTasks();
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a")));
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider ->
+        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("a"))));
 
     // Nested transaction where inner transaction fails.
-    expectWriteFail(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("c")));
-        storage.write(new MutateWork.NoResult.Quiet() {
-          @Override
-          public void execute(MutableStoreProvider storeProvider) {
-            storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("d")));
-            throw new CustomException();
-          }
-        });
-      }
+    expectWriteFail((NoResult.Quiet) storeProvider -> {
+      storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("c")));
+      storage.write(storeProvider1 -> {
+        storeProvider1.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("d")));
+        throw new CustomException();
+      });
     });
     expectTasks("a");
 
     // Nested transaction where outer transaction fails.
-    expectWriteFail(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("c")));
-        storage.write(new MutateWork.NoResult.Quiet() {
-          @Override
-          public void execute(MutableStoreProvider storeProvider) {
-            storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("d")));
-          }
-        });
-        throw new CustomException();
-      }
+    expectWriteFail(storeProvider -> {
+      storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("c")));
+      storage.write((NoResult.Quiet) storeProvider1 ->
+          storeProvider1.getUnsafeTaskStore().saveTasks(ImmutableSet.of(makeTask("d"))));
+      throw new CustomException();
     });
     expectTasks("a");
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java b/src/test/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
index dcc4ae9..bf344a4 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/testing/StorageTestUtil.java
@@ -31,7 +31,6 @@ import org.apache.aurora.scheduler.storage.Storage.Work;
 import org.apache.aurora.scheduler.storage.TaskStore;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.easymock.Capture;
-import org.easymock.IAnswer;
 import org.easymock.IExpectationSetters;
 
 import static org.easymock.EasyMock.capture;
@@ -74,24 +73,15 @@ public class StorageTestUtil {
   }
 
   public <T> IExpectationSetters<T> expectRead() {
-    final Capture<Work<T, RuntimeException>> work = EasyMockTest.createCapture();
+    Capture<Work<T, RuntimeException>> work = EasyMockTest.createCapture();
     return expect(storage.<T, RuntimeException>read(capture(work)))
-        .andAnswer(new IAnswer<T>() {
-          @Override
-          public T answer() {
-            return work.getValue().apply(storeProvider);
-          }
-        });
+        .andAnswer(() -> work.getValue().apply(storeProvider));
   }
 
   public <T> IExpectationSetters<T> expectWrite() {
-    final Capture<MutateWork<T, RuntimeException>> work = EasyMockTest.createCapture();
-    return expect(storage.<T, RuntimeException>write(capture(work))).andAnswer(new IAnswer<T>() {
-      @Override
-      public T answer() {
-        return work.getValue().apply(mutableStoreProvider);
-      }
-    });
+    Capture<MutateWork<T, RuntimeException>> work = EasyMockTest.createCapture();
+    return expect(storage.<T, RuntimeException>write(capture(work)))
+        .andAnswer(() -> work.getValue().apply(mutableStoreProvider));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
index f1f9f77..9082a31 100644
--- a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
+++ b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
@@ -59,17 +59,14 @@ public final class FakeScheduledExecutor extends FakeClock {
     return executor;
   }
 
-  private static IAnswer<Object> answerExecuteWithDelay(final FakeScheduledExecutor executor) {
-    return new IAnswer<Object>() {
-      @Override
-      public Object answer() {
-        Object[] args = EasyMock.getCurrentArguments();
-        Runnable work = (Runnable) args[0];
-        @SuppressWarnings("unchecked")
-        Amount<Long, Time> delay = (Amount<Long, Time>) args[1];
-        addDelayedWork(executor, delay.as(Time.MILLISECONDS), work);
-        return null;
-      }
+  private static IAnswer<Object> answerExecuteWithDelay(FakeScheduledExecutor executor) {
+    return () -> {
+      Object[] args = EasyMock.getCurrentArguments();
+      Runnable work = (Runnable) args[0];
+      @SuppressWarnings("unchecked")
+      Amount<Long, Time> delay = (Amount<Long, Time>) args[1];
+      addDelayedWork(executor, delay.as(Time.MILLISECONDS), work);
+      return null;
     };
   }
 
@@ -87,28 +84,22 @@ public final class FakeScheduledExecutor extends FakeClock {
   }
 
   private static IAnswer<Void> answerExecute() {
-    return new IAnswer<Void>() {
-      @Override
-      public Void answer() throws Throwable {
-        Object[] args = EasyMock.getCurrentArguments();
-        Runnable work = (Runnable) args[0];
-        work.run();
-        return null;
-      }
+    return () -> {
+      Object[] args = EasyMock.getCurrentArguments();
+      Runnable work = (Runnable) args[0];
+      work.run();
+      return null;
     };
   }
 
-  private static IAnswer<Object> answerSchedule(final FakeScheduledExecutor executor) {
-    return new IAnswer<Object>() {
-      @Override
-      public Object answer() {
-        Object[] args = EasyMock.getCurrentArguments();
-        Runnable work = (Runnable) args[0];
-        long value = (Long) args[1];
-        TimeUnit unit = (TimeUnit) args[2];
-        addDelayedWork(executor, toMillis(value, unit), work);
-        return null;
-      }
+  private static IAnswer<Object> answerSchedule(FakeScheduledExecutor executor) {
+    return () -> {
+      Object[] args = EasyMock.getCurrentArguments();
+      Runnable work = (Runnable) args[0];
+      long value = (Long) args[1];
+      TimeUnit unit = (TimeUnit) args[2];
+      addDelayedWork(executor, toMillis(value, unit), work);
+      return null;
     };
   }
 
@@ -142,22 +133,19 @@ public final class FakeScheduledExecutor extends FakeClock {
   }
 
   private static IAnswer<ScheduledFuture<?>> answerScheduleAtFixedRate(
-      final FakeScheduledExecutor executor,
-      final int workCount) {
-
-    return new IAnswer<ScheduledFuture<?>>() {
-      @Override
-      public ScheduledFuture<?> answer() {
-        Object[] args = EasyMock.getCurrentArguments();
-        Runnable work = (Runnable) args[0];
-        long initialDelay = (Long) args[1];
-        long period = (Long) args[2];
-        TimeUnit unit = (TimeUnit) args[3];
-        for (int i = 0; i <= workCount; i++) {
-          addDelayedWork(executor, toMillis(initialDelay, unit) + i * toMillis(period, unit), work);
-        }
-        return null;
+      FakeScheduledExecutor executor,
+      int workCount) {
+
+    return () -> {
+      Object[] args = EasyMock.getCurrentArguments();
+      Runnable work = (Runnable) args[0];
+      long initialDelay = (Long) args[1];
+      long period = (Long) args[2];
+      TimeUnit unit = (TimeUnit) args[3];
+      for (int i = 0; i <= workCount; i++) {
+        addDelayedWork(executor, toMillis(initialDelay, unit) + i * toMillis(period, unit), work);
       }
+      return null;
     };
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
index 76b0476..72d2182 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
@@ -74,12 +74,7 @@ final class Fixtures {
       IJobUpdateKey.build(new JobUpdateKey(JOB_KEY.newBuilder(), UPDATE_ID));
   static final UUID UU_ID = UUID.fromString(UPDATE_ID);
   private static final Function<String, ResponseDetail> MESSAGE_TO_DETAIL =
-      new Function<String, ResponseDetail>() {
-        @Override
-        public ResponseDetail apply(String message) {
-          return new ResponseDetail().setMessage(message);
-        }
-      };
+      message -> new ResponseDetail().setMessage(message);
   static final String CRON_SCHEDULE = "0 * * * *";
   static final IResourceAggregate QUOTA =
       IResourceAggregate.build(new ResourceAggregate(10.0, 1024, 2048));

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 1fd106b..129851c 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -13,9 +13,7 @@
  */
 package org.apache.aurora.scheduler.thrift;
 
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Map;
 import java.util.Set;
@@ -215,26 +213,23 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
             auditMessages));
   }
 
-  private static AuroraAdmin.Iface getResponseProxy(final AuroraAdmin.Iface realThrift) {
+  private static AuroraAdmin.Iface getResponseProxy(AuroraAdmin.Iface realThrift) {
     // Capture all API method calls to validate response objects.
     Class<AuroraAdmin.Iface> thriftClass = AuroraAdmin.Iface.class;
     return (AuroraAdmin.Iface) Proxy.newProxyInstance(
         thriftClass.getClassLoader(),
         new Class<?>[] {thriftClass},
-        new InvocationHandler() {
-          @Override
-          public Object invoke(Object o, Method method, Object[] args) throws Throwable {
-            Response response;
-            try {
-              response = (Response) method.invoke(realThrift, args);
-            } catch (InvocationTargetException e) {
-              Throwables.propagateIfPossible(e.getTargetException(), TException.class);
-              throw e;
-            }
-            assertTrue(response.isSetResponseCode());
-            assertNotNull(response.getDetails());
-            return response;
+        (o, method, args) -> {
+          Response response;
+          try {
+            response = (Response) method.invoke(realThrift, args);
+          } catch (InvocationTargetException e) {
+            Throwables.propagateIfPossible(e.getTargetException(), TException.class);
+            throw e;
           }
+          assertTrue(response.isSetResponseCode());
+          assertNotNull(response.getDetails());
+          return response;
         });
   }
 
@@ -393,7 +388,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
     assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
   }
 
-  private void assertMessageMatches(Response response, final String string) {
+  private void assertMessageMatches(Response response, String string) {
     // TODO(wfarner): This test coverage could be much better.  Circle back to apply more thorough
     // response contents testing throughout.
     assertTrue(Iterables.any(response.getDetails(), detail -> detail.getMessage().equals(string)));

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdminTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdminTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdminTest.java
index b755504..065ad42 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdminTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdminTest.java
@@ -16,8 +16,6 @@ package org.apache.aurora.scheduler.thrift.aop;
 import java.lang.reflect.Method;
 import java.util.Collection;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.FluentIterable;
 import com.google.common.reflect.Invokable;
@@ -32,30 +30,20 @@ import static org.junit.Assert.assertEquals;
 public class AnnotatedAuroraAdminTest {
   @Test
   public void testAllAuroraSchedulerManagerIfaceMethodsHaveAuthorizingParam() throws Exception {
-    for (final Method declaredMethod : AuroraSchedulerManager.Iface.class.getDeclaredMethods()) {
+    for (Method declaredMethod : AuroraSchedulerManager.Iface.class.getDeclaredMethods()) {
       Invokable<?, ?> invokable = Invokable.from(declaredMethod);
       Collection<Parameter> parameters = invokable.getParameters();
       Invokable<?, ?> annotatedInvokable = Invokable.from(
           AnnotatedAuroraAdmin.class.getDeclaredMethod(
               invokable.getName(),
               FluentIterable.from(parameters)
-                  .transform(new Function<Parameter, Class<?>>() {
-                    @Override
-                    public Class<?> apply(Parameter input) {
-                      return input.getType().getRawType();
-                    }
-                  })
+                  .transform(input -> input.getType().getRawType())
                   .toList()
                   .toArray(new Class<?>[0])));
 
       Collection<Parameter> annotatedParameters = Collections2.filter(
           annotatedInvokable.getParameters(),
-          new Predicate<Parameter>() {
-            @Override
-            public boolean apply(Parameter input) {
-              return input.getAnnotation(AuthorizingParam.class) != null;
-            }
-          });
+          input -> input.getAnnotation(AuthorizingParam.class) != null);
 
       assertEquals(
           "Method " + invokable + " should have 1 " + AuthorizingParam.class.getName()

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/updater/AddTaskTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/updater/AddTaskTest.java b/src/test/java/org/apache/aurora/scheduler/updater/AddTaskTest.java
index 749e5b8..0583a63 100644
--- a/src/test/java/org/apache/aurora/scheduler/updater/AddTaskTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/updater/AddTaskTest.java
@@ -14,7 +14,6 @@
 package org.apache.aurora.scheduler.updater;
 
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
-
 import org.apache.aurora.gen.InstanceKey;
 import org.apache.aurora.gen.JobUpdateInstructions;
 import org.apache.aurora.gen.JobUpdateSettings;

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java b/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
index 12ee5b8..f7f5275 100644
--- a/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/updater/JobUpdaterIT.java
@@ -76,8 +76,6 @@ import org.apache.aurora.scheduler.state.UUIDGenerator;
 import org.apache.aurora.scheduler.state.UUIDGenerator.UUIDGeneratorImpl;
 import org.apache.aurora.scheduler.storage.JobUpdateStore;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
-import org.apache.aurora.scheduler.storage.Storage.Work;
 import org.apache.aurora.scheduler.storage.db.DbModule;
 import org.apache.aurora.scheduler.storage.entities.IInstanceTaskConfig;
 import org.apache.aurora.scheduler.storage.entities.IJobInstanceUpdateEvent;
@@ -163,7 +161,7 @@ public class JobUpdaterIT extends EasyMockTest {
   public void setUp() {
     // Avoid console spam due to stats registered multiple times.
     Stats.flush();
-    final ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
+    ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
     clock = FakeScheduledExecutor.scheduleExecutor(executor);
     driver = createMock(Driver.class);
     eventBus = new EventBus();
@@ -186,12 +184,7 @@ public class JobUpdaterIT extends EasyMockTest {
                         Amount.of(1L, Time.SECONDS), Amount.of(1L, Time.MINUTES)),
                     FLAPPING_THRESHOLD,
                     Amount.of(1, Time.MINUTES)));
-            bind(EventSink.class).toInstance(new EventSink() {
-              @Override
-              public void post(PubsubEvent event) {
-                eventBus.post(event);
-              }
-            });
+            bind(EventSink.class).toInstance(eventBus::post);
             bind(LockManager.class).to(LockManagerImpl.class);
             bind(UUIDGenerator.class).to(UUIDGeneratorImpl.class);
           }
@@ -231,25 +224,23 @@ public class JobUpdaterIT extends EasyMockTest {
   }
 
   private void changeState(
-      final IJobKey job,
-      final int instanceId,
+      IJobKey job,
+      int instanceId,
       ScheduleStatus status,
       ScheduleStatus... statuses) {
 
-    for (final ScheduleStatus s
+    for (ScheduleStatus s
         : ImmutableList.<ScheduleStatus>builder().add(status).add(statuses).build()) {
 
-      storage.write(new NoResult.Quiet() {
-        @Override
-        public void execute(Storage.MutableStoreProvider storeProvider) {
-          assertEquals(StateChangeResult.SUCCESS, stateManager.changeState(
-              storeProvider,
-              getTaskId(job, instanceId),
-              Optional.absent(),
-              s,
-              Optional.absent()));
-        }
-      });
+      storage.write((NoResult.Quiet) storeProvider ->
+          assertEquals(
+              StateChangeResult.SUCCESS,
+              stateManager.changeState(
+                  storeProvider,
+                  getTaskId(job, instanceId),
+                  Optional.absent(),
+                  s,
+                  Optional.absent())));
     }
   }
 
@@ -261,20 +252,11 @@ public class JobUpdaterIT extends EasyMockTest {
         }
       });
   private static final Function<IJobInstanceUpdateEvent, Integer> EVENT_TO_INSTANCE =
-      new Function<IJobInstanceUpdateEvent, Integer>() {
-        @Override
-        public Integer apply(IJobInstanceUpdateEvent event) {
-          return event.getInstanceId();
-        }
-      };
+      IJobInstanceUpdateEvent::getInstanceId;
 
   private IJobUpdateDetails getDetails() {
-    return storage.read(new Work.Quiet<IJobUpdateDetails>() {
-      @Override
-      public IJobUpdateDetails apply(StoreProvider storeProvider) {
-        return storeProvider.getJobUpdateStore().fetchJobUpdateDetails(UPDATE_ID).get();
-      }
-    });
+    return storage.read(
+        storeProvider -> storeProvider.getJobUpdateStore().fetchJobUpdateDetails(UPDATE_ID).get());
   }
 
   private void assertLatestUpdateMessage(String expected) {
@@ -302,22 +284,15 @@ public class JobUpdaterIT extends EasyMockTest {
     return expectLastCall();
   }
 
-  private void insertPendingTasks(final ITaskConfig task, final Set<Integer> instanceIds) {
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        stateManager.insertPendingTasks(storeProvider, task, instanceIds);
-      }
-    });
+  private void insertPendingTasks(ITaskConfig task, Set<Integer> instanceIds) {
+    storage.write((NoResult.Quiet) storeProvider ->
+        stateManager.insertPendingTasks(storeProvider, task, instanceIds));
   }
 
-  private void insertInitialTasks(final IJobUpdate update) {
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        for (IInstanceTaskConfig config : update.getInstructions().getInitialState()) {
-          insertPendingTasks(config.getTask(), expandInstanceIds(ImmutableSet.of(config)));
-        }
+  private void insertInitialTasks(IJobUpdate update) {
+    storage.write((NoResult.Quiet) storeProvider -> {
+      for (IInstanceTaskConfig config : update.getInstructions().getInitialState()) {
+        insertPendingTasks(config.getTask(), expandInstanceIds(ImmutableSet.of(config)));
       }
     });
   }
@@ -454,18 +429,14 @@ public class JobUpdaterIT extends EasyMockTest {
     JobUpdate builder =
         setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2).newBuilder();
     builder.getInstructions().getSettings().setBlockIfNoPulsesAfterMs((int) PULSE_TIMEOUT_MS);
-    final IJobUpdate update = IJobUpdate.build(builder);
+    IJobUpdate update = IJobUpdate.build(builder);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     changeState(JOB, 1, ASSIGNED, STARTING, RUNNING);
     clock.advance(ONE_DAY);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD);
-      }
-    });
+    storage.write(
+        storeProvider -> saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD));
 
     subscriber.startAsync().awaitRunning();
     ImmutableMultimap.Builder<Integer, JobUpdateAction> actions = ImmutableMultimap.builder();
@@ -499,17 +470,13 @@ public class JobUpdaterIT extends EasyMockTest {
     JobUpdate builder =
         setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 0, OLD_CONFIG)), 1).newBuilder();
     builder.getInstructions().getSettings().setBlockIfNoPulsesAfterMs((int) PULSE_TIMEOUT_MS);
-    final IJobUpdate update = IJobUpdate.build(builder);
+    IJobUpdate update = IJobUpdate.build(builder);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     clock.advance(ONE_DAY);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLL_FORWARD_AWAITING_PULSE);
-      }
-    });
+    storage.write(storeProvider ->
+        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLL_FORWARD_AWAITING_PULSE));
 
     subscriber.startAsync().awaitRunning();
     ImmutableMultimap.Builder<Integer, JobUpdateAction> actions = ImmutableMultimap.builder();
@@ -534,17 +501,13 @@ public class JobUpdaterIT extends EasyMockTest {
     JobUpdate builder =
         setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 0, OLD_CONFIG)), 1).newBuilder();
     builder.getInstructions().getSettings().setBlockIfNoPulsesAfterMs((int) PULSE_TIMEOUT_MS);
-    final IJobUpdate update = IJobUpdate.build(builder);
+    IJobUpdate update = IJobUpdate.build(builder);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     clock.advance(ONE_DAY);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLL_FORWARD_PAUSED);
-      }
-    });
+    storage.write(storeProvider ->
+        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLL_FORWARD_PAUSED));
 
     subscriber.startAsync().awaitRunning();
     ImmutableMultimap.Builder<Integer, JobUpdateAction> actions = ImmutableMultimap.builder();
@@ -571,7 +534,7 @@ public class JobUpdaterIT extends EasyMockTest {
     JobUpdate builder =
         setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2).newBuilder();
     builder.getInstructions().getSettings().setBlockIfNoPulsesAfterMs((int) PULSE_TIMEOUT_MS);
-    final IJobUpdate update = IJobUpdate.build(builder);
+    IJobUpdate update = IJobUpdate.build(builder);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     changeState(JOB, 1, ASSIGNED, STARTING, RUNNING);
@@ -672,18 +635,14 @@ public class JobUpdaterIT extends EasyMockTest {
     JobUpdate builder =
         setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2).newBuilder();
     builder.getInstructions().getSettings().setBlockIfNoPulsesAfterMs((int) PULSE_TIMEOUT_MS);
-    final IJobUpdate update = IJobUpdate.build(builder);
+    IJobUpdate update = IJobUpdate.build(builder);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     changeState(JOB, 1, ASSIGNED, STARTING, RUNNING);
     clock.advance(ONE_DAY);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD);
-      }
-    });
+    storage.write(
+        storeProvider -> saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD));
 
     subscriber.startAsync().awaitRunning();
 
@@ -691,12 +650,9 @@ public class JobUpdaterIT extends EasyMockTest {
     // The update is blocked initially waiting for a pulse.
     assertState(ROLL_FORWARD_AWAITING_PULSE, actions.build());
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents();
-        releaseAllLocks();
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents();
+      releaseAllLocks();
     });
 
     // The pulse still returns OK but the error is handled.
@@ -1069,8 +1025,7 @@ public class JobUpdaterIT extends EasyMockTest {
 
     control.replay();
 
-    final IJobUpdate update =
-        setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2);
+    IJobUpdate update = setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2);
     insertInitialTasks(update);
 
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
@@ -1084,19 +1039,16 @@ public class JobUpdaterIT extends EasyMockTest {
     actions.putAll(0, INSTANCE_UPDATING);
     assertState(ROLLING_FORWARD, actions.build());
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        JobUpdateStore.Mutable store = storeProvider.getJobUpdateStore();
-        store.deleteAllUpdatesAndEvents();
+    storage.write((NoResult.Quiet) storeProvider -> {
+      JobUpdateStore.Mutable store = storeProvider.getJobUpdateStore();
+      store.deleteAllUpdatesAndEvents();
 
-        JobUpdate builder = update.newBuilder();
-        builder.getInstructions().getSettings().setUpdateGroupSize(0);
-        for (ILock lock : lockManager.getLocks()) {
-          lockManager.releaseLock(lock);
-        }
-        saveJobUpdate(store, IJobUpdate.build(builder), ROLLING_FORWARD);
+      JobUpdate builder = update.newBuilder();
+      builder.getInstructions().getSettings().setUpdateGroupSize(0);
+      for (ILock lock : lockManager.getLocks()) {
+        lockManager.releaseLock(lock);
       }
+      saveJobUpdate(store, IJobUpdate.build(builder), ROLLING_FORWARD);
     });
 
     changeState(JOB, 0, KILLED, ASSIGNED, STARTING, RUNNING);
@@ -1142,19 +1094,14 @@ public class JobUpdaterIT extends EasyMockTest {
 
     control.replay();
 
-    final IJobUpdate update =
-        setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2);
+    IJobUpdate update = setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 2);
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     changeState(JOB, 1, ASSIGNED, STARTING, RUNNING);
     clock.advance(ONE_DAY);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD);
-      }
-    });
+    storage.write(
+        storeProvider -> saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD));
 
     subscriber.startAsync().awaitRunning();
 
@@ -1177,15 +1124,11 @@ public class JobUpdaterIT extends EasyMockTest {
   public void testSystemResumeNoLock() throws Exception {
     control.replay();
 
-    final IJobUpdate update =
-        setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 0);
+    IJobUpdate update = setInstanceCount(makeJobUpdate(makeInstanceConfig(0, 1, OLD_CONFIG)), 0);
 
-    storage.write(new NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        ILock lock = saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD);
-        lockManager.releaseLock(lock);
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      ILock lock = saveJobUpdate(storeProvider.getJobUpdateStore(), update, ROLLING_FORWARD);
+      lockManager.releaseLock(lock);
     });
 
     subscriber.startAsync().awaitRunning();
@@ -1196,7 +1139,7 @@ public class JobUpdaterIT extends EasyMockTest {
   public void testImmediatelySuccessfulUpdate() throws Exception {
     control.replay();
 
-    final IJobUpdate update = makeJobUpdate(makeInstanceConfig(0, 2, NEW_CONFIG));
+    IJobUpdate update = makeJobUpdate(makeInstanceConfig(0, 2, NEW_CONFIG));
     insertInitialTasks(update);
     changeState(JOB, 0, ASSIGNED, STARTING, RUNNING);
     changeState(JOB, 1, ASSIGNED, STARTING, RUNNING);
@@ -1209,7 +1152,7 @@ public class JobUpdaterIT extends EasyMockTest {
   public void testNoopUpdateEmptyDiff() throws Exception {
     control.replay();
 
-    final IJobUpdate update = makeJobUpdate();
+    IJobUpdate update = makeJobUpdate();
     JobUpdate builder = update.newBuilder();
     builder.getInstructions().unsetDesiredState();
 


Mime
View raw message