• Vijay A 8
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
public class AddPersonCtrl {
    
    public Opportunity Opps;
    public Outside_People_Roles__c del;
    public Boolean refreshPage { get; set; }
    public List<Outside_People_Roles__c> addattendeeList {get;set;}
    public List<Outside_People_Roles__c> delattendeeList {get;set;}
    public List<Outside_People_Roles__c> attendeeList {get;set;}
    
    public Integer rowIndex {get;set;}
    public String currentRecordId;
    //public Boolean shouldRedirect {get;set;}
    
    public List<Outside_People_Roles__c> delAttendees {get; set;} 
    public AddPersonCtrl(ApexPages.StandardSetController controller) {
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        System.debug('currentRecordId'+currentRecordId);
        attendeelist=New List<Outside_People_Roles__c>();
        attendeeList.add(new Outside_People_Roles__c(Opportunity__c = currentRecordId));
        refreshPage = false;
        delattendeeList = new List<Outside_People_Roles__c>();
        delattendees = new List<Outside_People_Roles__c>();
    }
    public void addRow(){
        attendeeList.add(new Outside_People_Roles__c(Opportunity__c = currentRecordId));
    }
    public PageReference save(){
        upsert attendeeList;
        PageReference pr = new PageReference('/' +currentRecordId);        
        refreshPage = true;
        return pr;
    } 
    public void deleteRow(){
        rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        System.debug('row be deleted ' + rowIndex );
        attendeeList.remove(rowIndex);    
    }
}

Thankyou Advance.
Hi All,
Below is my trigger code with test class. Please help me test class for code coverage
trigger PropUpdate on D_D__c (after insert, after update) {
    
    set<id> accids = new set<id>();
    set<D_D__c> amc_recs = new set<D_D__c>();
    List<D_D__c>Amc_Lst_Upd = New List<D_D__c>();
    map<Id, Id> mp = new map<Id, Id>();
    if((Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) && checkRecursive.runOnce()){
        try{
            for (D_D__c am : Trigger.new){
                accids.add(am.Account__c);
                amc_recs.add(am);
                //mp.add(am.Id, am.Account__c);
            }
            if(accids.size() >= 1){
                for(Property__c pr : [SELECT Id,Account__c  FROM Property__c where Account__c IN:accids]){
                    mp.put(pr.Account__c, pr.Id);
                }
                
                if(!mp.isEmpty() && !amc_recs.isEmpty()){
                    D_D__c amc = new D_D__c();
                    system.debug('amc_recs.size()====='+amc_recs.size());
                    for(D_D__c amc_lst : amc_recs){
                        
                        amc.Id = amc_lst.Id;
                        amc.Property__c = mp.get(amc_lst.Account__c);
                        Amc_Lst_Upd.add(amc);
                    }
                    Update Amc_Lst_Upd;
                }
            }
        } 
        catch (Exception e) {
            System.debug(e);
        }
    }
}

-----------------------------------------------------------------

@isTest
public class PropUpdateTest {
    
    public static testmethod void PropUpdateTestmeth(){
        test.startTest();
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
        
        Account acc = new Account();
            acc.user__c = u.id;
            acc.AccountSource = 'Walk-in';
            acc.Name = 'testaccount';
        	
            insert acc;
        
        D_D__c dd = new  D_D__c();
            dd.account__c = acc.id;
            dd.Status__c = 'Active';
            dd.Actual_Amount__c = 2000;
            insert dd;   
         Test.stopTest();
        
    }
}

Thank you Advance.
Hi All,
Below are my Controller and my Test Class. Please help me test class for code coverage 75%.
 
public class ContactDuplicationCon {
    
    private final Contact contact;
    public string accId {get; set;}
    public string accname {get; set;}
    public boolean acclookup {get; set;}
    public boolean accstring {get; set;}
    
