You need to sign in to do that
Don't have an account?
Test case
Hi I am trying to write test case for below class file. CAn any one help me ?
Thanks.
public with sharing class ListOf_Deliverables { public string oppId=''; public ListOf_Deliverables(ApexPages.StandardSetController controller) { oppId= ApexPages.currentPage().getParameters().get('id'); //getDels(); } public ListOf_Deliverables() { oppId= ApexPages.currentPage().getParameters().get('id'); getDels(); } public void setOppId(string DSId){ oppId = DSId; } string UrltoOpen {get;set;} List<Deliverable__c> dels{get; set;} List<Deliverable__c> unReceiveDels{get; set;} public string getUrltoOpen(){ if(UrltoOpen == null || UrltoOpen == ''){ UrltoOpen = 'httpss://cs13.salesforce.com/apex/Receive_Deliverables?scontrolCaching=1&id=' + ApexPages.currentPage().getParameters().get('id') + '&DeliverablesIds='; } return UrltoOpen; } public List<Deliverable__c> getDels() { if(dels == null) dels = [select id,Name,Amount_Paid__c,Balance__c,Deliverable_Number__c,Partial_Amount__c,Make_Partial_Payment__c,Notify_DS_Owner_for_PO_TroubleShoot_Del__c,Work_Approved_By__c,Approved_By_Date__c,Contractor_Invoice__c, Deliverable_Amount__c,due_date__c,Approval_Status__c,Deliverable_Description__c,Opportunity__c from Deliverable__c where ((Approval_Status__c =: 'Not Completed') and Extracted__c =: true) and Update__c =: 'U' and PO_Number__c <> null and Opportunity__c =:oppId ];//OR (Approval_Status__c =: 'Deliverable Approved for Payment') return dels ; } public List<Deliverable__c> getUnReceiveDels() { if(unReceiveDels == null) unReceiveDels = [select id,Name,Amount_Paid__c,Balance__c,Deliverable_Number__c,Partial_Amount__c,Make_Partial_Payment__c,Notify_DS_Owner_for_PO_TroubleShoot_Del__c,Work_Approved_By__c,Approved_By_Date__c,Contractor_Invoice__c, Deliverable_Amount__c,due_date__c,Approval_Status__c,Deliverable_Description__c,Opportunity__c from Deliverable__c where (Approval_Status__c =: 'Deliverable Approved for Payment' and (Extracted__c =: true OR Make_Partial_Payment__c =: true )) and Update__c =: 'U' and PO_Number__c <> null and Opportunity__c =:oppId ];//OR (Approval_Status__c =: 'Deliverable Approved for Payment') return unReceiveDels ; } public PageReference ConfirmAction(){ string Del_Id=null; if(dels != null){ for(integer count=0; count< dels.size();count++) { if(dels[count].Notify_DS_Owner_for_PO_TroubleShoot_Del__c == true) { if(Del_Id != null){ Del_Id = Del_Id + dels[count].Id +','; } else{ Del_Id = dels[count].Id +','; } } } } if(unReceiveDels != null){ for(integer count=0; count< unReceiveDels.size();count++) { if(unReceiveDels[count].Notify_DS_Owner_for_PO_TroubleShoot_Del__c == true) { if(Del_Id != null){ Del_Id = Del_Id + unReceiveDels[count].Id +','; } else{ Del_Id = unReceiveDels[count].Id +','; } } } } string id = ApexPages.currentPage().getParameters().get('id'); UrltoOpen = UrltoOpen+Del_Id; PageReference OppPage = new PageReference('/apex/Receive_Deliverables?scontrolCaching=1&id=' + id + '&DeliverablesIds='+Del_Id); OppPage.setRedirect(true); return OppPage; } public PageReference CancelAction(){ string id = ApexPages.currentPage().getParameters().get('id'); PageReference OppPage = new PageReference('https://cs3.salesforce.com/' + oppId); OppPage.setRedirect(true); return OppPage; }}
Please help me to write teset case for below calss? Thanks
public
withsharingclassListOf_Deliverables {
public string oppId='';
publicListOf_Deliverables(ApexPages.StandardSetController controller) {
oppId= ApexPages.currentPage().getParameters().
get('id');
//getDels();
}
publicListOf_Deliverables() {
oppId= ApexPages.currentPage().getParameters().
get('id');
getDels();
}
publicvoidsetOppId(string DSId){
oppId = DSId;
}
string UrltoOpen {
get;set;}
List<
Deliverable__c> dels{get; set;}
List<
Deliverable__c> unReceiveDels{get; set;}
publicstring getUrltoOpen(){
if(UrltoOpen == null || UrltoOpen == ''){
UrltoOpen =
'httpss://cs13.salesforce.com/apex/Receive_Deliverables?scontrolCaching=1&id=' + ApexPages.currentPage().getParameters().get('id') + '&DeliverablesIds=';
}
returnUrltoOpen;
}
public List<Deliverable__c> getDels() {
if(dels == null) dels = [select id,Name,Amount_Paid__c,Balance__c,Deliverable_Number__c,Partial_Amount__c,Make_Partial_Payment__c,Notify_DS_Owner_for_PO_TroubleShoot_Del__c,Work_Approved_By__c,Approved_By_Date__c,Contractor_Invoice__c, Deliverable_Amount__c,due_date__c,Approval_Status__c,Deliverable_Description__c,Opportunity__c fromDeliverable__cwhere ((Approval_Status__c =: 'Not Completed') and Extracted__c =: true) and Update__c =: 'U'and PO_Number__c <> nulland Opportunity__c =:oppId ];//OR (Approval_Status__c =: 'Deliverable Approved for Payment')returndels ;
}
public List<Deliverable__c> getUnReceiveDels() {
if(unReceiveDels == null) unReceiveDels = [select id,Name,Amount_Paid__c,Balance__c,Deliverable_Number__c,Partial_Amount__c,Make_Partial_Payment__c,Notify_DS_Owner_for_PO_TroubleShoot_Del__c,Work_Approved_By__c,Approved_By_Date__c,Contractor_Invoice__c, Deliverable_Amount__c,due_date__c,Approval_Status__c,Deliverable_Description__c,Opportunity__c fromDeliverable__cwhere (Approval_Status__c =: 'Deliverable Approved for Payment'and (Extracted__c =: trueOR Make_Partial_Payment__c =: true )) and Update__c =: 'U'and PO_Number__c <> nulland Opportunity__c =:oppId ];//OR (Approval_Status__c =: 'Deliverable Approved for Payment')returnunReceiveDels ;
}
publicPageReference ConfirmAction(){
string Del_Id=
null;
if(dels != null){
for(integer count=0; count< dels.size();count++)
{
if(dels[count].Notify_DS_Owner_for_PO_TroubleShoot_Del__c == true)
{
if(Del_Id != null){
Del_Id = Del_Id + dels[
count].Id +',';
}
else{
Del_Id = dels[
count].Id +',';
}
}
}
}
if(unReceiveDels != null){
for(integer count=0; count< unReceiveDels.size();count++)
{
if(unReceiveDels[count].Notify_DS_Owner_for_PO_TroubleShoot_Del__c == true)
{
if(Del_Id != null){
Del_Id = Del_Id + unReceiveDels[
count].Id +',';
}
else{
Del_Id = unReceiveDels[
count].Id +',';
}
}
}
}
string id = ApexPages.currentPage().getParameters().
get('id');
UrltoOpen = UrltoOpen+Del_Id;
PageReference OppPage =
new PageReference('/apex/Receive_Deliverables?scontrolCaching=1&id=' + id + '&DeliverablesIds='+Del_Id);
OppPage.setRedirect(
true);
returnOppPage;
}
publicPageReference CancelAction(){
string id = ApexPages.currentPage().getParameters().
get('id');
PageReference OppPage =
new PageReference('https://cs3.salesforce.com/'+ oppId);
OppPage.setRedirect(
true);
returnOppPage;
}
}
You can find a very helpful and detailed explanation for the same here: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm
Anand