Add Database Result Support to CallableLogger class #905
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I took a stab at adding support for Database Result classes in
CallableLogger. I added parameters to take in single result objects as well as a list, and added a parameter to pass through the type of result. I didn't bother adding support to pass through a recordId since that can already be accomplished through the 'recordId' parameter.I ended up adding two generic implementations of
LogEntryEventBuilder.setDatabaseResultto allow the log builder to take in a generic list of typeObject, or a singleObjectinstance. I went with this vs trying to route the result(s) through the overloaded methods because there isn't really a way to cast in Apex using theSystem.Typethat I'm aware of, andLogEntryEventBuilder.setDatabaseDetailsis already abstracted to take in aList<Object>parameter anyway. It's not exposed through theLoggerclass so I figured it would be fine.Currently the
'resultType'parameter would not be required, since there is a call:resultType.getName();inLogEntryEventBuilder.setDatabaseDetailsthat I switched toresultType?.getName();to handle the case where the'resultType'parameter is not passed to CallableLogger.I also added methods to
LoggerMockDataCreatorto create lists of mocked Database Result objects and updatedLogger_Teststo use those methods as well.I didn't update the
Nebula Logger DemoOmniscript since the other record parameters weren't in there either.Tests were passing when I ran through the github build actions locally but I'll update the branch if anything fails.
Let me know if there is anything else that needs to be taken into consideration here.