You need to sign in to do that
Don't have an account?
![Anonymous Developer Anonymous Developer](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Need help with creating a test class
This is my code
Thanks in advance
public without sharing class AS_GroupDatatableSourceCollection { @InvocableMethod(label = 'Groups Action') public static List<Response> getResults( List<Request> parserInput ) { // My Group List<Id> myGroupIds = new List<Id>(); List<CollaborationGroupMember> cgmList = [SELECT CollaborationGroupId FROM CollaborationGroupMember WHERE MemberId = :parserInput[0].user_id]; for ( CollaborationGroupMember cgm : cgmList ) { myGroupIds.add(cgm.CollaborationGroupId); } system.debug('myGroupIds>>>' +myGroupIds); // Public List<Id> publicGroupIds = new List<Id>(); for ( CollaborationGroup cg : [SELECT Id FROM CollaborationGroup WHERE CollaborationType = 'Public' AND Id NOT IN :myGroupIds] ) { publicGroupIds.add(cg.Id); } system.debug('publicGroupIds>>>' +publicGroupIds); // Same Type Groups List<AS_Membership_Groups__c> listmg = Database.query('SELECT Id, Name, AS_Type__c, AS_Group_Id__c, AS_Paid__c, AS_Status__c FROM AS_Membership_Groups__c WHERE AS_Type__c INCLUDES (\''+ parserInput[0].type +'\')'); List<Id> collabGroupsFromMG = new List<Id>(); // For eacgh membership groups, parse and store all into a single collection for (AS_Membership_Groups__c mg : listmg) { if ( ! String.isBlank( mg.AS_Group_Id__c ) ) { collabGroupsFromMG.addAll( mg.AS_Group_Id__c.split(',') ); } } List<Id> myGroupTypeIds = new List<Id>(); for ( CollaborationGroup cg : [SELECT Id FROM CollaborationGroup WHERE Id IN :collabGroupsFromMG AND Id NOT IN :myGroupIds] ) { myGroupTypeIds.add(cg.Id); } system.debug('myGroupTypeIds>>>' +myGroupTypeIds); Response res = new Response(); res.myGroups = myGroupIds; res.eligibleGroups = myGroupTypeIds; res.publicGroups = publicGroupIds; List<Response> resList = new List<Response>(); resList.add(res); return resList; } public class Request { @InvocableVariable public String type; @InvocableVariable public String user_id; } public class Response { @InvocableVariable public List<Id> myGroups; @InvocableVariable public List<Id> eligibleGroups; @InvocableVariable public List<Id> publicGroups; @InvocableVariable public List<String> parsedCollectionOfStrings; } }
Thanks in advance
If you find my answer helpful, please mark it as the best answer. Thanks!
All Answers
If you find my answer helpful, please mark it as the best answer. Thanks!