use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionManagerTest method shouldCommitInsertedAuthor.
@Test
public void shouldCommitInsertedAuthor() throws Exception {
try {
manager.startManagedSession();
AuthorMapper mapper = manager.getMapper(AuthorMapper.class);
Author expected = new Author(500, "cbegin", "******", "cbegin@somewhere.com", "Something...", null);
mapper.insertAuthor(expected);
manager.commit();
Author actual = mapper.selectAuthor(500);
assertNotNull(actual);
} finally {
manager.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionManagerTest method shouldImplicitlyRollbackInsertedAuthor.
@Test
public void shouldImplicitlyRollbackInsertedAuthor() throws Exception {
manager.startManagedSession();
AuthorMapper mapper = manager.getMapper(AuthorMapper.class);
Author expected = new Author(502, "emacarron", "******", "emacarron@somewhere.com", "Something...", null);
mapper.insertAuthor(expected);
manager.close();
Author actual = mapper.selectAuthor(502);
assertNull(actual);
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectAuthorsUsingMapperClass.
@Test
public void shouldSelectAuthorsUsingMapperClass() {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
List<Author> authors = mapper.selectAllAuthors();
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 shouldInsertAuthorUsingMapperClass.
@Test
public void shouldInsertAuthorUsingMapperClass() throws Exception {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
Author expected = new Author(500, "cbegin", "******", "cbegin@somewhere.com", "Something...", null);
mapper.insertAuthor(expected);
Author actual = mapper.selectAuthor(500);
assertNotNull(actual);
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getUsername(), actual.getUsername());
assertEquals(expected.getPassword(), actual.getPassword());
assertEquals(expected.getEmail(), actual.getEmail());
assertEquals(expected.getBio(), actual.getBio());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.mappers.AuthorMapper in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsVector.
@Test
public void shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsVector() {
SqlSession session = sqlMapper.openSession();
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
Collection<Author> authors = mapper.selectAllAuthorsVector();
assertEquals(2, authors.size());
} finally {
session.close();
}
}
Aggregations