You need to sign in to do that
Don't have an account?
Raumil
Help in Test Class
Hello friend i am writing test class for following class but i am not able to know where to start from so please help me my Class is below.
public with sharing class ExternalPDFGetway{ public static Blob getInvoicePdf( String tempkey ) { if(tempkey != null ){ //Map < String ,Transaction__c > trxmap = new Map < String , Transaction__c>(); akritiv__Temp_Object_Holder__c objtemp = [select ID,akritiv__Key__c,akritiv__value__c from akritiv__Temp_Object_Holder__c where akritiv__Key__c =: tempkey ]; System.debug('--------------->> TOH :: '+ objtemp ); string trxList = objtemp.akritiv__value__c; System.debug('--------------->> trxlist :: '+ trxList); List<ID> txids = new List<ID>(); for(String onetrx : trxList.split(',')) { System.debug('--------------->> one-trx :: '+ onetrx ); if(onetrx !='') { txids.add(onetrx); } } List<akritiv__Transaction__c> objTrxlist = [select id,Name, akritiv__Transaction_key__c from akritiv__Transaction__c where Id in :txids ]; System.debug('--------------->> get invoice pdf :: '+ objTrxlist.size()); if(objTrxlist.size() == 1){ return getInvoice(objTrxlist.get(0).Name); }else if(objTrxlist.size() > 1){ System.debug('----- More then one Transactions ------'); String txnumbers = ''; for(akritiv__Transaction__c objtx : objTrxlist ){ txnumbers = txnumbers + ',' + objtx.name ; } System.debug('----- trx numbers :: '+txnumbers ); return getMultipleInvoice(txnumbers); }else{ System.debug('----- No Transactions ------'); } } return null; } public static Blob getInvoice( String invoicenumber ){ String url = ExternalPDFGetway.getExternalPDFUrl(); url = url + '?invoice='+invoicenumber; System.debug('------->>> Url :: '+url); Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('GET'); HttpResponse res = h.send(req); return EncodingUtil.base64Decode(res.getBody()); } public static Blob getMultipleInvoice( String invoicenumbers ){ String url = ExternalPDFGetway.getExternalPDFUrl(); url = url + '?invoices='+invoicenumbers ; Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('GET'); HttpResponse res = h.send(req); return EncodingUtil.base64Decode(res.getBody()); } public static Blob getAllOpenInvoice( String accountNumber ) { String url = ExternalPDFGetway.getExternalPDFUrl(); url = url + '?account='+accountNumber ; Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('GET'); HttpResponse res = h.send(req); return EncodingUtil.base64Decode(res.getBody()); } // * -------------- PDF Endpoint ------------- // Returns default value of PDF PDF_Endpoint__c Setting // Return Type PDF_Endpoint__c // No parameters are passed in this method public static PDF_Endpoint__c getPDFEndpointConfigurationObj() { return PDF_Endpoint__c.getOrgDefaults(); } // Returns External PDF URL specified in PDF_Endpoint__c Custom Setting // Return Type PDF_Endpoint__c // No parameters are passed in this method public static String getexternalPDFUrl() { return getPDFEndpointConfigurationObj().External_PDF_URL__c; } // Fetches the value of Use External PDF which is specified in PDF_Endpoint__c Custom Setting // Return Type - Boolean // No Parameters are passed in this method public static boolean isEnableUseExternalPDF() { PDF_Endpoint__c pdfConfObj = ExternalPDFGetway.getPDFEndpointConfigurationObj(); boolean isExternalPDFOptionEnabled = false; if(pdfConfObj !=null) { if(pdfConfObj.Use_External_PDF__c !=null) { isExternalPDFOptionEnabled = pdfConfObj.Use_External_PDF__c; } } return isExternalPDFOptionEnabled; } // * -------------- PDF Endpoint ------------- }
Any Help would be appreciated.
Regards
Raumil Setalwad