### Question:
SimpleTaskExecutor implements TaskExecutor { @Override public void execute(String tokenId, Task task) { try { if (!connectionFactory.isValid(connection)) { close(); start(); } } catch (DataLayerException e) { error("acquiring connection", e); task.processError(e); return; } try { task.execute(connection, adapter); } catch (DataLayerException e) { error("processing task", e); } } @Inject  SimpleTaskExecutor(ConnectionFactory connectionFactory,
            @Named(DataLayerConstants.DATA_LAYER_DEBUG) Debug debug,
            TokenStorageAdapter adapter); @Override synchronized void start(); @Override void execute(String tokenId, Task task);  }### Answer:
@Test public void testExecute() throws Exception { Task task = mock(Task.class); Closeable connection = mock(Closeable.class); when(connectionFactory.create()).thenReturn(connection); when(connectionFactory.isValid(connection)).thenReturn(true); executor.start(); executor.execute(null, task); verify(task).execute(connection, adapter); }