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

    Region newRegion = _persistence.create(pk);

    newRegion.setMvccVersion(RandomTestUtil.nextLong());

    newRegion.setCountryId(RandomTestUtil.nextLong());

    newRegion.setRegionCode(RandomTestUtil.randomString());

    newRegion.setName(RandomTestUtil.randomString());

    newRegion.setActive(RandomTestUtil.randomBoolean());

    _persistence.update(newRegion);

    Region existingRegion = _persistence.findByPrimaryKey(newRegion.getPrimaryKey());

    Assert.assertEquals(existingRegion.getMvccVersion(), newRegion.getMvccVersion());
    Assert.assertEquals(existingRegion.getRegionId(), newRegion.getRegionId());
    Assert.assertEquals(existingRegion.getCountryId(), newRegion.getCountryId());
    Assert.assertEquals(existingRegion.getRegionCode(), newRegion.getRegionCode());
    Assert.assertEquals(existingRegion.getName(), newRegion.getName());
    Assert.assertEquals(existingRegion.getActive(), newRegion.getActive());
  }
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    Region newRegion = addRegion();

    Region existingRegion = _persistence.fetchByPrimaryKey(newRegion.getPrimaryKey());

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

    Region region = _persistence.create(pk);

    Assert.assertNotNull(region);

    Assert.assertEquals(region.getPrimaryKey(), pk);
  }
  @Test
  public void testRemove() throws Exception {
    Region newRegion = addRegion();

    _persistence.remove(newRegion);

    Region existingRegion = _persistence.fetchByPrimaryKey(newRegion.getPrimaryKey());

    Assert.assertNull(existingRegion);
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    Region newRegion = addRegion();

    _persistence.clearCache();

    RegionModelImpl existingRegionModelImpl =
        (RegionModelImpl) _persistence.findByPrimaryKey(newRegion.getPrimaryKey());

    Assert.assertEquals(
        existingRegionModelImpl.getCountryId(), existingRegionModelImpl.getOriginalCountryId());
    Assert.assertTrue(
        Validator.equals(
            existingRegionModelImpl.getRegionCode(),
            existingRegionModelImpl.getOriginalRegionCode()));
  }