System.FinalizerContext and System.FinalizerContextImpl

26 views
Skip to first unread message

Eric Kintzer

unread,
Aug 30, 2022, 9:02:00 PM8/30/22
to Illuminated Cloud Q&A
Chris Peterson (Apex PM at the time 2021) mentioned in a Richmond Users Group meeting that one could provide a mock implementation of System.FinalizerContext for uint testing TransactionFinalizers. He couldn't remember if it was an abstract or virtual class, or an interface.  So, I dug into the definitions as exposed by IC2 and got confused:

Here's FinalizerContextImpl implementing an interface FinalizerContext

global class /*System.*/FinalizerContextImpl implements FinalizerContext
{
global Object clone(){}
global Id getAsyncApexJobId(){}
global Exception getException(){}
global String getRequestId(){}
global ParentJobResult getResult(){}
}

And here's FinalizerContext - a class, not an interface ?!

global class /*System.*/FinalizerContext
{
global Id getAsyncApexJobId(){}
global Exception getException(){}
global String getRequestId(){}
global ParentJobResult getResult(){}
}

So, I don't know if Chris misspoke or IC2 is in error but the path to creating a mock FinalizerContext for unit testing is not as straightforward as I would have thought

Eric

Scott

unread,
Aug 31, 2022, 9:41:54 AM8/31/22
to Illuminated Cloud Q&A, eric.k...@helix.com
Those types come straight from the Tooling API's completions REST resource, but pretty much everything is reported by that API as a class and inheritance relationships aren't expressed. Right now the only adjustment that IC2 makes is to have FinalizerContextImpl implement FinalizerContext, but it does look like FinalizerContext should be an interface based on this:


That should have been obvious by the fact that it's an implements relationship and not an extends relationship, so that was my oversight when adding these explicit type adjustments. I've added that to the OST generator and it should be included in tomorrow's build.

Regards,
Scott Wells

Scott

unread,
Sep 1, 2022, 12:37:11 PM9/1/22
to Illuminated Cloud Q&A, Scott, eric.k...@helix.com
I posted 2.2.3.4 today which includes a fix for this. After updating regenerate your OST and FinalizerContext will be rendered into the OST as an interface instead of a class.

Regards,
Scott Wells
Reply all
Reply to author
Forward
0 new messages