Search in sources :

Example 1 with ProviderSqlSource

use of org.apache.ibatis.builder.annotation.ProviderSqlSource in project mybatis-3 by mybatis.

the class SqlProviderTest method notSupportParameterObjectOnNamedArgument.

@Test
public void notSupportParameterObjectOnNamedArgument() throws NoSuchMethodException {
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameWithParamNameQuery). Cannot invoke a method that holds named argument(@Param) using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
    new ProviderSqlSource(new Configuration(), Mapper.class.getMethod("getUsersByNameWithParamName", String.class).getAnnotation(SelectProvider.class)).getBoundSql(new Object());
}
Also used : Configuration(org.apache.ibatis.session.Configuration) ProviderSqlSource(org.apache.ibatis.builder.annotation.ProviderSqlSource) Test(org.junit.Test)

Example 2 with ProviderSqlSource

use of org.apache.ibatis.builder.annotation.ProviderSqlSource in project mybatis-3 by mybatis.

the class SqlProviderTest method methodOverload.

@Test
public void methodOverload() throws NoSuchMethodException {
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error creating SqlSource for SqlProvider. Method 'overload' is found multiple in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'. Sql provider method can not overload."));
    new ProviderSqlSource(new Configuration(), ErrorMapper.class.getMethod("methodOverload", String.class).getAnnotation(SelectProvider.class));
}
Also used : SelectProvider(org.apache.ibatis.annotations.SelectProvider) Configuration(org.apache.ibatis.session.Configuration) ProviderSqlSource(org.apache.ibatis.builder.annotation.ProviderSqlSource) Test(org.junit.Test)

Example 3 with ProviderSqlSource

use of org.apache.ibatis.builder.annotation.ProviderSqlSource in project mybatis-3 by mybatis.

the class SqlProviderTest method notSupportParameterObjectOnMultipleArguments.

@Test
public void notSupportParameterObjectOnMultipleArguments() throws NoSuchMethodException {
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameQuery). Cannot invoke a method that holds multiple arguments using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
    new ProviderSqlSource(new Configuration(), Mapper.class.getMethod("getUsersByName", String.class, String.class).getAnnotation(SelectProvider.class)).getBoundSql(new Object());
}
Also used : Configuration(org.apache.ibatis.session.Configuration) ProviderSqlSource(org.apache.ibatis.builder.annotation.ProviderSqlSource) Test(org.junit.Test)

Example 4 with ProviderSqlSource

use of org.apache.ibatis.builder.annotation.ProviderSqlSource in project mybatis-3 by mybatis.

the class SqlProviderTest method invokeError.

@Test
public void invokeError() throws NoSuchMethodException {
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invokeError).  Cause: java.lang.reflect.InvocationTargetException"));
    new ProviderSqlSource(new Configuration(), ErrorMapper.class.getMethod("invokeError").getAnnotation(SelectProvider.class)).getBoundSql(new Object());
}
Also used : Configuration(org.apache.ibatis.session.Configuration) ProviderSqlSource(org.apache.ibatis.builder.annotation.ProviderSqlSource) Test(org.junit.Test)

Example 5 with ProviderSqlSource

use of org.apache.ibatis.builder.annotation.ProviderSqlSource in project mybatis-3 by mybatis.

the class SqlProviderTest method notSqlProvider.

@Test
public void notSqlProvider() throws NoSuchMethodException {
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error creating SqlSource for SqlProvider.  Cause: java.lang.NoSuchMethodException: java.lang.Object.type()"));
    new ProviderSqlSource(new Configuration(), new Object());
}
Also used : Configuration(org.apache.ibatis.session.Configuration) ProviderSqlSource(org.apache.ibatis.builder.annotation.ProviderSqlSource) Test(org.junit.Test)

Aggregations

ProviderSqlSource (org.apache.ibatis.builder.annotation.ProviderSqlSource)6 Configuration (org.apache.ibatis.session.Configuration)6 Test (org.junit.Test)6 SelectProvider (org.apache.ibatis.annotations.SelectProvider)2