From fe47a5b45a94689b3c857178517eb6b503041d98 Mon Sep 17 00:00:00 2001 From: "Adrienne D. Millican" Date: Mon, 16 Jun 2025 17:05:12 -0600 Subject: [PATCH] Updated the test and mocking classes to use realistic phone numbers, mailing cities, mailing states, and mailing countries so as not to cause issues within orgs that have State and Country picklists enabled and any orgs where there may be checks on realistic phone numbers and cities. --- .../classes/DummyJSONCalloutMockGenerator.cls | 2 +- .../default/classes/DummyJSONCalloutTest.cls | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/force-app/main/default/classes/DummyJSONCalloutMockGenerator.cls b/force-app/main/default/classes/DummyJSONCalloutMockGenerator.cls index d12523b..62debbb 100644 --- a/force-app/main/default/classes/DummyJSONCalloutMockGenerator.cls +++ b/force-app/main/default/classes/DummyJSONCalloutMockGenerator.cls @@ -16,7 +16,7 @@ * https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_httpcalloutmock.htm */ public with sharing class DummyJSONCalloutMockGenerator implements HttpCalloutMock { - public static String DUMMY_JSON_USER_PAYLOAD = '{"id": 1, "firstName":"Johnny", "lastName":"Test", "email": "test@example.com", "phone": "+123456789", "birthDate": "1990-01-01", "address": {"address": "123 Test St", "city": "Test City", "postalCode": "12345", "state": "TS", "country": "Testland"}}'; + public static String DUMMY_JSON_USER_PAYLOAD = '{"id": 1, "firstName":"Johnny", "lastName":"Test", "email": "test@example.com", "phone": "15183425678", "birthDate": "1990-01-01", "address": {"address": "123 Test St", "city": "Schenectady", "postalCode": "12345", "state": "New York", "country": "United States"}}'; public HTTPResponse respond(HTTPRequest req) { // Create a fake response diff --git a/force-app/main/default/classes/DummyJSONCalloutTest.cls b/force-app/main/default/classes/DummyJSONCalloutTest.cls index 08e3fcc..a4b68dc 100644 --- a/force-app/main/default/classes/DummyJSONCalloutTest.cls +++ b/force-app/main/default/classes/DummyJSONCalloutTest.cls @@ -27,7 +27,7 @@ public with sharing class DummyJSONCalloutTest { // Assert statements to ensure that the values in the created contact match what was in our mock response. System.assertEquals('test@example.com', cont.Email, 'Email does not match your value: ' + cont.Email); - System.assertEquals('+123456789', cont.Phone, 'Phone does not match your value: ' + cont.Phone); + System.assertEquals('15183425678', cont.Phone, 'Phone does not match your value: ' + cont.Phone); System.assertEquals( Date.valueOf('1990-01-01'), cont.Birthdate, @@ -39,7 +39,7 @@ public with sharing class DummyJSONCalloutTest { 'MailingStreet does not match your value: ' + cont.MailingStreet ); System.assertEquals( - 'Test City', + 'Schenectady', cont.MailingCity, 'MailingCity does not match your value: ' + cont.MailingCity ); @@ -48,9 +48,9 @@ public with sharing class DummyJSONCalloutTest { cont.MailingPostalCode, 'MailingPostalCode does not match your value: ' + cont.MailingPostalCode ); - System.assertEquals('TS', cont.MailingState, 'MailingState does not match your value: ' + cont.MailingState); + System.assertEquals('New York', cont.MailingState, 'MailingState does not match your value: ' + cont.MailingState); System.assertEquals( - 'Testland', + 'United States', cont.MailingCountry, 'MailingCountry does not match your value: ' + cont.MailingCountry ); @@ -63,7 +63,7 @@ public with sharing class DummyJSONCalloutTest { FirstName = 'John', LastName = 'Doe', Email = 'john.doe@example.com', - Phone = '+123456789' + Phone = '15182349999' ); insert testContact; @@ -93,7 +93,7 @@ public with sharing class DummyJSONCalloutTest { FirstName = 'John', LastName = 'Doe', Email = 'john.doe@example.com', - Phone = '1234567890', + Phone = '15182349999', DummyJSON_Id__c = '101' ); insert testContact; @@ -109,7 +109,7 @@ public with sharing class DummyJSONCalloutTest { System.assertEquals('John', payloadMap.get('firstName'), 'FirstName does not match.'); System.assertEquals('Doe', payloadMap.get('lastName'), 'LastName does not match.'); System.assertEquals('john.doe@example.com', payloadMap.get('email'), 'Email does not match.'); - System.assertEquals('1234567890', payloadMap.get('phone'), 'Phone does not match.'); + System.assertEquals('15182349999', payloadMap.get('phone'), 'Phone does not match.'); } @isTest @@ -122,13 +122,13 @@ public with sharing class DummyJSONCalloutTest { // Assertions to check if the Contact object was populated correctly System.assertEquals('test@example.com', cont.Email, 'Email does not match.'); - System.assertEquals('+123456789', cont.Phone, 'Phone does not match.'); + System.assertEquals('15183425678', cont.Phone, 'Phone does not match.'); System.assertEquals(Date.valueOf('1990-01-01'), cont.Birthdate, 'Birthdate does not match.'); System.assertEquals('123 Test St', cont.MailingStreet, 'MailingStreet does not match.'); - System.assertEquals('Test City', cont.MailingCity, 'MailingCity does not match.'); + System.assertEquals('Schenectady', cont.MailingCity, 'MailingCity does not match.'); System.assertEquals('12345', cont.MailingPostalCode, 'MailingPostalCode does not match.'); - System.assertEquals('TS', cont.MailingState, 'MailingState does not match.'); - System.assertEquals('Testland', cont.MailingCountry, 'MailingCountry does not match.'); + System.assertEquals('New York', cont.MailingState, 'MailingState does not match.'); + System.assertEquals('United States', cont.MailingCountry, 'MailingCountry does not match.'); } @IsTest @@ -181,7 +181,7 @@ public with sharing class DummyJSONCalloutTest { FirstName = 'Test', LastName = 'User', Email = 'test@example.com', - Phone = '+123456789', + Phone = '+15182341234', DummyJSON_Id__c = '105' ); insert cont;