Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apex :-
- @RestResource(urlMapping='/IntershopRelatedAccounts/*')
- global class IntershopInboundRestTofetchContacts {
- @HttpGet
- global static void fetchRelatedAccountswithContacts(){
- Id potentialrecordtype =e().get('Existing SAP Account').getRecordTypeId(); Schema.SObjectType.Account.getRecordTypeInfosByName().get('Potential Account').getRecordTypeId();
- Id existingSAPrecordtype = Schema.SObjectType.Account.getRecordTypeInfosByNam
- Boolean flag1;
- Boolean flag2;
- Boolean flag3;
- Boolean flag4;
- Map<string,string> countrymap = new Map<string,string>();
- Map<string,string> inactivecountrymap = new Map<string,string>();
- List<contact> inactivecontacts = new List<Contact>();
- set<Id> accidsforActiveContacts = new Set<Id>();
- set<Id> accidsforInActiveContacts = new Set<Id>();
- // searching for active contacts
- for(Contact c: [ Select Id, Name, Email,AccountId,Current_Employee__c,Ecommerce_User__c,MailingCountry from Contact where Email=:emailstr AND Current_Employee__c=:true AND Ecommerce_User__c=:false ]){
- accidsforActiveContacts.add(c.AccountId);
- if(c.MailingCountry!=null) {
- countrymap.put(c.MailingCountry, c.MailingCountry);
- }
- }
- }
- Test class code coverage:---
- @isTest
- public class Test_IntershopInboundRest {
- public static testMethod void Test_1(){
- RestRequest req = new RestRequest();
- RestResponse res = new RestResponse();
- // pass the req and resp objects to the method
- req.requestURI = 'https://danaherlbs--test.cs86.my.salesforce.com/services/apexrest/IntershopRelatedAccounts?Email=vineet@gmail.com';
- req.httpMethod = 'GET';
- req.addHeader('Content-Type', 'application/json');
- RestContext.request = req;
- RestContext.response = res;
- string emailstr = req.params.get('Email');
- List<string> sendto = new List<string>();
- Account a= new Account();
- a.name='account';
- a.SAP_Account_Number__c='569';
- a.Inactive__c=false;
- insert a;
- contact c= new contact();
- c.LastName='james';
- c.AccountId=a.Id;
- c.MailingCountry ='India';
- c.Current_Employee__c=true;
- c.Ecommerce_User__c=false;
- c.Email='james@gmail.com';
- insert c;
- List<Contact> conlst=[select id ,Email from contact where Email=:emailstr];
- if(conlst.size()>1){
- Email_Notify__c emailnotify = new Email_Notify__c();
- emailnotify.Name='InboundEmailId';
- emailnotify.EmailId__c='james@gmail.com';
- insert emailnotify;
- Email_Notify__c emailcustset=[select Id, EmailId__c from Email_Notify__c where Id=:emailnotify.Id];
- system.debug('11111'+emailcustset.EmailId__c);
- IntershopInboundRestTofetchContacts.fetchRelatedAccountswithContacts();
- }
- hi all, the code is not getting covered ,please help.
Add Comment
Please, Sign In to add comment