use of org.apache.ibatis.binding.MapperMethod in project mybatis-3 by acbfo-iscte.
the class SqlProviderTest method invalidArgumentsCombination.
@Test
void invalidArgumentsCombination() throws NoSuchMethodException {
try {
Class<?> mapperType = ErrorMapper.class;
Method mapperMethod = mapperType.getMethod("invalidArgumentsCombination", String.class);
new ProviderSqlSource(new Configuration(), mapperMethod.getAnnotation(DeleteProvider.class), mapperType, mapperMethod).getBoundSql("foo");
fail();
} catch (BuilderException e) {
assertTrue(e.getMessage().contains("Cannot invoke SqlProvider method 'public java.lang.String org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invalidArgumentsCombination(org.apache.ibatis.builder.annotation.ProviderContext,java.lang.String,java.lang.String)' with specify parameter 'class java.lang.String' because SqlProvider method arguments for 'public abstract void org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorMapper.invalidArgumentsCombination(java.lang.String)' is an invalid combination."));
}
}
use of org.apache.ibatis.binding.MapperMethod in project mybatis-3 by acbfo-iscte.
the class SqlProviderTest method keepBackwardCompatibilityOnDeprecatedConstructorWithAnnotation.
@Test
@SuppressWarnings("deprecation")
void keepBackwardCompatibilityOnDeprecatedConstructorWithAnnotation() throws NoSuchMethodException {
Class<?> mapperType = StaticMethodSqlProviderMapper.class;
Method mapperMethod = mapperType.getMethod("noArgument");
ProviderSqlSource sqlSource = new ProviderSqlSource(new Configuration(), (Object) mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod);
assertEquals("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS", sqlSource.getBoundSql(null).getSql());
}
use of org.apache.ibatis.binding.MapperMethod in project mybatis-3 by acbfo-iscte.
the class SqlProviderTest method notSupportParameterObjectOnMultipleArguments.
@Test
void notSupportParameterObjectOnMultipleArguments() throws NoSuchMethodException {
try {
Class<?> mapperType = Mapper.class;
Method mapperMethod = mapperType.getMethod("getUsersByName", String.class, String.class);
new ProviderSqlSource(new Configuration(), mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod).getBoundSql(new Object());
fail();
} catch (BuilderException e) {
assertTrue(e.getMessage().contains("Error invoking SqlProvider method 'public java.lang.String org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameQuery(java.lang.String,java.lang.String)' with specify parameter 'class java.lang.Object'. Cause: java.lang.IllegalArgumentException: wrong number of arguments"));
}
}
use of org.apache.ibatis.binding.MapperMethod in project mybatis-3 by mybatis.
the class SqlProviderTest method invokeError.
@Test
void invokeError() throws NoSuchMethodException {
try {
Class<?> mapperType = ErrorMapper.class;
Method mapperMethod = mapperType.getMethod("invokeError");
new ProviderSqlSource(new Configuration(), mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod).getBoundSql(new Object());
fail();
} catch (BuilderException e) {
assertTrue(e.getMessage().contains("Error invoking SqlProvider method 'public java.lang.String org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invokeError()' with specify parameter 'class java.lang.Object'. Cause: java.lang.UnsupportedOperationException: invokeError"));
}
}
use of org.apache.ibatis.binding.MapperMethod in project mybatis-3 by mybatis.
the class SqlProviderTest method invalidArgumentsCombination.
@Test
void invalidArgumentsCombination() throws NoSuchMethodException {
try {
Class<?> mapperType = ErrorMapper.class;
Method mapperMethod = mapperType.getMethod("invalidArgumentsCombination", String.class);
new ProviderSqlSource(new Configuration(), mapperMethod.getAnnotation(DeleteProvider.class), mapperType, mapperMethod).getBoundSql("foo");
fail();
} catch (BuilderException e) {
assertTrue(e.getMessage().contains("Cannot invoke SqlProvider method 'public java.lang.String org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invalidArgumentsCombination(org.apache.ibatis.builder.annotation.ProviderContext,java.lang.String,java.lang.String)' with specify parameter 'class java.lang.String' because SqlProvider method arguments for 'public abstract void org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorMapper.invalidArgumentsCombination(java.lang.String)' is an invalid combination."));
}
}
Aggregations