You need to sign in to do that
Don't have an account?

Test class (dml not allowed on UserTeamMember)
I'm trying to write a test class on the code below. However i can only achieve 66% as i cannot insert the UserTeamMember object with a dml statement. The 2 lines of code marked as No Code Coverage are the only lines not covered and mainly because i can't insert the object. would appreciate any help . thanks !!!
trigger SSSUpdate on User (before Update)
{
Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u : [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' AND OwnerId IN:Trigger.New]){
mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId); (No CODE COVERAGE)
}
for(User u1 : Trigger.New){
if(mapUserTeamIdVsuserId.containsKey(u1.id)){
u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id); (NO CODE COVERAGE)
}
}
}
trigger SSSUpdate on User (before Update)
{
Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u : [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' AND OwnerId IN:Trigger.New]){
mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId); (No CODE COVERAGE)
}
for(User u1 : Trigger.New){
if(mapUserTeamIdVsuserId.containsKey(u1.id)){
u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id); (NO CODE COVERAGE)
}
}
}
There are couple of ways of doing it :-
1.) Query on existing data of your org by making (SeeallData=true) in your test class.
2.) Insert a user in test class and add it to Opportunity Team with the Team role which is there in your where filter.
Hope this helps !!
All Answers
There are couple of ways of doing it :-
1.) Query on existing data of your org by making (SeeallData=true) in your test class.
2.) Insert a user in test class and add it to Opportunity Team with the Team role which is there in your where filter.
Hope this helps !!
First approach I understood, but can u elaborate second approach little bit more because I am creating an opportunity team member but that is not being retrieved in soql on Userteammember?
Thanks,
Rajat