### Question:
CommonsQueryEngine implements IQueryEngine { @Override public final void asyncExecute(String queryId, LogicalWorkflow workflow, IResultHandler resultHandler) throws ConnectorException { Long time = null; try { for (LogicalStep project : workflow.getInitialSteps()) { ClusterName clusterName = ((Project) project).getClusterName(); connectionHandler.startJob(clusterName.getName()); } if (logger.isDebugEnabled()) { logger.debug("Async Executing [" + workflow.toString() + "] : queryId [" + queryId + "]"); } time = System.currentTimeMillis(); asyncExecuteWorkFlow(queryId, workflow, resultHandler); if (logger.isDebugEnabled()) { logger.debug( "The async query [" + queryId + "] has ended"); } } finally { for (LogicalStep project : workflow.getInitialSteps()) { connectionHandler.endJob(((Project) project).getClusterName().getName()); } if (time != null) { logger.info("TIME - The execute time to async executed with queryId [" + queryId + "] has been [" + (System .currentTimeMillis() - time) + "]"); } } } protected  CommonsQueryEngine(ConnectionHandler connectionHandler); @Override final void asyncExecute(String queryId, LogicalWorkflow workflow, IResultHandler resultHandler); @Override final void pagedExecute(String queryId, LogicalWorkflow workflow, IResultHandler resultHandler,
                                   int pageSize); @Override final QueryResult execute(String queryId, LogicalWorkflow workflow);  }### Answer:
@Test public void testasyncExecute() throws Exception { String queryID = "queryID"; LogicalWorkflow logicalworkFlow = mock(LogicalWorkflow.class); IResultHandler resultHandler = mock(IResultHandler.class); commonsQueryEngineStub.asyncExecute(queryID, logicalworkFlow, resultHandler); assertTrue("executeWorkFlow is executed", executeAsyncExecute); assertEquals("The queryId is correct", queryIdSend, queryID); assertEquals("The workflow is correct", workflowSend, logicalworkFlow); assertEquals("The resultHandler is correct", resultHandler, resultHandlerSend); }
@Test public void testasyncExecuteLog() throws Exception { Logger logger = mock(Logger.class); Whitebox.setInternalState(commonsQueryEngineStub, "logger", logger); when(logger.isDebugEnabled()).thenReturn(true); String queryID = "queryID"; LogicalWorkflow logicalworkFlow = mock(LogicalWorkflow.class); IResultHandler resultHandler = mock(IResultHandler.class); commonsQueryEngineStub.asyncExecute(queryID, logicalworkFlow, resultHandler); verify(logger).debug("Async Executing [" + logicalworkFlow.toString() + "] : queryId [" + queryID + "]"); verify(logger).debug("The async query [" + queryID + "] has ended"); }