function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shruthi NarsiShruthi Narsi 

Method does not exist or incorrect signature: void attachPDF() from the type QuoteApexClass

Can Anyone help me with the test class and make the code coverage to 100%

Apex class

public class QuotePDF {
    public boolean show{get;set;}
    public id pdtId{get;set;}
    public Quote op{get;set;}
    public QuoteLineItem oli{get;set;}
    public string pb{get;set;}
    public Id opid{get;set;}
    public id prodid{get;set;}
    public list<QuoteLineItem> OliList{get;set;}
    public list<Quotelineitem> OliCreate;
    public integer deleteIndex{get;set;}
    
    public QuotePDF()
    {
        show=false;
        oli=new QuoteLineItem();
        op=new Quote();
        OliList=new list<QuoteLineItem>();
        OliCreate=new list<Quotelineitem>();
    }
    
    public void save(){
        pricebook2 spbid=[select id from pricebook2 where isStandard=true limit 1];
        
        opportunity o1=[select id from opportunity limit 1];
        op.OpportunityId=o1.id;
        op.Pricebook2Id=spbid.id;
        upsert op;
        map<id,id>pdtTopbemap=new map<id,id>();
        
        for(pricebookentry pb:[select product2id,id from pricebookentry where pricebook2id =:spbid.id ])
        {
            pdtTopbemap.put(pb.product2id,pb.id);
        }
        for(QuoteLineItem o:OliList)
        {
            o.QuoteId=op.id;
            o.unitprice=o.unitprice; 
            o.quantity=o.quantity;
            o.pricebookentryid=pdtTopbemap.get(o.product2id);
            o.Product2Id=o.product2id;
            OliCreate.add(o);
        }
        insert OliCreate;
    }
    public void AddOli()
    {
        show=true;
        QuoteLineItem olitemp = new QuoteLineItem();
        OliList.add(olitemp);
    }
    
    public void deleteOpp()
    {
        OliList.remove(deleteIndex);
    }
}

Test Class

@isTest
Public class QuoteApexClassTest {
    @isTest public static void QuoteApextestMethod() {
        Opportunity opp = new Opportunity();
        opp.Name = 'TestOpp';
        opp.CloseDate = System.today() + 5;
        opp.StageName = 'Prospecting';
        Insert opp;
        
        Quote q = new Quote();
        q.Name = 'test';
        q.OpportunityId = opp.Id;
        Insert q;
        

       ApexPages.StandardController sc = new ApexPages.StandardController(q);
        PageReference pageRef = Page.QuoteTemplate;
        pageRef.getParameters().put('id', String.valueOf(q.Id));
        Test.setCurrentPage(pageRef);
    
        QuoteApexClass qac = new QuoteApexClass(sc);        
        qac.saveQuoteAsPDFandEmail();
        qac.attachPDF();
        qac.getShowPrintLink();
        qac.print();
    }
}

User-added image
AbhishekAbhishek (Salesforce Developers) 
Hi Shruthi,

Try the code as mentioned in the below blog,

https://gist.github.com/citrus/19ce62aded1e6d9ff8ffa25db00bad71

https://developer.salesforce.com/forums/?id=906F0000000AbLQIA0

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Shruthi NarsiShruthi Narsi
Can you change the code and help me i tired  am getting stuck