@Test public void testSelectByPrimaryKey() { User selectByPrimaryKey = userMapper.selectByPrimaryKey(Long.valueOf(102)); assertNotNull(selectByPrimaryKey); assertEquals("first_name_102", selectByPrimaryKey.getFirstName()); assertEquals("last_name_102", selectByPrimaryKey.getLastName()); }
@Test public void testUpdateByPrimaryKey() { User record = userMapper.selectByPrimaryKey(104L); record.setFirstName("firstName-updated"); record.setLastName("lastName-updated"); int updateByPrimaryKey = userMapper.updateByPrimaryKey(record); assertEquals(1, updateByPrimaryKey); }
@Test public void testInsert() { User record = new User(); record.setFirstName("firstName"); record.setLastName("lastName"); int insert = userMapper.insert(record); assertEquals(1, insert); assertNotNull(record.getId()); }
@Test public void testCount() { User search = new User(); search.setFirstName("first_name_page"); search.setLastName("last_name_page"); Example example = Example.create(search); DetachedCriteria dc = DetachedCriteria.forClass(User.class).add(example); Long count = userMapper.count(dc); assertEquals(Long.valueOf(3), count); }
@Test public void testFind() { User search = new User(); search.setFirstName("first_name_page"); search.setLastName("last_name_page"); Example example = Example.create(search); DetachedCriteria dc = DetachedCriteria.forClass(User.class).add(example); OrderBy orderBy = new OrderBy(); orderBy.setOrderBy("firstName"); orderBy.setSequance("asc"); List<User> find = userMapper.find(dc, orderBy); assertEquals(3, find.size()); }