Skip to content

Commit

Permalink
dynamicFiltersGroupOnSoqlInstance Test
Browse files Browse the repository at this point in the history
  • Loading branch information
pgajek2 committed Nov 21, 2023
1 parent 5c32174 commit 8527d43
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions force-app/main/default/classes/SOQL_Test.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,35 @@ private class SOQL_Test {
Assert.areEqual('Krakow', binding.get('v2'));
}

@IsTest
static void dynamicFiltersGroupOnSoqlInstance() {
// Setup
SOQL.FilterGroup filterGroup = SOQL.FilterGroup;

filterGroup.add(SOQL.Filter.with(Account.Name).equal('Test'));
filterGroup.add(SOQL.Filter.with(Account.BillingCity).equal('Krakow'));

// Test
SOQL builder = SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Industry).equal('IT'));

Assert.areEqual('SELECT Id FROM Account WHERE Industry = :v1', builder.toString());

builder.whereAre(
SOQL.FilterGroup
.add(SOQL.Filter.with(Account.Name).equal('Test'))
.add(SOQL.Filter.with(Account.BillingCity).equal('Krakow'))
);

// Verify
Assert.areEqual('SELECT Id FROM Account WHERE Industry = :v1 AND (Name = :v2 AND BillingCity = :v3)', builder.toString());

Map<String, Object> binding = builder.binding();
Assert.areEqual('IT', binding.get('v1'));
Assert.areEqual('Test', binding.get('v2'));
Assert.areEqual('Krakow', binding.get('v3'));
}

@IsTest
static void anyConditionMatchingForInnerGroup() {
// Test
Expand Down

0 comments on commit 8527d43

Please sign in to comment.