use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREORWithTABForFirstCondition.
@Test
public void shouldTrimWHEREORWithTABForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE \t ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" or\t ID = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method createDynamicSqlSource.
private DynamicSqlSource createDynamicSqlSource(SqlNode... contents) throws IOException, SQLException {
createBlogDataSource();
final String resource = "org/apache/ibatis/builder/MapperConfig.xml";
final Reader reader = Resources.getResourceAsReader(resource);
SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(reader);
Configuration configuration = sqlMapper.getConfiguration();
MixedSqlNode sqlNode = mixedContents(contents);
return new DynamicSqlSource(configuration, sqlNode);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class WrongMapperTest method shouldFailForBothOneAndMany.
@Test(expected = RuntimeException.class)
public void shouldFailForBothOneAndMany() throws Exception {
Configuration configuration = new Configuration();
configuration.addMapper(MapperWithOneAndMany.class);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class WrongNamespacesTest method shouldFailForWrongNamespace.
@Test(expected = RuntimeException.class)
public void shouldFailForWrongNamespace() throws Exception {
Configuration configuration = new Configuration();
configuration.addMapper(WrongNamespaceMapper.class);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class WrongNamespacesTest method shouldFailForMissingNamespace.
@Test(expected = RuntimeException.class)
public void shouldFailForMissingNamespace() throws Exception {
Configuration configuration = new Configuration();
configuration.addMapper(MissingNamespaceMapper.class);
}
Aggregations