    public Datetime activityLastDate;
    public List<ActivityHistory> activityList = new List<ActivityHistory>();
    public List<ActivityHistory> activityListcontact = new List<ActivityHistory>();
    public ContactDuplicationCon(ApexPages.StandardController controller) {
        
        // Define the values for the contact you’re processing based on its ID
        Id id = ApexPages.currentPage().getParameters().get('id');
        accId = ApexPages.currentPage().getParameters().get('accId');        
        //system.debug('accid====='+accId);
        acclookup = true;
        accstring = false;   
        if(accId != NULL){
           Account ac = [select id,name from Account where id =: accId];
            accname = ac.name;
            acclookup = false;
            accstring = true;
        }
        
        this.contact = (id == null) ? new Contact() :
        [SELECT Id, FirstName, LastName, Email, Phone, AccountId ,Sub_Division__c,Account.Sub_Division_Name__c,Address__c,Title,Active__c,Target_Audience__c,MailingStreet,
         MailingCity,MailingState,MailingPostalCode,MailingCountry,    Fax,LeadSource,AssistantName,Department FROM Contact WHERE Id = :id];
             
             }
    // Return contact and its values to the Visualforce page for display
    public Contact getContact() {
        return this.contact;    
    }
    
    public PageReference contactsave() {
        if(accId != Null){
        Contact.AccountId = accId;
        }
        Account acc = [select id,name,Sub_Division_Name__c from account where id =: contact.AccountId];
        List<Contact> cc = new List<Contact>();
        system.debug('account===='+contact.AccountId);
            cc = [Select id,lastname,firstname,email,Sub_Division__c,Account.Sub_Division_Name__c,
                  (Select id,Status,OwnerId,CreatedDate,EndDateTime,LastModifiedDate,WhoId,Priority,Subject From ActivityHistories ORDER BY LastModifiedDate ASC Limit 1)
                  from contact where email =: contact.email AND Sub_Division__c =: acc.Sub_Division_Name__c ];
        
        List<Lead> ld = [Select id,name,email,Sub_Division_Name__c,
                         (Select id,Status,OwnerId,CreatedDate,EndDateTime,LastModifiedDate,WhoId,Priority,Subject From ActivityHistories ORDER BY LastModifiedDate ASC Limit 1)
                         from Lead where email =: contact.email AND Sub_Division_Name__c =: acc.Sub_Division_Name__c];
        //system.debug('subdivision====='+acc.Sub_Division_Name__c);
        //System.debug('Contact List Size =====>'+cc.size());        
        //System.debug('Lead List Size =====>'+ld.size());
        
        //System.debug('email==='+contact.email);
        
        if(cc.size() >= 1){
            for(Contact contacts : cc){
                //System.debug('Inside ContactActivity Loop');
                for(ActivityHistory activityhiscon : contacts.ActivityHistories){
                    activityListcontact.add(activityhiscon);
                }
                System.debug('Contact Activity Size ======>'+activityListcontact.size());
                if(activityListcontact.size() <= 0){
                    //System.debug('Contact Inside Activity List');                    
                    insert contact;
                    PageReference ContactDuplication = new PageReference('/' + Contact.Id);
                    ContactDuplication.setRedirect(true);
                    return ContactDuplication;
                }else{
                    for(ActivityHistory activityhiscon : contacts.ActivityHistories){
                        //System.debug('contact ActivityHistory LastModifiedDate ====> '+activityhiscon.LastModifiedDate);
                        activityLastDate = activityhiscon.LastModifiedDate + 30;
                        //System.debug('Contact activityLastDate  ====> '+activityLastDate);
                        if(activityLastDate > System.now()){
                            User u = [select id,Name,username,email from User where id =: userInfo.getUserId()];
                            Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
                            string [] toAdd = new string[]{'xyz@gmail.com'};
                                mail.setToAddresses(toAdd);
                            mail.setSubject('Contact Duplication');                            
                            mail.setPlainTextBody('Dear Admin'+
                                                  '\n\nBelow User trying to create duplicate email '+contact.email+
                                                  '\n\nName:' + u.Name+
                                                  '\nUserName : '+ u.Username +                                      
                                                  '\n\nThank You.'+
                                                  '\n\n TEAM.');
                            Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
                                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
                            if (results[0].success) {
                                System.debug('The email was sent successfully.');
                            } else {
                                System.debug('The email failed to send: '
                                             + results[0].errors[0].message);
                            }
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Email already exist with same subdivision in Contact'));                        }                              
                    }                                              
                }
            }
        }
        else if(ld.size() >= 1){
            System.debug('Inside Lead Loop');
            for(Lead leads : ld){
                //System.debug('Inside LeadActivity Loop');
                for(ActivityHistory activityhis : leads.ActivityHistories){
                    activityList.add(activityhis);
                }
                //System.debug('Activity Size ======>'+activityList.size());
                if(activityList.size() <= 0){
                    System.debug('Lead Inside Activity List');
                    insert contact;
                    PageReference ContactDuplication = new PageReference('/' + Contact.Id);
                    ContactDuplication.setRedirect(true);
                    return ContactDuplication;
                }else{
                    for(ActivityHistory activityhis : leads.ActivityHistories){
                        //System.debug('Lead ActivityHistory LastModifiedDate ====> '+activityhis.LastModifiedDate);
                        activityLastDate = activityhis.LastModifiedDate + 30;
                        //System.debug('Lead activityLastDate  ====> '+activityLastDate);
                        if(activityLastDate > System.now()){
                            User u = [select id,Name,username,email from User where id =: userInfo.getUserId()];
                            Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
                            string [] toAdd = new string[]{'xyz@gmail.com'};
                                mail.setToAddresses(toAdd);
                            mail.setSubject('Lead Duplication');                            
                            mail.setPlainTextBody('Dear Admin'+
                                                  '\n\nBelow User trying to create duplicate email '+contact.email+
                                                  '\n\nName:' + u.Name+
                                                  '\nUserName : '+ u.Username +                                      
                                                  '\n\nThank You.'+
                                                  '\n\nTEAM.');
                            Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
                                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
                            if (results[0].success) {
                                System.debug('The email was sent successfully.');
                            } else {
                                System.debug('The email failed to send: '
                                             + results[0].errors[0].message);
                            }
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Email already exist with same subdivision in Lead'));                            
                        }                              
                    }                                              
                }
            }
        }
        
        else{
            insert contact;
            PageReference ContactDuplication = new PageReference('/' + Contact.Id);
            ContactDuplication.setRedirect(true);
            return ContactDuplication;
        }        
        return null;
    }
    
    public PageReference Cancel(){        
        PageReference pageRef = new PageReference('/lightning/o/Contact/list?filterName=Recent');
        pageRef.setRedirect(true);
        return pageRef;          
    }
}

-----------------------------------

@isTest
public class ContactDuplicationConTest {
    static testMethod void testMethod1(){
        lead ld = new lead ();
        ld.LastName = 'Test';
        ld.email = 'testlead@gmail.com';
        ld.Company = 'testcomp';
        ld.Status = 'Followup';
        ld.LeadSource = '360 camp';
        ld.Division_Name__c = 'test division';
        ld.Sub_Division_Name__c = 'test subdivision';        
        insert ld;
        
        Account a = new Account();
        a.Name = 'testaccount';
        a.Sub_Division_Name__c = 'Global division';
        insert a;
        
        contact con = new contact();
        con.LastName = 'testcon';
        con.AccountId = a.id;
        con.Email= 'test@gmail.com';
        insert con;
        
        Event e = new Event();
        e.WhoId=ld.id;
        e.StartDateTime=system.today();
        e.EndDateTime=system.today()+5;
        insert e;
        
        Task taskCreate = new Task();
        taskCreate.WhoId = ld.Id;
        taskCreate.Status = 'Completed';
        taskCreate.Priority = 'Normal';
        taskCreate.Subject = 'Dummy subject';
        taskCreate.ActivityDate = system.today();
        insert taskCreate;
        
        apexPages.Currentpage().getParameters().put('Id',con.id);
        Apexpages.StandardController sc = new Apexpages.StandardController(con);
        ContactDuplicationCon ext = new ContactDuplicationCon(sc);
        
        ext.cancel();
        ext.contactsave();
        ext.getContact();
    }
    
