@Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    MDRRuleGroup newMDRRuleGroup = addMDRRuleGroup();

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

    primaryKeys.add(newMDRRuleGroup.getPrimaryKey());

    Map<Serializable, MDRRuleGroup> mdrRuleGroups = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mdrRuleGroups.size());
    Assert.assertEquals(newMDRRuleGroup, mdrRuleGroups.get(newMDRRuleGroup.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    MDRRuleGroup newMDRRuleGroup = addMDRRuleGroup();

    long pk = RandomTestUtil.nextLong();

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

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

    Map<Serializable, MDRRuleGroup> mdrRuleGroups = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mdrRuleGroups.size());
    Assert.assertEquals(newMDRRuleGroup, mdrRuleGroups.get(newMDRRuleGroup.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    MDRRuleGroup newMDRRuleGroup1 = addMDRRuleGroup();
    MDRRuleGroup newMDRRuleGroup2 = addMDRRuleGroup();

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

    primaryKeys.add(newMDRRuleGroup1.getPrimaryKey());
    primaryKeys.add(newMDRRuleGroup2.getPrimaryKey());

    Map<Serializable, MDRRuleGroup> mdrRuleGroups = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, mdrRuleGroups.size());
    Assert.assertEquals(newMDRRuleGroup1, mdrRuleGroups.get(newMDRRuleGroup1.getPrimaryKey()));
    Assert.assertEquals(newMDRRuleGroup2, mdrRuleGroups.get(newMDRRuleGroup2.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    MDRRuleGroup newMDRRuleGroup = addMDRRuleGroup();

    MDRRuleGroup existingMDRRuleGroup =
        _persistence.fetchByPrimaryKey(newMDRRuleGroup.getPrimaryKey());

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

    MDRRuleGroup mdrRuleGroup = _persistence.create(pk);

    Assert.assertNotNull(mdrRuleGroup);

    Assert.assertEquals(mdrRuleGroup.getPrimaryKey(), pk);
  }
  @Test
  public void testRemove() throws Exception {
    MDRRuleGroup newMDRRuleGroup = addMDRRuleGroup();

    _persistence.remove(newMDRRuleGroup);

    MDRRuleGroup existingMDRRuleGroup =
        _persistence.fetchByPrimaryKey(newMDRRuleGroup.getPrimaryKey());

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

    MDRRuleGroup newMDRRuleGroup = _persistence.create(pk);

    newMDRRuleGroup.setUuid(RandomTestUtil.randomString());

    newMDRRuleGroup.setGroupId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setCompanyId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setUserId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setUserName(RandomTestUtil.randomString());

    newMDRRuleGroup.setCreateDate(RandomTestUtil.nextDate());

    newMDRRuleGroup.setModifiedDate(RandomTestUtil.nextDate());

    newMDRRuleGroup.setName(RandomTestUtil.randomString());

    newMDRRuleGroup.setDescription(RandomTestUtil.randomString());

    _persistence.update(newMDRRuleGroup);

    MDRRuleGroup existingMDRRuleGroup =
        _persistence.findByPrimaryKey(newMDRRuleGroup.getPrimaryKey());

    Assert.assertEquals(existingMDRRuleGroup.getUuid(), newMDRRuleGroup.getUuid());
    Assert.assertEquals(existingMDRRuleGroup.getRuleGroupId(), newMDRRuleGroup.getRuleGroupId());
    Assert.assertEquals(existingMDRRuleGroup.getGroupId(), newMDRRuleGroup.getGroupId());
    Assert.assertEquals(existingMDRRuleGroup.getCompanyId(), newMDRRuleGroup.getCompanyId());
    Assert.assertEquals(existingMDRRuleGroup.getUserId(), newMDRRuleGroup.getUserId());
    Assert.assertEquals(existingMDRRuleGroup.getUserName(), newMDRRuleGroup.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingMDRRuleGroup.getCreateDate()),
        Time.getShortTimestamp(newMDRRuleGroup.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingMDRRuleGroup.getModifiedDate()),
        Time.getShortTimestamp(newMDRRuleGroup.getModifiedDate()));
    Assert.assertEquals(existingMDRRuleGroup.getName(), newMDRRuleGroup.getName());
    Assert.assertEquals(existingMDRRuleGroup.getDescription(), newMDRRuleGroup.getDescription());
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    MDRRuleGroup newMDRRuleGroup = addMDRRuleGroup();

    _persistence.clearCache();

    MDRRuleGroupModelImpl existingMDRRuleGroupModelImpl =
        (MDRRuleGroupModelImpl) _persistence.findByPrimaryKey(newMDRRuleGroup.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingMDRRuleGroupModelImpl.getUuid(),
            existingMDRRuleGroupModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingMDRRuleGroupModelImpl.getGroupId(),
        existingMDRRuleGroupModelImpl.getOriginalGroupId());
  }