コード例 #1
0
  @Test
  @Transactional
  public void testUpdate() throws Exception {
    User user = this.insertUser("makersoft-vertical", "makersoft-vertical", 18, User.SEX_MALE);

    assertNotNull("Insert User does not success!", user);

    user.setUsername("fengkuok");
    user.setPassword("password");
    int rows = userMapper.updateById(user);

    assertTrue("Update User does not success!", rows == 1);

    User fengkuok = userMapper.getById(user.getId());

    assertTrue("Update User does not success!", user.equals(fengkuok));
  }
コード例 #2
0
  @Test
  @SuppressWarnings("unchecked")
  public void testObject() throws Exception {
    User user = new User();
    user.setId("id");
    user.setUsername("makersoft");
    user.setPassword("password");
    user.setAge(20);

    Object obj = ParameterUtil.resolve(user, shardId);
    Assert.assertTrue(obj instanceof Map);

    Map<String, Object> map = (Map<String, Object>) obj;
    Assert.assertEquals(PREFIX_VALUE, map.get(PREFIX));
    Assert.assertEquals(SUFFIX_VALUE, map.get(SUFFIX));

    Assert.assertEquals(user.getId(), map.get("id"));
    Assert.assertEquals(user.getUsername(), map.get("username"));
    Assert.assertEquals(user.getPassword(), map.get("password"));
    Assert.assertEquals(user.getAge(), map.get("age"));
  }