/**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static ResourcePermission toModel(ResourcePermissionSoap soapModel) {
    ResourcePermission model = new ResourcePermissionImpl();

    model.setResourcePermissionId(soapModel.getResourcePermissionId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setName(soapModel.getName());
    model.setScope(soapModel.getScope());
    model.setPrimKey(soapModel.getPrimKey());
    model.setRoleId(soapModel.getRoleId());
    model.setOwnerId(soapModel.getOwnerId());
    model.setActionIds(soapModel.getActionIds());

    return model;
  }
  public static ResourcePermission addResourcePermission(
      long actionIds, String name, String primKey, long roleId, int scope) throws Exception {

    long resourcePermissionId =
        CounterLocalServiceUtil.increment(ResourcePermission.class.getName());

    ResourcePermission resourcePermission =
        ResourcePermissionLocalServiceUtil.createResourcePermission(resourcePermissionId);

    resourcePermission.setCompanyId(TestPropsValues.getCompanyId());
    resourcePermission.setName(name);
    resourcePermission.setScope(scope);
    resourcePermission.setPrimKey(primKey);
    resourcePermission.setRoleId(roleId);
    resourcePermission.setActionIds(actionIds);

    return ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission);
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    ResourcePermission newResourcePermission = _persistence.create(pk);

    newResourcePermission.setCompanyId(ServiceTestUtil.nextLong());

    newResourcePermission.setName(ServiceTestUtil.randomString());

    newResourcePermission.setScope(ServiceTestUtil.nextInt());

    newResourcePermission.setPrimKey(ServiceTestUtil.randomString());

    newResourcePermission.setRoleId(ServiceTestUtil.nextLong());

    newResourcePermission.setOwnerId(ServiceTestUtil.nextLong());

    newResourcePermission.setActionIds(ServiceTestUtil.nextLong());

    _persistence.update(newResourcePermission, false);

    ResourcePermission existingResourcePermission =
        _persistence.findByPrimaryKey(newResourcePermission.getPrimaryKey());

    Assert.assertEquals(
        existingResourcePermission.getResourcePermissionId(),
        newResourcePermission.getResourcePermissionId());
    Assert.assertEquals(
        existingResourcePermission.getCompanyId(), newResourcePermission.getCompanyId());
    Assert.assertEquals(existingResourcePermission.getName(), newResourcePermission.getName());
    Assert.assertEquals(existingResourcePermission.getScope(), newResourcePermission.getScope());
    Assert.assertEquals(
        existingResourcePermission.getPrimKey(), newResourcePermission.getPrimKey());
    Assert.assertEquals(existingResourcePermission.getRoleId(), newResourcePermission.getRoleId());
    Assert.assertEquals(
        existingResourcePermission.getOwnerId(), newResourcePermission.getOwnerId());
    Assert.assertEquals(
        existingResourcePermission.getActionIds(), newResourcePermission.getActionIds());
  }
  protected ResourcePermission addResourcePermission() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    ResourcePermission resourcePermission = _persistence.create(pk);

    resourcePermission.setCompanyId(ServiceTestUtil.nextLong());

    resourcePermission.setName(ServiceTestUtil.randomString());

    resourcePermission.setScope(ServiceTestUtil.nextInt());

    resourcePermission.setPrimKey(ServiceTestUtil.randomString());

    resourcePermission.setRoleId(ServiceTestUtil.nextLong());

    resourcePermission.setOwnerId(ServiceTestUtil.nextLong());

    resourcePermission.setActionIds(ServiceTestUtil.nextLong());

    _persistence.update(resourcePermission, false);

    return resourcePermission;
  }