use of org.apache.ibatis.domain.blog.Author 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.Author in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldUpdateAuthorImplicitRollback.
@Test
public void shouldUpdateAuthorImplicitRollback() throws Exception {
SqlSession session = sqlMapper.openSession();
Author original;
Author updated;
try {
original = session.selectOne("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthor", 101);
original.setEmail("new@email.com");
int updates = session.update("org.apache.ibatis.domain.blog.mappers.AuthorMapper.updateAuthor", original);
assertEquals(1, updates);
updated = session.selectOne("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthor", 101);
assertEquals(original.getEmail(), updated.getEmail());
} finally {
session.close();
}
try {
session = sqlMapper.openSession();
updated = session.selectOne("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthor", 101);
assertEquals("jim@ibatis.apache.org", updated.getEmail());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectOneImmutableAuthor.
@Test
public void shouldSelectOneImmutableAuthor() throws Exception {
SqlSession session = sqlMapper.openSession();
try {
ImmutableAuthor author = session.selectOne("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectImmutableAuthor", new Author(101));
assertEquals(101, author.getId());
assertEquals(Section.NEWS, author.getFavouriteSection());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectOneAuthorAsList.
@Test
public void shouldSelectOneAuthorAsList() throws Exception {
SqlSession session = sqlMapper.openSession();
try {
List<Author> authors = session.selectList("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthor", new Author(101));
assertEquals(101, authors.get(0).getId());
assertEquals(Section.NEWS, authors.get(0).getFavouriteSection());
} finally {
session.close();
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectOneAuthor.
@Test
public void shouldSelectOneAuthor() throws Exception {
SqlSession session = sqlMapper.openSession();
try {
Author author = session.selectOne("org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthor", new Author(101));
assertEquals(101, author.getId());
assertEquals(Section.NEWS, author.getFavouriteSection());
} finally {
session.close();
}
}
Aggregations