Happy Business Starts Here

Valued Scholar

Test failed on custom test case, but not failed on Zuora one

We have some Zuora test, for example ZuoraUtil (with API version 23), and it also have one test case called ZuoraUtilTests (API version 19), when I run the testCreateAmendments(), inside the method it will invoke ZuoraUtil.createAmendament and also called findZuoraSubscriptionIdByNamemethod in Zuora Utils. That is fine, and no "Please update Zuora WSDL first" exception.

 

However, ZuoraUtil.createAmendament method have some issue on it, so I need to create a separate class, and copy the method from ZuoraUtil into my own class. My class have API version 42. The only difference is all the method that make static call in ZuoraUtil, for example findZuoraSubscriptionIdByName, in my class I used ZuoraUtil.findZuoraSubscriptionIdByName(). And when I develop the test case and try to run the test, I got "Please update Zuora WSDL first". 

 

Now my question is, does API version affect the test case? Because I don't understand why one of them work but the other is not

5 REPLIES 5
Guru

Re: Test failed on custom test case, but not failed on Zuora one

It would be helpful if you showed part of the code so we can understand the differences in the two tests.

Maggie Longshore
Valued Scholar

Re: Test failed on custom test case, but not failed on Zuora one

Like here is the sample example.

 

In ZuoraUtil, it have :

 

 

    public static String findZuoraSubscriptionIdByName(String zsubname){
        ZuoraClient api = login();
        
        List<Zuora.zObject> subs = api.zquery('select Id, Name, AccountId, AutoRenew, InitialTerm, Notes, RenewalTerm, Status, TermStartDate, Version from Subscription where Name = \'' + zsubname + '\' and Status = \'Active\'');
        if(subs.size() == 0) return null;
        else{
            return (String)subs[0].getValue('Id');
        }       
    }

 

Then in the ZuoraUtilTests. here is the way they write the test cases

 

    
    public static testMethod void testFind2(){
        ZuoraClient.isTest = true;
        string subid = ZuoraUtil.findZuoraSubscriptionIdByName('1');
        string subName = ZuoraUtil.findZuoraSubscriptionName(subid);
        ZuoraUtil.updateSubscriptionStatus(subid, 'new');
    }

 

 

And when I execute this one, it doesn't throw the "Please upload Zuora WSDL at first" exception.

 

 

Now here is my code that actually using that method findZuoraSubscriptionIdByName(), this createAmendments() method is in my helper class

 

public class RatePlanChangeHelper {
@future(callout=true)
/**
** This method will create and process all of the add/remove product and price override amendments on a subscription
** @param workOrderId - the Id of the work order Case record
** @param workOrderRequestId - the Id of the Work_Order_Request__c record
** @param provRequestId - the Id of the Provisioning_Request__c record
** @param subscriptionId - the Id of the Subscription_Relationship__c record
** @param quoteId - the Id of the zqu__Quote__c record
**/
public static void createAmendments(Id workOrderId, Id workOrderRequestId, Id provRequestId, String subscriptionId, String quoteId, String orderId, Id oldRPId, Id newRPId){

Order__c order = [Select Id, Customer_Subscription__c from Order__c where Id =:orderId][0];
List<Order_Line__c> orderLine = [Select Id, Key_ID__c, Line_Status__c from Order_Line__c where Order__c = :order.Id];
try{
system.debug('workOrderId='+workOrderId+'; workOrderRequestId='+workOrderRequestId+'; provRequestId='+provRequestId+'; subscriptionId=' + subscriptionId + '; quoteId='+ quoteId);
//load all the necessary Sobjects to get the quote data we need
Provisioning_Request__c provRequest = provRequestId != null ? WorkOrderUtil.loadProvisioningRequest(provRequestId) : null;
Subscription_Relationship__c subscription = [Select Id, Name, Base_Product_Name__c, Base_Rate_Plan_Name__c, (Select Name from Quotes1__r) from
Subscription_Relationship__c where Id =: subscriptionId][0];


zqu__Quote__c quote = QuoteControllerUtil.loadQuote(quoteId);

//determine the effective date and the contract effective date from the quote and existing subscription
//Date effectiveDate = subscription.Subscription__r.Zuora__TermStartDate__c;
Date effectiveDate = Date.today();
Date contractEffectiveDate = Date.today();

//Callout #1, #2...
//login, find the Zuora subscription by name
String zsubscriptionId = ZuoraUtil.findZuoraSubscriptionIdByName(subscription.Name);

// the rest of the code

}

 

And in my main class I just called 

 

RatePlanChangeHelper.createAmendments(// pass the parameters);

 

 

Now here is the way I create the test method to invoke the RatePlanChangeHelper.createAmendments (Also have setup properly before)

 

 

    @isTest
    static void testOldPlanToNewPlan(){
        ZuoraClient.isTest = true;
        // This test method should contains different plan change
        // include optional vas change
        Order__c order = [Select Id, Customer_Subscription__c from Order__c where Type__c = 'Change Rate Plan' 
                          and Description__c = 'OldPlanToNewPlan'];
        Test.startTest();
        ChangeRatePlanOrder.changeRatePlan(order.Id);
        Test.stopTest();
    }
    

 

And this time I got the error on 

ZuoraUtil.findZuoraSubscriptionIdByName(subscription.Name);

 

Why we have this difference?

 

 

Guru

Re: Test failed on custom test case, but not failed on Zuora one

Does your first test find any objects? If it doesn't then it is not trying to build an object so it is not using the wsdl.

Maggie Longshore
Valued Scholar

Re: Test failed on custom test case, but not failed on Zuora one

I check the log, yes, it returns, the value is 1

Valued Scholar

Re: Test failed on custom test case, but not failed on Zuora one

Also one more interest thing

 

I copied that Test cases into my own create test class, and try to run it, and I still got the "Please upload Zuora WSDL at first" exception