Skip to content
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

Simplification of setting mocks for Selectors and Domains #453

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions sfdx-source/apex-common/main/classes/fflib_Application.cls
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,15 @@ public virtual class fflib_Application
@TestVisible
protected virtual void setMock(fflib_ISObjectSelector selectorInstance)
{
m_sObjectByMockSelector.put(selectorInstance.sObjectType(), selectorInstance);
}
System.debug(System.LoggingLevel.INFO, '*** fflib - Please note your mocked class should have sObjectType() stubbed, or use setMock( SObjectType, SelectorMock )');
setMock(selectorInstance.sObjectType(), selectorInstance);
}

@TestVisible
protected virtual void setMock(SObjectType sType, fflib_ISObjectSelector selectorInstance)
{
m_sObjectByMockSelector.put(sType, selectorInstance);
}
}

/**
Expand Down Expand Up @@ -415,7 +422,14 @@ public virtual class fflib_Application
@TestVisible
protected virtual void setMock(fflib_ISObjectDomain mockDomain)
{
mockDomainByObject.put((Object) mockDomain.sObjectType(), (fflib_IDomain) mockDomain);
System.debug(System.LoggingLevel.INFO, '*** fflib - Please note your mocked class should have sObjectType() stubbed, or use setMock( SObjectType, SelectorMock )');
setMock(mockDomain.sObjectType(), mockDomain);
}

@TestVisible
protected virtual void setMock(SObjectType sType, fflib_ISObjectDomain mockDomain)
{
mockDomainByObject.put((Object)sType, (fflib_IDomain)mockDomain);
}

@TestVisible
Expand Down