Closed AllanOricil closed 3 years ago
It could follow something like the code below, that enables us to generate Objects by building a JSON, but with an Apex API
SObjectFactory.new(Schema.SObjectName.class).addField(SObjectName.FieldName, VALUE).addChildren().....
addField
adds any field or reference, such as LatestPublishedVersionId
addChildren
adds a factory for the related object
this will enable us to create object building a JSON with an Apex API
No need for this. There is a method called setReadOnlyFields which allows me to do it.
I found a use case that is not coverade by
fflib_ApexMocksUtils.makeRelationship()
I had to create a
ContentDocument
with the fieldLatestPublishedVersionId
filled in, and I couldnt.When I tried the code below, I got this error:
Field is not writeable: ContentDocument.LatestPublishedVersionId
To get over it, I used the same strategy implemented by
fflib_ApexMocksUtils.makeRelationship
but I did not write a cool serializer. I just typed in the json and bound the values I needed on it.The result is the code below :D
I was able to create my ContentDocument with the field LatestPublishedVersionId filled in.