You need to sign in to do that
Don't have an account?
Test CAse help
Hi, How to write test case for below class?
Adavance thanks,
public with sharing class Search_AESignatory
{
public List results{get;set;} // search results
public string searchString{get;set;} // search keyword
public Search_AESignatory()
{
// get the current search
string searchString = System.currentPageReference().getParameters().get('lksrch');
runSearch();
}
// performs the keyword search
public PageReference search()
{ runSearch();
return null; } // prepare the query and issue the search command
private void runSearch()
{
// TODO prepare query string for complex serarches & prevent injections
results = performSearch(searchString);
}
// run the search and return the records found.
private List performSearch(string searchString)
{
String soql;
List lstAgreements = [Select Id,echosign_dev1__Opportunity__c from echosign_dev1__SIGN_Agreement__c where Id =: System.currentPageReference().getParameters().get('AgreementId')];
Opportunity opp = [Select Legal_Entity__c,Amount from Opportunity where Id =: lstAgreements[0].echosign_dev1__Opportunity__c limit 1];
if(opp.Amount >= 50000)
{
soql = 'select id, name,Legal_Entity_ies_Signatory_Can_Sign_For__c,Signature_Authority__c from AE_Signatories__c where Legal_Entity_ies_Signatory_Can_Sign_For__c LIKE \'%'+ opp.Legal_Entity__c + '%\' AND Signature_Authority__c =\'VP+ (above USD 50K)\''; if(searchString != '' && searchString != null) soql = soql + ' And (name LIKE \'%' + searchString +'%\' Or Legal_Entity_ies_Signatory_Can_Sign_For__c Like \'%' + searchString +'%\') ';
System.debug(soql);
}
else
{
soql = 'select id, name,Legal_Entity_ies_Signatory_Can_Sign_For__c,Signature_Authority__c from AE_Signatories__c where Legal_Entity_ies_Signatory_Can_Sign_For__c LIKE \'%'+ opp.Legal_Entity__c + '%\' '; if(searchString != '' && searchString != null) soql = soql + ' And (name LIKE \'%' + searchString +'%\' Or Legal_Entity_ies_Signatory_Can_Sign_For__c Like \'%' + searchString +'%\') ';
System.debug(soql);
}
soql = soql + 'Order by name ASC';
return database.query(soql);
}
// used by the visualforce page to send the link to the right dom element
public string getFormTag()
{
return System.currentPageReference().getParameters().get('frm');
}
// used by the visualforce page to send the link to the right dom element for the text box
public string getTextBox()
{
return System.currentPageReference().getParameters().get('txt');
}
}
Hi
Try this
@is Test
Private class Search_AESignatory_Test{
static testmethod void Search_AESignatory_Test(){
Opportunityopp = new Opportunity();
opp.Legal_Entity__c ='Test';
opp.Amount=8000;
insert opp
echosign_dev1__SIGN_Agreement__c eds = new echosign_dev1__SIGN_Agreement__c();
eds.//here insert the mandatory fileds
eds.
insert eds;
AE_Signatories__c ae = new AE_Signatories__c();
ae. //here also insert the mandatory fields
ae.
insert ae;
PageReference pageRef = Page.yourPageName;
Test.setCurrentPage(pageRef);
Search_AESignatory sa = new Search_AESignatory();
sa.runSearch();
sa.search();
sa.getFormTag();
sa.getTextBox();
}}
Regards,
Rajesh.