Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task_Chatter_Tst Test case failed w/This user cannot follow any other users or records #51

Closed
brountre opened this issue Jan 23, 2012 · 21 comments
Milestone

Comments

@brountre
Copy link

Installed Milestone PM into a developer org, getting the following error on Milestone1_Tasks_Chatter_Tst method testChatterTaskReassignment (Line 96)

System.DmlException: Update failed. First exception on row 0 with id a0TF0000003aXycMAE; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, This user cannot follow any other users or records: []: []

@ReidCarlberg
Copy link
Contributor

Seem like two different issues. #22 is about the 500 record following limit (still 500?). This appears to be that a user can follow anything, let alone more. @brountre is this a real user or one created during testin? Is it a clean dev org or was it populated? I ask b/c i 'm not able to reproduce in a clean org.

@tompatros
Copy link
Contributor

Haven't seen this error come up either in a couple of installs. Crazy question: is Chatter enabled in the org?

@brountre
Copy link
Author

Interestingly if I disable chatter the test passes.

On Tue, Jan 24, 2012 at 8:49 AM, Tom Patros <
reply@reply.github.com

wrote:

Haven't seen this error come up either in a couple of installs. Crazy
question: is Chatter enabled in the org?


Reply to this email directly or view it on GitHub:

#51 (comment)

@brountre
Copy link
Author

The user is the admin user. It isn't a clean org, it had several classes
unrelated to Milestone PM. The developer org has been around for quite
sometime. I will try a new org and test again.

Thanks,
Bryan

On Tue, Jan 24, 2012 at 7:34 AM, ReidCarlberg <
reply@reply.github.com

wrote:

Seem like two different issues. #22 is about the 500 record following
limit (still 500?). This appears to be that a user can follow anything,
let alone more. @brountre is this a real user or one created during
testin? Is it a clean dev org or was it populated? I ask b/c i 'm not
able to reproduce in a clean org.


Reply to this email directly or view it on GitHub:

#51 (comment)

@ReidCarlberg
Copy link
Contributor

We're you able to reproduce in a new org?

@brountre
Copy link
Author

brountre commented Feb 7, 2012

No, when I created a new dev org. The test failures went away. I'm
currently stuck on another project at the moment, but I do want to get back
around on this and figure out the root cause.

Thanks for the follow up.

Bryan
On Mon, Feb 6, 2012 at 7:42 PM, ReidCarlberg <
reply@reply.github.com

wrote:

We're you able to reproduce in a new org?


Reply to this email directly or view it on GitHub:

#51 (comment)

@dostal76
Copy link

dostal76 commented Mar 5, 2012

Hi Reid, I am also experiencing this problem. Getting
"System.DmlException: Update failed. First exception on row 0 with id a0BT00000091A2XMAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, This user cannot follow any other users or records: []: []"

When I disable Chatter it runs fine, but when enabled, I get the above. Now when trying to deploy anything else, this is stopping me from deploying my code as I can no longer disable Chatter in production.

Any advice on this?

@fengxia41103
Copy link

I encountered the exact problem as dostal76 above.

System.DmlException: Update failed. First exception on row 0 with id a0i40000000wDpxAAE; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, This user cannot follow any other users or records: []: []

Class.Milestone1_Task_Chatter_Tst.testChatterTaskReassignment: line 95, column 1

Pasting the code below:

EntitySubscription subscription = [Select Id, ParentId, SubscriberId from EntitySubscription where ParentId =: testTask.Id];
//assert that the user is following this object
system.assertEquals(UserInfo.getUserId(),subscription.SubscriberId);
system.debug('Other User Id == ' + otherUser.Id + 'Task Assigned Id ==' + testTask.Assigned_To__c);
testTask.Assigned_To__c = otherUser.Id;
update testTask;

This is also blocking us from deploying a new application. Any advice would be highly appreciated.

@ReidCarlberg
Copy link
Contributor

What's the sharing model on Milestone1_Milestone__c?

@fengxia41103
Copy link

Reid, How to look that up?

@fengxia41103
Copy link

If you are referring to "API Name Milestone1_Milestone__c", then there isn't Apex Sharing Reasons or Apex Sharing Recalculation.

Milestone PM has been deployed and in production for 3-4 months without issues. During deployment I remember checking the "ignore error" option. We have recently deployed another application successfully. So only now the test is blocking us from deploying a new class and a page.

Is there any workaround that we can deactivate this test? edit and comment out the offending lines?

@ReidCarlberg
Copy link
Contributor