    static testMethod void testMethod2(){
        
        lead ld = new lead ();
        ld.LastName = 'Test123';
        ld.Email = 'test1232345575676579@gmail.com';
        ld.Company = 'testcomp123';
        ld.Status = 'Followup';
        ld.LeadSource = '360 camp';
        ld.Division_Name__c = 'test division';
        ld.Sub_Division_Name__c = 'test subdivision';
        insert ld;
        
        Event e = new Event();
        e.WhoId=ld.id;
        e.StartDateTime=system.today();
        e.EndDateTime=system.today()+5;
        insert e;
        
        Task taskCreate = new Task();
        taskCreate.WhoId = ld.Id;
        taskCreate.Status = 'Completed';
        taskCreate.Priority = 'Normal';
        taskCreate.Subject = 'Dummy subject';
        taskCreate.ActivityDate = system.today();
        insert taskCreate;
        
        Account a = new Account();
        a.Name = 'testaccount';
        a.Sub_Division_Name__c = 'Global division';
        insert a;        
        
        contact con1 = new contact();
        con1.LastName = 'testcon1';
        con1.AccountId = a.id;
        con1.Email = 'testcon1@gmail.com';        
        insert con1;
        
        apexPages.Currentpage().getParameters().put('Id',con1.id);
        Apexpages.StandardController sc = new Apexpages.StandardController(con1);
        ContactDuplicationCon ext = new ContactDuplicationCon(sc);
        
        ext.cancel();
        ext.contactsave();
        ext.getContact();
        
    }
}

 
Hi All,
Below is my trigger code with test class. Please help me test class for code coverage
trigger PropUpdate on D_D__c (after insert, after update) {
    
    set<id> accids = new set<id>();
    set<D_D__c> amc_recs = new set<D_D__c>();
    List<D_D__c>Amc_Lst_Upd = New List<D_D__c>();
    map<Id, Id> mp = new map<Id, Id>();
    if((Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) && checkRecursive.runOnce()){
        try{
            for (D_D__c am : Trigger.new){
                accids.add(am.Account__c);
                amc_recs.add(am);
                //mp.add(am.Id, am.Account__c);
            }
            if(accids.size() >= 1){
                for(Property__c pr : [SELECT Id,Account__c  FROM Property__c where Account__c IN:accids]){
                    mp.put(pr.Account__c, pr.Id);
                }
                
                if(!mp.isEmpty() && !amc_recs.isEmpty()){
                    D_D__c amc = new D_D__c();
                    system.debug('amc_recs.size()====='+amc_recs.size());
                    for(D_D__c amc_lst : amc_recs){
                        
                        amc.Id = amc_lst.Id;
                        amc.Property__c = mp.get(amc_lst.Account__c);
                        Amc_Lst_Upd.add(amc);
                    }
                    Update Amc_Lst_Upd;
                }
            }
        } 
        catch (Exception e) {
            System.debug(e);
        }
    }
}

-----------------------------------------------------------------

@isTest
public class PropUpdateTest {
    
