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

Examples of org.mule.module.db.internal.domain.param.DefaultInputQueryParam


    }

    @Test(expected = UnknownDbTypeException.class)
    public void failsResolvingInvalidType() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, new DynamicDbType(CUSTOM_TYPE_NAME), "7", "param1")));

        when(metadataParamTypeResolver.getParameterTypes(connection, queryTemplate)).thenThrow(new SQLException("Error"));
        when(dbTypeManager.lookup(connection, CUSTOM_TYPE_NAME)).thenThrow(new UnknownDbTypeException(CUSTOM_TYPE_NAME));

        paramTypeResolver.getParameterTypes(connection, queryTemplate);
View Full Code Here


        return new DbConnectionBuilder().preparing(SQL_TEXT, preparedStatement).build();
    }

    private QueryTemplate createQueryTemplate()
    {
        return new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", "param1")));
    }
View Full Code Here

        final String sqlText = "call testStoredProcedure(?)";

        DbConnection connection = new DbConnectionBuilder().onCalatog(catalog).with(databaseMetaData).build();

        QueryTemplate queryTemplate = new QueryTemplate(sqlText, QueryType.STORE_PROCEDURE_CALL, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", TYPE_COLUMN)));

        DbTypeManager dbTypeManager = new DbTypeManagerBuilder().on(connection).managing(JdbcTypes.INTEGER_DB_TYPE).build();

        StoredProcedureParamTypeResolver paramTypeResolver = new StoredProcedureParamTypeResolver(dbTypeManager);
View Full Code Here

    }

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

    }

    @Test
    public void createsQueryWithOverriddenParams() throws Exception
    {
        QueryTemplate createdQueryTemplate = doOverriddenParamTest(JdbcTypes.INTEGER_DB_TYPE, new DefaultInputQueryParam(1, JdbcTypes.INTEGER_DB_TYPE, OVERRIDDEN_PARAM_VALUE, POSITION_PARAM_NAME));

        assertThat(createdQueryTemplate.getSqlText(), equalTo(PARSED_PARAMETERIZED_QUERY));
        assertThat(createdQueryTemplate.getType(), equalTo(QueryType.SELECT));
        assertThat(createdQueryTemplate.getParams().size(), equalTo(1));
        InputQueryParam inputQueryParam = createdQueryTemplate.getInputParams().get(0);
View Full Code Here

        doOutputParamOverrideTest(UnknownDbType.getInstance(), JdbcTypes.INTEGER_DB_TYPE, JdbcTypes.INTEGER_DB_TYPE);
    }

    private void doInputParamOverrideTest(DbType templateParamType, DbType overriddenParamType, DbType expectedParamType) throws Exception
    {
        QueryParam overriddenParam = new DefaultInputQueryParam(2, overriddenParamType, OVERRIDDEN_PARAM_VALUE, POSITION_PARAM_NAME);

        QueryTemplate createdQueryTemplate = doOverriddenParamTest(templateParamType, overriddenParam);

        assertThat(createdQueryTemplate.getParams().size(), equalTo(1));
        InputQueryParam inputQueryParam = createdQueryTemplate.getInputParams().get(0);
View Full Code Here

        assertThat(queryParam.getValue(), IsEqual.<Object>equalTo(OVERRIDDEN_PARAM_VALUE));
    }

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

TOP

Related Classes of org.mule.module.db.internal.domain.param.DefaultInputQueryParam

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.