You need to sign in to do that
Don't have an account?
mamatha devaraj
Please write a test class for below method i tried but failed
I got below exception msg
USER_DEBUG [283]|DEBUG|exception2Insert failed. First exception on row 0 with id a7o3K000000DwPWQA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
public static string billSpecSoInsert(Customer_Billing_Spec_Template__c billSpecins, List<Customer_Billing_Spec_SOMap__c> SoMapList, List<Cust_Billing_Spec_Extra_Parameter__c> billingExtParamList){
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert billSpecins:'+billSpecins);
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList:'+SoMapList);
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList size:'+SoMapList.size());
string status='Success';
try{
insert billSpecins;
//NAD-4567(SF-8490): Order Extra Parameters Phase 2
if(!billingExtParamList.isEmpty()){
for(Cust_Billing_Spec_Extra_Parameter__c ep : billingExtParamList){
ep.Customer_Billing_Spec_Template__c = billSpecins.id;
}
insert billingExtParamList;
}
if(!SoMapList.isEmpty()){
for(Customer_Billing_Spec_SOMap__c billspecId : SoMapList){
billspecId.Customer_Billing_Spec__c = billSpecins.id;
}
insert SoMapList;
}
}catch(DMLexception ex) {
ECOB_LogUtility.createDMLExceptionLog(ex);
system.debug('exception1 '+ex.getCause());
system.debug('exception2'+ex.getMessage());
status = ex.getMessage();
}
return status;
}
USER_DEBUG [283]|DEBUG|exception2Insert failed. First exception on row 0 with id a7o3K000000DwPWQA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
public static string billSpecSoInsert(Customer_Billing_Spec_Template__c billSpecins, List<Customer_Billing_Spec_SOMap__c> SoMapList, List<Cust_Billing_Spec_Extra_Parameter__c> billingExtParamList){
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert billSpecins:'+billSpecins);
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList:'+SoMapList);
System.debug('In ECOB_CloneBillingSpecsAccessor class for billSpecSoInsert SoMapList size:'+SoMapList.size());
string status='Success';
try{
insert billSpecins;
//NAD-4567(SF-8490): Order Extra Parameters Phase 2
if(!billingExtParamList.isEmpty()){
for(Cust_Billing_Spec_Extra_Parameter__c ep : billingExtParamList){
ep.Customer_Billing_Spec_Template__c = billSpecins.id;
}
insert billingExtParamList;
}
if(!SoMapList.isEmpty()){
for(Customer_Billing_Spec_SOMap__c billspecId : SoMapList){
billspecId.Customer_Billing_Spec__c = billSpecins.id;
}
insert SoMapList;
}
}catch(DMLexception ex) {
ECOB_LogUtility.createDMLExceptionLog(ex);
system.debug('exception1 '+ex.getCause());
system.debug('exception2'+ex.getMessage());
status = ex.getMessage();
}
return status;
}
Can you confirm how you are passing the parameters to billSpecSoInsert method?
Thanks,
Below is entair apex class and test class, I am new to development , help me to increse the code caverage of the test class from 76 to 86%.