@isTest(SeeAllData=true)
public with sharing class clsForCaseShareUserTracker {
static testMethod void validateshareCaseWithUser()
{
//User objUser=[Select id,User_License__c,ProfileId,AccountId,userRoleId from User where User_License__c='Partner Community' and IsActive=true limit 1 ];
// update objUser;
clsForCaseShareUserTracker objUtil=new clsForCaseShareUserTracker();
Account objAccount1=objUtil.newAccount('Account1','platinum','Aurea','Indirect','Accept','German',123456,'Active','
saasforce.in','IDEU');
Contact objContact1=objUtil.newContact('Gupta',objAccount1.id,'
TheKrrish@saasforce.in',true,'
TheKrrish2@saasforce.in','password',false);
Contact objContact2=objUtil.newContact('Singh',objAccount1.id,'
TheKrrish2@saasforce.in',true,'
TheKrrish@saasforce.in','password',false);
RecordType rt=[SELECT Id, Name FROM RecordType WHERE SobjectType = 'Case' AND (Name = 'CS - Support Case' or Name = 'Platinum Services Case' ) limit 1];
Case objCase1=objUtil.newCase('Users','Internal User','
TheKrrish3@saasforce.in','Sales','medium',
rt.id,objAccount1.id,'Problem','Extension');
Profile p = [select id from profile where name='CS - Customer Portal User' limit 1];
User objUser1=objUtil.newUser('
TheKrrish4@saasforce.in',objContact1.id,'
TheKrrish4@saasforce.in','Gupta','en_US','en_US','UTF-8','Als1',
p.id,'America/Los_Angeles',true,'null');
List<UserRole> lstUserRole =[Select id from UserRole where PortalRole='Executive' and PortalAccountId=:objAccount1.id];
User objUser2=objUtil.newUser('
TheKrrish5@saasforce.in',objContact2.id,'
TheKrrish5@saasforce.in','Gupta','en_US','en_US','UTF-8','Als1',
p.id,'America/Los_Angeles',true,lstUserRole[0].id);
}
public Account newAccount(String name,String supportProgram,String LegalEntityName,String AccountChannel,String VersataEntity,String Language,Integer AnnualRevenue,String AccountType,String AccountDomainName,String AccountSubChannel )
{
Account objAccount = new Account();
objAccount.Name = name;
objAccount.Support_Program__c = supportProgram;
objAccount.LegalEntityName__c = LegalEntityName;
objAccount.Account_Channel__c = AccountChannel;
objAccount.Versata_Entity__c = VersataEntity;
objAccount.Language__c = Language;
objAccount.Annual_Revenue__c = AnnualRevenue;
objAccount.Account_Type__c =AccountType;
objAccount.Account_Domain_Name__c =AccountDomainName;
objAccount.Account_SubChannel__c = AccountSubChannel;
insert objAccount;
return objAccount;
}
public Contact newContact(String lastName,String AccountId,String Email,Boolean IsPlatinumUser,String ContactUsername,String ContactPassword,Boolean IsTemporarypasswordSent)
{
Contact objContact = new Contact();
objContact.LastName = lastName;
objContact.AccountId = AccountId;
objContact.Email = Email;
objContact.Is_Platinum_User__c = IsPlatinumUser;
objContact.Contact_Username__c = ContactUsername;
objContact.Contact_Password__c = ContactPassword;
objContact.Is_Temporary_password_Sent__c = IsTemporarypasswordSent;
insert objContact;
return objContact;
}
public Case newCase(String RequestType,String CVTypeofUserAccount,String AffectedUserEmailAddress,String AffectedBusinessUnit,String Priority,String RecordTypeid,String Accountid,String Type,String PlatinumServiceType)
{
Case objCase=new Case();
objCase.Request_Type__c=RequestType;
objCase.CV_Type_of_User_Account__c=CVTypeofUserAccount;
objCase.Affected_User_s_Email_Address__c=AffectedUserEmailAddress;
objCase.Desired_Effective_Date__c=system.today();
objCase.Affected_Business_Unit__c=AffectedBusinessUnit;
objCase.Priority=Priority;
objCase.RecordTypeid=RecordTypeid;
objCase.Accountid=Accountid;
objCase.Type=Type;
objCase.Platinum_Service_Type__c =PlatinumServiceType;
insert objCase;
return objCase;
}
public User newUser(String Email,String ContactId,String Username,String LastName,String languagelocalekey,String localesidkey ,String emailencodingkey,String alias,String profileid,String timezonesidkey,Boolean IsActive,String userRoleId)
{
User objUser= new User();
objUser.Email=Email;
objUser.ContactId=ContactId;
objUser.Username =Username;
objUser.LastName=LastName;
objUser.languagelocalekey=languagelocalekey;
objUser.localesidkey=localesidkey;
objUser.emailencodingkey=emailencodingkey;
objUser.alias = alias;
objUser.profileid = profileid;
objUser.timezonesidkey=timezonesidkey;
objUser.IsActive =IsActive;
if(userRoleId!='null' && userRoleId!='NULL' && userRoleId!='Null')
{
objUser.userRoleId=userRoleId;
}
insert objUser;
return objUser;
}
}