You need to sign in to do that
Don't have an account?
Error messages in test runs
I am getting the following error with this code :
System.DmlException: Update failed. First exception on row 0 with id a1I20000000VfoZEAS; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, This person’s information is private because they’re not a member of the community.: []: []
That's all the code says. It doesn't give any further description.
The stack trace is this :
Class.Milestone1_Task_Chatter_Tst.testChatterTaskReassignment: line 95, column 1
lines 94 & 95 are this :
testTask.Assigned_To__c = otherUser.Id; update testTask;
So I'm guessing that the problem lies in Assigning the task to otherUser.id because of sharing rules ? I've already de-activated all of the Validation Rules, so it can't be that.
This whole code is already in production. Apparently somebody made changes to it a while ago and now I can't deploy anything new into production. So, if I could just get the test to run successfully I would be happy, even if that means changing the Assigned_To__c to a setting which would work in the test.
Here is the entire class :
@isTest private class Milestone1_Task_Chatter_Tst { static testMethod void testChatterTaskFollows() { Milestone1_Settings__c settings = Milestone1_Test_Utility.createDefaultCustomChatterSettings(true); System.assert(settings.Auto_Follow_Task__c, 'Auto Follow Task must be true for this test to work.'); Milestone1_Project__c testProject = Milestone1_Test_Utility.sampleProject('UNIT TEST PROJECT NAME ABC123XYZ UNIQUE' + System.now()); insert testProject; Milestone1_Milestone__c testMilestone = Milestone1_Test_Utility.sampleMilestone(testProject.Id,null,'UNIT TEST MILESTONE NAME ACB123XYZ UNIQUE' + System.now()); insert testMilestone; Milestone1_Task__c testTask = Milestone1_Test_Utility.sampleTask(testMilestone.Id); testTask.Assigned_To__c = UserInfo.getUserId(); testTask.Complete__c = false; insert testTask; 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); testTask.Complete__c = true; update testTask; List<EntitySubscription> subscriptionList = [Select Id, ParentId, SubscriberId from EntitySubscription where ParentId =: testTask.Id]; //assert that no one is following this object after its marked as complete system.assertEquals(0,subscriptionList.size()); } static testMethod void testChatterTaskReassignment() { // List<User> otherUserList = [Select Id from User where Id <> :UserInfo.getUserId() limit 1]; List<User> otherUserList = [Select Id from User where Id <> :UserInfo.getUserId() and IsActive = true and Profile.UserLicense.Name <> 'Chatter Only' limit 1]; User otherUser = null; //if(otherUserList.size() == 0) 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; }else { otherUser = otherUserList.get(0); } Milestone1_Test_Utility.createDefaultCustomChatterSettings(true); Milestone1_Project__c testProject = Milestone1_Test_Utility.sampleProject('UNIT TEST PROJECT NAME ABC123XYZ UNIQUE' + System.now()); insert testProject; Milestone1_Milestone__c testMilestone = Milestone1_Test_Utility.sampleMilestone(testProject.Id,null,'UNIT TEST MILESTONE NAME ACB123XYZ UNIQUE' + System.now()); insert testMilestone; Milestone1_Task__c testTask = Milestone1_Test_Utility.sampleTask(testMilestone.Id); testTask.Assigned_To__c = UserInfo.getUserId(); testTask.Complete__c = false; insert testTask; 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; List<EntitySubscription> subscriptionList = [Select Id, ParentId, SubscriberId from EntitySubscription where ParentId =: testTask.Id and SubscriberId =: UserInfo.getUserId()]; //assert that no one is following this object after its marked as complete system.assertEquals(0,subscriptionList.size()); } }
Any help you could give me would be very appreciated.
Thank you very much.
I guess it was caused by the code:
Yes, I believe that is it.
But now I can't figure out what else to equate that field to besides otherUser.id.
Thanks for your input.