### Question:
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); }  Object provision(ProvisioningJob job); @Override void close();  }### Answer:
@Test public void testProvision() throws IOException { ProvisioningManager manager = new ProvisioningManager(); AtomicInteger completedJobs = new AtomicInteger(0); try { for (int i = 0; i < 5; i++) { manager.provision(new MockJob(200, "slow", completedJobs)); manager.provision(new MockJob(0, "fast", completedJobs)); manager.provision(new MockJob(100, "normal", completedJobs)); } } finally { manager.close(); } assertEquals(completedJobs.get(), 15); }
@Test public void testProvisionInterrupted() { ProvisioningManager manager = new ProvisioningManager(); AtomicInteger completedJobs = new AtomicInteger(0); manager.provision(new ShutdownExecutorJob(manager, completedJobs)); manager.provision(new MockJob(0, "rejected", completedJobs)); assertEquals(completedJobs.get(), 1); }