You need to sign in to do that
Don't have an account?
Pavani Akella 9
Help writing test classes
Can someone please please help me writing test classes. It's urgent.
public without sharing abstract class XmlPayloadController {
public static final String XML_HEADER { get; }
public Case theCase { get; private set; }
static {
XML_HEADER = '<?xml version="1.0" ?>';
}
public virtual String getBusinessUnit() {
for (Replacement_Part__c rp : theCase.Replacement_Parts__r) {
if (String.isNotBlank(rp.Replacement_Item__r.Business_Unit__c)) {
return rp.Replacement_Item__r.Business_Unit__c;
}
}
return null;
}
public virtual String getDeptId() {
String deptId = '';
String businessUnit = getBusinessUnit();
if (businessUnit == 'M140') {
deptId = '170';
}
else if (businessUnit == 'M170') {
deptId = '172';
}
return deptId;
}
protected void loadCase(Id caseId) {
// TODO: add new custom fields when they become available
theCase = [SELECT Id, CaseNumber,
Account.PeopleSoft_Customer_ID__c,
Account.PeopleSoft_Vendor_ID__c,
Ship_To_Address__r.Sequence_Number__c,
Business_Unit__c
FROM Case WHERE Id = :caseId];
}
}
public without sharing abstract class XmlPayloadController {
public static final String XML_HEADER { get; }
public Case theCase { get; private set; }
static {
XML_HEADER = '<?xml version="1.0" ?>';
}
public virtual String getBusinessUnit() {
for (Replacement_Part__c rp : theCase.Replacement_Parts__r) {
if (String.isNotBlank(rp.Replacement_Item__r.Business_Unit__c)) {
return rp.Replacement_Item__r.Business_Unit__c;
}
}
return null;
}
public virtual String getDeptId() {
String deptId = '';
String businessUnit = getBusinessUnit();
if (businessUnit == 'M140') {
deptId = '170';
}
else if (businessUnit == 'M170') {
deptId = '172';
}
return deptId;
}
protected void loadCase(Id caseId) {
// TODO: add new custom fields when they become available
theCase = [SELECT Id, CaseNumber,
Account.PeopleSoft_Customer_ID__c,
Account.PeopleSoft_Vendor_ID__c,
Ship_To_Address__r.Sequence_Number__c,
Business_Unit__c
FROM Case WHERE Id = :caseId];
}
}
http://www.infallibletechie.com/2014/04/test-class-for-abstract-class-in.html
Refer this link
http://www.infallibletechie.com/2014/04/test-class-for-abstract-class-in.html