Given the following method, I would like to verify the registerNew/registerRelationship using Apex Mocks on my unit tests, basically to know if the record is going to be created as expected.
public Opportunity createOpportunity(fflib_ISObjectUnitOfWork uow, Contact c, Id userId){
Opportunity opp = new Opportunity(
name = 'First Opp',
StageName = 'First step',
CloseDate = Date.today(),
OwnerId = userId
);
uow.registerNew(opp,Opportunity.ContactId, c);
uow.registerRelationship(opp,Opportunity.Contacto__c, c);
return opp;
}
I am not able to find any documentation where I can understand how to do it, only found some articles registering sObjects without any relation like uow.registerNew(contacts)
and therefore verifying later, for example, using the following piece of code:
((fflib_ISObjectUnitOfWork) mocks.verify(unitOfWorkMock)).registerNew(fflib_Match.sObjectWith(
new Map<SObjectField, Object>{
Contact.FirstName => requestDTO.consumer.consumerName}
));