function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tlaportetlaporte 

S2S Unit Test weird behavior

Hey all, first post.  I'm stuck.

I wrote a trigger on Contact that fires after insert and after update.  The purpose of the trigger is to check the PartnerNetworkRecordConnection able to see if the parent Account on the Contact has been previously shared.  If the condition is met, a second condition is checked to see if the contact has been previously shared.  If this is found not to be true, then a new record in PartnerNetworkRecordConnection is created that shares the Contact with the target org.

I wrote a similar trigger for Tasks.

I have thoroughly tested both triggers using the two orgs' sandboxes, through the platform and the data loader.  Everything works perfectly.

On to the issue - It's time to deploy, and I have written unit tests for both triggers.  The unit tests look nearly identical except for the change from Task to Contact, and WhatId to AccountId.  The Task trigger test class executes perfectly.  The Contact test fails.  I've included my debugging in the post below.

As you can see, the IDs are all lining up properly, and the same exact logic works for Tasks.  I am stumped.  Thanks for the help!

 

Code::

 

*** Beginning Test 1: SyncTasksContactTriggersTest.static testMethod void testContactTrigger()

20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 33, column 10: Insert: SOBJECT:Account
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 33, column 10:     DML Operation executed in 95 ms
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 34, column 10: ----------------Account:Account:{Name=Test Account, Id=001R000000HPQacIAH}
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 44, column 86: SOQL query with 1 row finished in 18 ms
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 45, column 10: (PartnerNetworkConnection:{ConnectionName=EDITED OUT, ConnectionStatus=Accepted, Id=04PR00000008UGFMA2})
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 47, column 10: SelectLoop:LIST:SOBJECT:PartnerNetworkConnection
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 48, column 11: ----------------Network:PartnerNetworkConnection:{ConnectionName=City of cityName BPS, ConnectionStatus=Accepted, Id=04PR00000008UGFMA2}
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 50, column 11: Insert: SOBJECT:PartnerNetworkRecordConnection
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 50, column 11:     DML Operation executed in 34 ms
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 51, column 11: ----------------PNRC:PartnerNetworkRecordConnection:{ConnectionId=04PR00000008UGFMA2, LocalRecordId=001R000000HPQacIAH, Id=04VR00000008QkqMAE}
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 53, column 11: ----------------Contact:Contact:{AccountId=001R000000HPQacIAH, LastName=Contact}
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 57, column 12: Insert: SOBJECT:Contact
20090701150801.066:Class.SyncTasksContactTriggersTest.testContactTrigger: line 57, column 12:     Changing testing limit context based on DML operation of size: 1
*** Beginning sendContacts on Contact trigger event AfterInsert for 003R000000ENK5J

20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 48, column 3: SelectLoop:LIST:SOBJECT:Contact
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 51, column 79: SOQL query with 1 row finished in 4 ms
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 52, column 3: (PartnerNetworkConnection:{ConnectionName=City of cityName BPS, ConnectionStatus=Accepted, Id=04PR00000008UGFMA2})
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 53, column 4: SelectLoop:LIST:SOBJECT:PartnerNetworkConnection
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 55, column 55: SOQL query with 1 row finished in 4 ms
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 57, column 5: SelectLoop:LIST:SOBJECT:Contact
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 60, column 101: SOQL query with 1 row finished in 6 ms
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 62, column 5: SelectLoop:LIST:SOBJECT:PartnerNetworkRecordConnection
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 65, column 5: -------------Account IDs:( 001R000000HPQacIAH)
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 67, column 101: SOQL query with 0 rows finished in 5 ms
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 69, column 6: SelectLoop:LIST:SOBJECT:PartnerNetworkRecordConnection
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 72, column 6: ----------------Old Contacts:()
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 73, column 52: SOQL query with 1 row finished in 4 ms
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 74, column 6: ----------------New Contacts:(Contact:{AccountId=001R000000HPQacIAH, Id=003R000000ENK5JIAX})
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 76, column 6: SelectLoop:LIST:SOBJECT:Contact
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 83, column 6: ----------------Inserting Records:(PartnerNetworkRecordConnection:{ConnectionId=04PR00000008UGFMA2, LocalRecordId=003R000000ENK5JIAX, ParentRecordId=001R000000HPQacIAH })
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 84, column 6: Upsert: LIST:SOBJECT:PartnerNetworkRecordConnection
20090701150801.277:Class.SyncTasksContactTriggers.sendContactsTocityName: line 84, column 6:     DML Operation executed in 14 ms
System.DmlException: Upsert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation: [] 

Message Edited by tlaporte on 07-01-2009 11:28 AM
Best Answer chosen by Admin (Salesforce Developers) 
tlaportetlaporte

I queried the S2S product team and was told the issue is with the new account I am creating to test with, has not yet been 'Accepted' in the target organization.  Even with Auto-Accept enabled, the requests are inserted in batch, so my unit test wasn't working.  Once I changed the code to query for a previously shared Account, everything worked fine.

 

Regarding the Task trigger - Tasks require no such acceptance.

 

Good luck everyone with your S2S endeavors!

All Answers

tlaportetlaporte

I queried the S2S product team and was told the issue is with the new account I am creating to test with, has not yet been 'Accepted' in the target organization.  Even with Auto-Accept enabled, the requests are inserted in batch, so my unit test wasn't working.  Once I changed the code to query for a previously shared Account, everything worked fine.

 

Regarding the Task trigger - Tasks require no such acceptance.

 

Good luck everyone with your S2S endeavors!

This was selected as the best answer
AltafurRahmanAltafurRahman

Hi Thank you very much!

 

i have read your post and saw your resolution was "Once I changed the code to query for a previously shared Account, everything worked fine."  could you please let me the changes you have  made to your code to solve this issue. as me too experiencing the same problem.

 

thanks in advance!

 

Regards,

Altaf

alaschgarialaschgari

I'd love to see your code change, too! Thank you!