You need to sign in to do that
Don't have an account?
Apex Code coverage fpr this Class
I am struggleing understanding how to write test units for this class.
//@RestResource(urlMapping='/Google/*') is used to tell the class that it is a REST resource used for POST GET etc @RestResource(urlMapping='/Google/*') global with sharing class GoogleWebHookListener { //HttpPost tells the method that it will be a POST method @HttpPost global static void handlePost() { //set up varibles for the Lead String name; String phone; String email; String postCode; String firstName; String lastName; //try to do the JSON deserialization and Lead Creation //******EXAMPLE JSON AT BOTTOM***** try { // This gets the body of the webhook makes the body a string and sets the string to the variable 'jsonString' String jsonString = RestContext.request.requestBody.toString(); //This deserializes the JSON based on the the properties setup in the Class GoogleJsonLeadExample GoogleJsonLeadExample g = (GoogleJsonLeadExample)JSON.deserialize(jsonString, GoogleJsonLeadExample.class); //This tests the JSON to see if it is legit. if(g.google_key == ''){ //This loops through the JSON array set up in the Class GoogleJsonLeadExample for(GoogleJsonLeadExample.userData d : g.user_column_data) { if(d.column_name == 'Full Name') { //The JSON has Full Name, this breaks Full Name into First and Last Names name = d.string_value; List<String> names = name.split(' '); firstName = names[0]; lastName = names[1]; } if(d.column_name == 'User Phone') { phone = d.string_value; } if(d.column_name == 'User Email') { email = d.string_value; } if(d.column_name == 'Postal Code') { postCode = d.string_value; } } //This creates the Lead Lead detail = new Lead(); detail.LastName = lastName; detail.FirstName = firstName; detail.Phone = phone; detail.Company = name; detail.Email = email; detail.OwnerId = '0051Q00000GrANL'; // This Id is the user Hubspot. insert detail; } } catch (DMLException e) { System.debug('The following exception has occurred: ' + e.getMessage()); } } }
Please try the below test class:
Thanks,
Maharajan.C
All Answers
Can you please post the GoogleJsonLeadExample Class and Sample JSON here to help you.
Thanks,
Maharajan.C
Please try the below test class:
Thanks,
Maharajan.C
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
BUY COVID19 VACCINATION RECORD CARD
BUY COVID19 VACCINATION RECORD CARD
BUY COVID19 VACCINATION RECORD CARD
BUY CDC COVID-19 CACCINATION RECORD CARD
covid19 vaccination card
BUY D.M.V DRIVER'S LICENSE ONLINE, WE PRODUCE REAL REGISTERED DMV DRIVERS LICENCE,
YOU DON'T NEED ANY EXAMS OR TEST OKAY, MY BOSS WORKS IN THE DMV OFFICE AND HAS THE POWERS TO PRODUCE YOU A REAL REGISTERED DRIVERS LICENCE WITHIN 3 DAYS.
BUY USA EAL REGISTERED DIVERS LICENCE
BUY UK REAL REGISTERED DRIVERS LICENCE
BUY AUSTRALIAN REAL REGISTERED DRIVERS LICENCE
BUY GERMAN REAL REGISTERED DRIVERS LICENCE AND MANY OTHER COUNTRIES
BUY COVID-19 VACCINATION RECORD CARD AT
BUY COVID19 VACCINATION RECORD CARD
BUY COVID19 VACCINATION RECORD CARD
BUY COVID19 VACCINATION RECORD CARD
BUY COVID19 VACCINATION RECORD CARD
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
Buy covid-19 vaccine record card online without taking the vaccine
Buy covid-19 vaccine record card nline, for now, the best way to show that you have been inoculated against the corona virus is a simple white card
Buy covid-19 vaccination card online
Covid-19 vaccine record card for sale in USA
paper COVID-19 vaccination ID is a verified , physical eveidence of your individual vaccination ststus, complete with sophisticated anti counterfeit technology to ensure authenticity and peace of mind
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
We produce verified registered cdc covid19 vaccination cards that can enable you travel or present at your job side on request, Buy regietered covid19 vaccine card at affordable prices without getting vaccinated
GET REGISTERED JAB CARD AT AFFORDABLE PRICES, WE PRODUCE AND GIVE OUT REGISTERED COVID CARDS
BUY JAB CARDS
BUY CDC COVID-19 VACCINATION CARD
GET JAB CARD
OBTAIN JAB CARD
contact
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
Email: realdocs78@gmail.com
GET REGISTERED JAB CARD AT AFFORDABLE PRICES, WE PRODUCE AND GIVE OUT REGISTERED COVID CARDS
BUY JAB CARDS
BUY CDC COVID-19 VACCINATION CARD
GET JAB CARD
OBTAIN JAB CARD
WhatsApp: +1 (951) 480-4136
We produce a verified registered cdc covid-19 vaccination cards that can enable you travel or present at your job side
buy registered covid19 vaccination cards at affordable prices
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
email....realdocs78@gmail.com
email....realdocs78@gmail.com
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
We produce verified registered cdc covid19 vaccination cards that can enable you travel or present at your job side on request, Buy regietered covid19 vaccine card at affordable prices without getting vaccinated
email....realdocs78@gmail.com
email....realdocs78@gmail.com
Buy covid-19 vaccine record card online without taking the vaccine
Buy covid-19 vaccine record card nline, for now, the best way to show that you have been inoculated against the corona virus is a simple white card
Buy covid-19 vaccination card online
Covid-19 vaccine record card for sale in USA
paper COVID-19 vaccination ID is a verified , physical eveidence of your individual vaccination ststus, complete with sophisticated anti counterfeit technology to ensure authenticity and peace of mind
WhatsApp: +1 (951) 480-4136
WhatsApp: +1 (951) 480-4136
Email: realdocs78@gmail.com