Package org.mule.module.db.internal.domain.statement

Examples of org.mule.module.db.internal.domain.statement.StatementFactory


    {
        ResultSet resultSet = mock(ResultSet.class);
        Statement statement = mock(Statement.class);
        String sqlText = "SELECT * FROM dummy";
        when(statement.executeQuery(sqlText)).thenReturn(resultSet);
        StatementFactory statementFactory = mock(StatementFactory.class);

        DbConnection connection = mock(DbConnection.class);

        ResultSetHandler resultHandler = mock(ResultSetHandler.class);
        List<Object> processedResult = new ArrayList<Object>();
        when(resultHandler.processResultSet(connection, resultSet)).thenReturn(processedResult);
        SelectExecutor selectExecutor = new SelectExecutor(statementFactory, resultHandler);

        QueryTemplate queryTemplate = new QueryTemplate(sqlText, QueryType.SELECT, Collections.<QueryParam>emptyList());
        Mockito.when(statementFactory.create(connection, queryTemplate)).thenReturn(statement);

        Query query = new Query(queryTemplate, null);
        Object result = selectExecutor.execute(connection, query);

        assertEquals(processedResult, result);
View Full Code Here


    public void testUpdate() throws Exception
    {
        Statement statement = mock(Statement.class);
        String sqlText = "UPDATE dummy SET NAME='Mercury' WHERE id=777";
        when(statement.executeUpdate(sqlText, Statement.NO_GENERATED_KEYS)).thenReturn(1);
        StatementFactory statementFactory = mock(StatementFactory.class);
        DbConnection connection = mock(DbConnection.class);
        UpdateExecutor updateExecutor = new UpdateExecutor(statementFactory);

        QueryTemplate queryTemplate = new QueryTemplate(sqlText, QueryType.UPDATE, Collections.<QueryParam>emptyList());
        Mockito.when(statementFactory.create(connection, queryTemplate)).thenReturn(statement);
        Query query = new Query(queryTemplate, null);

        Object result = updateExecutor.execute(connection, query);

        assertEquals(1, result);
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.domain.statement.StatementFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.