Merge branch 'main' into main
This commit is contained in:
@@ -108,8 +108,6 @@ private class fflib_SObjects2Test
|
||||
domain.getIdFieldsByIdField(Account.Id, Account.Id);
|
||||
domain.getIdFieldValues(Account.Id);
|
||||
domain.getIdFieldValues(Account.Id, criteria);
|
||||
domain.getIntegerFieldValues(Account.NumberOfEmployees);
|
||||
domain.getIntegerFieldValues(Account.NumberOfEmployees, criteria);
|
||||
domain.getDecimalFieldValues(Account.BillingLatitude, criteria);
|
||||
domain.getDoubleFieldValues(Account.BillingLatitude);
|
||||
domain.getDoubleFieldValues(Account.BillingLatitude, criteria);
|
||||
@@ -117,7 +115,6 @@ private class fflib_SObjects2Test
|
||||
domain.getSObjectsByIdField(Account.Id);
|
||||
domain.getSObjectByStringField(Account.Name);
|
||||
domain.getSObjectsByStringField(Account.Name);
|
||||
domain.getStringFieldByIdField(Account.Id, Account.Name);
|
||||
domain.getStringFieldByStringField(Account.Name, Account.AccountNumber);
|
||||
domain.getStringFieldValues(Account.Name, criteria);
|
||||
|
||||
@@ -137,6 +134,89 @@ private class fflib_SObjects2Test
|
||||
System.assertEquals(accountId, nameById.get(accountId));
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReturnStringFieldByIdField()
|
||||
{
|
||||
final String accountName = 'My Account';
|
||||
final Id accountId = fflib_IDGenerator.generate(Account.SObjectType);
|
||||
DomainAccounts domain = new DomainAccounts(
|
||||
new List<Account>
|
||||
{
|
||||
new Account(Id = accountId, Name = accountName),
|
||||
new Account(Name = accountName + ' 2') // This one should be ignored
|
||||
});
|
||||
|
||||
System.Test.startTest();
|
||||
Map<Id, String> result = domain.getStringFieldByIdField(Account.Name, Account.Id);
|
||||
System.Test.stopTest();
|
||||
|
||||
System.assertEquals(1, result.size(), 'Incorrect returned amount of results');
|
||||
System.assert(result.keySet().contains(accountId), 'The accountId is missing from the results');
|
||||
System.assertEquals(accountName, result.get(accountId), 'Incorrect returned account name');
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReturnIntegerFieldValues()
|
||||
{
|
||||
final Integer numberOfEmployees = 10;
|
||||
final String accountName = 'Test Account';
|
||||
DomainAccounts domain = new DomainAccounts(
|
||||
new List<Account>
|
||||
{
|
||||
new Account(NumberOfEmployees = numberOfEmployees),
|
||||
new Account(Name = accountName, NumberOfEmployees = numberOfEmployees * 2),
|
||||
new Account() // This one should be ignored
|
||||
});
|
||||
|
||||
System.Test.startTest();
|
||||
Set<Integer> result = domain.getIntegerFieldValues(Account.NumberOfEmployees).getIntegerSet();
|
||||
Set<Integer> result2 =
|
||||
domain.getIntegerFieldValues(
|
||||
Account.NumberOfEmployees,
|
||||
new fflib_Criteria().equalTo(Schema.Account.Name, accountName)
|
||||
)
|
||||
.getIntegerSet();
|
||||
System.Test.stopTest();
|
||||
|
||||
System.assertEquals(2, result.size(), 'Incorrect amount of results');
|
||||
System.assert(result.contains(numberOfEmployees), 'The expected numberOfEmployees was not returned');
|
||||
System.assert(result.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||
|
||||
System.assertEquals(1, result2.size(), 'Incorrect amount of results');
|
||||
System.assert(result2.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReturnLongFieldValues()
|
||||
{
|
||||
final Integer numberOfEmployees = 10;
|
||||
final String accountName = 'Test Account';
|
||||
DomainAccounts domain = new DomainAccounts(
|
||||
new List<Account>
|
||||
{
|
||||
new Account(NumberOfEmployees = numberOfEmployees),
|
||||
new Account(Name = accountName, NumberOfEmployees = numberOfEmployees * 2),
|
||||
new Account() // This one should be ignored
|
||||
});
|
||||
|
||||
System.Test.startTest();
|
||||
Set<Long> result = domain.getLongFieldValues(Account.NumberOfEmployees).getLongSet();
|
||||
Set<Long> result2 =
|
||||
domain.getLongFieldValues(
|
||||
Account.NumberOfEmployees,
|
||||
new fflib_Criteria().equalTo(Schema.Account.Name, accountName)
|
||||
)
|
||||
.getLongSet();
|
||||
System.Test.stopTest();
|
||||
|
||||
System.assertEquals(2, result.size(), 'Incorrect amount of results');
|
||||
System.assert(result.contains(numberOfEmployees), 'The expected numberOfEmployees was not returned');
|
||||
System.assert(result.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||
|
||||
System.assertEquals(1, result2.size(), 'Incorrect amount of results');
|
||||
System.assert(result2.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReturnRecordIdById()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user