System.assertEquals() fails for identical Map<ID,ID> in summer 13
Last updated 2022-02-10 ·Reference W-1757725 ·Reported By 2 users
Summary
The System.assertEquals(Map<ID,ID> , Map<ID,ID> ) fails for identical Map<ID,ID> in summer 13.
Repro
Steps to Replicate:
Create a test class and run test . It will fail with following error-
System.AssertException: Assertion Failed: Expected: {001D000000JVGTrIAP=001D000000JVGTrIAP}, Actual: {001D000000JVGTrIAP=001D000000JVGTrIAP}
Stack Trace Class.Summer13RegressionTests.mapIdComparisionTest: line 26, column 1
Apex class
============
@isTest class Summer13RegressionTests {
@isTest static void mapIdComparisionTest() {
final Map <Id, Id> identicalMapIdA = new Map<Id, Id>{'001D000000JVGTr' => '001D000000JVGTr'};
final Map <Id, Id> identicalMapIdB = new Map<Id, Id>{'001D000000JVGTr' => '001D000000JVGTr'};
final Map<String, String> identicalMapStringA = new Map<String, String>{};
final Map<String, String> identicalMapStringB = new Map<String, String>{};
for (Id keyId : identicalMapIdA.keySet()){
identicalMapStringA.put(keyId, identicalMapIdA.get(keyId));
}
for (Id keyId : identicalMapIdB.keySet()) {
identicalMapStringB.put(keyId, identicalMapIdB.get(keyId));
}
//comparing the keysets also works
System.assertEquals(identicalMapIdA.keyset(), identicalMapIdB.keyset());
//comparing the values also works
System.assertEquals(identicalMapIdA.get('001D000000JVGTr'), identicalMapIdB.get('001D000000JVGTr'));
// Workaround is to put Map<Id, Id> into Map<String, String>
System.assertEquals(identicalMapStringA, identicalMapStringB);
// Comparision of two identical Map<Id, Id> fails in Summer '13 (28.0), was passing in Spring '13 (27.0)
System.assertEquals(identicalMapIdA, identicalMapIdB);
// using system.assert also fails
System.assert(identicalMapIdA==identicalMapIdB);
}
}
Workaround
Convert Map<Id, Id> into Map<String, String>
Reported By (2)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.