You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: force-app/main/default/classes/main/standard-soql/SOQL_Test.cls
+82-16Lines changed: 82 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -566,7 +566,7 @@ private class SOQL_Test {
566
566
.toString();
567
567
568
568
// Verify
569
-
Assert.areEqual('SELECT Id, toLabel(Status), Subject FROM Case', soql);
569
+
Assert.areEqual('SELECT Id, toLabel(Status), Subject FROM Case', soql, 'The generated SOQL should match the expected one.');
570
570
}
571
571
572
572
@IsTest
@@ -764,6 +764,19 @@ private class SOQL_Test {
764
764
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts) FROM Account', soql, 'The generated SOQL should match the expected one.');
765
765
}
766
766
767
+
@IsTest
768
+
staticvoidsubQueryStringFields() {
769
+
// Test
770
+
Stringsoql=SOQL.of(Account.SObjectType)
771
+
.with(Account.Name)
772
+
.with(SOQL.SubQuery.of('Contacts')
773
+
.with('Id, Name')
774
+
).toString();
775
+
776
+
// Verify
777
+
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts) FROM Account', soql, 'The generated SOQL should match the expected one.');
778
+
}
779
+
767
780
@IsTest
768
781
staticvoidsubQueryRelatedFields() {
769
782
// Test
@@ -826,7 +839,7 @@ private class SOQL_Test {
826
839
}
827
840
828
841
@IsTest
829
-
staticvoidsubQueryOrderBy() {
842
+
staticvoidsubQueryOrderBySObjectField() {
830
843
// Test
831
844
Stringsoql=SOQL.of(Account.SObjectType)
832
845
.with(Account.Name)
@@ -841,6 +854,22 @@ private class SOQL_Test {
841
854
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts ORDER BY Name DESC NULLS LAST) FROM Account', soql, 'The generated SOQL should match the expected one.');
842
855
}
843
856
857
+
@IsTest
858
+
staticvoidsubQueryOrderByStringField() {
859
+
// Test
860
+
Stringsoql=SOQL.of(Account.SObjectType)
861
+
.with(Account.Name)
862
+
.with(SOQL.SubQuery.of('Contacts')
863
+
.with(Contact.Id, Contact.Name)
864
+
.orderBy('Name')
865
+
.sortDesc()
866
+
.nullsLast()
867
+
).toString();
868
+
869
+
// Verify
870
+
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts ORDER BY Name DESC NULLS LAST) FROM Account', soql, 'The generated SOQL should match the expected one.');
871
+
}
872
+
844
873
@IsTest
845
874
staticvoidsubQueryOrderByDynamic() {
846
875
// Test
@@ -853,7 +882,7 @@ private class SOQL_Test {
853
882
).toString();
854
883
855
884
// Verify
856
-
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts ORDER BY Name ASC NULLS LAST) FROM Account', soql);
885
+
Assert.areEqual('SELECT Name , (SELECT Id, Name FROM Contacts ORDER BY Name ASC NULLS LAST) FROM Account', soql, 'The generated SOQL should match the expected one.');
Assert.areEqual('SELECT Id FROM Account WHERE (Name = :v1 AND BillingCity = :v2)', soql);
1614
+
Assert.areEqual('SELECT Id FROM Account WHERE (Name = :v1 AND BillingCity = :v2)', soql, 'The generated SOQL should match the expected one.');
1586
1615
1587
1616
Map<String, Object> binding=builder.binding();
1588
-
Assert.areEqual('Test', binding.get('v1'));
1589
-
Assert.areEqual('Krakow', binding.get('v2'));
1617
+
Assert.areEqual('Test', binding.get('v1'), 'The binding variable should match the expected value.');
1618
+
Assert.areEqual('Krakow', binding.get('v2'), 'The binding variable should match the expected value.');
1590
1619
}
1591
1620
1592
1621
@IsTest
@@ -1598,31 +1627,68 @@ private class SOQL_Test {
1598
1627
filterGroup.add('BillingCity = \'Krakow\'');
1599
1628
1600
1629
// Test
1601
-
SOQLbuilder=SOQL.of(Account.SObjectType)
1602
-
.whereAre(filterGroup);
1630
+
Stringsoql=SOQL.of(Account.SObjectType)
1631
+
.whereAre(filterGroup)
1632
+
.toString();
1603
1633
1604
1634
// Verify
1605
-
Stringsoql=builder.toString();
1606
-
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' AND BillingCity = \'Krakow\')', soql);
1635
+
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' AND BillingCity = \'Krakow\')', soql, 'The generated SOQL should match the expected one.');
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' OR BillingCity = \'Krakow\')', soql, 'The generated SOQL should match the expected one.');
1607
1654
}
1608
1655
1609
1656
@IsTest
1610
1657
staticvoiddynamicStringFiltersListGroup() {
1658
+
// Test
1659
+
Stringsoql=SOQL.of(Account.SObjectType)
1660
+
.whereAre(SOQL.FilterGroup
1661
+
.add(newList<String> {
1662
+
'Name = \'Test\'',
1663
+
'BillingCity = \'Krakow\''
1664
+
})
1665
+
).toString();
1666
+
1667
+
// Verify
1668
+
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' AND BillingCity = \'Krakow\')', soql, 'The generated SOQL should match the expected one.');
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' AND BillingCity = \'Krakow\')', soql);
1691
+
Assert.areEqual('SELECT Id FROM Account WHERE (Name = \'Test\' OR BillingCity = \'Krakow\')', soql, 'The generated SOQL should match the expected one.');
0 commit comments