I am trying to improve my test coverage for my test class and for that I want to call a particular method with if conditions in it and I am not sure how to call that in my test class. Below is my method I want to have in my test class.
/**
* This method finds the related reps based on the territoryID
*/
public static Shipping_Address__c FindTerritoryReps(Shipping_Address__c a, Id matchingTerritoryObjectID, Map<id,territory__c> SalesTerritoryMappings) { //returns Id of pricebook
//Get only the matching sales territory mappings
List<Sales_Territory_Mapping__c> salesRepMappings = SalesTerritoryMappings.get(matchingTerritoryObjectID).Sales_Territory_Mapping__r;
String RepBasedTerritoryNames = null;
for(Sales_Territory_Mapping__c salesRepMapping : salesRepMappings){
//system.debug('TEST SalesTerrMName__c '+ salesRepMapping.SalesTerrMName__c);
if(salesRepMapping.Role__c=='FSALM'){
a.Sales_Rep_M_Name__c = salesRepMapping.Sales_Rep__c;
a.AccTerritoryNameM__c = salesRepMapping.SalesTerrMapName__c;
}
if(salesRepMapping.Role__c=='FSALCS'){
a.Sales_Rep_CS_Name__c = salesRepMapping.Sales_Rep__c;
a.AccTerritoryNameCS__c = salesRepMapping.SalesTerrMapName__c;
}
if(salesRepMapping.Role__c=='ISALCS'){
a.ISAL_CS_ID__c = salesRepMapping.Sales_Rep__c;
}
if(salesRepMapping.Role__c=='ISALM'){
a.ISAL_M_ID__c = salesRepMapping.Sales_Rep__c;
}
if(salesRepMapping.Role__c=='Sales Manager M'){
a.Sales_Manager_M_ID__c = salesRepMapping.Sales_Rep__c;
}
if(salesRepMapping.Role__c=='Sales Manager CS'){
a.Sales_Manager_CS_ID__c = salesRepMapping.Sales_Rep__c;
}
if(salesRepMapping.Role__c=='ISAL ManagerM'){
a.ISAL_Manager_M_ID__c = salesRepMapping.Sales_Rep__c;
}
if(salesRepMapping.Role__c=='ISAL Manager CS'){
a.ISAL_Manager_CS_ID__c = salesRepMapping.Sales_Rep__c;
}
/*
if(salesRepMapping.Account_Owner__c == true){
a.OwnerId = salesRepMapping.Sales_Rep__c;
}
*/
a.Territory__c = RepBasedTerritoryNames;
}
system.debug('TEST terrnames '+ a.TerritoryNames__c);
return a;
/**
* This method finds the related SoldinCountry based on the territoryID
*/
}
}