Skip to content

Commit

Permalink
Make sure method return non-null values
Browse files Browse the repository at this point in the history
  • Loading branch information
wimvelzeboer committed May 27, 2022
1 parent a64b4a2 commit 5dbfb3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 12 additions & 2 deletions sfdx-source/apex-common/main/classes/fflib_SObjects.cls
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,16 @@ public virtual class fflib_SObjects
* @return Return a set with all the Id values of the given field
*/
@TestVisible
protected Set<Id> getIdFieldValues(Schema.SObjectField field)
protected virtual Set<Id> getIdFieldValues(Schema.SObjectField field)
{
Set<Id> result = new Set<Id>();
for (SObject record : getRecords())
{
if (record.get(field) == null)
{
continue;
}

result.add((Id) record.get(field));
}
return result;
Expand All @@ -177,11 +182,16 @@ public virtual class fflib_SObjects
* @return Return a set with all the String values of the given field
*/
@TestVisible
protected Set<String> getStringFieldValues(Schema.SObjectField field)
protected virtual Set<String> getStringFieldValues(Schema.SObjectField field)
{
Set<String> result = new Set<String>();
for (SObject record : getRecords())
{
if (String.isBlank((String) record.get(field)))
{
continue;
}

result.add((String) record.get(field));
}
return result;
Expand Down
2 changes: 0 additions & 2 deletions sfdx-source/apex-common/test/classes/fflib_SObjectsTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ private class fflib_SObjectsTest

final Set<String> expected = new Set<String>
{
null,
'',
'Canada',
'Ireland',
'UK',
Expand Down

0 comments on commit 5dbfb3a

Please sign in to comment.