You need to sign in to do that
Don't have an account?
Can please write test class for bulk trigger
trigger BulkCreating180upsell on Opportunity (after Update)
{
List<Opportunity> o = new List<Opportunity>();
//List<account> acc = new List<account>();
Set<id>accId = new Set<Id>();
//for(Account a :acc)
// accId.add(aId);
Set<Id> setId = new Set<Id>();
for(Opportunity opp :trigger.new)
{
setId.add(opp.Id);
accId.add(opp.accountId);
}
//opp.adderror(opp.AccountId);
// Account acc=[Select id,Name from Account where id=:opp.AccountId];
/*if(opp.StageName=='Closed Won' && opp.Name =='Up-Sell 90 days'+' ('+ mapacc.ContainsKey.Name +')')
{
o.add(new Opportunity (Name ='Up-Sell 180 days'+' ('+ acc.Name +')',CloseDate=date.today().adddays(180),AccountId=mapacc.id,StageName='Prospecting'));
}*/
Map<Id, Account> mapacc = new Map<Id, Account>([Select id,Name from Account where Id=:accId]);
Map<Id, Opportunity> mapopp = new Map<Id, Opportunity>([Select id,Name,CloseDate,AccountId,StageName from Opportunity where Id=:setId]);
for(Opportunity opp :trigger.new)
{
/*opp.Name = mapopp.get(opp.Id).opp.'Up-Sell 180 days'+' ('+ mapacc.Name +')';
opp.CloseDate=mapopp.get(opp.Id).opp.date.today().adddays(180);
opp.AccountId=mapopp.get(opp.Id).opp.mapacc.Id;
opp.StageName=mapopp.get(opp.Id).opp.'Prospecting';*/
opportunity op=mapopp.get(opp.Id);
Account ac=mapacc.get(opp.accountId);
if(op.StageName=='Closed Won' && op.Name =='Up-Sell 90 days'+' ('+ ac.Name +')')
{
/*Opportunity oppInsert = new Opportunity();
oppInsert.Name = 'Up-Sell 180 days'+' ('+ aFullName +')';
oppInsert.CloseDate = date.today().adddays(180);
//oppInsert.AccountId = convertedLead.ConvertedAccountId;
oppInsert.StageName = 'Prospecting';
oppInsert.OwnerId=UserInfo[0].id;*/
o.add(new Opportunity (Name ='Up-Sell 180 days'+' ('+ ac.Name +')',CloseDate=date.today().adddays(180),AccountId=ac.id,StageName='Prospecting',LeadSource=opp.LeadSource));
}
}
//System.debug('Account Id is'+opp.AccountId);
insert o;
}
Hi,
Find below test class to cover your trigger.
It is covering above 90%. Try to cover 100 if needed. Other wise use it as it is.
Find below link to get knowledge on writing test methods
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods