- Vidyut Devam
- NEWBIE
- 0 Points
- Member since 2017
- Salesforce Developer
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
1Replies
Not able to cover this class. help
Can anyone please take a look at my test class and figure out why the class is not getting covered. i am stuck on 27 %
Here is the trigger:
and here is my test class which has fault somewhere:
Coverage from line no 96 to 196 not getting covered.
Here is the trigger:
trigger checkActiveContacts on Contact (before insert,after insert,before update) { system.debug('trigger called'); if(Trigger.isBefore){ if(Trigger.isInsert || Trigger.isUpdate){ system.debug('trigger.oldmpa'+trigger.oldmap); //contactTriggerHandler objATH = new contactTriggerHandler(); //objATH.checkActive(trigger.new,trigger.oldmap); contactTriggerHandler objATH2 = new contactTriggerHandler(); objATH2.updateFG(trigger.new); } } }here is the helper class:
public class contactTriggerHandler { public Set<String> setParentId; public Set<String> contactid; public Map<String,String> mapParentToId; public Map<String,Integer> mapPrentIdToCount; public Map<String,String> mapAccountIdToName; public contact contactrec; public contactTriggerHandler(){ setParentId = new Set<String>(); contactid = new Set<String>(); mapParentToId = new Map<String,String>(); mapPrentIdToCount = new Map<String,Integer>(); mapAccountIdToName = new Map<String,String>(); contact Contactrec = new contact(); System.debug('I am in'); } public void checkActive(List<contact> lstcontact, map<id,contact>oldmapcontacts ){/** System.debug('I am in1'); for(contact objcon: lstcontact){ if(objcon.accountId != null){ setParentId.add(objcon.accountId); contactid.add(objcon.Id); mapParentToId.put(objcon.accountId,objcon.Id); } } // System.debug('I am in1++'+setParentId); // System.debug('I am in1++'+mapParentToId); AggregateResult[] groupedResults = [SELECT accountId, Count(Id) FROM contact where (Status__c = 'Current' OR Status_override__c = 'Current' ) AND accountId in :setParentId AND Id NOT In:contactid GROUP BY accountId]; for (AggregateResult ar : groupedResults) { //System.debug('accountid' + ar.get('accountid')); //System.debug('Count Of Active contact' + ar.get('expr0')); mapPrentIdToCount.put(String.valueOf(ar.get('accountid')),Integer.valueOf(ar.get('expr0'))); } for(Contact objContact : [Select id,Name,AccountId from Contact where Status__c='Current' OR Status_override__c = 'Status_override__c']){ mapAccountIdToName.put(objContact.AccountId,objContact.Name); } System.debug('mapPrentIdToCount++'+mapPrentIdToCount); if(lstcontact!=null) for(Contact objcontact : lstcontact){ if(mapPrentIdToCount.get(objcontact.accountId) != null && (objcontact.Status__c == 'Current' || objcontact.Status_override__c=='Current') ){ if(mapPrentIdToCount.get(objcontact.accountid)>=1){ system.debug('inside 49'); if(mapAccountIdToName.get(objcontact.accountid) != null) system.debug('inside 509'); //Contactrec=[select id,name from Contact where name= :mapAccountIdToName.get(objcontact.accountid)]; //string Contactid = '55';//Contactrec.Id; //system.debug('Contactid--->'+string.valueof(Contactid)); //system.debug('url-->'+'https://cs79.salesforce.com/'+Contactid+'>'); objcontact.addError('Only one child Contact can be associated at a time. Hence an active Contact ' +mapAccountIdToName.get(objcontact.accountid) +' already associated with this Account'); // objcontact.addError('Only one child Contact can be associated at a time and there is already an active Contact associated with this account :<a href=https://cs79.salesforce.com/'+contactid+'>'+mapAccountIdToName.get(objcontact.accountid)+'</a>', false); } } } */ } //method for updating the functional groups.. public void updateFG(List<contact>conlist){ list<contact>conlist2; map<string,string> mymap=new map<string,string>(); mymap.put('Executive_Aide_to_the_Governor__c', 'Governors Direct Support'); mymap.put('Governor_s_Personal_Attendant__c', 'Governors Direct Support'); mymap.put('Governor__c', 'Governors'); //mymap.put(key, value) conlist2=new list<contact>(); system.debug('Functional group called'); list<recordtype>rectypeinfo=[SELECT Id, Name, DeveloperName FROM RecordType WHERE SObjectType = 'Contact' and developername='Member_NGA' limit 1]; system.debug('rectypeinfo-->'+rectypeinfo); string rectypenameid=rectypeinfo[0].id; system.debug('rectypenameid-->'+rectypenameid); List <String> strlist; List <String> strlistnew; strlistnew= new list<string>(); strlist = new List<String>(); for(contact con:conlist){ if(con.RecordTypeId==rectypenameid){ conlist2.add(con); system.debug('correct rectype'); } system.debug('before foreach'); // not getting covered anything beyond this line for(contact con1: conlist2 ){ system.debug('afterfor each'); if(con1.Governor__c==false && con1.Executive_Aide_to_the_Governor__c==false && con1.Governor_s_Personal_Attendant__c==false && con1.Deputy_Chief_of_Staff_Senior_Advisor__c==false && con1.Deputy_Chief_s_Support_Staff__c==false && con1.Director_of_Communications__c==false && con1.Deputy_Director_of_Communications__c==false && con1.Press_Secretary__c==false && con1.Communications_Support_Staff__c==false && con1.Counsel__c==false && con1.Deputy_Counsel__c==false && con1.Counsel_Support_Staff__c==false && con1.Executive_Aide_to_the_First_Spouse__c==false && con1.Residence_Managers__c==false && con1.Spouse_s_Support_Staff__c==false && con1.DC_Director__c==false&& con1.State_Federal_Contact__c==false && con1.Intergovernmental_Affairs_Support_Staff__c==false && con1.Policy_Director__c==false && con1.Policy_Support_Staff__c==false && con1.Economic_Development__c==false && con1.Energy__c==false && con1.Transportation__c==false && con1.Labor__c==false && con1.Criminal_Justice__c==false && con1.Homeland_Security__c==false && con1.Human_Services__c==false && con1.Appointments__c==false && con1.Deputy_Chiefs__c==false && con1.Chief_s_of_Staff__c==false && con1.Chief_s_Assistant__c==false && con1.Chief_s_Support_Staff__c==false && con1.COO__c==false && con1.COO_Support_Staff__c==false && con1.Director_of_Scheduling__c==false && con1.Deputy_Director_of_Scheduling__c==false && con1.Scheduling_Support_Staff__c==false && con1.Director_of_Boards_and_Appointments__c==false && con1.Boards_and_Appointments_Support_Staff__c==false && con1.Director_of_Constituent_Services__c==false && con1.Director_of_Correspondence__c ==false && con1.Constituent_Services_Support_Staff__c==false && con1.Constituent_Services_Support_Staff__c==false && con1.Legislative_Director__c==false && con1.Legislative_Affairs_Support_Staff__c ==false && con1.Education__c==false && con1.Water__c==false && con1.Health__c==false && con1.Workforce_Development__c==false && con1.Public_Safety__c==false && con1.Post_secondary_Eduation__c==false && con1.Communications__c==false && con1.Governor_s_Assistants__c==false && con1.Schedulers__c==false){ system.debug('all empty checkboxes'); con1.addError('Member role(s) must be selected to save this contact.'); } if(con1.Executive_Aide_to_the_Governor__c==true || con1.Governor_s_Personal_Attendant__c==true){ strlist.add('Governors Direct Support'); } if(con1.Governor__c==true ){ strlist.add('Governors'); } if(con1.Chief_s_of_Staff__c==true || con1.Chief_s_Assistant__c==true||con1.Chief_s_Support_Staff__c==true){ strlist.add('Chiefs'); } if(con1.Deputy_Chief_of_Staff_Senior_Advisor__c==true||con1.Deputy_Chief_s_Support_Staff__c==true){ strlist.add('Deputy Chiefs/Senior Advisors'); } if(con1.COO__c==true || con1.COO_Support_Staff__c==true){ strlist.add('Chief Operating Officers'); } if(con1.Director_of_Communications__c==true || con1.Deputy_Director_of_Communications__c==true ||con1.Press_Secretary__c==true||con1.Communications_Support_Staff__c==true){ strlist.add('Communications'); } if(con1.Director_of_Scheduling__c==true || con1.Deputy_Director_of_Scheduling__c==true ||con1.Scheduling_Support_Staff__c==true){ system.debug('scheduling true'); strlist.add('Scheduling'); }if(con1.Counsel__c==true || con1.Deputy_Counsel__c==true ||con1.Counsel_Support_Staff__c==true){ strlist.add('Legal Counsel'); }if(con1.Director_of_Boards_and_Appointments__c==true || con1.Boards_and_Appointments_Support_Staff__c==true ){ strlist.add('Boards and Appointments'); }if(con1.Director_of_Constituent_Services__c==true || con1.Director_of_Correspondence__c==true ||con1.Constituent_Services_Support_Staff__c==true){ strlist.add('Constituent Services'); }if(con1.Executive_Aide_to_the_First_Spouse__c==true || con1.Residence_Managers__c==true ||con1.Spouse_s_Support_Staff__c==true){ strlist.add('Spouses Direct Support'); }if(con1.First_Spouse__c==true){ strlist.add(' First Spouses'); } if(con1.DC_Director__c==true || con1.State_Federal_Contact__c==true ||con1.Intergovernmental_Affairs_Support_Staff__c==true){ strlist.add(' Intergovernmental Affairs(Washington Reps)'); } if(con1.Legislative_Director__c==true || con1.Legislative_Affairs_Support_Staff__c==true){ strlist.add('Legislative Affairs'); } if(con1.Policy_Director__c==true || con1.Policy_Support_Staff__c==true){ strlist.add('Policy Director'); } if(con1.Policy_Director__c==true || con1.Economic_Development__c==true ||con1.Education__c==true||con1.Energy__c==true|| con1.Water__c==true||con1.Transportation__c==true||con1.Health__c==true|| con1.Labor__c==true||con1.Workforce_Development__c==true|| con1.Criminal_Justice__c==true||con1.Public_Safety__c==true|| con1.Homeland_Security__c==true||con1.Post_secondary_Eduation__c==true|| con1.Human_Services__c==true){ strlist.add('policy'); } system.debug('strlist--->'+strlist); string fg=string.valueOf(strlist); fg=fg.remove('('); fg=fg.remove(')'); con1.Functional_Groups__c=fg; } list<contact>conlist3=new list<contact>(); conlist3=new list<contact>(); update conlist3; } } }
and here is my test class which has fault somewhere:
@istest public class contactTriggerHandler_test { static testMethod void unittest1 (){ account a = new account(); a.name='Parentaccount'; insert a; account b = new account(); b.Name= 'childaccount'; b.ParentId=a.Id; insert b; contact cc = new contact(); cc.LastName='xyzz'; cc.AccountId=b.Id; cc.Governor__c = true ; cc.Executive_Aide_to_the_Governor__c=true ; cc.Governor_s_Personal_Attendant__c=true ; cc.Deputy_Chief_of_Staff_Senior_Advisor__c=true ; cc.Deputy_Chief_s_Support_Staff__c=true ; cc.Director_of_Communications__c=true ; cc.Deputy_Director_of_Communications__c=true ; cc.Press_Secretary__c=true ; cc.Communications_Support_Staff__c=true ; cc.Counsel__c=true ; cc.Deputy_Counsel__c=true ; cc.Counsel_Support_Staff__c=true ; cc.Executive_Aide_to_the_First_Spouse__c=true ; cc.Residence_Managers__c=true ; cc.Spouse_s_Support_Staff__c=true ; cc.DC_Director__c=true; cc.State_Federal_Contact__c=true ; cc.Intergovernmental_Affairs_Support_Staff__c=true ; cc.Policy_Director__c=true ; cc.Policy_Support_Staff__c=true ; cc.Economic_Development__c=true ; cc.Energy__c=true ; cc.Transportation__c=true ; cc.Labor__c=true ; cc.Criminal_Justice__c=true ; cc.Homeland_Security__c=true ; cc.Human_Services__c=true ; cc.Appointments__c=true ; cc.Deputy_Chiefs__c=true ; cc.Chief_s_of_Staff__c=true ; cc.Chief_s_Assistant__c=true ; cc.Chief_s_Support_Staff__c=true ; cc.COO__c=true ; cc.COO_Support_Staff__c=true ; cc.Director_of_Scheduling__c=true ; cc.Deputy_Director_of_Scheduling__c=true ; cc.Scheduling_Support_Staff__c=true ; cc.Director_of_Boards_and_Appointments__c=true ; cc.Boards_and_Appointments_Support_Staff__c=true ; cc.Director_of_Constituent_Services__c=true ; cc.Director_of_Correspondence__c =true ; cc.Constituent_Services_Support_Staff__c=true ; cc.Constituent_Services_Support_Staff__c=true ; cc.Legislative_Director__c=true ; cc.Legislative_Affairs_Support_Staff__c =true ; cc.Education__c=true ; cc.Water__c=true ; cc.Health__c=true ; cc.Workforce_Development__c=true ; cc.Public_Safety__c=true ; cc.Post_secondary_Eduation__c=true ; cc.Communications__c=true ; cc.Governor_s_Assistants__c=true ; cc.Schedulers__c=true; insert cc; contact ccc= new contact (); ccc.LastName='aa'; ccc.Governor__c = true ; ccc.Executive_Aide_to_the_Governor__c=true ; ccc.Governor_s_Personal_Attendant__c=true ; ccc.Deputy_Chief_of_Staff_Senior_Advisor__c=true ; ccc.Deputy_Chief_s_Support_Staff__c=true ; ccc.Director_of_Communications__c=true ; ccc.Deputy_Director_of_Communications__c=true ; ccc.Press_Secretary__c=true ; ccc.Communications_Support_Staff__c=true ; ccc.Counsel__c=true ; ccc.Deputy_Counsel__c=true ; ccc.Counsel_Support_Staff__c=true ; ccc.Executive_Aide_to_the_First_Spouse__c=true ; ccc.Residence_Managers__c=true ; ccc.Spouse_s_Support_Staff__c=true ; ccc.DC_Director__c=true; ccc.State_Federal_Contact__c=true ; ccc.Intergovernmental_Affairs_Support_Staff__c=true ; ccc.Policy_Director__c=true ; ccc.Policy_Support_Staff__c=true ; ccc.Economic_Development__c=true ; ccc.Energy__c=true ; ccc.Transportation__c=true ; ccc.Labor__c=true ; ccc.Criminal_Justice__c=true ; ccc.Homeland_Security__c=true ; ccc.Human_Services__c=true ; ccc.Appointments__c=true ; ccc.Deputy_Chiefs__c=true ; ccc.Chief_s_of_Staff__c=true ; ccc.Chief_s_Assistant__c=true ; ccc.Chief_s_Support_Staff__c=true ; ccc.COO__c=true ; ccc.COO_Support_Staff__c=true ; ccc.Director_of_Scheduling__c=true ; ccc.Deputy_Director_of_Scheduling__c=true ; ccc.Scheduling_Support_Staff__c=true ; ccc.Director_of_Boards_and_Appointments__c=true ; ccc.Boards_and_Appointments_Support_Staff__c=true ; ccc.Director_of_Constituent_Services__c=true ; ccc.Director_of_Correspondence__c =true ; ccc.Constituent_Services_Support_Staff__c=true ; ccc.Constituent_Services_Support_Staff__c=true ; ccc.Legislative_Director__c=true ; ccc.Legislative_Affairs_Support_Staff__c =true ; ccc.Education__c=true ; ccc.Water__c=true ; ccc.Health__c=true ; ccc.Workforce_Development__c=true ; ccc.Public_Safety__c=true ; ccc.Post_secondary_Eduation__c=true ; ccc.Communications__c=true ; ccc.Governor_s_Assistants__c=true ; ccc.Schedulers__c=true; insert ccc; Id RecordTypeIdContact = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Member_NGA').getRecordTypeId(); contact c = new contact(); c.lastName='xyz'; c.AccountId=b.id; c.RecordTypeId=RecordTypeIdContact; c.Governor__c = true ; c.Executive_Aide_to_the_Governor__c=true ; c.Governor_s_Personal_Attendant__c=true ; c.Deputy_Chief_of_Staff_Senior_Advisor__c=true ; c.Deputy_Chief_s_Support_Staff__c=true ; c.Director_of_Communications__c=true ; c.Deputy_Director_of_Communications__c=true ; c.Press_Secretary__c=true ; c.Communications_Support_Staff__c=true ; c.Counsel__c=true ; c.Deputy_Counsel__c=true ; c.Counsel_Support_Staff__c=true ; c.Executive_Aide_to_the_First_Spouse__c=true ; c.Residence_Managers__c=true ; c.Spouse_s_Support_Staff__c=true ; c.DC_Director__c=true; c.State_Federal_Contact__c=true ; c.Intergovernmental_Affairs_Support_Staff__c=true ; c.Policy_Director__c=true ; c.Policy_Support_Staff__c=true ; c.Economic_Development__c=true ; c.Energy__c=true ; c.Transportation__c=true ; c.Labor__c=true ; c.Criminal_Justice__c=true ; c.Homeland_Security__c=true ; c.Human_Services__c=true ; c.Appointments__c=true ; c.Deputy_Chiefs__c=true ; c.Chief_s_of_Staff__c=true ; c.Chief_s_Assistant__c=true ; c.Chief_s_Support_Staff__c=true ; c.COO__c=true ; c.COO_Support_Staff__c=true ; c.Director_of_Scheduling__c=true ; c.Deputy_Director_of_Scheduling__c=true ; c.Scheduling_Support_Staff__c=true ; c.Director_of_Boards_and_Appointments__c=true ; c.Boards_and_Appointments_Support_Staff__c=true ; c.Director_of_Constituent_Services__c=true ; c.Director_of_Correspondence__c =true ; c.Constituent_Services_Support_Staff__c=true ; c.Constituent_Services_Support_Staff__c=true ; c.Legislative_Director__c=true ; c.Legislative_Affairs_Support_Staff__c =true ; c.Education__c=true ; c.Water__c=true ; c.Health__c=true ; c.Workforce_Development__c=true ; c.Public_Safety__c=true ; c.Post_secondary_Eduation__c=true ; c.Communications__c=true ; c.Governor_s_Assistants__c=true ; c.Schedulers__c=true; insert c; list <contact> conlist = new list<contact>(); conlist.add(c); conlist.add(ccc); conlist.add(cc); contactTriggerHandler instcontactTriggerHandler = new contactTriggerHandler(); instcontactTriggerHandler.updateFG(conlist); } }
Coverage from line no 96 to 196 not getting covered.
-
- Vidyut Devam
- January 03, 2019
- Like
- 0
Limitations of a Component.
Just wondering -- How many records can be shown on a lightning component without doing the pagination. Do Components have the limitations just like that of VF pages?
-
- Vidyut Devam
- August 29, 2018
- Like
- 0
Quiktrak integeration to salesforce.: Error: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported
hi
I am integrating salesforce to quiktrak. and I am generating apex classes using WSDLtoApex . i am a newbie to integeration and unfamilliar with WSDL .Despite my great efforts at debugging it - it continues to remain an issue. i am stuck for 5 days .
The error is
Error: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported
Here is the Link for wsdl.
https://usstgweb.quiktrak.com/QTAOE/QTOrderEntry.asmx?WSDL
any help will be greatly appreciated.
I am integrating salesforce to quiktrak. and I am generating apex classes using WSDLtoApex . i am a newbie to integeration and unfamilliar with WSDL .Despite my great efforts at debugging it - it continues to remain an issue. i am stuck for 5 days .
The error is
Error: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported
Here is the Link for wsdl.
https://usstgweb.quiktrak.com/QTAOE/QTOrderEntry.asmx?WSDL
any help will be greatly appreciated.
-
- Vidyut Devam
- February 07, 2018
- Like
- 0
SFDX: Authorize an Org failed to run
Hi All,
I am tring to authorize an org on visual studio code but when I am trying authorize it, I am getting the below error.
SFDX: Authorize an Org failed to run
Try this:
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.
19:31:13.241 sfdx force:auth:web:login --setalias VSCodePlayground --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1
I have Killed the Process on port 1717 and tried it again then I am not getting any error but it is running for infinite time.
Please help.
Thanks,
Parteek
I am tring to authorize an org on visual studio code but when I am trying authorize it, I am getting the below error.
SFDX: Authorize an Org failed to run
Try this:
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.
19:31:13.241 sfdx force:auth:web:login --setalias VSCodePlayground --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1
I have Killed the Process on port 1717 and tried it again then I am not getting any error but it is running for infinite time.
Please help.
Thanks,
Parteek
- Parteek Goyal 3
- July 04, 2019
- Like
- 0