• Martina Ompusunggu
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi,
I was click a button to generate a document but I don't know why this appeared (see below). I didn't change any codes. Why this is happend? How can I fix this?
Any solutions?
User-added image
User-added image
User-added image
 
test class 
@isTest
private class testPickedLeads_2 {
    static testMethod void DataConfirmationQueue() 
    {        
        Lead lead2 = new Lead(LastName = 'Yoyo', Company='Yoyo',OwnerId='00G90000002YRAF',Enter_Data_Confirmation_Queue_Timestamp__c=system.today().addDays(-10), Status='Qualified',Phone='0812728658125 wrong',Debt_Amount_1__c=11,Total_Debt_Amount__c=11);
        
        Lead lead3 = new Lead(LastName = 'Yaya', Company='Yaya',OwnerId='00G90000002YRAF',Enter_Data_Confirmation_Queue_Timestamp__c=system.today().addDays(-10), Status='Qualified',Total_Debt_Amount__c=7);
        
        insert lead2;
        insert lead3;
        
        System.schedule('scheduleDataConfirmationQueueAutomation', '0 31 13 * * ?', new pickedLeadsDataConfirmationQueue());
    }
    
    static testMethod void UnqualifiedOnCallQueue() 
    {
        Lead lead1 = new Lead(LastName='Yodhi',Company='Yodhi',OwnerId='00G90000002zs7H',Status='Open',Phone='0912824 wrong', Debt_Amount_1__c=9,Total_Debt_Amount__c=9);
        Lead lead2 = new Lead(LastName='Yodhi',Company='Yodhi',OwnerId='00G90000002YRAF',Status='Open',Phone='0812728658125',MobilePhone='0812512856',Debt_Amount_1__c=11,Total_Debt_Amount__c=11);
        insert lead2;

        insert lead1;
        //lead1.OwnerId='';
        //update lead1;
        
        System.schedule('scheduleUnqualifiedOnCallQueue', '0 31 13 * * ?', new pickedLeadsUnqualifiedOnCallQueue());
    }

    static testMethod void HubspotScore() 
    {
        Datetime createDate = Datetime.now().addDays(-29);
        
        Lead lead1 = new Lead(LastName='Yodhi',Company='Yodhi',OwnerId='00G90000002zs7H',Status='Open',Hubspot_Score__c=79,In_Queue_End_Date__c= null, Is_Picked__c=false);
        Lead lead2 = new Lead(LastName='Bob',Company='Bob',OwnerId='00G90000002zs7H',Status='Open',Hubspot_Score__c=70,In_Queue_End_Date__c=system.today().addDays(-1), Is_Picked__c=false);
        insert lead1;
        insert lead2;
        Test.setCreatedDate(lead1.Id, createDate);
        Test.setCreatedDate(lead2.Id, createDate);
        Test.startTest();
        
        List<Task> listTask = new List<Task>();
        for(Integer i=0; i<3; i++){
            listTask.add(new Task(WhoId=lead1.id,Subject='Call '+i, Type='Unreached Call',Status='Completed'));
            listTask.add(new Task(WhoId=lead2.id,Subject='Call '+i, Type='Unreached Call',Status='Completed'));
        }  
        insert listTask;
        
        map<Id, List<Task>> map1 = new map<Id, List<Task>>(); 
        for(Task t : listTask)
        {
           map1.put(t.WhoId, new List<Task>{t});
        }
        
        System.schedule('scheduleHubspotScore', '0 31 13 * * ?', new pickedLeadsHubspotScore());
        Test.stopTest();
    }
}

I only got 52% code coverage. Could somebody help me to resolve this? I need 100% coverage asap. Thank you.

*I am really a newbie, so help me

Here is my task controller:
newTaskController
and here is my test class:

@isTest
private class newTaskTest{

    static testMethod void createTask() 
    {
        Lead lead = new Lead(LastName='febrian',company='febrian test');
        insert lead;
        Account acc = new Account(Name='test');
        insert acc;
        Opportunity opp = new Opportunity(AccountId=acc.Id,Name='test opp',StageName = 'Prospecting',CloseDate = date.today());
        insert opp;
        
        PageReference pR = Page.newTaskContactLayout;
        Test.setCurrentPage(pR);
        
        ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(lead);
        ApexPages.currentPage().getParameters().put('Id',lead.id);
        
        newTaskController ntc = new newTaskController(sc);
        
        Task tsk = new Task(Status='Completed',Subject='Reached Call',Type='Reached Call',Description='test',ActivityDate=System.today(),whoId =lead.id);
        insert tsk;
        ntc.saveTask();
        
        ApexPages.Standardcontroller sc2 = new ApexPages.Standardcontroller(opp);
        ApexPages.currentPage().getParameters().put('Id',opp.id);
        
        newTaskController ntc2 = new newTaskController(sc2);
        
        Task tsk2 = new Task(Status='Completed',Subject='Reached Call',Type='Reached Call',Description='test',ActivityDate=System.today(),whatId =lead.id);
        insert tsk2;
        ntc2.saveTask();
        
        system.assertEquals(null, pR);
    }  
    static testMethod void updateTimestamp(){
        //PageReference pr = Page.newTaskContactLayout;
        //Test.setCurrentPage(pr);
        Account acc = new Account();
        acc.Name = 'Test Account';
        insert acc;
        
        Contact cont = new Contact();
        cont.AccountId = acc.Id;
        cont.FirstName = 'FirstName';
        cont.LastName = 'LastName';
        cont.Email='flname@email.com';
        insert cont;
        
        Opportunity opp = new Opportunity(AccountId = acc.Id,Name='test opp',StageName = 'Prospecting',CloseDate = date.today());
        insert opp;
        
        test.startTest();
        //Test.setCurrentPageReference(pr);
        test.setCurrentPage(Page.newTaskContactLayout);
        
        ApexPages.StandardController sc2 = new ApexPages.StandardController(opp);
        //ApexPages.StandardSetController sc2 = new ApexPages.StandardSetController(opp);
        //sc2.setSelected(opp);
        ApexPages.currentPage().getParameters().put('Id',opp.id);
        
        newTaskController ntc2 = new newTaskController(sc2);
        cont.Follow_Up_Timestamp__c = System.NOW();
        update cont;
        ntc2.callQueue();
        
        ApexPages.StandardController sc3 = new ApexPages.StandardController(cont);
        ApexPages.currentPage().getParameters().put('Id',cont.id);
        
        newTaskController ntc3 = new newTaskController(sc3);
        cont.Follow_Up_Timestamp__c = System.now();
        update cont;
        ntc3.callQueue();
        //system.assertEquals(null, pR);  
    }
}

after run test, I got code coverage 80%. Could anybody give me solutions to resolve this? I need 100% coverage asap. Thank you.