    public static testmethod void PropUpdateTestmeth(){
        test.startTest();
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
        
        Account acc = new Account();
            acc.user__c = u.id;
            acc.AccountSource = 'Walk-in';
            acc.Name = 'testaccount';
        	
            insert acc;
        
        D_D__c dd = new  D_D__c();
            dd.account__c = acc.id;
            dd.Status__c = 'Active';
            dd.Actual_Amount__c = 2000;
            insert dd;   
         Test.stopTest();
        
    }
}

Thank you Advance.
Hi All,
Below are my Controller and my Test Class. Please help me test class for code coverage 75%.
 
public class ContactDuplicationCon {
    
    private final Contact contact;
    public string accId {get; set;}
    public string accname {get; set;}
    public boolean acclookup {get; set;}
    public boolean accstring {get; set;}
    
    public Datetime activityLastDate;
    public List<ActivityHistory> activityList = new List<ActivityHistory>();
    public List<ActivityHistory> activityListcontact = new List<ActivityHistory>();
    public ContactDuplicationCon(ApexPages.StandardController controller) {
        
        // Define the values for the contact you’re processing based on its ID
        Id id = ApexPages.currentPage().getParameters().get('id');
        accId = ApexPages.currentPage().getParameters().get('accId');        
        //system.debug('accid====='+accId);
        acclookup = true;
        accstring = false;   
        if(accId != NULL){
           Account ac = [select id,name from Account where id =: accId];
            accname = ac.name;
            acclookup = false;
            accstring = true;
        }
        
        this.contact = (id == null) ? new Contact() :
        [SELECT Id, FirstName, LastName, Email, Phone, AccountId ,Sub_Division__c,Account.Sub_Division_Name__c,Address__c,Title,Active__c,Target_Audience__c,MailingStreet,
         MailingCity,MailingState,MailingPostalCode,MailingCountry,    Fax,LeadSource,AssistantName,Department FROM Contact WHERE Id = :id];
             
             }
    // Return contact and its values to the Visualforce page for display
    public Contact getContact() {
        return this.contact;    
    }
    
