You need to sign in to do that
Don't have an account?
Vikas Kumar 135
test data for @HTTP Post
Hi Everyone,
I have created a @HTTP get method which working fine.
@RestResource(urlMapping='/Opportunity/*')
global with sharing class OpportunityResource {
@HttpGet
global static Opportunity doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String opportunity_id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Opportunity result = [SELECT Id, Name, OwnerId, CurrencyIsoCode, IO_Status__c, Agency_Buyer__c, Campaign_Summary__c, Campaign_Goals__c, KPI_s_and_success_metrics__c, Ad_Ops_Lead__c, User__c, Campaign_Performance_Analyst__c, Account_Manager__c, Discount_Off_Rate_Card__c, Viewability_Tags__c, Additional_Tags__c, Opportunity_ID__c, Quote_Flight_Start_Date__c, Quote_Flight_End_Date__c, Quote_Total_Impressions__c FROM Opportunity WHERE Id = :opportunity_id];
return result;
}
}
I wrote a test class but I need help with inserting test data to the test class. Can anyone help me with writing the test class with test data?
Appreciate your help.
I have created a @HTTP get method which working fine.
@RestResource(urlMapping='/Opportunity/*')
global with sharing class OpportunityResource {
@HttpGet
global static Opportunity doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String opportunity_id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Opportunity result = [SELECT Id, Name, OwnerId, CurrencyIsoCode, IO_Status__c, Agency_Buyer__c, Campaign_Summary__c, Campaign_Goals__c, KPI_s_and_success_metrics__c, Ad_Ops_Lead__c, User__c, Campaign_Performance_Analyst__c, Account_Manager__c, Discount_Off_Rate_Card__c, Viewability_Tags__c, Additional_Tags__c, Opportunity_ID__c, Quote_Flight_Start_Date__c, Quote_Flight_End_Date__c, Quote_Total_Impressions__c FROM Opportunity WHERE Id = :opportunity_id];
return result;
}
}
I wrote a test class but I need help with inserting test data to the test class. Can anyone help me with writing the test class with test data?
Appreciate your help.
All Answers