Пример #1
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());
 }
 @Test
 public void testAdd() throws Exception {
   int preSize = userMapper.selectAll().size();
   User user = new User();
   user.setName("ysjian003");
   user.setPassword(new BCryptPasswordEncoder().encode("000"));
   user.setSex(User.Sex.MALE);
   userMapper.insert(user);
   assertEquals(preSize + 1, userMapper.selectAll().size());
 }
Пример #3
0
  @Test
  public void insert() {
    final String loginName = "snafu";
    final String hashedUserData = "snafupw";
    User user = new User(loginName, hashedUserData);
    UserMapper sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());
    final int id = sut.insert(user);

    // avoid cache
    sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());
    user = sut.find(id);
    assertThat(user.getLoginName(), is(loginName));
    assertThat(user.getHashedUserData(), is(hashedUserData));
  }
 public int insert(User user) {
   byte[] bytes = null;
   try {
     System.out.println("privatekey: " + userStatusCache.getPrivateKey());
     System.out.println("password: "******"UTF-8");
     System.out.println("md5pw: " + md5pw);
     user.setPassword(md5pw);
     return userMapper.insert(user);
   } catch (Exception e) {
     e.printStackTrace();
     return -1;
   }
 }