### Question:
BatchJobSupplier implements ChainableSupplier<SparkJobResponse> { @Nonnull @Override public SparkJobResponse get() { SparkJobResponse response = restClient.createJob(process, request); while (response.getStatus() == SparkJobResponse.Status.PENDING) { sleep(pollInterval); response = restClient.getJobResult(process, response.getId()).orElseThrow(NoSuchElementException::new); } return response; } BatchJobSupplier(@Nonnull final SparkJobRequest request, @Nonnull final SparkShellProcess process, @Nonnull final SparkShellRestClient restClient); @Nonnull @Override SparkJobResponse get(); void setPollInterval(final long time, @Nonnull final TimeUnit unit);  }### Answer:
@Test public void testError() { Mockito.when(restClient.createJob(process, request)).thenReturn(ERROR_RESPONSE); final SparkJobResponse response = new MockBatchJob().get(); Assert.assertEquals(ERROR_RESPONSE, response); Assert.assertEquals(0, sleepMillis.get()); }
@Test public void testSuccess() { Mockito.when(restClient.createJob(process, request)).thenReturn(SUCCESS_RESPONSE); final SparkJobResponse response = new MockBatchJob().get(); Assert.assertEquals(SUCCESS_RESPONSE, response); Assert.assertEquals(0, sleepMillis.get()); }