You need to sign in to do that
Don't have an account?
swain 10
How to get code coverage for apex class?
Hi ,
How to get code coverage for this apex class.
public class OV_Flw_Searchcc360 {
@InvocableMethod(label='Saerch the CC360 ' description='This will get the configuration from Flow and search in cc360')
public static List<String> searchCC360(List<List<String>> config) {
try{
String dispFields=config[0][0];
String[] fetchFields=config[0][1].split(',');
String searchFields=config[0][2];
String objectType=config[0][3];
List<String> filterFields = searchFields.split(',');
Map<String, String> fields = new Map<String, String>();
Map<String, String> sources = new Map<String, String>();
sources.put('1',objectType);
for(String f : filterFields ){
List<String> fiterMap=f.split('=');
fields.put(fiterMap[0], fiterMap[1]);
}
system.debug('-------objectType-----'+objectType);
system.debug('-------fields-----'+fields);
system.debug('-------sources-----'+sources);
List<sObject> allResult= OV_Searchcc360.isDuplicate(objectType, fields, sources, null);
List<Map<String,String>> tblResule = new List<Map<String,String>>();
for(sObject result : allResult){
Map<String,Object> retObject = (Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(result));
Map<String,String> consolidatedMap = new Map<String,String>();
for(String f : fetchFields ){
f=f.trim();
consolidatedMap.put(f,(String)retObject.get(f));
}
system.debug('------result------'+consolidatedMap);
tblResule.add(consolidatedMap);
}
List<String> finalResult = new List<String>();
for(Map<String,String> fResult : tblResule){
finalResult.add(JSON.serialize(fResult));
}
system.debug('------finalResult------'+finalResult);
system.debug('------result------'+allResult);
system.debug('------tblResule------'+tblResule);
List<String> accountNames = new List<String>();
List<List<String>> stringList = new List<List<String>>();
stringList.add(finalResult);
List<String> cc360resultList = new List<String>();
String cc360result=JSON.serialize(finalResult);
cc360resultList.add(cc360result);
system.debug('-----------'+cc360result);
if(finalResult.size()==0){
return null;
}
return cc360resultList;
}catch(Exception ex){
system.debug('------Error-------'+ex.getLineNumber());
system.debug('------Error-------'+ex.getMessage());
}
return null;
}
}
How to get code coverage for this apex class.
public class OV_Flw_Searchcc360 {
@InvocableMethod(label='Saerch the CC360 ' description='This will get the configuration from Flow and search in cc360')
public static List<String> searchCC360(List<List<String>> config) {
try{
String dispFields=config[0][0];
String[] fetchFields=config[0][1].split(',');
String searchFields=config[0][2];
String objectType=config[0][3];
List<String> filterFields = searchFields.split(',');
Map<String, String> fields = new Map<String, String>();
Map<String, String> sources = new Map<String, String>();
sources.put('1',objectType);
for(String f : filterFields ){
List<String> fiterMap=f.split('=');
fields.put(fiterMap[0], fiterMap[1]);
}
system.debug('-------objectType-----'+objectType);
system.debug('-------fields-----'+fields);
system.debug('-------sources-----'+sources);
List<sObject> allResult= OV_Searchcc360.isDuplicate(objectType, fields, sources, null);
List<Map<String,String>> tblResule = new List<Map<String,String>>();
for(sObject result : allResult){
Map<String,Object> retObject = (Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(result));
Map<String,String> consolidatedMap = new Map<String,String>();
for(String f : fetchFields ){
f=f.trim();
consolidatedMap.put(f,(String)retObject.get(f));
}
system.debug('------result------'+consolidatedMap);
tblResule.add(consolidatedMap);
}
List<String> finalResult = new List<String>();
for(Map<String,String> fResult : tblResule){
finalResult.add(JSON.serialize(fResult));
}
system.debug('------finalResult------'+finalResult);
system.debug('------result------'+allResult);
system.debug('------tblResule------'+tblResule);
List<String> accountNames = new List<String>();
List<List<String>> stringList = new List<List<String>>();
stringList.add(finalResult);
List<String> cc360resultList = new List<String>();
String cc360result=JSON.serialize(finalResult);
cc360resultList.add(cc360result);
system.debug('-----------'+cc360result);
if(finalResult.size()==0){
return null;
}
return cc360resultList;
}catch(Exception ex){
system.debug('------Error-------'+ex.getLineNumber());
system.debug('------Error-------'+ex.getMessage());
}
return null;
}
}
Raj Vakati
Here is the sample code. Update the code as per the comment