You can definitely edit the test. What version do you have installed? Current is 1.51

@fengxia41103
Copy link

I don't see there is an "edit" option in production.

Version is 1.53, deployed 10/28/2011 to be exact.

How should I proceed? Please advise.

@ReidCarlberg
Copy link
Contributor

You won't have an edit in prod. Needs to be in the sandbox. Should be able to edit in sandbox and push over. Alternatively, if you don't have a sandbox, you could push from a dev edition.

@fengxia41103
Copy link

Interesting, the same test passed in Sandbox. This makes me thinking that it has something to do with data limit.

I commented out the "assert" line in Sandbox and put the class in a changeset. But it got blocked when validating in production. How to override the one in production? This is the first time we deploy in-house developed application in SF, so apologize ahead for asking SF questions here.

@fengxia41103
Copy link

This is what I ultimately did to remove the test failure in production:

  1. Force.com IDE to create a new project and pull by application "Milestone PM". This will pull all components, classes, .... to the project.
  2. Edit class Class.Milestone1_Task_Chatter_Tst.testChatterTaskReassignment:

a. commented out these two lines:
//testTask.Assigned_To__c = otherUser.Id;
//update testTask;

b. Changed this line actual from 0 to 1.
system.assertEquals(1,subscriptionList.size());

Save to server. The test passed, 52% coverage.

@ReidCarlberg
Copy link
Contributor

Cool. Are you up and running now?

@fengxia41103
Copy link

Yes. At least now there is a way to update classes in Production.

I'll spend sometime to look into the error once this deployment is all done. If there is anything I'll let you know. Thanks for the app. It's really nice.

@ToddAH
Copy link

ToddAH commented Mar 6, 2012

we are running the Managed Package version 1.57 and are getting the same test failure in our sandbox.

LABSMPM.Milestone1_Task_Chatter_Tst.testChatterTaskReassignment 512.0 System.DmlException: Update failed. First exception on row 0 with id a0kV0000000MFcwIAG; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, This user cannot follow any other users or records: []: []

Schedule to try this installation into our production org this week. Is there a way I can update the managed package to verify it will install and not block other change set deployments?

@ReidCarlberg
Copy link
Contributor

April 2012 Milestone work-- ensure the code isn't selecting a random user. That's guaranteed to be a flapper test. Replace the code that is selecting a random user with code that is creating a specific type of user.

Example of error in Partner Dev org -- https://skitch.com/reidcarlberg/8u1ig/salesforce.com-developer-edition -- this is after install, with simple initialization and then a run all tests from the Apex Classes screen.

Here's the offending code -- it's basically just grabbing any old user (in this case it get's a portal user) and should create a new test user instead. Add this code to the Milestone1 Test Utilities class and use it to create users instead. https://github.com/ForceDotComLabs/ActionPlans/blob/master/src/classes/ActionPlansTestUtilities.cls

      return; //chatter is disabled - we can't run this test. 
    List<User> otherUserList = [Select Id from User where Id <> :UserInfo.getUserId() and IsActive = true limit 1];
    User otherUser = null;
    if(otherUserList.size() == 0)
    {
        List<Profile> prof = [Select Id from Profile limit 1]; 
        otherUser = new User(Alias='testxyz1',emailencodingkey='UTF-8', languagelocalekey='en_US',timezonesidkey='America/Los_Angeles',  CommunityNickname='XYZTEST12301', FirstName='Test Account', LastName='LastName', Email='testaccountxzy@testfacke123.com', username='UnitTest123fake@testfake.com',localesidkey='en_US', ProfileId=prof.get(0).Id);
        insert otherUser;

@kbentsen
Copy link

kbentsen commented Apr 6, 2012

I am also having issues with these errors. I replicated @fengxia41103 fixes, but now I am receiving different errors:

Failure Message: "System.QueryException: invalid ID field: null", Failure Stack Trace: "Class.Milestone1_Task_Chatter_Tst.testChatterTaskFollows: line 50, column 1"

I am also receiving the following error that I would not know how to address:

Failure Message: "System.AssertException: Assertion Failed: Expected: 3418.99000000000000000000000000000000000196, Actual: 3418.990000000000000000000000000000000003", Failure Stack Trace: "Class.Milestone1_Test_Field_Values.testFieldValues: line 278, column 1"

I've done both editing the classes in my Sandbox as well as in the Force.com IDE and attempting to deploy to production, but to no avail. I really want to get these resolved as it is holding up some changes I'm looking to add to my production.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants