You need to sign in to do that
Don't have an account?

Help With Test Class Please!
public with sharing class AttachController { //private ApexPages.StandardController controller { get; set; } public List<Deal_License__c> dp{get;set;} public Deal__c D{get;set;} public AttachController(ApexPages.StandardController controller) { D = [Select Name,Id,Account__c,Account__r.Name,Rate__c,Total_Value__c,Account__r.BillingStreet, Account__r.BillingCity,Account__r.Billingstate,Account__r.BillingPostalcode,Account__r.BillingCountry from Deal__c where id=:ApexPages.currentPage().getParameters().get('id')]; system.debug('TestDeal'+D); Account acc=[Select Id,BillingStreet,BillingCity,Billingstate,BillingPostalcode,BillingCountry from Account where id=:D.Account__c]; system.debug('Account%%%%%%%%%%%%%%'+acc); dp=[select id,Name,Deal__c,Months__c,List_Price__c,Unit_Price__c,Quantity__c,Total_Value__c from Deal_License__c where Deal__c=:D.Id]; System.debug('DEALPRDODUCT&&&&&&&&&&'+dp); } public void attach() { try{ Attachment myAttach = new Attachment(); myAttach.ParentId = ApexPages.currentPage().getParameters().get('id'); System.debug('Id: ' + ApexPages.currentPage().getParameters().get('id')); List<Attachment> at=[Select id from Attachment where parentId=:myAttach.ParentId]; Integer c=at.size()+1; myAttach.name =D.Account__r.Name +''+ 'License Version' + c +'.pdf'; PageReference psPdf = new PageReference('/apex/Quotation?id=' + ApexPages.currentPage().getParameters().get('id')); myAttach.body = psPdf.getContentAsPdf(); insert myAttach; System.debug('After attach'); System.debug(myAttach); /* ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Quotation has been attached.')); */ } catch(Exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There was an error while attaching')); System.debug('Exception'); } } public PageReference QA() { PageReference secondPage = new PageReference('/apex/EmailQuote?id=' + ApexPages.currentPage().getParameters().get('id')); Attachment myAttach = new Attachment(); myAttach.ParentId = ApexPages.currentPage().getParameters().get('id'); System.debug('Id: ' + ApexPages.currentPage().getParameters().get('id')); List<Attachment> at=[Select id from Attachment where parentId=:myAttach.ParentId]; Integer c=at.size()+1; myAttach.name = D.Account__r.Name +''+ 'License Version' + c +'.pdf'; PageReference psPdf = new PageReference('/apex/Quotation?id=' + ApexPages.currentPage().getParameters().get('id')); myAttach.body = psPdf.getContentAsPdf(); insert myAttach; secondPage.setRedirect(true); return secondPage; } public PageReference back() { attach(); PageReference pr = new PageReference('/' + ApexPages.currentPage().getParameters().get('id') +'#'+ ApexPages.currentPage().getParameters().get('id') + '_RelatedNoteList_target'); pr.setRedirect(true); System.debug('Inside back'); return pr; } public PageReference cancel() { PageReference pr = new PageReference('/' + ApexPages.currentPage().getParameters().get('id') +'#'+ ApexPages.currentPage().getParameters().get('id') + '_RelatedNoteList_target'); pr.setRedirect(true); System.debug('Inside back'); return pr; } public String attachmentName{get; set;} public pagereference AttachQuote(){ Pagereference pdf = page.Quotation; blob b = pdf.getContent(); attachment att = new attachment(); att.parentId = ApexPages.currentPage().getParameters().get('id') ; att.body = b; att.name = 'Quotation.pdf'; insert att; return null; }