I have an apex trigger which fires a platform event. And in the platform event trigger, it creates a big object.
My unit test code is pretty simple and looks like below:
Account acc = DataFactory.generateSingleAccount();
Test.startTest();
insert acc;
Test.getEventBus().deliver();
Test.stopTest();
List<Object_Feed_Store__b> objFeedList = [Select Id, DomainEntityId__c From Object_Feed_Store__b];
System.assertEquals(1, objFeedList.size());
I checked the code coverage, the platform event trigger is fired successfully, and the below line is successfully executed:
database.insertImmediate(bigObjList);
During normal testing, I have verified the big object is successfully created. But in this scenario, when I query that, the big object is not there. So the assertion failed in my unit test.
I would assume this is due to creation of big object is an asynchronous process even if I have used insertImmediate. But I am not sure how to make that completed in my unit test. Any suggestions?