Untitled
unknown
plain_text
4 years ago
1.4 kB
7
Indexable
public class Helper_Trigger {
public static list<lead> UpdateLead(list<lead> listaLead) {
for (Lead l:listaLead){
if (l.numberofemployees > 100) {
if (l.status == 'Working - Contacted'){
l.status = 'Closed - Converted';
}
}
}
return listaLead;
}
}
@isTest
private class Test_Trigger {
@isTest
private static void testa(){
list<lead> listaLead = new list<lead>();
Lead l = new Lead(lastname = 'prova1', company= 'company1', status='Working - Contacted', numberofemployees = 120);
/*Lead l1 = new Lead(lastname = 'prova2', company= 'company2', status='Working - Contacted', numberofemployees = 10);
Lead l2 = new Lead(lastname = 'prova3', company= 'company3', status='Open - Not Contacted', numberofemployees = 120);*/
listaLead.add(l);
//listaLead.add(l1);
//listaLead.add(l2);
//Helper_trigger.UpdateLead(listaLead);
list<lead> verifica = Helper_trigger.UpdateLead(listaLead);
for (lead l1:verifica){
System.assertEquals('Closed - Converted', l1.status, 'ERRORE');
}
}
}
trigger TriggerLead on Lead (before insert, before update) {
Helper_Trigger.UpdateLead(trigger.new);
}Editor is loading...