@isTest public class TestBrevoContactTrigger_Handler { @isTest static void testBrevoContactTrigger_Handler() { // Create a new contact Contact con = new Contact(LastName = 'Test', Email = 'test@example.com'); insert con; // Set the mock callout class Test.setMock(HttpCalloutMock.class, new BrevoMockHttpResponseGenerator()); // Start the test, this enables governor limit testing and prevents actual callouts Test.startTest(); // Call your method here BrevoContactTrigger_Handler.createContactInBrevo(con.Email, con.FirstName, con.LastName, con.Phone, con.Id); // Stop the test, this changes limit context back to test from trigger Test.stopTest(); } @isTest static void testUpdateContactInBrevo_ExistingContact() { // Create a new contact Contact con = new Contact(LastName = 'Test', Email = 'test@example.com'); insert con; // Set the mock callout class Test.setMock(HttpCalloutMock.class, new BrevoMockHttpResponseGenerator()); // Start the test Test.startTest(); // Call your method here BrevoContactTrigger_Handler.updateContactInBrevo(con.Email, con.FirstName, con.LastName, con.Phone, con.Id); // Stop the test Test.stopTest(); } @isTest static void testUpdateContactInBrevo_NonExistingContact() { // Create a new contact Contact con = new Contact(LastName = 'Test', Email = 'test2@example.com'); insert con; // Set the mock callout class Test.setMock(HttpCalloutMock.class, new BrevoMockHttpResponseGenerator()); // Start the test Test.startTest(); // Call your method here BrevoContactTrigger_Handler.updateContactInBrevo(con.Email, con.FirstName, con.LastName, con.Phone, con.Id); // Stop the test Test.stopTest(); } @isTest static void testDeleteContactInBrevo() { // Create a new contact Contact con = new Contact(LastName = 'Test', Email = 'test@example.com'); insert con; // Set the mock callout class Test.setMock(HttpCalloutMock.class, new BrevoMockHttpResponseGenerator()); // Start the test Test.startTest(); // Call your method here BrevoContactTrigger_Handler.deleteContactInBrevo(con.Email); // Stop the test Test.stopTest(); } }