aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [2/3] aurora git commit: Convert test sources to use lambdas throughout.
Date Thu, 10 Dec 2015 18:11:44 GMT
http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java b/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
index f8940ed..73ea3cb 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/local/FakeMaster.java
@@ -124,23 +124,20 @@ public class FakeMaster implements SchedulerDriver, DriverFactory {
     eventBus.post(new Started());
 
     executor.scheduleAtFixedRate(
-        new Runnable() {
-          @Override
-          public void run() {
-            List<Offer> allOffers;
-            synchronized (sentOffers) {
-              synchronized (idleOffers) {
-                sentOffers.putAll(idleOffers);
-                allOffers = ImmutableList.copyOf(idleOffers.values());
-                idleOffers.clear();
-              }
+        () -> {
+          List<Offer> allOffers;
+          synchronized (sentOffers) {
+            synchronized (idleOffers) {
+              sentOffers.putAll(idleOffers);
+              allOffers = ImmutableList.copyOf(idleOffers.values());
+              idleOffers.clear();
             }
+          }
 
-            if (allOffers.isEmpty()) {
-              LOG.info("All offers consumed, suppressing offer cycle.");
-            } else {
-              Futures.getUnchecked(schedulerFuture).resourceOffers(FakeMaster.this, allOffers);
-            }
+          if (allOffers.isEmpty()) {
+            LOG.info("All offers consumed, suppressing offer cycle.");
+          } else {
+            Futures.getUnchecked(schedulerFuture).resourceOffers(FakeMaster.this, allOffers);
           }
         },
         1,
@@ -226,17 +223,12 @@ public class FakeMaster implements SchedulerDriver, DriverFactory {
     }
 
     executor.schedule(
-        new Runnable() {
-          @Override
-          public void run() {
-            Futures.getUnchecked(schedulerFuture).statusUpdate(
-                FakeMaster.this,
-                TaskStatus.newBuilder()
-                    .setTaskId(task.getTaskId())
-                    .setState(TaskState.TASK_RUNNING)
-                    .build());
-          }
-        },
+        () -> Futures.getUnchecked(schedulerFuture).statusUpdate(
+            FakeMaster.this,
+            TaskStatus.newBuilder()
+                .setTaskId(task.getTaskId())
+                .setState(TaskState.TASK_RUNNING)
+                .build()),
         1,
         TimeUnit.SECONDS);
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/app/local/simulator/FakeSlaves.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/local/simulator/FakeSlaves.java b/src/test/java/org/apache/aurora/scheduler/app/local/simulator/FakeSlaves.java
index 46be83c..9274e7b 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/local/simulator/FakeSlaves.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/local/simulator/FakeSlaves.java
@@ -54,24 +54,16 @@ class FakeSlaves {
   }
 
   @Subscribe
-  public void offerAccepted(final OfferAccepted accepted) {
+  public void offerAccepted(OfferAccepted accepted) {
     // Move the task to starting after a delay.
     executor.schedule(
-        new Runnable() {
-          @Override
-          public void run() {
-            master.changeState(accepted.task.getTaskId(), TaskState.TASK_STARTING);
+        () -> {
+          master.changeState(accepted.task.getTaskId(), TaskState.TASK_STARTING);
 
-            executor.schedule(
-                new Runnable() {
-                  @Override
-                  public void run() {
-                    master.changeState(accepted.task.getTaskId(), TaskState.TASK_RUNNING);
-                  }
-                },
-                1,
-                TimeUnit.SECONDS);
-          }
+          executor.schedule(
+              () -> master.changeState(accepted.task.getTaskId(), TaskState.TASK_RUNNING),
+              1,
+              TimeUnit.SECONDS);
         },
         1,
         TimeUnit.SECONDS);

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java b/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
index c62a1d5..55b9a8b 100644
--- a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
@@ -22,9 +22,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.scheduler.async.GatedWorkQueue.GatedOperation;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
@@ -58,12 +56,9 @@ public class GatingDelayExecutorTest extends EasyMockTest {
   }
 
   private IExpectationSetters<?> invokeWorkWhenSubmitted() {
-    return expectLastCall().andAnswer(new IAnswer<Object>() {
-      @Override
-      public Object answer() {
-        ((Runnable) EasyMock.getCurrentArguments()[0]).run();
-        return null;
-      }
+    return expectLastCall().andAnswer(() -> {
+      ((Runnable) EasyMock.getCurrentArguments()[0]).run();
+      return null;
     });
   }
 
@@ -75,23 +70,15 @@ public class GatingDelayExecutorTest extends EasyMockTest {
 
     CountDownLatch gateClosed = new CountDownLatch(1);
     CountDownLatch unblock = new CountDownLatch(1);
-    Runnable closer = new Runnable() {
-      @Override
-      public void run() {
-        gatingExecutor.closeDuring(new GatedOperation<String, RuntimeException>() {
-          @Override
-          public String doWithGateClosed() {
-            gateClosed.countDown();
-            try {
-              unblock.await();
-            } catch (InterruptedException e) {
-              throw Throwables.propagate(e);
-            }
-            return "hi";
-          }
-        });
+    Runnable closer = () -> gatingExecutor.closeDuring(() -> {
+      gateClosed.countDown();
+      try {
+        unblock.await();
+      } catch (InterruptedException e) {
+        throw Throwables.propagate(e);
       }
-    };
+      return "hi";
+    });
     new ThreadFactoryBuilder()
         .setDaemon(true)
         .setNameFormat("GateTest")
@@ -119,24 +106,18 @@ public class GatingDelayExecutorTest extends EasyMockTest {
     gatingExecutor.execute(runnable);
     assertQueueSize(0);
 
-    String result = gatingExecutor.closeDuring(new GatedOperation<String, RuntimeException>() {
-      @Override
-      public String doWithGateClosed() {
+    String result = gatingExecutor.closeDuring(() -> {
+      gatingExecutor.execute(runnable);
+      assertQueueSize(1);
+
+      String result1 = gatingExecutor.closeDuring(() -> {
         gatingExecutor.execute(runnable);
-        assertQueueSize(1);
-
-        String result = gatingExecutor.closeDuring(new GatedOperation<String, RuntimeException>() {
-          @Override
-          public String doWithGateClosed() {
-            gatingExecutor.execute(runnable);
-            assertQueueSize(2);
-            return "hello";
-          }
-        });
-        assertEquals("hello", result);
-
-        return "hi";
-      }
+        assertQueueSize(2);
+        return "hello";
+      });
+      assertEquals("hello", result1);
+
+      return "hi";
     });
     assertEquals("hi", result);
     assertQueueSize(0);

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java b/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
index 58b4dc9..8761106 100644
--- a/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java
@@ -23,9 +23,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
-
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -50,11 +48,8 @@ public class AsyncUtilTest extends EasyMockTest {
 
     control.replay();
 
-    scheduledExecutor().schedule(new Runnable() {
-      @Override
-      public void run() {
-        throw new IllegalArgumentException("Expected exception.");
-      }
+    scheduledExecutor().schedule(() -> {
+      throw new IllegalArgumentException("Expected exception.");
     }, 0, TimeUnit.MILLISECONDS);
 
     latch.await();
@@ -83,12 +78,9 @@ public class AsyncUtilTest extends EasyMockTest {
     control.replay();
 
     ThreadPoolExecutor executor =
-        AsyncUtil.loggingExecutor(1, 1, new LinkedBlockingQueue<Runnable>(), NAME_FORMAT, logger);
-    executor.execute(new Runnable() {
-      @Override
-      public void run() {
-        throw new IllegalArgumentException("Expected exception.");
-      }
+        AsyncUtil.loggingExecutor(1, 1, new LinkedBlockingQueue<>(), NAME_FORMAT, logger);
+    executor.execute(() -> {
+      throw new IllegalArgumentException("Expected exception.");
     });
 
     latch.await();
@@ -100,12 +92,9 @@ public class AsyncUtilTest extends EasyMockTest {
         contains("Expected exception."),
         EasyMock.<ExecutionException>anyObject());
 
-    expectLastCall().andAnswer(new IAnswer<Object>() {
-      @Override
-      public Object answer() throws Throwable {
-        latch.countDown();
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      latch.countDown();
+      return null;
     }).once();
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java b/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
index 986fd01..13f656f 100644
--- a/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
@@ -15,7 +15,6 @@ package org.apache.aurora.scheduler.base;
 
 import java.util.EnumSet;
 
-import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 
@@ -35,12 +34,8 @@ public class JobsTest {
     ImmutableList<IScheduledTask> tasks =
         FluentIterable
             .from(EnumSet.allOf(ScheduleStatus.class))
-            .transform(new Function<ScheduleStatus, IScheduledTask>() {
-              @Override
-              public IScheduledTask apply(ScheduleStatus status) {
-                return addStateTransition(makeTask("id", TaskTestUtil.JOB), status, 100L);
-              }
-            }).toList();
+            .transform(status ->
+                addStateTransition(makeTask("id", TaskTestUtil.JOB), status, 100L)).toList();
 
     IJobStats expectedStats = IJobStats.build(new JobStats()
         .setActiveTaskCount(7)

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java b/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
index be921c3..5dd4aba 100644
--- a/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/cron/quartz/AuroraCronJobTest.java
@@ -26,6 +26,7 @@ import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.state.StateChangeResult;
 import org.apache.aurora.scheduler.state.StateManager;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.easymock.Capture;
@@ -34,7 +35,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.quartz.JobExecutionException;
 
-import static org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
@@ -120,37 +120,22 @@ public class AuroraCronJobTest extends EasyMockTest {
     auroraCronJob.doExecute(QuartzTestUtil.AURORA_JOB_KEY);
     assertFalse(capture.getValue().get());
     storage.write(
-        new Storage.MutateWork.NoResult.Quiet() {
-          @Override
-          public void execute(MutableStoreProvider storeProvider) {
-            storeProvider.getUnsafeTaskStore().deleteAllTasks();
-          }
-        });
+        (NoResult.Quiet) storeProvider -> storeProvider.getUnsafeTaskStore().deleteAllTasks());
     assertTrue(capture.getValue().get());
   }
 
   private void populateTaskStore() {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(
             IScheduledTask.build(new ScheduledTask()
                 .setStatus(ScheduleStatus.RUNNING)
                 .setAssignedTask(new AssignedTask()
                     .setTaskId(TASK_ID)
-                    .setTask(QuartzTestUtil.JOB.getTaskConfig().newBuilder())))
-        ));
-      }
-    });
+                    .setTask(QuartzTestUtil.JOB.getTaskConfig().newBuilder()))))));
   }
 
-  private void populateStorage(final CronCollisionPolicy policy) {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getCronJobStore().saveAcceptedJob(
-            QuartzTestUtil.makeSanitizedCronJob(policy).getSanitizedConfig().getJobConfig());
-      }
-    });
+  private void populateStorage(CronCollisionPolicy policy) {
+    storage.write((NoResult.Quiet) storeProvider -> storeProvider.getCronJobStore().saveAcceptedJob(
+        QuartzTestUtil.makeSanitizedCronJob(policy).getSanitizedConfig().getJobConfig()));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronIT.java b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronIT.java
index 400f295..9cca71b 100644
--- a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronIT.java
@@ -35,10 +35,10 @@ import org.apache.aurora.scheduler.cron.CrontabEntry;
 import org.apache.aurora.scheduler.cron.SanitizedCronJob;
 import org.apache.aurora.scheduler.state.StateManager;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Test;
 import org.quartz.JobExecutionContext;
@@ -136,12 +136,8 @@ public class CronIT extends EasyMockTest {
     control.replay();
     final Scheduler scheduler = injector.getInstance(Scheduler.class);
 
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getCronJobStore().saveAcceptedJob(CRON_JOB);
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getCronJobStore().saveAcceptedJob(CRON_JOB));
 
     final CountDownLatch cronRan = new CountDownLatch(1);
     scheduler.getListenerManager().addTriggerListener(new CountDownWhenComplete(cronRan));
@@ -163,22 +159,16 @@ public class CronIT extends EasyMockTest {
     final CountDownLatch secondExecutionCompleted = new CountDownLatch(1);
 
     auroraCronJob.execute(isA(JobExecutionContext.class));
-    expectLastCall().andAnswer(new IAnswer<Void>() {
-      @Override
-      public Void answer() throws Throwable {
-        firstExecutionTriggered.countDown();
-        firstExecutionCompleted.await();
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      firstExecutionTriggered.countDown();
+      firstExecutionCompleted.await();
+      return null;
     });
     auroraCronJob.execute(isA(JobExecutionContext.class));
-    expectLastCall().andAnswer(new IAnswer<Object>() {
-      @Override
-      public Void answer() throws Throwable {
-        secondExecutionTriggered.countDown();
-        secondExecutionCompleted.await();
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      secondExecutionTriggered.countDown();
+      secondExecutionCompleted.await();
+      return null;
     });
 
     control.replay();

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronJobManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronJobManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronJobManagerImplTest.java
index 5b0405f..ce6426b 100644
--- a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronJobManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronJobManagerImplTest.java
@@ -29,6 +29,7 @@ import org.apache.aurora.scheduler.cron.CronJobManager;
 import org.apache.aurora.scheduler.cron.CrontabEntry;
 import org.apache.aurora.scheduler.cron.SanitizedCronJob;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
@@ -245,21 +246,12 @@ public class CronJobManagerImplTest extends EasyMockTest {
   }
 
   private void populateStorage() throws Exception {
-    storage.write(new Storage.MutateWork.NoResult<Exception>() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) throws Exception {
-        storeProvider.getCronJobStore().saveAcceptedJob(
-            QuartzTestUtil.makeSanitizedCronJob().getSanitizedConfig().getJobConfig());
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider -> storeProvider.getCronJobStore().saveAcceptedJob(
+        QuartzTestUtil.makeSanitizedCronJob().getSanitizedConfig().getJobConfig()));
   }
 
   private Optional<IJobConfiguration> fetchFromStorage() {
-    return storage.read(new Storage.Work.Quiet<Optional<IJobConfiguration>>() {
-      @Override
-      public Optional<IJobConfiguration> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getCronJobStore().fetchJob(QuartzTestUtil.AURORA_JOB_KEY);
-      }
-    });
+    return storage.read(
+        storeProvider -> storeProvider.getCronJobStore().fetchJob(QuartzTestUtil.AURORA_JOB_KEY));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronPredictorImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronPredictorImplTest.java b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronPredictorImplTest.java
index b879d6f..b85f4ab 100644
--- a/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronPredictorImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/cron/quartz/CronPredictorImplTest.java
@@ -17,7 +17,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.TimeZone;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 
 import org.apache.aurora.common.quantity.Amount;
@@ -73,12 +72,7 @@ public class CronPredictorImplTest {
           "Cron schedule " + expectedPrediction.getSchedule() + " made unexpected predictions.",
           Lists.transform(
               expectedPrediction.getTriggerTimes(),
-              new Function<Long, Date>() {
-                @Override
-                public Date apply(Long time) {
-                  return new Date(time);
-                }
-              }
+              Date::new
           ),
           results);
     }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java b/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
index 3794b96..abf823a 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
@@ -24,7 +24,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Key;
 import com.google.inject.Module;
-import com.google.inject.Provider;
 import com.google.inject.TypeLiteral;
 import com.google.inject.util.Modules;
 import com.sun.jersey.api.client.Client;
@@ -128,11 +127,8 @@ public abstract class JettyServerModuleTest extends EasyMockTest {
             bindMock(TaskScheduler.class);
             bindMock(Thread.UncaughtExceptionHandler.class);
 
-            bind(ServletContextListener.class).toProvider(new Provider<ServletContextListener>() {
-              @Override
-              public ServletContextListener get() {
-                return makeServletContextListener(injector, getChildServletModule());
-              }
+            bind(ServletContextListener.class).toProvider(() -> {
+              return makeServletContextListener(injector, getChildServletModule());
             });
           }
         },

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java b/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
index b831c9d..98b6ef6 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
@@ -45,14 +45,9 @@ public class LeaderRedirectTest extends EasyMockTest {
   private static final int HTTP_PORT = 500;
 
   private static final Function<HostAndPort, ServiceInstance> CREATE_INSTANCE =
-      new Function<HostAndPort, ServiceInstance>() {
-        @Override
-        public ServiceInstance apply(HostAndPort endpoint) {
-          return new ServiceInstance()
-              .setAdditionalEndpoints(ImmutableMap.of(HTTP_PORT_NAME,
-                  new Endpoint(endpoint.getHostText(), endpoint.getPort())));
-        }
-      };
+      endpoint -> new ServiceInstance()
+          .setAdditionalEndpoints(ImmutableMap.of(HTTP_PORT_NAME,
+              new Endpoint(endpoint.getHostText(), endpoint.getPort())));
 
   private Capture<HostChangeMonitor<ServiceInstance>> monitorCapture;
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/http/RequestLoggerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/RequestLoggerTest.java b/src/test/java/org/apache/aurora/scheduler/http/RequestLoggerTest.java
index 4fd2abe..a2f786a 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/RequestLoggerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/RequestLoggerTest.java
@@ -20,7 +20,6 @@ import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
 import org.apache.aurora.common.util.testing.FakeClock;
-
 import org.eclipse.jetty.http.HttpHeaders;
 import org.eclipse.jetty.http.HttpURI;
 import org.eclipse.jetty.server.Request;

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/log/mesos/MesosLogTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/log/mesos/MesosLogTest.java b/src/test/java/org/apache/aurora/scheduler/log/mesos/MesosLogTest.java
index 9189bde..f142f54 100644
--- a/src/test/java/org/apache/aurora/scheduler/log/mesos/MesosLogTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/log/mesos/MesosLogTest.java
@@ -19,7 +19,6 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.concurrent.TimeoutException;
 
-import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSortedSet;
@@ -33,6 +32,7 @@ import org.apache.aurora.common.base.Command;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
+import org.apache.aurora.scheduler.log.Log.Entry;
 import org.apache.aurora.scheduler.log.Log.Stream.StreamAccessException;
 import org.apache.aurora.scheduler.log.mesos.LogInterface.ReaderInterface;
 import org.apache.aurora.scheduler.log.mesos.LogInterface.WriterInterface;
@@ -182,20 +182,10 @@ public class MesosLogTest extends EasyMockTest {
 
   private List<String> readAll() {
     List<byte[]> entryBytes = FluentIterable.from(ImmutableList.copyOf(logStream.readAll()))
-        .transform(new Function<org.apache.aurora.scheduler.log.Log.Entry, byte[]>() {
-          @Override
-          public byte[] apply(org.apache.aurora.scheduler.log.Log.Entry entry) {
-            return entry.contents();
-          }
-        })
+        .transform(Entry::contents)
         .toList();
     return FluentIterable.from(entryBytes)
-        .transform(new Function<byte[], String>() {
-          @Override
-          public String apply(byte[] data) {
-            return new String(data, StandardCharsets.UTF_8);
-          }
-        })
+        .transform(data -> new String(data, StandardCharsets.UTF_8))
         .toList();
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/mesos/Offers.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/Offers.java b/src/test/java/org/apache/aurora/scheduler/mesos/Offers.java
index 0e4e008..13f41e3 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/Offers.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/Offers.java
@@ -14,7 +14,6 @@
 package org.apache.aurora.scheduler.mesos;
 
 import org.apache.aurora.common.collections.Pair;
-
 import org.apache.mesos.Protos;
 import org.apache.mesos.Protos.Offer;
 import org.apache.mesos.Protos.OfferID;

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/offers/RandomJitterReturnDelayTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/offers/RandomJitterReturnDelayTest.java b/src/test/java/org/apache/aurora/scheduler/offers/RandomJitterReturnDelayTest.java
index d446caf..ba30a0c 100644
--- a/src/test/java/org/apache/aurora/scheduler/offers/RandomJitterReturnDelayTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/offers/RandomJitterReturnDelayTest.java
@@ -15,7 +15,6 @@ package org.apache.aurora.scheduler.offers;
 
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
 import org.apache.aurora.common.util.Random;
-
 import org.junit.Test;
 
 import static org.easymock.EasyMock.expect;

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
index 5cb8508..fca4c81 100644
--- a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
@@ -17,7 +17,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
@@ -51,7 +50,6 @@ import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.apache.mesos.Protos;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
@@ -476,12 +474,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
   private static ImmutableSet<PreemptionVictim> preemptionVictims(ScheduledTask... tasks) {
     return FluentIterable.from(ImmutableSet.copyOf(tasks))
         .transform(
-            new Function<ScheduledTask, PreemptionVictim>() {
-              @Override
-              public PreemptionVictim apply(ScheduledTask task) {
-                return PreemptionVictim.fromTask(IAssignedTask.build(task.getAssignedTask()));
-              }
-            }).toSet();
+            task -> PreemptionVictim.fromTask(IAssignedTask.build(task.getAssignedTask()))).toSet();
   }
 
   private static void assertVictims(
@@ -541,12 +534,7 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
         EasyMock.anyObject(),
         EasyMock.anyObject()))
         .andAnswer(
-            new IAnswer<Set<SchedulingFilter.Veto>>() {
-              @Override
-              public Set<SchedulingFilter.Veto> answer() {
-                return veto.asSet();
-              }
-            });
+            veto::asSet);
   }
 
   static ScheduledTask makeTask(

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
index 373e8b1..295960f 100644
--- a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
@@ -13,10 +13,7 @@
  */
 package org.apache.aurora.scheduler.pruning;
 
-import java.io.Closeable;
-import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
@@ -59,7 +56,6 @@ import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -267,12 +263,8 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
             .setDaemon(true)
             .setNameFormat("testThreadSafeEvents-executor")
             .build());
-    closer.register(new Closeable() {
-      @Override
-      public void close() throws IOException {
-        MoreExecutors.shutdownAndAwaitTermination(realExecutor, 1L, TimeUnit.SECONDS);
-      }
-    });
+    closer.register(
+        () -> MoreExecutors.shutdownAndAwaitTermination(realExecutor, 1L, TimeUnit.SECONDS));
 
     Injector injector = Guice.createInjector(
         new AsyncModule(realExecutor),
@@ -305,9 +297,9 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
         storageUtil.storage);
   }
 
-  private CountDownLatch expectTaskDeleted(final Command onDelete, String taskId) {
-    final CountDownLatch deleteCalled = new CountDownLatch(1);
-    final CountDownLatch eventDelivered = new CountDownLatch(1);
+  private CountDownLatch expectTaskDeleted(Command onDelete, String taskId) {
+    CountDownLatch deleteCalled = new CountDownLatch(1);
+    CountDownLatch eventDelivered = new CountDownLatch(1);
 
     Thread eventDispatch = new Thread() {
       @Override
@@ -328,18 +320,15 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
     eventDispatch.start();
 
     stateManager.deleteTasks(storageUtil.mutableStoreProvider, ImmutableSet.of(taskId));
-    expectLastCall().andAnswer(new IAnswer<Void>() {
-      @Override
-      public Void answer() {
-        deleteCalled.countDown();
-        try {
-          eventDelivered.await();
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-          fail("Interrupted while awaiting for event delivery.");
-        }
-        return null;
+    expectLastCall().andAnswer(() -> {
+      deleteCalled.countDown();
+      try {
+        eventDelivered.await();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        fail("Interrupted while awaiting for event delivery.");
       }
+      return null;
     });
 
     return eventDelivered;
@@ -368,13 +357,10 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
     // Expect a deferred prune operation when a new task is being watched.
     executor.execute(EasyMock.<Runnable>anyObject());
     expectLastCall().andAnswer(
-        new IAnswer<Future<?>>() {
-          @Override
-          public Future<?> answer() {
-            Runnable work = (Runnable) EasyMock.getCurrentArguments()[0];
-            work.run();
-            return null;
-          }
+        () -> {
+          Runnable work = (Runnable) EasyMock.getCurrentArguments()[0];
+          work.run();
+          return null;
         }
     );
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskReconcilerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskReconcilerTest.java b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskReconcilerTest.java
index e6a39ac..d1675c6 100644
--- a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskReconcilerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskReconcilerTest.java
@@ -40,7 +40,6 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.apache.aurora.common.quantity.Time.MINUTES;
-
 import static org.apache.aurora.scheduler.reconciliation.TaskReconciler.EXPLICIT_STAT_NAME;
 import static org.apache.aurora.scheduler.reconciliation.TaskReconciler.IMPLICIT_STAT_NAME;
 import static org.apache.aurora.scheduler.reconciliation.TaskReconciler.TASK_TO_PROTO;

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/scheduling/RescheduleCalculatorImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/RescheduleCalculatorImplTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/RescheduleCalculatorImplTest.java
index 71ce376..b380f21 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/RescheduleCalculatorImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/RescheduleCalculatorImplTest.java
@@ -14,7 +14,6 @@
 package org.apache.aurora.scheduler.scheduling;
 
 import java.util.Map;
-import java.util.Map.Entry;
 
 import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
@@ -174,12 +173,7 @@ public class RescheduleCalculatorImplTest extends EasyMockTest {
   }
 
   private static final Function<Map.Entry<ScheduleStatus, Long>, TaskEvent> TO_EVENT =
-      new Function<Entry<ScheduleStatus, Long>, TaskEvent>() {
-        @Override
-        public TaskEvent apply(Entry<ScheduleStatus, Long> input) {
-          return new TaskEvent().setStatus(input.getKey()).setTimestamp(input.getValue());
-        }
-      };
+      input -> new TaskEvent().setStatus(input.getKey()).setTimestamp(input.getValue());
 
   private IScheduledTask setEvents(IScheduledTask task, Map<ScheduleStatus, Long> events) {
     return IScheduledTask.build(task.newBuilder().setTaskEvents(

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
index b9be4ad..95cf25e 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
@@ -33,7 +33,6 @@ import org.apache.aurora.scheduler.scheduling.TaskGroups.TaskGroupsSettings;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.apache.aurora.scheduler.testing.FakeScheduledExecutor;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -84,16 +83,13 @@ public class TaskGroupsTest extends EasyMockTest {
   public void testTaskDeletedBeforeEvaluating() {
     final IScheduledTask task = makeTask(TASK_A_ID);
     expect(rateLimiter.acquire()).andReturn(0D);
-    expect(taskScheduler.schedule(Tasks.id(task))).andAnswer(new IAnswer<Boolean>() {
-      @Override
-      public Boolean answer() {
-        // Test a corner case where a task is deleted while it is being evaluated by the task
-        // scheduler.  If not handled carefully, this could result in the scheduler trying again
-        // later to satisfy the deleted task.
-        taskGroups.tasksDeleted(new TasksDeleted(ImmutableSet.of(task)));
-
-        return false;
-      }
+    expect(taskScheduler.schedule(Tasks.id(task))).andAnswer(() -> {
+      // Test a corner case where a task is deleted while it is being evaluated by the task
+      // scheduler.  If not handled carefully, this could result in the scheduler trying again
+      // later to satisfy the deleted task.
+      taskGroups.tasksDeleted(new TasksDeleted(ImmutableSet.of(task)));
+
+      return false;
     });
     expect(backoffStrategy.calculateBackoffMs(FIRST_SCHEDULE_DELAY.as(Time.MILLISECONDS)))
         .andReturn(0L);

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
index 13c9f47..4c447b2 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskSchedulerImplTest.java
@@ -46,8 +46,7 @@ import org.apache.aurora.scheduler.scheduling.TaskScheduler.TaskSchedulerImpl;
 import org.apache.aurora.scheduler.state.PubsubTestUtil;
 import org.apache.aurora.scheduler.state.TaskAssigner;
 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.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
@@ -95,7 +94,7 @@ public class TaskSchedulerImplTest extends EasyMockTest {
     eventSink = PubsubTestUtil.startPubsub(injector);
   }
 
-  private Injector getInjector(final Storage storageImpl) {
+  private Injector getInjector(Storage storageImpl) {
     return Guice.createInjector(
         new PubsubEventModule(),
         new AbstractModule() {
@@ -252,16 +251,12 @@ public class TaskSchedulerImplTest extends EasyMockTest {
     eventSink = PubsubTestUtil.startPubsub(injector);
 
     ScheduledTask builder = TASK_A.newBuilder();
-    final IScheduledTask taskA = IScheduledTask.build(builder.setStatus(PENDING));
+    IScheduledTask taskA = IScheduledTask.build(builder.setStatus(PENDING));
     builder.getAssignedTask().setTaskId("b");
-    final IScheduledTask taskB = IScheduledTask.build(builder.setStatus(THROTTLED));
-
-    memStorage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider store) {
-        store.getUnsafeTaskStore().saveTasks(ImmutableSet.of(taskA, taskB));
-      }
-    });
+    IScheduledTask taskB = IScheduledTask.build(builder.setStatus(THROTTLED));
+
+    memStorage.write((NoResult.Quiet)
+        store -> store.getUnsafeTaskStore().saveTasks(ImmutableSet.of(taskA, taskB)));
 
     expectAsMap(NO_RESERVATION);
     expect(assigner.maybeAssign(

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java b/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
index 00a872c..341e346 100644
--- a/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/sla/SlaModuleTest.java
@@ -28,7 +28,6 @@ import com.google.inject.Module;
 
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.stats.Stat;
 import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
 import org.apache.aurora.common.util.Clock;
@@ -39,7 +38,6 @@ import org.apache.aurora.scheduler.sla.SlaModule.SlaUpdater;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -105,12 +103,9 @@ public class SlaModuleTest extends EasyMockTest {
     expect(statsProvider.untracked()).andReturn(untracked).anyTimes();
     expect(untracked.makeGauge(EasyMock.anyString(), EasyMock.anyObject()))
         .andReturn(EasyMock.anyObject())
-        .andAnswer(new IAnswer<Stat<Number>>() {
-          @Override
-          public Stat<Number> answer() throws Throwable {
-            latch.countDown();
-            return null;
-          }
+        .andAnswer(() -> {
+          latch.countDown();
+          return null;
         }).anyTimes();
 
     storageUtil.expectTaskFetch(

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
index 95b22ae..4a655f1 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
@@ -36,7 +36,6 @@ import org.apache.aurora.scheduler.storage.entities.ILock;
 import org.apache.aurora.scheduler.storage.entities.ILockKey;
 import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -174,16 +173,13 @@ public class LockManagerImplTest extends EasyMockTest {
     final CountDownLatch reads = new CountDownLatch(2);
     EasyMock.makeThreadSafe(storageUtil.storage, false);
     expect(storageUtil.storage.read(EasyMock.anyObject()))
-        .andAnswer(new IAnswer<Object>() {
-          @Override
-          public Object answer() throws Throwable {
-            @SuppressWarnings("unchecked")
-            Work<?, ?> work = (Work<?, ?>) EasyMock.getCurrentArguments()[0];
-            Object result = work.apply(storageUtil.storeProvider);
-            reads.countDown();
-            reads.await();
-            return result;
-          }
+        .andAnswer(() -> {
+          @SuppressWarnings("unchecked")
+          Work<?, ?> work = (Work<?, ?>) EasyMock.getCurrentArguments()[0];
+          Object result = work.apply(storageUtil.storeProvider);
+          reads.countDown();
+          reads.await();
+          return result;
         }).atLeastOnce();
 
     lockManager = new LockManagerImpl(storageUtil.storage, clock, tokenGenerator);
@@ -194,14 +190,11 @@ public class LockManagerImplTest extends EasyMockTest {
         .setDaemon(true)
         .setNameFormat("LockRead-%s")
         .build()
-        .newThread(new Runnable() {
-          @Override
-          public void run() {
-            try {
-              lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
-            } catch (LockException e) {
-              throw Throwables.propagate(e);
-            }
+        .newThread(() -> {
+          try {
+            lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
+          } catch (LockException e) {
+            throw Throwables.propagate(e);
           }
         })
         .start();

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
index 01f5273..c51d9f9 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/StateManagerImplTest.java
@@ -47,6 +47,7 @@ import org.apache.aurora.scheduler.mesos.Driver;
 import org.apache.aurora.scheduler.scheduling.RescheduleCalculator;
 import org.apache.aurora.scheduler.storage.AttributeStore;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
@@ -54,7 +55,6 @@ import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
 import org.apache.mesos.Protos.SlaveID;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.easymock.IArgumentMatcher;
 import org.junit.Before;
 import org.junit.Test;
@@ -112,12 +112,9 @@ public class StateManagerImplTest extends EasyMockTest {
         taskIdGenerator,
         eventSink,
         rescheduleCalculator);
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        AttributeStore.Mutable attributeStore = storeProvider.getAttributeStore();
-        attributeStore.saveHostAttributes(HOST_A);
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      AttributeStore.Mutable attributeStore = storeProvider.getAttributeStore();
+      attributeStore.saveHostAttributes(HOST_A);
     });
   }
 
@@ -264,12 +261,9 @@ public class StateManagerImplTest extends EasyMockTest {
 
     // Trigger an event that produces a side-effect and a PubSub event .
     eventSink.post(matchStateChange(id, INIT, PENDING));
-    expectLastCall().andAnswer(new IAnswer<Void>() {
-      @Override
-      public Void answer() throws Throwable {
-        changeState(id, ASSIGNED);
-        return null;
-      }
+    expectLastCall().andAnswer(() -> {
+      changeState(id, ASSIGNED);
+      return null;
     });
 
     // Final event sink execution that adds no side effect or event.
@@ -406,12 +400,8 @@ public class StateManagerImplTest extends EasyMockTest {
     assignTask(taskId, HOST_A);
     changeState(taskId, RUNNING);
     changeState(taskId, FINISHED);
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        stateManager.deleteTasks(storeProvider, ImmutableSet.of(taskId));
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> stateManager.deleteTasks(storeProvider, ImmutableSet.of(taskId)));
   }
 
   private static ITaskConfig setRequestedPorts(ITaskConfig config, Set<String> portNames) {
@@ -472,15 +462,10 @@ public class StateManagerImplTest extends EasyMockTest {
   @Test(expected = IllegalArgumentException.class)
   public void insertEmptyPendingInstancesFails() {
     control.replay();
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        stateManager.insertPendingTasks(
-            storeProvider,
-            NON_SERVICE_CONFIG,
-            ImmutableSet.of());
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider -> stateManager.insertPendingTasks(
+        storeProvider,
+        NON_SERVICE_CONFIG,
+        ImmutableSet.of()));
   }
 
   @Test(expected = IllegalArgumentException.class)
@@ -542,35 +527,26 @@ public class StateManagerImplTest extends EasyMockTest {
     }
   }
 
-  private void insertTask(final ITaskConfig task, final int instanceId) {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        stateManager.insertPendingTasks(storeProvider, task, ImmutableSet.of(instanceId));
-      }
-    });
+  private void insertTask(ITaskConfig task, int instanceId) {
+    storage.write((NoResult.Quiet) storeProvider ->
+        stateManager.insertPendingTasks(storeProvider, task, ImmutableSet.of(instanceId)));
   }
 
   private StateChangeResult changeState(
-      final String taskId,
-      final Optional<ScheduleStatus> casState,
-      final ScheduleStatus newState,
-      final Optional<String> auditMessage) {
-
-    return storage.write(new Storage.MutateWork.Quiet<StateChangeResult>() {
-      @Override
-      public StateChangeResult apply(Storage.MutableStoreProvider storeProvider) {
-        return stateManager.changeState(
-            storeProvider,
-            taskId,
-            casState,
-            newState,
-            auditMessage);
-      }
-    });
+      String taskId,
+      Optional<ScheduleStatus> casState,
+      ScheduleStatus newState,
+      Optional<String> auditMessage) {
+
+    return storage.write(storeProvider -> stateManager.changeState(
+        storeProvider,
+        taskId,
+        casState,
+        newState,
+        auditMessage));
   }
 
-  private StateChangeResult changeState(final String taskId, final ScheduleStatus status) {
+  private StateChangeResult changeState(String taskId, ScheduleStatus status) {
     return changeState(
         taskId,
         Optional.absent(),
@@ -582,21 +558,12 @@ public class StateManagerImplTest extends EasyMockTest {
     assignTask(taskId, host, ImmutableMap.of());
   }
 
-  private void assignTask(
-      final String taskId,
-      final IHostAttributes host,
-      final Map<String, Integer> ports) {
-
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        stateManager.assignTask(
-            storeProvider,
-            taskId,
-            host.getHost(),
-            SlaveID.newBuilder().setValue(host.getSlaveId()).build(),
-            ports);
-      }
-    });
+  private void assignTask(String taskId, IHostAttributes host, Map<String, Integer> ports) {
+    storage.write(storeProvider -> stateManager.assignTask(
+        storeProvider,
+        taskId,
+        host.getHost(),
+        SlaveID.newBuilder().setValue(host.getSlaveId()).build(),
+        ports));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java b/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
index e2c82b7..c3a803e 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
@@ -276,12 +276,7 @@ public class TaskStateMachineTest {
   }
 
   private static final Function<Action, SideEffect> TO_SIDE_EFFECT =
-      new Function<Action, SideEffect>() {
-        @Override
-        public SideEffect apply(Action action) {
-          return new SideEffect(action, Optional.absent());
-        }
-      };
+      action -> new SideEffect(action, Optional.absent());
 
   private void legalTransition(TaskState state, SideEffect.Action... expectedActions) {
     legalTransition(state, ImmutableSet.copyOf(expectedActions));

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/stats/ResourceCounterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/stats/ResourceCounterTest.java b/src/test/java/org/apache/aurora/scheduler/stats/ResourceCounterTest.java
index 24dcf61..845de41 100644
--- a/src/test/java/org/apache/aurora/scheduler/stats/ResourceCounterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/stats/ResourceCounterTest.java
@@ -33,6 +33,7 @@ import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.configuration.ConfigurationManager;
 import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
@@ -117,14 +118,11 @@ public class ResourceCounterTest {
 
   @Test
   public void testComputeQuotaAllocationTotals() {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getQuotaStore()
-            .saveQuota("a", IResourceAggregate.build(new ResourceAggregate(1, 1, 1)));
-        storeProvider.getQuotaStore()
-            .saveQuota("b", IResourceAggregate.build(new ResourceAggregate(2, 3, 4)));
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      storeProvider.getQuotaStore()
+          .saveQuota("a", IResourceAggregate.build(new ResourceAggregate(1, 1, 1)));
+      storeProvider.getQuotaStore()
+          .saveQuota("b", IResourceAggregate.build(new ResourceAggregate(2, 3, 4)));
     });
 
     assertEquals(new Metric(3, 4, 5), resourceCounter.computeQuotaAllocationTotals());
@@ -184,11 +182,7 @@ public class ResourceCounterTest {
   }
 
   private void insertTasks(final IScheduledTask... tasks) {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-          storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.copyOf(tasks));
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.copyOf(tasks)));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/AbstractCronJobStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/AbstractCronJobStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/AbstractCronJobStoreTest.java
index 25af7da..a6bfc7a 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/AbstractCronJobStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/AbstractCronJobStoreTest.java
@@ -29,10 +29,7 @@ import org.apache.aurora.scheduler.base.JobKeys;
 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.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.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
@@ -110,28 +107,16 @@ public abstract class AbstractCronJobStoreTest {
   public void testTaskConfigDedupe() {
     // Test for regression of AURORA-1392.
 
-    final IScheduledTask instance = TaskTestUtil.makeTask("a", JOB_A.getTaskConfig());
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(instance));
-      }
-    });
+    IScheduledTask instance = TaskTestUtil.makeTask("a", JOB_A.getTaskConfig());
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(instance)));
 
     saveAcceptedJob(JOB_A);
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().mutateTasks(Query.taskScoped(Tasks.id(instance)),
-            new TaskStore.Mutable.TaskMutation() {
-              @Override
-              public IScheduledTask apply(IScheduledTask task) {
-                return IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.RUNNING));
-              }
-            });
-      }
-    });
+    storage.write(storeProvider ->
+        storeProvider.getUnsafeTaskStore().mutateTasks(
+            Query.taskScoped(Tasks.id(instance)),
+            task -> IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.RUNNING))));
   }
 
   @Test
@@ -162,47 +147,25 @@ public abstract class AbstractCronJobStoreTest {
   }
 
   private Set<IJobConfiguration> fetchJobs() {
-    return storage.read(new Work.Quiet<Set<IJobConfiguration>>() {
-      @Override
-      public Set<IJobConfiguration> apply(StoreProvider storeProvider) {
-        return ImmutableSet.copyOf(storeProvider.getCronJobStore().fetchJobs());
-      }
-    });
+    return storage.read(
+        storeProvider -> ImmutableSet.copyOf(storeProvider.getCronJobStore().fetchJobs()));
   }
 
-  private Optional<IJobConfiguration> fetchJob(final IJobKey jobKey) {
-    return storage.read(new Work.Quiet<Optional<IJobConfiguration>>() {
-      @Override
-      public Optional<IJobConfiguration> apply(StoreProvider storeProvider) {
-        return storeProvider.getCronJobStore().fetchJob(jobKey);
-      }
-    });
+  private Optional<IJobConfiguration> fetchJob(IJobKey jobKey) {
+    return storage.read(storeProvider -> storeProvider.getCronJobStore().fetchJob(jobKey));
   }
 
-  private void saveAcceptedJob(final IJobConfiguration jobConfig) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getCronJobStore().saveAcceptedJob(jobConfig);
-      }
-    });
+  private void saveAcceptedJob(IJobConfiguration jobConfig) {
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getCronJobStore().saveAcceptedJob(jobConfig));
   }
 
-  private void removeJob(final IJobKey jobKey) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getCronJobStore().removeJob(jobKey);
-      }
-    });
+  private void removeJob(IJobKey jobKey) {
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getCronJobStore().removeJob(jobKey));
   }
 
   private void deleteJobs() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getCronJobStore().deleteJobs();
-      }
-    });
+    storage.write((NoResult.Quiet) storeProvider -> storeProvider.getCronJobStore().deleteJobs());
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
index fa1d1cd..c025f4e 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
@@ -15,7 +15,6 @@ package org.apache.aurora.scheduler.storage;
 
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -48,6 +47,7 @@ import org.apache.aurora.scheduler.base.JobKeys;
 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.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.TaskStore.Mutable.TaskMutation;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
@@ -95,75 +95,47 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
     storage = injector.getInstance(Storage.class);
     storage.prepare();
 
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        AttributeStore.Mutable attributeStore = storeProvider.getAttributeStore();
-        attributeStore.saveHostAttributes(HOST_A);
-        attributeStore.saveHostAttributes(HOST_B);
-      }
+    storage.write((NoResult.Quiet) storeProvider -> {
+      AttributeStore.Mutable attributeStore = storeProvider.getAttributeStore();
+      attributeStore.saveHostAttributes(HOST_A);
+      attributeStore.saveHostAttributes(HOST_B);
     });
   }
 
-  private Iterable<IScheduledTask> fetchTasks(final Query.Builder query) {
-    return storage.read(new Storage.Work.Quiet<Iterable<IScheduledTask>>() {
-      @Override
-      public Iterable<IScheduledTask> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getTaskStore().fetchTasks(query);
-      }
-    });
+  private Iterable<IScheduledTask> fetchTasks(Query.Builder query) {
+    return storage.read(storeProvider -> storeProvider.getTaskStore().fetchTasks(query));
   }
 
-  protected void saveTasks(final IScheduledTask... tasks) {
+  protected void saveTasks(IScheduledTask... tasks) {
     saveTasks(ImmutableSet.copyOf(tasks));
   }
 
-  private void saveTasks(final Set<IScheduledTask> tasks) {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.copyOf(tasks));
-      }
-    });
+  private void saveTasks(Set<IScheduledTask> tasks) {
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.copyOf(tasks)));
   }
 
   private ImmutableSet<IScheduledTask> mutateTasks(
       final Query.Builder query,
       final TaskMutation mutation) {
 
-    return storage.write(new Storage.MutateWork.Quiet<ImmutableSet<IScheduledTask>>() {
-      @Override
-      public ImmutableSet<IScheduledTask> apply(Storage.MutableStoreProvider storeProvider) {
-        return storeProvider.getUnsafeTaskStore().mutateTasks(query, mutation);
-      }
-    });
+    return storage.write(
+        storeProvider -> storeProvider.getUnsafeTaskStore().mutateTasks(query, mutation));
   }
 
-  private boolean unsafeModifyInPlace(final String taskId, final ITaskConfig taskConfiguration) {
-    return storage.write(new Storage.MutateWork.Quiet<Boolean>() {
-      @Override
-      public Boolean apply(Storage.MutableStoreProvider storeProvider) {
-        return storeProvider.getUnsafeTaskStore().unsafeModifyInPlace(taskId, taskConfiguration);
-      }
-    });
+  private boolean unsafeModifyInPlace(String taskId, ITaskConfig taskConfiguration) {
+    return storage.write(storeProvider ->
+        storeProvider.getUnsafeTaskStore().unsafeModifyInPlace(taskId, taskConfiguration));
   }
 
-  protected void deleteTasks(final String... taskIds) {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().deleteTasks(ImmutableSet.copyOf(taskIds));
-      }
-    });
+  protected void deleteTasks(String... taskIds) {
+    storage.write((NoResult.Quiet) storeProvider ->
+        storeProvider.getUnsafeTaskStore().deleteTasks(ImmutableSet.copyOf(taskIds)));
   }
 
   protected void deleteAllTasks() {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().deleteAllTasks();
-      }
-    });
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getUnsafeTaskStore().deleteAllTasks());
   }
 
   @Test
@@ -290,23 +262,17 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
     saveTasks(TASK_A, TASK_B, TASK_C, TASK_D);
     assertQueryResults(Query.statusScoped(RUNNING));
 
-    mutateTasks(Query.taskScoped("a"), new TaskMutation() {
-      @Override
-      public IScheduledTask apply(IScheduledTask task) {
-        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
-      }
-    });
+    mutateTasks(
+        Query.taskScoped("a"),
+        task -> IScheduledTask.build(task.newBuilder().setStatus(RUNNING)));
 
     assertQueryResults(
         Query.statusScoped(RUNNING),
         IScheduledTask.build(TASK_A.newBuilder().setStatus(RUNNING)));
 
-    mutateTasks(Query.unscoped(), new TaskMutation() {
-      @Override
-      public IScheduledTask apply(IScheduledTask task) {
-        return IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.ASSIGNED));
-      }
-    });
+    mutateTasks(
+        Query.unscoped(),
+        task -> IScheduledTask.build(task.newBuilder().setStatus(ScheduleStatus.ASSIGNED)));
 
     assertStoreContents(
         IScheduledTask.build(TASK_A.newBuilder().setStatus(ScheduleStatus.ASSIGNED)),
@@ -376,12 +342,7 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
     assertQueryResults(jimsJob2, c);
     assertQueryResults(joesJob, d);
 
-    mutateTasks(jimsJob, new TaskMutation() {
-      @Override
-      public IScheduledTask apply(IScheduledTask task) {
-        return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
-      }
-    });
+    mutateTasks(jimsJob, task -> IScheduledTask.build(task.newBuilder().setStatus(RUNNING)));
     IScheduledTask aRunning = IScheduledTask.build(a.newBuilder().setStatus(RUNNING));
     assertQueryResults(jimsJob, aRunning);
     assertQueryResults(jimsJob2, c);
@@ -454,12 +415,9 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
 
     final IScheduledTask b = setHost(a, HOST_A);
     Set<IScheduledTask> result = mutateTasks(Query.taskScoped(Tasks.id(a)),
-        new TaskMutation() {
-          @Override
-          public IScheduledTask apply(IScheduledTask task) {
-            assertEquals(a, task);
-            return b;
-          }
+        task -> {
+          assertEquals(a, task);
+          return b;
         });
     assertEquals(ImmutableSet.of(b), result);
     assertQueryResults(Query.slaveScoped(HOST_A.getHost()), b);
@@ -467,12 +425,9 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
     // Unrealistic behavior, but proving that the secondary index can handle key mutations.
     final IScheduledTask c = setHost(b, HOST_B);
     Set<IScheduledTask> result2 = mutateTasks(Query.taskScoped(Tasks.id(a)),
-        new TaskMutation() {
-          @Override
-          public IScheduledTask apply(IScheduledTask task) {
-            assertEquals(b, task);
-            return c;
-          }
+        task -> {
+          assertEquals(b, task);
+          return c;
         });
     assertEquals(ImmutableSet.of(c), result2);
     assertQueryResults(Query.slaveScoped(HOST_B.getHost()), c);
@@ -491,12 +446,9 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
 
     final IScheduledTask b = unsetHost(a);
     Set<IScheduledTask> result = mutateTasks(Query.taskScoped(Tasks.id(a)),
-        new TaskMutation() {
-          @Override
-          public IScheduledTask apply(IScheduledTask task) {
-            assertEquals(a, task);
-            return b;
-          }
+        task -> {
+          assertEquals(a, task);
+          return b;
         });
     assertEquals(ImmutableSet.of(b), result);
     assertQueryResults(Query.slaveScoped(HOST_A.getHost()));
@@ -526,12 +478,7 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
   }
 
   private Set<IJobKey> getJobKeys() {
-    return storage.read(new Storage.Work.Quiet<Set<IJobKey>>() {
-      @Override
-      public Set<IJobKey> apply(Storage.StoreProvider storeProvider) {
-        return storeProvider.getTaskStore().getJobKeys();
-      }
-    });
+    return storage.read(storeProvider -> storeProvider.getTaskStore().getJobKeys());
   }
 
   private Set<IJobKey> toJobKeys(IScheduledTask... tasks) {
@@ -579,19 +526,11 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
       final CountDownLatch read = new CountDownLatch(numJobs);
       for (int j = 0; j < numJobs; j++) {
         final int id = j;
-        executor.submit(new Runnable() {
-          @Override
-          public void run() {
-            assertNotNull(fetchTasks(Query.jobScoped(JobKeys.from("role", "env", "name" + id))));
-            read.countDown();
-          }
-        });
-        executor.submit(new Runnable() {
-          @Override
-          public void run() {
-            saveTasks(createTask("TaskNew1" + id));
-          }
+        executor.submit(() -> {
+          assertNotNull(fetchTasks(Query.jobScoped(JobKeys.from("role", "env", "name" + id))));
+          read.countDown();
         });
+        executor.submit(() -> saveTasks(createTask("TaskNew1" + id)));
       }
 
       read.await();
@@ -614,21 +553,14 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
     addTearDown(() -> MoreExecutors.shutdownAndAwaitTermination(executor, 1, TimeUnit.SECONDS));
 
     saveTasks(TASK_A);
-    storage.write(new Storage.MutateWork.NoResult<Exception>() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) throws Exception {
-        IScheduledTask taskARunning = TaskTestUtil.addStateTransition(TASK_A, RUNNING, 1000L);
-        saveTasks(taskARunning);
-
-        Future<ScheduleStatus> asyncReadState = executor.submit(new Callable<ScheduleStatus>() {
-          @Override
-          public ScheduleStatus call() {
-            return Iterables.getOnlyElement(fetchTasks(Query.taskScoped(Tasks.id(TASK_A))))
-                .getStatus();
-          }
-        });
-        assertEquals(RUNNING, asyncReadState.get());
-      }
+    storage.write((NoResult<Exception>) storeProvider -> {
+      IScheduledTask taskARunning = TaskTestUtil.addStateTransition(TASK_A, RUNNING, 1000L);
+      saveTasks(taskARunning);
+
+      Future<ScheduleStatus> asyncReadState = executor.submit(
+          () -> Iterables.getOnlyElement(fetchTasks(Query.taskScoped(Tasks.id(TASK_A))))
+              .getStatus());
+      assertEquals(RUNNING, asyncReadState.get());
     });
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java b/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
index 2e3ac5a..2570464 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
@@ -22,6 +22,8 @@ import org.apache.aurora.gen.MesosContainer;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
+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.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.junit.Before;
@@ -48,12 +50,8 @@ public class StorageBackfillTest {
   @Test
   public void testBackfillTask() {
     final Set<IScheduledTask> backfilledTasks = ImmutableSet.of(TASK);
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(backfilledTasks);
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(backfilledTasks));
 
     backfill();
 
@@ -63,12 +61,7 @@ public class StorageBackfillTest {
   }
 
   private void backfill() {
-    storage.write(new Storage.MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(Storage.MutableStoreProvider storeProvider) {
-        StorageBackfill.backfill(storeProvider);
-      }
-    });
+    storage.write((Quiet) StorageBackfill::backfill);
   }
 
   private static IScheduledTask setMesosContainer(IScheduledTask task) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/d5d5a73c/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
index 20c9858..f5f5bda 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
@@ -26,10 +26,7 @@ import org.apache.aurora.gen.ScheduledTask;
 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.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.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.junit.Before;
@@ -148,12 +145,8 @@ public class DbAttributeStoreTest {
         .setSlaveId(HOST_A_ATTRS.getSlaveId());
     final IScheduledTask taskA = IScheduledTask.build(builder);
 
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(taskA));
-      }
-    });
+    storage.write((NoResult.Quiet)
+        storeProvider -> storeProvider.getUnsafeTaskStore().saveTasks(ImmutableSet.of(taskA)));
 
     HostAttributes attributeBuilder = HOST_A_ATTRS.newBuilder()
         .setMode(MaintenanceMode.DRAINED);
@@ -163,39 +156,21 @@ public class DbAttributeStoreTest {
     assertEquals(Optional.of(hostAUpdated), read(HOST_A));
   }
 
-  private void insert(final IHostAttributes attributes) {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getAttributeStore().saveHostAttributes(attributes);
-      }
-    });
+  private void insert(IHostAttributes attributes) {
+    storage.write(
+        storeProvider -> storeProvider.getAttributeStore().saveHostAttributes(attributes));
   }
 
-  private Optional<IHostAttributes> read(final String host) {
-    return storage.read(new Work.Quiet<Optional<IHostAttributes>>() {
-      @Override
-      public Optional<IHostAttributes> apply(StoreProvider storeProvider) {
-        return storeProvider.getAttributeStore().getHostAttributes(host);
-      }
-    });
+  private Optional<IHostAttributes> read(String host) {
+    return storage.read(storeProvider -> storeProvider.getAttributeStore().getHostAttributes(host));
   }
 
   private Set<IHostAttributes> readAll() {
-    return storage.read(new Work.Quiet<Set<IHostAttributes>>() {
-      @Override
-      public Set<IHostAttributes> apply(StoreProvider storeProvider) {
-        return storeProvider.getAttributeStore().getHostAttributes();
-      }
-    });
+    return storage.read(storeProvider -> storeProvider.getAttributeStore().getHostAttributes());
   }
 
   private void truncate() {
-    storage.write(new MutateWork.NoResult.Quiet() {
-      @Override
-      public void execute(MutableStoreProvider storeProvider) {
-        storeProvider.getAttributeStore().deleteHostAttributes();
-      }
-    });
+    storage.write(
+        (NoResult.Quiet) storeProvider -> storeProvider.getAttributeStore().deleteHostAttributes());
   }
 }


Mime
View raw message