Package org.mule.module.db.internal.parser

Examples of org.mule.module.db.internal.parser.QueryTemplateParser


    }

    @Test
    public void resolvesStaticBulkQuery() throws Exception
    {
        QueryTemplateParser queryTemplateParser = createQueryTemplateParser();

        StaticBulkQueryResolver bulkQueryResolver = new StaticBulkQueryResolver(BULK_SQL_QUERY, queryTemplateParser);

        BulkQuery resolvedBulkQuery = bulkQueryResolver.resolve(muleEvent);
View Full Code Here


    }

    @Test
    public void cachesResolvedBulkQueries() throws Exception
    {
        QueryTemplateParser queryTemplateParser = createQueryTemplateParser();

        StaticBulkQueryResolver bulkQueryResolver = new StaticBulkQueryResolver(BULK_SQL_QUERY, queryTemplateParser);

        BulkQuery resolvedBulkQuery1 = bulkQueryResolver.resolve(muleEvent);
        BulkQuery resolvedBulkQuery2 = bulkQueryResolver.resolve(muleEvent);
View Full Code Here

    protected final MuleEvent muleEvent = mock(MuleEvent.class);

    protected QueryTemplateParser createQueryTemplateParser()
    {
        QueryTemplateParser queryTemplateParser = mock(QueryTemplateParser.class);
        when(queryTemplateParser.parse(STATIC_SQL_1)).thenReturn(new QueryTemplate(STATIC_SQL_1, QueryType.DELETE, Collections.<QueryParam>emptyList()));
        when(queryTemplateParser.parse(STATIC_SQL_2)).thenReturn(new QueryTemplate(STATIC_SQL_2, QueryType.DELETE, Collections.<QueryParam>emptyList()));

        return queryTemplateParser;
    }
View Full Code Here

        ExpressionManager expressionManager = mock(ExpressionManager.class);
        String staticSqlText = STATIC_SQL_TEXT;
        when(expressionManager.parse(DYNAMIC_SQL_TEXT, muleEvent)).thenReturn(staticSqlText);

        QueryTemplate expectedQueryTemplate = createQueryTemplate(staticSqlText);
        QueryTemplateParser queryTemplateParser = mock(QueryTemplateParser.class);
        when(queryTemplateParser.parse(staticSqlText)).thenReturn(expectedQueryTemplate);

        DynamicQueryResolver queryResolver = new DynamicQueryResolver(query, queryTemplateParser, expressionManager);

        Query resolvedQuery = queryResolver.resolve(null, muleEvent);
View Full Code Here

    {
        ExpressionManager expressionManager = mock(ExpressionManager.class);
        String staticSqlText = STATIC_SQL_TEXT;
        when(expressionManager.parse(DYNAMIC_SQL_TEXT, muleEvent)).thenReturn(staticSqlText);

        QueryTemplateParser queryTemplateParser = mock(QueryTemplateParser.class);
        when(queryTemplateParser.parse(staticSqlText)).thenThrow(new QueryTemplateParsingException("Parse error"));

        DynamicQueryResolver queryResolver = new DynamicQueryResolver(query, queryTemplateParser, expressionManager);

        queryResolver.resolve(null, muleEvent);
    }
View Full Code Here

    @Test
    public void createsQueryWithNoParams() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(QUERY, QueryType.SELECT, Collections.<QueryParam>emptyList());

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

        ParameterizedQueryTemplateFactoryBean factoryBean = new ParameterizedQueryTemplateFactoryBean(QUERY, Collections.EMPTY_LIST, queryParser);

        QueryTemplate createdQueryTemplate = factoryBean.getObject();
View Full Code Here

    public void createsQueryWithDefaultParams() throws Exception
    {
        List<QueryParam> defaultParams = Collections.<QueryParam>singletonList(new DefaultInputQueryParam(1, JdbcTypes.INTEGER_DB_TYPE, 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);

        ParameterizedQueryTemplateFactoryBean factoryBean = new ParameterizedQueryTemplateFactoryBean(PARAMETERIZED_QUERY, Collections.EMPTY_LIST, queryParser);

        QueryTemplate createdQueryTemplate = factoryBean.getObject();
View Full Code Here

    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);

        ParameterizedQueryTemplateFactoryBean factoryBean = new ParameterizedQueryTemplateFactoryBean(PARAMETERIZED_QUERY, overriddenParams, queryParser);
View Full Code Here

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

    }

    @Test(expected = QueryResolutionException.class)
    public void throwsErrorOnEmptyBulkQuery() throws Exception
    {
        QueryTemplateParser queryTemplateParser = createQueryTemplateParser();

        ExpressionManager expressionManager = mock(ExpressionManager.class);
        when(expressionManager.parse(DYNAMIC_BULK_QUERY, muleEvent)).thenReturn("");

        DynamicBulkQueryResolver bulkQueryResolver = new DynamicBulkQueryResolver(DYNAMIC_BULK_QUERY, queryTemplateParser, expressionManager);
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.parser.QueryTemplateParser

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.