Skip to content

Commit f0d5c9f

Browse files
Merge pull request apex-enterprise-patterns#290 from wimvelzeboer/feature/UnitTestCoverageUnitOfWork
UnitOfWork test coverage
2 parents f191811 + 7c6889f commit f0d5c9f

File tree

2 files changed

+197
-175
lines changed

2 files changed

+197
-175
lines changed

sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,7 @@ public virtual class fflib_SObjectUnitOfWork
401401
**/
402402
public void registerDirty(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord)
403403
{
404-
if (record.Id == null)
405-
throw new UnitOfWorkException('New records cannot be registered as dirty');
406-
String sObjectType = record.getSObjectType().getDescribe().getName();
407-
408-
assertForNonEventSObjectType(sObjectType);
409-
assertForSupportedSObjectType(m_dirtyMapByType, sObjectType);
410-
411-
m_dirtyMapByType.get(sObjectType).put(record.Id, record);
404+
registerDirty(record);
412405
if (relatedToParentRecord!=null && relatedToParentField!=null)
413406
registerRelationship(record, relatedToParentField, relatedToParentRecord);
414407
}
@@ -735,6 +728,7 @@ public virtual class fflib_SObjectUnitOfWork
735728
}
736729
}
737730

731+
@TestVisible
738732
private void assertForNonEventSObjectType(String sObjectType)
739733
{
740734
if (sObjectType.length() > 3 && sObjectType.right(3) == '__e')
@@ -749,6 +743,7 @@ public virtual class fflib_SObjectUnitOfWork
749743
}
750744
}
751745

746+
@TestVisible
752747
private void assertForEventSObjectType(String sObjectType)
753748
{
754749
if (sObjectType.length() > 3 && sObjectType.right(3) != '__e')
@@ -762,6 +757,7 @@ public virtual class fflib_SObjectUnitOfWork
762757
}
763758
}
764759

760+
@TestVisible
765761
private void assertForSupportedSObjectType(Map<String, Object> theMap, String sObjectType)
766762
{
767763
if (!theMap.containsKey(sObjectType))

0 commit comments

Comments
 (0)