-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fixes, cleanup dead code, static save option and flexible unitOfWork injection #14
base: master
Are you sure you want to change the base?
Conversation
@@ -9,7 +9,7 @@ | |||
"default": true | |||
}, | |||
{ | |||
"path": "sfdx-source/apex-domainbuilder-samplecode", | |||
"path": "sfdx-source/apex-domainbuilder-sample", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ref was wrong
@@ -1,3 +1,4 @@ | |||
@IsTest | |||
public class Random { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class did not have almost coverage and is only used within @istest classes, hence adding it too
@@ -3,7 +3,7 @@ public class Account_t extends DomainBuilder { | |||
|
|||
public Account_t() { | |||
super(Account.SObjectType); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invisible whitespace removal
@@ -1,10 +1,30 @@ | |||
@IsTest | |||
public class DomainBuilder_Test { | |||
@IsTest | |||
private static void staticHappyPath() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test method to demostrate the possibility of calling the save() static method, similar to persist() but without requiring an instance, since it only actually operates on static variables it is logically meaningful.
|
||
@IsTest | ||
private static void happyPath() { | ||
|
||
Contact_t joe = new Contact_t().first('Ron').last('Harris'); | ||
Contact_t joe = new Contact_t().first('Joe').last('Harris'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable name is joe, so firstName should not be "Ron"
System.assertEquals(6, Limits.getDmlRows()); | ||
|
||
// Verify | ||
System.assertEquals(5, Limits.getDmlRows()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion was throwing an error because only 5 DML rows are consumed, not 6. SetSavePoint counts against DML Statements, but not against DML Rows. Added extra assert with comments for demostration
@@ -3,36 +3,31 @@ public abstract class DomainBuilder { | |||
private static DirectedGraph graph = new DirectedGraph(); | |||
private static Set<DomainBuilder> objects = new Set<DomainBuilder>(); | |||
|
|||
private Boolean isSetupObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused related dead code
// PUBLIC | ||
|
||
public SObject persist() { | ||
fflib_SObjectUnitOfWork uow = unitOfWork(); | ||
public static void save() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide possible static save() call
} | ||
|
||
public SObject persist(fflib_SObjectUnitOfWork.IDML dml) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow injection of custom implementation of UnitOfWork interface
No description provided.