From 8527d436a5900a3cad4b16a3d19ce9bf1598cad6 Mon Sep 17 00:00:00 2001 From: Piotr PG Gajek Date: Tue, 21 Nov 2023 21:59:44 +0100 Subject: [PATCH] dynamicFiltersGroupOnSoqlInstance Test --- force-app/main/default/classes/SOQL_Test.cls | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/force-app/main/default/classes/SOQL_Test.cls b/force-app/main/default/classes/SOQL_Test.cls index 2ea8f903..41db6aff 100644 --- a/force-app/main/default/classes/SOQL_Test.cls +++ b/force-app/main/default/classes/SOQL_Test.cls @@ -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 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