Esempio n. 1
0
  @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());
  }
Esempio n. 2
0
 @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);
 }
Esempio n. 3
0
 @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());
 }
Esempio n. 4
0
  @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);
  }
Esempio n. 5
0
  @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());
  }