use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldSelectBlogWithDefault30ParamNames.
@Test
void shouldSelectBlogWithDefault30ParamNames() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlogByDefault30ParamNames(1, "Jim Business");
assertNotNull(blog);
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldSelectBlogWithPostsUsingSubSelect.
@Test
void shouldSelectBlogWithPostsUsingSubSelect() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog b = mapper.selectBlogWithPostsUsingSubSelect(1);
assertEquals(1, b.getId());
assertNotNull(b.getAuthor());
assertEquals(101, b.getAuthor().getId());
assertEquals("jim", b.getAuthor().getUsername());
assertEquals("********", b.getAuthor().getPassword());
assertEquals(2, b.getPosts().size());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectOneBlogStatementWithConstructorUsingXMLConfig.
@Test
void shouldExecuteBoundSelectOneBlogStatementWithConstructorUsingXMLConfig() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlogByIdUsingConstructor(1);
assertEquals(1, blog.getId());
assertEquals("Jim Business", blog.getTitle());
assertNotNull(blog.getAuthor(), "author should not be null");
List<Post> posts = blog.getPosts();
assertTrue(posts != null && !posts.isEmpty(), "posts should not be empty");
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method executeWithResultHandlerAndRowBounds.
@Test
void executeWithResultHandlerAndRowBounds() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
final DefaultResultHandler handler = new DefaultResultHandler();
mapper.collectRangeBlogs(handler, new RowBounds(1, 1));
assertEquals(1, handler.getResultList().size());
Blog blog = (Blog) handler.getResultList().get(0);
assertEquals(2, blog.getId());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectListOfBlogsStatementUsingProvider.
@Test
void shouldExecuteBoundSelectListOfBlogsStatementUsingProvider() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
List<Blog> blogs = mapper.selectBlogsUsingProvider();
assertEquals(2, blogs.size());
}
}
Aggregations