-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add null checks for JSON stream #154
Comments
@Seelenoede -- Thanks for letting us know about this issue. Any chance that you could create some examples demonstrating the behavior, please? It would help us resolve this quicker. I appreciate it. |
@ImJohnMDaniel sure. I could reproduce this on a Trailhead Playground with the current version of apex-mocks. A set up an unit test.
|
In a project, I tried to create a mock Order record with a few OrderItems. But then makeRelationship failed.
After further digging, I noticed that one of the Product2 had a field with a value, while another Product2 had this field empty, which then lead to an issue with the "streamTokens method in fflib_ApexMocksUtils, as it couldn't parse the null token.
So basically it tried to write the JSON as
{ "data": "xyz",
"data2":,
"data3: "abc"}
which is of course is an invalid JSON.
I could fix it by adding
to the method.
I also saw that there is no parsing for NOT_AVAILABLE and VALUE_EMBEDDED_OBJECT, although I don't think, that is an issue.
It would be great to have the fix from above part of the code, unless there is a good reason why we shouldn't parse null values.
The text was updated successfully, but these errors were encountered: