T resource = createResource();
getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
getPolicyService().grantPolicyToPrincipal(policy, role);
AccessRights accessRights = createAllAccessRights(getResourceType().getPermissionClass());
PropertyList selectedPolicies = PropertyList.createFromArray(new int[] {policy.getResourceId()});
PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(accessRights, selectedPolicies, getSessionInfo());
assertEquals("The newly created and default.", getPolicyService().getPermittingAccessRights(null, null, null, user).size(), getDefaultAccessRightCount() + 1);
Permission[] permissions = new Permission[] {PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, PolicyConstants.PERM_DELETE};
assertTrue("The permissions should be permitted.", getPolicyService().isPermitted(getResourceType(), permissions, user, false));