コード例 #1
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan newMBBan = _persistence.create(pk);

    newMBBan.setUuid(RandomTestUtil.randomString());

    newMBBan.setGroupId(RandomTestUtil.nextLong());

    newMBBan.setCompanyId(RandomTestUtil.nextLong());

    newMBBan.setUserId(RandomTestUtil.nextLong());

    newMBBan.setUserName(RandomTestUtil.randomString());

    newMBBan.setCreateDate(RandomTestUtil.nextDate());

    newMBBan.setModifiedDate(RandomTestUtil.nextDate());

    newMBBan.setBanUserId(RandomTestUtil.nextLong());

    _mbBans.add(_persistence.update(newMBBan));

    MBBan existingMBBan = _persistence.findByPrimaryKey(newMBBan.getPrimaryKey());

    Assert.assertEquals(existingMBBan.getUuid(), newMBBan.getUuid());
    Assert.assertEquals(existingMBBan.getBanId(), newMBBan.getBanId());
    Assert.assertEquals(existingMBBan.getGroupId(), newMBBan.getGroupId());
    Assert.assertEquals(existingMBBan.getCompanyId(), newMBBan.getCompanyId());
    Assert.assertEquals(existingMBBan.getUserId(), newMBBan.getUserId());
    Assert.assertEquals(existingMBBan.getUserName(), newMBBan.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBBan.getCreateDate()),
        Time.getShortTimestamp(newMBBan.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBBan.getModifiedDate()),
        Time.getShortTimestamp(newMBBan.getModifiedDate()));
    Assert.assertEquals(existingMBBan.getBanUserId(), newMBBan.getBanUserId());
  }
コード例 #2
0
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    MBBan newMBBan = addMBBan();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBBan.class, MBBan.class.getClassLoader());

    dynamicQuery.add(RestrictionsFactoryUtil.eq("banId", newMBBan.getBanId()));

    List<MBBan> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    MBBan existingMBBan = result.get(0);

    Assert.assertEquals(existingMBBan, newMBBan);
  }
コード例 #3
0
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    MBBan newMBBan = addMBBan();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBBan.class, MBBan.class.getClassLoader());

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("banId"));

    Object newBanId = newMBBan.getBanId();

    dynamicQuery.add(RestrictionsFactoryUtil.in("banId", new Object[] {newBanId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingBanId = result.get(0);

    Assert.assertEquals(existingBanId, newBanId);
  }