You need to sign in to do that
Don't have an account?
bharath kuppala
can we provide test class these code
@RestResource(urlMapping='/ContactCRDID/*')
global with sharing class Ebuy_API
{
@HttpGet
global static List<Opportunity> doGet()
{
RestRequest request = RestContext.request;
Integer ConCRD= Integer.valueof(request.requestURI.substring(request.requestURI.lastIndexOf('/')+1));
List<Opportunity> result = [Select StageName, PrimaryBPCRDID__c, Opportunnity_Source__c, OpportunityNumber__c, Name,
LastModifiedDate, Id, CreatedDate, Amount, Account.Name, CloseDate From Opportunity
where PrimaryBPCRDID__c =: ConCRD AND (((NOT StageName LIKE '9-Closed%') AND
(NOT StageName LIKE '8-Closed%')) OR (StageName LIKE '8-Closed%' AND
CloseDate > LAST_N_MONTHS:1 )) ];
return result;
}
}
global with sharing class Ebuy_API
{
@HttpGet
global static List<Opportunity> doGet()
{
RestRequest request = RestContext.request;
Integer ConCRD= Integer.valueof(request.requestURI.substring(request.requestURI.lastIndexOf('/')+1));
List<Opportunity> result = [Select StageName, PrimaryBPCRDID__c, Opportunnity_Source__c, OpportunityNumber__c, Name,
LastModifiedDate, Id, CreatedDate, Amount, Account.Name, CloseDate From Opportunity
where PrimaryBPCRDID__c =: ConCRD AND (((NOT StageName LIKE '9-Closed%') AND
(NOT StageName LIKE '8-Closed%')) OR (StageName LIKE '8-Closed%' AND
CloseDate > LAST_N_MONTHS:1 )) ];
return result;
}
}
Please check once below sample code and add all-fields in the account and opportunity records.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
All Answers
Please check once below sample code and add all-fields in the account and opportunity records.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
can plz provide
private class Ebuy_APITest {
@isTest
private static void Ebuy_APITest() {
Test.startTest();
Account acc = new Account();
acc.Name = 'Japara Healthcare';
acc.Street1__c = '1 main street';
acc.ZipCode__c = '75001';
acc.Country__c = 'france';
acc.City__c = 'paris';
acc.Verticals__c ='unknown';
acc.AccountClassification__c = 'unknown';
acc.Type = 'prospect';
acc.CurrencyIsoCode = 'USD';
insert acc;
Opportunity opt = new Opportunity();
opt.Name ='Test2';
opt.CurrencyIsoCode = 'USD';
opt.Account.Name = acc.Name;
opt.CloseDate = '15/2/2018'; // its a mandatory field i am getting the error :: Illegal assignment from String to Date//
opt.StageName = '3-Solution Positionning';
opt.ALUProbability__c ='0';
insert opt ;
RestRequest req = new RestRequest();
RestResponse res = new RestResponse();
req.requestURI = '/services/apexrest/ContactCRDID';
req.params.put('ConCRD', '1346');
req.httpMethod = 'GET';
req.addHeader('Content-Type', 'application/json');
RestContext.request = req;
RestContext.response = res;
List<Opportunity> opps = Ebuy_API.doGet();
Test.stopTest();
}