    public PageReference contactsave() {
        if(accId != Null){
        Contact.AccountId = accId;
        }
        Account acc = [select id,name,Sub_Division_Name__c from account where id =: contact.AccountId];
        List<Contact> cc = new List<Contact>();
        system.debug('account===='+contact.AccountId);
            cc = [Select id,lastname,firstname,email,Sub_Division__c,Account.Sub_Division_Name__c,
                  (Select id,Status,OwnerId,CreatedDate,EndDateTime,LastModifiedDate,WhoId,Priority,Subject From ActivityHistories ORDER BY LastModifiedDate ASC Limit 1)
                  from contact where email =: contact.email AND Sub_Division__c =: acc.Sub_Division_Name__c ];
        
        List<Lead> ld = [Select id,name,email,Sub_Division_Name__c,
                         (Select id,Status,OwnerId,CreatedDate,EndDateTime,LastModifiedDate,WhoId,Priority,Subject From ActivityHistories ORDER BY LastModifiedDate ASC Limit 1)
                         from Lead where email =: contact.email AND Sub_Division_Name__c =: acc.Sub_Division_Name__c];
        //system.debug('subdivision====='+acc.Sub_Division_Name__c);
        //System.debug('Contact List Size =====>'+cc.size());        
        //System.debug('Lead List Size =====>'+ld.size());
        
        //System.debug('email==='+contact.email);
        
        if(cc.size() >= 1){
            for(Contact contacts : cc){
                //System.debug('Inside ContactActivity Loop');
                for(ActivityHistory activityhiscon : contacts.ActivityHistories){
                    activityListcontact.add(activityhiscon);
                }
                System.debug('Contact Activity Size ======>'+activityListcontact.size());
                if(activityListcontact.size() <= 0){
                    //System.debug('Contact Inside Activity List');                    
                    insert contact;
                    PageReference ContactDuplication = new PageReference('/' + Contact.Id);
                    ContactDuplication.setRedirect(true);
                    return ContactDuplication;
                }else{
                    for(ActivityHistory activityhiscon : contacts.ActivityHistories){
                        //System.debug('contact ActivityHistory LastModifiedDate ====> '+activityhiscon.LastModifiedDate);
                        activityLastDate = activityhiscon.LastModifiedDate + 30;
                        //System.debug('Contact activityLastDate  ====> '+activityLastDate);
                        if(activityLastDate > System.now()){
                            User u = [select id,Name,username,email from User where id =: userInfo.getUserId()];
                            Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
                            string [] toAdd = new string[]{'xyz@gmail.com'};
                                mail.setToAddresses(toAdd);
                            mail.setSubject('Contact Duplication');                            
                            mail.setPlainTextBody('Dear Admin'+
                                                  '\n\nBelow User trying to create duplicate email '+contact.email+
                                                  '\n\nName:' + u.Name+
                                                  '\nUserName : '+ u.Username +                                      
                                                  '\n\nThank You.'+
                                                  '\n\n TEAM.');
                            Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
                                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
                            if (results[0].success) {
                                System.debug('The email was sent successfully.');
                            } else {
                                System.debug('The email failed to send: '
                                             + results[0].errors[0].message);
                            }
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Email already exist with same subdivision in Contact'));                        }                              
                    }                                              
                }
            }
        }
        else if(ld.size() >= 1){
            System.debug('Inside Lead Loop');
            for(Lead leads : ld){
                //System.debug('Inside LeadActivity Loop');
                for(ActivityHistory activityhis : leads.ActivityHistories){
                    activityList.add(activityhis);
                }
                //System.debug('Activity Size ======>'+activityList.size());
                if(activityList.size() <= 0){
                    System.debug('Lead Inside Activity List');
                    insert contact;
                    PageReference ContactDuplication = new PageReference('/' + Contact.Id);
                    ContactDuplication.setRedirect(true);
                    return ContactDuplication;
                }else{
                    for(ActivityHistory activityhis : leads.ActivityHistories){
                        //System.debug('Lead ActivityHistory LastModifiedDate ====> '+activityhis.LastModifiedDate);
                        activityLastDate = activityhis.LastModifiedDate + 30;
                        //System.debug('Lead activityLastDate  ====> '+activityLastDate);
                        if(activityLastDate > System.now()){
                            User u = [select id,Name,username,email from User where id =: userInfo.getUserId()];
                            Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
                            string [] toAdd = new string[]{'xyz@gmail.com'};
                                mail.setToAddresses(toAdd);
                            mail.setSubject('Lead Duplication');                            
                            mail.setPlainTextBody('Dear Admin'+
                                                  '\n\nBelow User trying to create duplicate email '+contact.email+
                                                  '\n\nName:' + u.Name+
                                                  '\nUserName : '+ u.Username +                                      
                                                  '\n\nThank You.'+
                                                  '\n\nTEAM.');
                            Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
                                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
                            if (results[0].success) {
                                System.debug('The email was sent successfully.');
                            } else {
                                System.debug('The email failed to send: '
                                             + results[0].errors[0].message);
                            }
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Email already exist with same subdivision in Lead'));                            
                        }                              
                    }                                              
                }
            }
        }
        
        else{
            insert contact;
            PageReference ContactDuplication = new PageReference('/' + Contact.Id);
            ContactDuplication.setRedirect(true);
            return ContactDuplication;
        }        
        return null;
    }
    
    public PageReference Cancel(){        
        PageReference pageRef = new PageReference('/lightning/o/Contact/list?filterName=Recent');
        pageRef.setRedirect(true);
        return pageRef;          
    }
}

-----------------------------------

@isTest
public class ContactDuplicationConTest {
    static testMethod void testMethod1(){
        lead ld = new lead ();
        ld.LastName = 'Test';
        ld.email = 'testlead@gmail.com';
        ld.Company = 'testcomp';
        ld.Status = 'Followup';
        ld.LeadSource = '360 camp';
        ld.Division_Name__c = 'test division';
        ld.Sub_Division_Name__c = 'test subdivision';        
        insert ld;
        
        Account a = new Account();
        a.Name = 'testaccount';
        a.Sub_Division_Name__c = 'Global division';
        insert a;
        
        contact con = new contact();
        con.LastName = 'testcon';
        con.AccountId = a.id;
        con.Email= 'test@gmail.com';
        insert con;
        
        Event e = new Event();
        e.WhoId=ld.id;
        e.StartDateTime=system.today();
        e.EndDateTime=system.today()+5;
        insert e;
        
        Task taskCreate = new Task();
        taskCreate.WhoId = ld.Id;
        taskCreate.Status = 'Completed';
        taskCreate.Priority = 'Normal';
        taskCreate.Subject = 'Dummy subject';
        taskCreate.ActivityDate = system.today();
        insert taskCreate;
        
        apexPages.Currentpage().getParameters().put('Id',con.id);
        Apexpages.StandardController sc = new Apexpages.StandardController(con);
        ContactDuplicationCon ext = new ContactDuplicationCon(sc);
        
        ext.cancel();
        ext.contactsave();
        ext.getContact();
    }
    
