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

    SystemEvent newSystemEvent = _persistence.create(pk);

    newSystemEvent.setMvccVersion(RandomTestUtil.nextLong());

    newSystemEvent.setGroupId(RandomTestUtil.nextLong());

    newSystemEvent.setCompanyId(RandomTestUtil.nextLong());

    newSystemEvent.setUserId(RandomTestUtil.nextLong());

    newSystemEvent.setUserName(RandomTestUtil.randomString());

    newSystemEvent.setCreateDate(RandomTestUtil.nextDate());

    newSystemEvent.setClassNameId(RandomTestUtil.nextLong());

    newSystemEvent.setClassPK(RandomTestUtil.nextLong());

    newSystemEvent.setClassUuid(RandomTestUtil.randomString());

    newSystemEvent.setReferrerClassNameId(RandomTestUtil.nextLong());

    newSystemEvent.setParentSystemEventId(RandomTestUtil.nextLong());

    newSystemEvent.setSystemEventSetKey(RandomTestUtil.nextLong());

    newSystemEvent.setType(RandomTestUtil.nextInt());

    newSystemEvent.setExtraData(RandomTestUtil.randomString());

    _systemEvents.add(_persistence.update(newSystemEvent));

    SystemEvent existingSystemEvent = _persistence.findByPrimaryKey(newSystemEvent.getPrimaryKey());

    Assert.assertEquals(existingSystemEvent.getMvccVersion(), newSystemEvent.getMvccVersion());
    Assert.assertEquals(existingSystemEvent.getSystemEventId(), newSystemEvent.getSystemEventId());
    Assert.assertEquals(existingSystemEvent.getGroupId(), newSystemEvent.getGroupId());
    Assert.assertEquals(existingSystemEvent.getCompanyId(), newSystemEvent.getCompanyId());
    Assert.assertEquals(existingSystemEvent.getUserId(), newSystemEvent.getUserId());
    Assert.assertEquals(existingSystemEvent.getUserName(), newSystemEvent.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingSystemEvent.getCreateDate()),
        Time.getShortTimestamp(newSystemEvent.getCreateDate()));
    Assert.assertEquals(existingSystemEvent.getClassNameId(), newSystemEvent.getClassNameId());
    Assert.assertEquals(existingSystemEvent.getClassPK(), newSystemEvent.getClassPK());
    Assert.assertEquals(existingSystemEvent.getClassUuid(), newSystemEvent.getClassUuid());
    Assert.assertEquals(
        existingSystemEvent.getReferrerClassNameId(), newSystemEvent.getReferrerClassNameId());
    Assert.assertEquals(
        existingSystemEvent.getParentSystemEventId(), newSystemEvent.getParentSystemEventId());
    Assert.assertEquals(
        existingSystemEvent.getSystemEventSetKey(), newSystemEvent.getSystemEventSetKey());
    Assert.assertEquals(existingSystemEvent.getType(), newSystemEvent.getType());
    Assert.assertEquals(existingSystemEvent.getExtraData(), newSystemEvent.getExtraData());
  }
コード例 #2
0
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(SystemEvent.class, _dynamicQueryClassLoader);

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("systemEventId", newSystemEvent.getSystemEventId()));

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

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

    SystemEvent existingSystemEvent = result.get(0);

    Assert.assertEquals(existingSystemEvent, newSystemEvent);
  }
コード例 #3
0
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(SystemEvent.class, _dynamicQueryClassLoader);

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

    Object newSystemEventId = newSystemEvent.getSystemEventId();

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

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

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

    Object existingSystemEventId = result.get(0);

    Assert.assertEquals(existingSystemEventId, newSystemEventId);
  }