use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method executeWithCursorAndRowBounds.
@Test
void executeWithCursorAndRowBounds() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
try (Cursor<Blog> blogs = mapper.openRangeBlogs(new RowBounds(1, 1))) {
Iterator<Blog> blogIterator = blogs.iterator();
Blog blog = blogIterator.next();
assertEquals(2, blog.getId());
assertFalse(blogIterator.hasNext());
}
} catch (IOException e) {
Assertions.fail(e.getMessage());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectOneBlogStatementWithConstructor.
@Test
void shouldExecuteBoundSelectOneBlogStatementWithConstructor() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlogUsingConstructor(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 shouldExecuteBoundSelectMapOfBlogsById.
@Test
void shouldExecuteBoundSelectMapOfBlogsById() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Map<Integer, Blog> blogs = mapper.selectBlogsAsMapById();
assertEquals(2, blogs.size());
for (Map.Entry<Integer, Blog> blogEntry : blogs.entrySet()) {
assertEquals(blogEntry.getKey(), (Integer) blogEntry.getValue().getId());
}
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteMultipleBoundSelectMapOfBlogsByIdBetweenTwoSessionsWithGlobalCacheEnabled.
@Test
void shouldExecuteMultipleBoundSelectMapOfBlogsByIdBetweenTwoSessionsWithGlobalCacheEnabled() {
Map<Integer, Blog> blogs;
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
blogs = mapper.selectBlogsAsMapById();
}
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Map<Integer, Blog> moreBlogs = mapper.selectBlogsAsMapById();
assertEquals(2, blogs.size());
assertEquals(2, moreBlogs.size());
for (Map.Entry<Integer, Blog> blogEntry : blogs.entrySet()) {
assertEquals(blogEntry.getKey(), (Integer) blogEntry.getValue().getId());
}
for (Map.Entry<Integer, Blog> blogEntry : moreBlogs.entrySet()) {
assertEquals(blogEntry.getKey(), (Integer) blogEntry.getValue().getId());
}
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectBlogUsingConstructorWithResultMapCollection.
@Disabled
// issue #480 and #101
@Test
void shouldExecuteBoundSelectBlogUsingConstructorWithResultMapCollection() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlogUsingConstructorWithResultMapCollection(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");
}
}
Aggregations