use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsSet.
@Test
public void shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsSet() {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
Collection<Author> authors = mapper.selectAllAuthorsSet();
assertEquals(2, authors.size());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldFailExecutingAnAnnotatedMapperClassWithResultHandler.
@Test(expected = BindingException.class)
public void shouldFailExecutingAnAnnotatedMapperClassWithResultHandler() {
SqlSession session = sqlMapper.openSession();
try {
DefaultResultHandler handler = new DefaultResultHandler();
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
mapper.selectAuthor2(101, handler);
Author author = (Author) handler.getResultList().get(0);
assertEquals(101, author.getId());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionManagerTest method shouldRollbackInsertedAuthor.
@Test
public void shouldRollbackInsertedAuthor() throws Exception {
try {
manager.startManagedSession();
AuthorMapper mapper = manager.getMapper(AuthorMapper.class);
Author expected = new Author(501, "lmeadors", "******", "lmeadors@somewhere.com", "Something...", null);
mapper.insertAuthor(expected);
manager.rollback();
Author actual = mapper.selectAuthor(501);
assertNull(actual);
} finally {
manager.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldUpdateAuthorUsingMapperClass.
@Test
public void shouldUpdateAuthorUsingMapperClass() throws Exception {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
Author expected = mapper.selectAuthor(101);
expected.setUsername("NewUsername");
int count = mapper.updateAuthor(expected);
assertEquals(1, count);
Author actual = mapper.selectAuthor(101);
assertEquals(expected.getUsername(), actual.getUsername());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldExecuteSelectOneAuthorUsingMapperClassThatReturnsALinedHashMap.
@Test
public void shouldExecuteSelectOneAuthorUsingMapperClassThatReturnsALinedHashMap() {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
LinkedHashMap<String, Object> author = mapper.selectAuthorLinkedHashMap(101);
assertEquals(101, author.get("ID"));
} finally {
session.close();
}
}
Aggregations