mardi 18 décembre 2018

Write Apex Test Class for Scheduled FSC Batch Class

I am completely new to apex and am attempting to write a test class for a scheduled Apex batch class I wrote. Given the below scheduled class, how could I write test code?

global class ScheduleFSCRollUps implements Schedulable {
    global void execute(SchedulableContext ctx) {
    // Create your list of IDs
    List<Id> rollupsToRun = new List<Id>();
    List<FinServ__RollupByLookupConfig__c> queriedRollups = [SELECT Id 
    FROM FinServ__RollupByLookupConfig__c WHERE FinServ__Active__c = 
    true];
    for (FinServ__RollupByLookupConfig__c rollup : queriedRollups) {
        rollupsToRun.add(rollup.Id);
}

// Create an instance of RollupRecalculationBatchable
    FinServ.RollupRecalculationBatchable job = new 
    FinServ.RollupRecalculationBatchable(rollupsToRun);

// Run the rollups
    Database.executeBatch(job);     
}
}

Here is the test case I am currently trying to use and its error:

FinServ.MoiExceptionWrapper.IllegalArgumentException: Rollup Rules: 
Some records or IDs don't meet our criteria. Review your records and 
IDs and try again.


@isTest
private class ScheduleFSCRollupsTest {

    @isTest static void testScheduledJob() {
        Test.startTest();
        String jobId = System.schedule('ScheduleFSCRollups','0 0 0 15 
        3 ? 2100',new ScheduleFSCRollups());
        Test.stopTest();
        System.assertNotEquals(null, jobId);
    }

}

Aucun commentaire:

Enregistrer un commentaire