    static testMethod void testMethod2(){
        
        lead ld = new lead ();
        ld.LastName = 'Test123';
        ld.Email = 'test1232345575676579@gmail.com';
        ld.Company = 'testcomp123';
        ld.Status = 'Followup';
        ld.LeadSource = '360 camp';
        ld.Division_Name__c = 'test division';
        ld.Sub_Division_Name__c = 'test subdivision';
        insert ld;
        
        Event e = new Event();
        e.WhoId=ld.id;
        e.StartDateTime=system.today();
        e.EndDateTime=system.today()+5;
        insert e;
        
        Task taskCreate = new Task();
        taskCreate.WhoId = ld.Id;
        taskCreate.Status = 'Completed';
        taskCreate.Priority = 'Normal';
        taskCreate.Subject = 'Dummy subject';
        taskCreate.ActivityDate = system.today();
        insert taskCreate;
        
        Account a = new Account();
        a.Name = 'testaccount';
        a.Sub_Division_Name__c = 'Global division';
        insert a;        
        
        contact con1 = new contact();
        con1.LastName = 'testcon1';
        con1.AccountId = a.id;
        con1.Email = 'testcon1@gmail.com';        
        insert con1;
        
        apexPages.Currentpage().getParameters().put('Id',con1.id);
        Apexpages.StandardController sc = new Apexpages.StandardController(con1);
        ContactDuplicationCon ext = new ContactDuplicationCon(sc);
        
        ext.cancel();
        ext.contactsave();
        ext.getContact();
        
    }
}