protected MDRRuleGroup addMDRRuleGroup() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MDRRuleGroup mdrRuleGroup = _persistence.create(pk);

    mdrRuleGroup.setUuid(RandomTestUtil.randomString());

    mdrRuleGroup.setGroupId(RandomTestUtil.nextLong());

    mdrRuleGroup.setCompanyId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserName(RandomTestUtil.randomString());

    mdrRuleGroup.setCreateDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setModifiedDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setName(RandomTestUtil.randomString());

    mdrRuleGroup.setDescription(RandomTestUtil.randomString());

    _persistence.update(mdrRuleGroup);

    return mdrRuleGroup;
  }
  @Override
  public MDRRuleGroup addRuleGroup(
      long groupId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(serviceContext.getUserId());
    Date now = new Date();

    long ruleGroupId = counterLocalService.increment();

    MDRRuleGroup ruleGroup = createMDRRuleGroup(ruleGroupId);

    ruleGroup.setUuid(serviceContext.getUuid());
    ruleGroup.setGroupId(groupId);
    ruleGroup.setCompanyId(serviceContext.getCompanyId());
    ruleGroup.setCreateDate(serviceContext.getCreateDate(now));
    ruleGroup.setModifiedDate(serviceContext.getModifiedDate(now));
    ruleGroup.setUserId(user.getUserId());
    ruleGroup.setUserName(user.getFullName());
    ruleGroup.setNameMap(nameMap);
    ruleGroup.setDescriptionMap(descriptionMap);

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