use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectNestedBlogWithPostsAndAuthorUsingJoin.
@Test
void shouldSelectNestedBlogWithPostsAndAuthorUsingJoin() {
try (SqlSession session = sqlMapper.openSession()) {
Blog blog = session.selectOne("org.apache.ibatis.domain.blog.mappers.NestedBlogMapper.selectBlogJoinedWithPostsAndAuthor", 1);
assertEquals("Jim Business", blog.getTitle());
final Author author = blog.getAuthor();
assertEquals(101, author.getId());
assertEquals("jim", author.getUsername());
final List<Post> posts = blog.getPosts();
assertEquals(2, posts.size());
final Post post = blog.getPosts().get(0);
assertEquals(1, post.getId());
assertEquals("Corn nuts", post.getSubject());
final List<Comment> comments = post.getComments();
assertEquals(2, comments.size());
final List<Tag> tags = post.getTags();
assertEquals(3, tags.size());
final Comment comment = comments.get(0);
assertEquals(1, comment.getId());
assertEquals(DraftPost.class, blog.getPosts().get(0).getClass());
assertEquals(Post.class, blog.getPosts().get(1).getClass());
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldFindPostsInArray.
@Test
void shouldFindPostsInArray() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class);
Integer[] params = new Integer[] { 1, 3, 5 };
List<Post> posts = mapper.findPostsInArray(params);
assertEquals(3, posts.size());
session.rollback();
}
}
use of org.apache.ibatis.domain.blog.Post 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.Post 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");
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldFindThreeSpecificPosts.
@Test
void shouldFindThreeSpecificPosts() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class);
List<Post> posts = mapper.findThreeSpecificPosts(1, new RowBounds(1, 1), 3, 5);
assertEquals(1, posts.size());
assertEquals(3, posts.get(0).getId());
session.rollback();
}
}
Aggregations