@@ -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