function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
James BillingsJames Billings 

Get class name of queueable implementation

I'm writing some tests for a class which can trigger a couple of different queueables. 

In the tests, we have a mock implementaion of ISystemOperation which increments a number when a call to enqueue is made... 

I now want to only increment the counter when the expected queueable class is used, but I cannot find out a way of getting this... Example (pseudo)code, the line marked with **** is the one I'm wondering how to implement:
 

private class CapturingSystemOperation implements ISystemOperation
    {
        public Integer CallCount = 0;
        public String expectedClassName;

        public String enqueueJob(Queueable queueableClass)
        {
********if (queueableClass.class.Name == expectedClassName)
            {
                CallCount++;
            }

            return Utils.getFakeId(AsyncApexJob.SObjectType);
        }
    }
 

Any ideas?  

Best Answer chosen by James Billings
James BillingsJames Billings
Well, to answer my own question, this was actually easy to do:
 
String className = String.valueOf(queueableClass).substringBefore(':');
if (className == expectedClassName)
{
    ......

The string represention includes jsonified data passed to the class too, so grabbing everything before the first ":" gives just the class name