コード例 #1
0
  @Test
  public void update() {
    UserMapper sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());
    User user = sut.find(2);
    assertThat(user.getId(), is(2));
    assertThat(user.getLoginName(), is("Bar"));
    assertThat(user.getHashedUserData(), is("043bd227eaa879d438e7c1dfea568bc9"));

    user.setLoginName("snafu");
    user.setHashedUserData("snafupw");
    sut.update(user);

    user = sut.find(2); // get from cache
    assertThat(user.getId(), is(2));
    assertThat(user.getLoginName(), is("snafu"));
    assertThat(user.getHashedUserData(), is("snafupw"));

    sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());
    user = sut.find(2);
    assertThat(user.getId(), is(2));
    assertThat(user.getLoginName(), is("snafu"));
    assertThat(user.getHashedUserData(), is("snafupw"));
  }
コード例 #2
0
 public User update(User user) {
   userMapper.update(user);
   return getUser(user.getUid(), user.getMid());
 }