+ Start a Discussion

Group Object in test class

I have got a very urgent requirement . where i need to write the test class . to get the code coverage i have to create the test data like following . 


There would be a Group  object . lets say   G1    and a GroupMember  say  GM1. Now   GM1  would relate to G1 ........


                               GM1.GroupId =  G1.Id


              now     GM1. UserOrGroupId = "this woul be another group G2" 


Now G2 would be Group  where TYPE equals to ROLE or ROLE SUBORDINATES and I need to set Related ID to a Particualr business role .   

                                 G2 would contain User of a particular role . .that would related with

                                                        GM2 . GroupId  = G2.ID

                                                        GM2. UserorGroupId = any user id with some particular role 


Problem :- I am not able to create a group of  type role .   Not able to set related Id .  however  GM2  will contain a Single user with a particular role 


Please help me on this , Or Redirect to me where I can find the solution .