Advertisement
tet3

Untitled

Jan 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. global class SandboxRefreshScript implements SandboxPostCopy {
  2.     global void runApexClass(SandboxContext context) {
  3.         // Change value of Alias below to the Alias of user who should own the group, ensuring that it is unique among your users
  4.         List<User> groupOwner = [SELECT Id, Username FROM User WHERE Alias = 'TTayl'];
  5.         Id grpOwnerId = groupOwner[0].Id;
  6.        
  7.         // Change group privacy, description and name as needed for your purposes
  8.         CollaborationGroup newGroup = new CollaborationGroup(
  9.                                     CollaborationType = 'Public',
  10.                                     Description = 'Group description text',
  11.                                     Name = 'Group for mentions',
  12.                                     OwnerId = grpOwnerId
  13.                                     );
  14.  
  15.         insert newGroup;
  16.     }
  17. }
  18.  
  19.  
  20. /*****   In a Separate Apex Class File: *****/
  21.  
  22. @isTest
  23. class TestSandboxRefreshScript {
  24.  
  25.     @isTest
  26.     static void testMySandboxPrep() {
  27.  
  28.         Test.startTest();
  29.  
  30.         Test.testSandboxPostCopyScript(
  31.             new SandboxRefreshScript(), UserInfo.getOrganizationId(),
  32.                 UserInfo.getOrganizationId(), UserInfo.getOrganizationName());
  33.  
  34.         Test.stopTest();
  35.  
  36.         // Change Name value to the name of your group!
  37.         List<CollaborationGroup> chGroup = [SELECT Id, CollaborationType from CollaborationGroup WHERE Name = 'Group for mentions'];
  38.         System.assertEquals(1, chGroup.size(), 'Chatter Group List size not equal to 1');
  39.         System.assertEquals('Public', chGroup[0].CollaborationType, 'Chatter group is not public');
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement