@Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    ResourceBlock newResourceBlock = _persistence.create(pk);

    newResourceBlock.setMvccVersion(RandomTestUtil.nextLong());

    newResourceBlock.setCompanyId(RandomTestUtil.nextLong());

    newResourceBlock.setGroupId(RandomTestUtil.nextLong());

    newResourceBlock.setName(RandomTestUtil.randomString());

    newResourceBlock.setPermissionsHash(RandomTestUtil.randomString());

    newResourceBlock.setReferenceCount(RandomTestUtil.nextLong());

    _resourceBlocks.add(_persistence.update(newResourceBlock));

    ResourceBlock existingResourceBlock =
        _persistence.findByPrimaryKey(newResourceBlock.getPrimaryKey());

    Assert.assertEquals(existingResourceBlock.getMvccVersion(), newResourceBlock.getMvccVersion());
    Assert.assertEquals(
        existingResourceBlock.getResourceBlockId(), newResourceBlock.getResourceBlockId());
    Assert.assertEquals(existingResourceBlock.getCompanyId(), newResourceBlock.getCompanyId());
    Assert.assertEquals(existingResourceBlock.getGroupId(), newResourceBlock.getGroupId());
    Assert.assertEquals(existingResourceBlock.getName(), newResourceBlock.getName());
    Assert.assertEquals(
        existingResourceBlock.getPermissionsHash(), newResourceBlock.getPermissionsHash());
    Assert.assertEquals(
        existingResourceBlock.getReferenceCount(), newResourceBlock.getReferenceCount());
  }
  protected ResourceBlock addResourceBlock() throws Exception {
    long pk = RandomTestUtil.nextLong();

    ResourceBlock resourceBlock = _persistence.create(pk);

    resourceBlock.setMvccVersion(RandomTestUtil.nextLong());

    resourceBlock.setCompanyId(RandomTestUtil.nextLong());

    resourceBlock.setGroupId(RandomTestUtil.nextLong());

    resourceBlock.setName(RandomTestUtil.randomString());

    resourceBlock.setPermissionsHash(RandomTestUtil.randomString());

    resourceBlock.setReferenceCount(RandomTestUtil.nextLong());

    _resourceBlocks.add(_persistence.update(resourceBlock));

    return resourceBlock;
  }