You need to sign in to do that
Don't have an account?
Vishal K S
Need test class help for below class
Hi ,
Can anyone help test class for below.
@RestResource(urlMapping='/dcleads')
global without sharing class DC_RestResourceCls {
@HttpPost
global static PostResponseWrapper doPost() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
PostResponseWrapper response = new PostResponseWrapper();
intreq__c integrationObj = New intreq__c();
try {
LeadWrapper LeadWrapperObj = (LeadWrapper)JSON.deserialize(req.requestBody.toString(), LeadWrapper.class);
integrationObj.Request_Body__c = req.requestBody.toString();
List<lead> ld = [SELECT id,APIMOBILE__c,Call_Stage__c,Status,DC_Lead_Status__c,CreatedDate,convertedAccountId,convertedOpportunityId,
Follow_Up_Date_Time__c,FirstName,LastName,Meeting_Type__c,Meeting_Venue__c,Email,Country_Code__c,Home_Type__c,
Property_Possession_Status__c,Preferred_Time_to_Contact__c,Voucher_Code__c,Page_URL__c,Project_Name__c,OwnerId,
City,GClid__c,Area__c,Device_Name__c,Campagin__c,Ad_Group__c,Keyword__c,Match_Type__c,First_Visit_Time__c
from Lead WHERE APIMOBILE__c =:LeadWrapperObj.Mobile Limit 1];
IF(ld.size() != 0){
if((ld[0].Status == 'Followup' && LeadWrapperobj.dsaid!=Null && (ld[0].Follow_Up_Date_Time__c < system.today().addDays(-29) || ld[0].LastModifiedDate < system.today().addDays(-29)))||
(ld[0].Call_Stage__c == 'Undialed' && LeadWrapperobj.dsaid!=Null && ld[0].LastModifiedDate < system.today().addDays(-29))||
(ld[0].Status == 'Junk' && LeadWrapperobj.dsaid!=Null)||
(ld[0].DC_Lead_Status__c =='Qualified' && LeadWrapperobj.dsaid!=Null && (ld[0].Follow_Up_Date_Time__c < system.today().addDays(-29) || ld[0].LastModifiedDate < system.today().addDays(-29)))
)
{
//---------------- Attribution DSA(1) ------------------------------//
//---------------- Logic 1 ------------------------------//
}
else if(LeadWrapperobj.dsaid!=Null){
Lead LeadObj = new Lead();
LeadObj.id = ld[0].id;
LeadObj.DC_Lead_Status__c = 'Recontacted';
LeadObj.Re_Contact_Date__c = System.now();
update LeadObj;
response.message = 'Updated Successfully -1[Record Already Exists]';
response.status = 'Success';
response.recordId = LeadObj.id;
}
}}}}
Can anyone help test class for below.
@RestResource(urlMapping='/dcleads')
global without sharing class DC_RestResourceCls {
@HttpPost
global static PostResponseWrapper doPost() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
PostResponseWrapper response = new PostResponseWrapper();
intreq__c integrationObj = New intreq__c();
try {
LeadWrapper LeadWrapperObj = (LeadWrapper)JSON.deserialize(req.requestBody.toString(), LeadWrapper.class);
integrationObj.Request_Body__c = req.requestBody.toString();
List<lead> ld = [SELECT id,APIMOBILE__c,Call_Stage__c,Status,DC_Lead_Status__c,CreatedDate,convertedAccountId,convertedOpportunityId,
Follow_Up_Date_Time__c,FirstName,LastName,Meeting_Type__c,Meeting_Venue__c,Email,Country_Code__c,Home_Type__c,
Property_Possession_Status__c,Preferred_Time_to_Contact__c,Voucher_Code__c,Page_URL__c,Project_Name__c,OwnerId,
City,GClid__c,Area__c,Device_Name__c,Campagin__c,Ad_Group__c,Keyword__c,Match_Type__c,First_Visit_Time__c
from Lead WHERE APIMOBILE__c =:LeadWrapperObj.Mobile Limit 1];
IF(ld.size() != 0){
if((ld[0].Status == 'Followup' && LeadWrapperobj.dsaid!=Null && (ld[0].Follow_Up_Date_Time__c < system.today().addDays(-29) || ld[0].LastModifiedDate < system.today().addDays(-29)))||
(ld[0].Call_Stage__c == 'Undialed' && LeadWrapperobj.dsaid!=Null && ld[0].LastModifiedDate < system.today().addDays(-29))||
(ld[0].Status == 'Junk' && LeadWrapperobj.dsaid!=Null)||
(ld[0].DC_Lead_Status__c =='Qualified' && LeadWrapperobj.dsaid!=Null && (ld[0].Follow_Up_Date_Time__c < system.today().addDays(-29) || ld[0].LastModifiedDate < system.today().addDays(-29)))
)
{
//---------------- Attribution DSA(1) ------------------------------//
//---------------- Logic 1 ------------------------------//
}
else if(LeadWrapperobj.dsaid!=Null){
Lead LeadObj = new Lead();
LeadObj.id = ld[0].id;
LeadObj.DC_Lead_Status__c = 'Recontacted';
LeadObj.Re_Contact_Date__c = System.now();
update LeadObj;
response.message = 'Updated Successfully -1[Record Already Exists]';
response.status = 'Success';
response.recordId = LeadObj.id;
}
}}}}
Try Below Test Class Please Mark It As Best Answer if it Helps
Thank You!