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