Package com.github.dactiv.orm.test.entity

Examples of com.github.dactiv.orm.test.entity.User


    Fixtures.reloadData(dataSource, "/sample-data.xml");
  }
 
  @Test
  public void testInsert() {
    User entity = new User();
   
    entity.setCreateTime(new Date());
    entity.setLoginName("test");
    entity.setPassword("123456");
    entity.setPinyinCode("pinyin");
    entity.setRealName("测试");
    entity.setState(new Integer(1));
    entity.setWubiCode("wubi");
   
    int before = countRowsInTable("TB_ACCOUNT_USER");
   
    userDao.insert(entity);
    sessionFactory.getCurrentSession().flush();
View Full Code Here


   
  }

  @Test
  public void testInsertAll() {
    User entity1 = new User();
   
    entity1.setCreateTime(new Date());
    entity1.setLoginName("test");
    entity1.setPassword("123456");
    entity1.setPinyinCode("pinyin");
    entity1.setRealName("测试");
    entity1.setState(new Integer(1));
    entity1.setWubiCode("wubi");
   
    User entity2 = new User();
   
    entity2.setCreateTime(new Date());
    entity2.setLoginName("test");
    entity2.setPassword("123456");
    entity2.setPinyinCode("pinyin");
    entity2.setRealName("测试");
    entity2.setState(new Integer(1));
    entity2.setWubiCode("wubi");
   
    List<User> data = Lists.newArrayList(entity1,entity2);
   
    int before = countRowsInTable("TB_ACCOUNT_USER");
   
View Full Code Here

  }
 
  @Test
  @SuppressWarnings("unchecked")
  public void testFindOne() {
    User user = new User();
   
    user = userRepository.findOne(Specifications.get(Lists.newArrayList(PropertyFilters.get("EQS_loginName", "admin"))));
    Assert.assertEquals(user.getId(), "SJDK3849CKMS3849DJCK2039ZMSK0002");
  }
View Full Code Here

    assertEquals(before + 2, after);
  }

  @Test
  public void testUpdate() {
    User user = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0001");
    user.setLoginName("update login name");
   
    userDao.update(user);
    sessionFactory.getCurrentSession().flush();
    sessionFactory.getCurrentSession().clear();
   
    user = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0001");
    assertEquals(user.getLoginName(), "update login name");
  }
View Full Code Here

    assertEquals(user.getLoginName(), "update login name");
  }

  @Test
  public void testUpdateAll() {
    User user1 = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0001");
    User user2 = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0002");
   
    user1.setLoginName("update user 1 login name");
    user2.setLoginName("update user 2 login name");
   
    List<User> data = Lists.newArrayList(user1,user2);
   
    userDao.updateAll(data);
   
    sessionFactory.getCurrentSession().flush();
    sessionFactory.getCurrentSession().clear();
   
    user1 = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0001");
    user2 = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0002");
   
    assertEquals(user1.getLoginName(), "update user 1 login name");
    assertEquals(user2.getLoginName(), "update user 2 login name");
  }
View Full Code Here

    assertEquals(user2.getLoginName(), "update user 2 login name");
  }

  @Test
  public void testSave() {
    User entity = new User();
   
    entity.setCreateTime(new Date());
    entity.setLoginName("test");
    entity.setPassword("123456");
    entity.setPinyinCode("pinyin");
    entity.setRealName("测试");
    entity.setState(new Integer(1));
    entity.setWubiCode("wubi");
   
    int before = countRowsInTable("TB_ACCOUNT_USER");
   
    userDao.save(entity);
    sessionFactory.getCurrentSession().flush();
   
    int after = countRowsInTable("TB_ACCOUNT_USER");
   
    assertEquals(before + 1, after);
   
    entity.setLoginName("update login name");
   
    userDao.save(entity);
   
    entity = userDao.load(entity.getId());
   
    assertEquals(entity.getLoginName(), "update login name");
  }
View Full Code Here

    assertEquals(entity.getLoginName(), "update login name");
  }

  @Test
  public void testSaveAll() {
    User entity1 = new User();
   
    entity1.setCreateTime(new Date());
    entity1.setLoginName("test");
    entity1.setPassword("123456");
    entity1.setPinyinCode("pinyin");
    entity1.setRealName("测试");
    entity1.setState(new Integer(1));
    entity1.setWubiCode("wubi");
   
    User entity2 = new User();
   
    entity2.setCreateTime(new Date());
    entity2.setLoginName("test");
    entity2.setPassword("123456");
    entity2.setPinyinCode("pinyin");
    entity2.setRealName("测试");
    entity2.setState(new Integer(1));
    entity2.setWubiCode("wubi");
   
    List<User> data = Lists.newArrayList(entity1,entity2);
   
    int before = countRowsInTable("TB_ACCOUNT_USER");
   
    userDao.saveAll(data);
    sessionFactory.getCurrentSession().flush();
   
    int after = countRowsInTable("TB_ACCOUNT_USER");
   
    assertEquals(before + 2, after);
   
    entity1.setLoginName("update user 1 login name");
    entity2.setLoginName("update user 2 login name");
   
    userDao.saveAll(data);
   
    entity1 = userDao.load(entity1.getId());
    entity2 = userDao.load(entity2.getId());
   
    assertEquals(entity1.getLoginName(), "update user 1 login name");
    assertEquals(entity2.getLoginName(), "update user 2 login name");
  }
View Full Code Here

  @Test
  public void testGet() {
    List<User> data = userDao.get(Lists.newArrayList("SJDK3849CKMS3849DJCK2039ZMSK0001","SJDK3849CKMS3849DJCK2039ZMSK0002"));
    assertEquals(data.size(), 2);
   
    User user = userDao.get("SJDK3849CKMS3849DJCK2039ZMSK0001");
    assertEquals(user.getLoginName(), "maurice");
   
    data = userDao.get(new String[] {"SJDK3849CKMS3849DJCK2039ZMSK0001","SJDK3849CKMS3849DJCK2039ZMSK0002"});
    assertEquals(data.size(), 2);
   
  }
View Full Code Here

   
  }

  @Test
  public void testLoad() {
    User user = userDao.load("SJDK3849CKMS3849DJCK2039ZMSK0001");
    assertEquals(user.getLoginName(), "maurice");
  }
View Full Code Here

  }

  @Test
  public void testFindUniqueByQuery() {
   
    User user = new User();
   
    user = userDao.findUniqueByQuery("from User u where u.id=?", "SJDK3849CKMS3849DJCK2039ZMSK0001");
    assertEquals(user.getLoginName(), "maurice");
    user = userDao.findUniqueByQuery("from User u where u.id=?1", "SJDK3849CKMS3849DJCK2039ZMSK0001");
    assertEquals(user.getLoginName(), "maurice");
   
    Map<String, Object> map = Maps.newHashMap();
    map.put("id", "SJDK3849CKMS3849DJCK2039ZMSK0001");
    user = userDao.findUniqueByQuery("from User u where u.id=:id", map);
    assertEquals(user.getLoginName(), "maurice");
    user = userDao.findUniqueByQuery("QueryUserJpa", "maurice");
    assertEquals(user.getLoginName(), "maurice");
    user = userDao.findUniqueByQuery("QueryUser", "maurice");
    assertEquals(user.getLoginName(), "maurice");
  }
View Full Code Here

TOP

Related Classes of com.github.dactiv.orm.test.entity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.