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

Examples of org.mule.module.db.internal.domain.query.QueryTemplate


    }

    private QueryTemplate doOverriddenParamTest(DbType templateParamType, QueryParam overriddenParam) throws Exception
    {
        List<QueryParam> defaultParams = Collections.<QueryParam>singletonList(new DefaultInputQueryParam(1, templateParamType, TEMPLATE_PARAM_VALUE, POSITION_PARAM_NAME));
        QueryTemplate queryTemplate = new QueryTemplate(PARSED_PARAMETERIZED_QUERY, QueryType.SELECT, defaultParams);

        QueryTemplateParser queryParser = mock(QueryTemplateParser.class);
        when(queryParser.parse(PARAMETERIZED_QUERY)).thenReturn(queryTemplate);

        List<QueryParam> overriddenParams = Collections.<QueryParam>singletonList(overriddenParam);
View Full Code Here


    private void doOutputParamOverrideTest(DbType templateParamType, DbType overriddenParamType, DbType expectedParamType) throws Exception
    {
        QueryParam overriddenParam = new DefaultOutputQueryParam(2, overriddenParamType, POSITION_PARAM_NAME);

        List<QueryParam> defaultParams = Collections.<QueryParam>singletonList(new DefaultInputQueryParam(1, templateParamType, TEMPLATE_PARAM_VALUE, POSITION_PARAM_NAME));
        QueryTemplate queryTemplate = new QueryTemplate(PARSED_PARAMETERIZED_QUERY, QueryType.SELECT, defaultParams);

        QueryTemplateParser queryParser = mock(QueryTemplateParser.class);
        when(queryParser.parse(PARAMETERIZED_QUERY)).thenReturn(queryTemplate);

        List<QueryParam> overriddenParams = Collections.singletonList(overriddenParam);

        ParameterizedQueryTemplateFactoryBean factoryBean = new ParameterizedQueryTemplateFactoryBean(PARAMETERIZED_QUERY, overriddenParams, queryParser);

        QueryTemplate createdQueryTemplate = factoryBean.getObject();

        assertThat(createdQueryTemplate.getParams().size(), equalTo(1));
        OutputQueryParam queryParam = createdQueryTemplate.getOutputParams().get(0);
        assertThat(queryParam.getIndex(), equalTo(1));
        assertThat(queryParam.getType(), equalTo(expectedParamType));
        assertThat(queryParam.getName(), equalTo(POSITION_PARAM_NAME));
    }
View Full Code Here

    @Test
    public void configuresSimpleQuery() throws Exception
    {
        Object queryTemplateBean = muleContext.getRegistry().get("simple");
        assertTrue(queryTemplateBean instanceof QueryTemplate);
        QueryTemplate queryTemplate = (QueryTemplate) queryTemplateBean;
        assertEquals(QueryType.UPDATE, queryTemplate.getType());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

    @Test
    public void configuresParameterizedQuery() throws Exception
    {
        Object queryTemplateBean = muleContext.getRegistry().get("parameterized");
        assertTrue(queryTemplateBean instanceof QueryTemplate);
        QueryTemplate queryTemplate = (QueryTemplate) queryTemplateBean;
        assertEquals(QueryType.UPDATE, queryTemplate.getType());
        assertEquals(1, queryTemplate.getInputParams().size());

        InputQueryParam inputSqlParam = queryTemplate.getInputParams().get(0);
        assertEquals(UnknownDbType.getInstance(), inputSqlParam.getType());
    }
View Full Code Here

    {
        String dynamicQuery = "select from #[table]";

        DynamicQueryTemplateFactoryBean factoryBean = new DynamicQueryTemplateFactoryBean(dynamicQuery);

        QueryTemplate queryTemplate = factoryBean.getObject();

        assertThat(queryTemplate.getSqlText(), equalTo(dynamicQuery));
        assertThat(queryTemplate.getType(), equalTo(QueryType.DDL));
        assertThat(queryTemplate.getParams(), is(empty()));
    }
View Full Code Here

        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);
View Full Code Here

        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);
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.domain.query.QueryTemplate

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.