jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
222 stars 30 forks source link

Test setup for integration test not working as shown in the tutorial #598

Closed HamboneWilson closed 5 months ago

HamboneWilson commented 5 months ago

The following code gives a variable not visible error when I try to deploy it:

    @IsTest
    static void apexRollup_InsertIntegration_CorrectContextCalled() {
        JHU_Core.TriggerHandler.bypassAll();
        Account parent = new ExternalAccountBuilder().buildAccount();
        JHU_Core.TriggerHandler.clearAllBypasses();

        Funding__c testFunding = new FundingBuilder().receivingAccountId(parent.Id).buildFunding();

        Set<System.TriggerOperation> expectedOperations = new Set<System.TriggerOperation>{System.TriggerOperation.AFTER_INSERT};

        Assert.areEqual(expectedOperations, Rollup.CACHED_APEX_OPERATIONS.get(Funding__c.SObjectType));
    }

The specific error:

Update of ApexClass TEST_FundingTrigger: Error on line 32, col 45: Variable is not visible: Rollup.CACHED_APEX_OPERATIONS

I am on version 1.6.27

jamessimone commented 5 months ago

@HamboneWilson apologies that the video(?) has gotten out of date. Here's what you can do in the interim (I may re-add the @TestVisible annotation in a future release):

private class RollupMock extends Rollup {
  public RollupMock() {
    super();
  }

  public Set<System.TriggerOperation> getOperations() {
    return this.getCachedApexOperations();
  }
}

// and then in your test:
Assert.areEqual(expectedOperations, new RollupMock().getOperations().get(Funding__c.SObjectType));