@SuppressWarnings("unchecked") @Test public void executeTest() throws Exception { Project project = mock(Project.class); LogicalWorkflowExecutor logicalWorkflowExecutor = mock(LogicalWorkflowExecutor.class); Connection<MongoClient> connection = mock(Connection.class); ProjectParsed projectParsed = mock(ProjectParsed.class); PowerMockito.whenNew(ProjectParsed.class).withAnyArguments().thenReturn(projectParsed); PowerMockito.mockStatic(LogicalWorkflowExecutorFactory.class); PowerMockito.when(LogicalWorkflowExecutorFactory.getLogicalWorkflowExecutor(Matchers.any(ProjectParsed.class))) .thenReturn(logicalWorkflowExecutor); ResultSet resultSet = mock(ResultSet.class); when(logicalWorkflowExecutor.executeQuery(connection)).thenReturn(resultSet); QueryResult queryResult = mock(QueryResult.class); PowerMockito.mockStatic(QueryResult.class); PowerMockito.when(QueryResult.createQueryResult(resultSet, 0, true)).thenReturn(queryResult); QueryResult returnQueryResult = mongoQueryEngine.execute(project, connection); verify(logicalWorkflowExecutor, times(1)).executeQuery(connection); PowerMockito.verifyStatic(times(1)); QueryResult.createQueryResult(resultSet, 0, true); assertEquals("The query result is wrong", queryResult, returnQueryResult); }
@Override @TimerJ public QueryResult execute(Project project, Connection<MongoClient> connection) throws MongoValidationException, ConnectorException { ProjectParsed logicalWorkfloParsed = new ProjectParsed(project, new MongoLogicalWorkflowValidator()); LogicalWorkflowExecutor executor = LogicalWorkflowExecutorFactory .getLogicalWorkflowExecutor(logicalWorkfloParsed); ResultSet resultSet = executor.executeQuery(connection); return QueryResult.createQueryResult(resultSet, 0, true); }
MongoQueryEngine extends SingleProjectQueryEngine<MongoClient> { @Override @TimerJ public QueryResult execute(Project project, Connection<MongoClient> connection) throws MongoValidationException, ConnectorException { ProjectParsed logicalWorkfloParsed = new ProjectParsed(project, new MongoLogicalWorkflowValidator()); LogicalWorkflowExecutor executor = LogicalWorkflowExecutorFactory .getLogicalWorkflowExecutor(logicalWorkfloParsed); ResultSet resultSet = executor.executeQuery(connection); return QueryResult.createQueryResult(resultSet, 0, true); } }
MongoQueryEngine extends SingleProjectQueryEngine<MongoClient> { @Override @TimerJ public QueryResult execute(Project project, Connection<MongoClient> connection) throws MongoValidationException, ConnectorException { ProjectParsed logicalWorkfloParsed = new ProjectParsed(project, new MongoLogicalWorkflowValidator()); LogicalWorkflowExecutor executor = LogicalWorkflowExecutorFactory .getLogicalWorkflowExecutor(logicalWorkfloParsed); ResultSet resultSet = executor.executeQuery(connection); return QueryResult.createQueryResult(resultSet, 0, true); } private  MongoQueryEngine(MongoConnectionHandler connectionHandler); }
MongoQueryEngine extends SingleProjectQueryEngine<MongoClient> { @Override @TimerJ public QueryResult execute(Project project, Connection<MongoClient> connection) throws MongoValidationException, ConnectorException { ProjectParsed logicalWorkfloParsed = new ProjectParsed(project, new MongoLogicalWorkflowValidator()); LogicalWorkflowExecutor executor = LogicalWorkflowExecutorFactory .getLogicalWorkflowExecutor(logicalWorkfloParsed); ResultSet resultSet = executor.executeQuery(connection); return QueryResult.createQueryResult(resultSet, 0, true); } private  MongoQueryEngine(MongoConnectionHandler connectionHandler); static MongoQueryEngine getInstance(MongoConnectionHandler connectionHandler); @Override @TimerJ QueryResult execute(Project project, Connection<MongoClient> connection); @Override void stop(String queryId); }
MongoQueryEngine extends SingleProjectQueryEngine<MongoClient> { @Override @TimerJ public QueryResult execute(Project project, Connection<MongoClient> connection) throws MongoValidationException, ConnectorException { ProjectParsed logicalWorkfloParsed = new ProjectParsed(project, new MongoLogicalWorkflowValidator()); LogicalWorkflowExecutor executor = LogicalWorkflowExecutorFactory .getLogicalWorkflowExecutor(logicalWorkfloParsed); ResultSet resultSet = executor.executeQuery(connection); return QueryResult.createQueryResult(resultSet, 0, true); } private  MongoQueryEngine(MongoConnectionHandler connectionHandler); static MongoQueryEngine getInstance(MongoConnectionHandler connectionHandler); @Override @TimerJ QueryResult execute(Project project, Connection<MongoClient> connection); @Override void stop(String queryId);  }