Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]", "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": "[email protected]", "phone": "15183425678", "birthDate": "1990-01-01", "address": {"address": "123 Test St", "city": "Schenectady", "postalCode": "12345", "state": "New York", "country": "United States"}}';

Check failure

Code scanning / PMD

Configurable naming conventions for field declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind ---e.g. constants (static final), static field, final field. Each regex can be configured through properties. By default this rule uses the standard Apex naming convention (Camel case). Error

The static field name 'DUMMY_JSON_USER_PAYLOAD' doesn't match '[a-z][a-zA-Z0-9]*'

public HTTPResponse respond(HTTPRequest req) {
// Create a fake response
Expand Down
24 changes: 12 additions & 12 deletions force-app/main/default/classes/DummyJSONCalloutTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]', 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,
Expand All @@ -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
);
Expand All @@ -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
);
Expand All @@ -63,7 +63,7 @@ public with sharing class DummyJSONCalloutTest {
FirstName = 'John',
LastName = 'Doe',
Email = '[email protected]',
Phone = '+123456789'
Phone = '15182349999'
);
insert testContact;

Expand Down Expand Up @@ -93,7 +93,7 @@ public with sharing class DummyJSONCalloutTest {
FirstName = 'John',
LastName = 'Doe',
Email = '[email protected]',
Phone = '1234567890',
Phone = '15182349999',
DummyJSON_Id__c = '101'
);
insert testContact;
Expand All @@ -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('[email protected]', 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
Expand All @@ -122,13 +122,13 @@ public with sharing class DummyJSONCalloutTest {

// Assertions to check if the Contact object was populated correctly
System.assertEquals('[email protected]', 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
Expand Down Expand Up @@ -181,7 +181,7 @@ public with sharing class DummyJSONCalloutTest {
FirstName = 'Test',
LastName = 'User',
Email = '[email protected]',
Phone = '+123456789',
Phone = '+15182341234',
DummyJSON_Id__c = '105'
);
insert cont;
Expand Down
Loading