@Test
  public void testFindByPrimaryKeyExisting() throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

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

    Assert.assertEquals(existingSystemEvent, newSystemEvent);
  }
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    SystemEvent systemEvent = _persistence.create(pk);

    Assert.assertNotNull(systemEvent);

    Assert.assertEquals(systemEvent.getPrimaryKey(), pk);
  }
  @Test
  public void testRemove() throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

    _persistence.remove(newSystemEvent);

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

    Assert.assertNull(existingSystemEvent);
  }
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newSystemEvent.getPrimaryKey());

    Map<Serializable, SystemEvent> systemEvents = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, systemEvents.size());
    Assert.assertEquals(newSystemEvent, systemEvents.get(newSystemEvent.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    SystemEvent newSystemEvent = addSystemEvent();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newSystemEvent.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, SystemEvent> systemEvents = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, systemEvents.size());
    Assert.assertEquals(newSystemEvent, systemEvents.get(newSystemEvent.getPrimaryKey()));
  }
  @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);
  }
  @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);
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    SystemEvent newSystemEvent1 = addSystemEvent();
    SystemEvent newSystemEvent2 = addSystemEvent();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newSystemEvent1.getPrimaryKey());
    primaryKeys.add(newSystemEvent2.getPrimaryKey());

    Map<Serializable, SystemEvent> systemEvents = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, systemEvents.size());
    Assert.assertEquals(newSystemEvent1, systemEvents.get(newSystemEvent1.getPrimaryKey()));
    Assert.assertEquals(newSystemEvent2, systemEvents.get(newSystemEvent2.getPrimaryKey()));
  }
  protected SystemEvent addSystemEvent() throws Exception {
    long pk = RandomTestUtil.nextLong();

    SystemEvent systemEvent = _persistence.create(pk);

    systemEvent.setMvccVersion(RandomTestUtil.nextLong());

    systemEvent.setGroupId(RandomTestUtil.nextLong());

    systemEvent.setCompanyId(RandomTestUtil.nextLong());

    systemEvent.setUserId(RandomTestUtil.nextLong());

    systemEvent.setUserName(RandomTestUtil.randomString());

    systemEvent.setCreateDate(RandomTestUtil.nextDate());

    systemEvent.setClassNameId(RandomTestUtil.nextLong());

    systemEvent.setClassPK(RandomTestUtil.nextLong());

    systemEvent.setClassUuid(RandomTestUtil.randomString());

    systemEvent.setReferrerClassNameId(RandomTestUtil.nextLong());

    systemEvent.setParentSystemEventId(RandomTestUtil.nextLong());

    systemEvent.setSystemEventSetKey(RandomTestUtil.nextLong());

    systemEvent.setType(RandomTestUtil.nextInt());

    systemEvent.setExtraData(RandomTestUtil.randomString());

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

    return systemEvent;
  }
  @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());
  }