• piyush chawla
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello everybody,
I needed to modify an apex class I deployed to production before.
The problem is that the code coverage is now 45% and I don't understand why it doesn't enter if neither if nor else. 

I'm doing a callout into a future method, using HttpCalloutMock.
Main class example :
User-added imageTest class :
Test.startTest();
        Test.setMock(HttpCalloutMock.class, new AppelAPIMock());
        ExpeditionSearchDPD.updateExpe(expeditions);
Test.stopTest();
AppelAPIMock :
@isTest
global with sharing class AppelAPIMock implements HTTPCalloutMock{
    global HTTPResponse respond(HTTPRequest req){
        HttpResponse res = new HTTPResponse();
        res.setHeader('Content-Type', 'text/xml');
        res.setBody('<?xml version="1.0" encoding="utf-8"?>' +
        	'<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
        		'<soap12:Body>' + 
            		'<getShipmentTraceResponse xmlns="http://www.cargonet.software/">' + 
            			'<getShipmentTraceResult>' + 
                            '<ShippingDate>02.08.2019</ShippingDate>' + 
                            '<DeliveryDate>05.08.2019</DeliveryDate>' + 
                            '<Weight>0</Weight>' + 
                    	'</getShipmentTraceResult>' + 
                 	'</getShipmentTraceResponse>' + 
               	'</soap12:Body>' + 
            '</soap12:Envelope>');
        res.setStatusCode(200);
        return res;
    }
}
Thank you for your answers