You need to sign in to do that
Don't have an account?
Arav Sundar
Need help Test class for webservice
Hi,
Need help on the below things
global class OpprtunityWEbservice2{
webService static String test1(String year,String accId, String mheCourseId, String term, String stage, String name ,Boolean productInUseUpdate,String creationSourceId,String contactId,String productId, String pricebookEntryId,Double unitPrice, String targetedCreationSourceId, Boolean restrictOppLineCreation){
String newOptyId;
try{
test2 o = new test2(Name=name,year__c=year,accountId=accId,MHE_Course__c=mheCourseId,Term__c=term,StageName=stage,CloseDate=System.Today(),Product_in_Use_Update__c=productInUseUpdate,Creation_Source_ID__c=creationSourceId);
insert o;
newOptyId =''+o.id;
test 3 oc=new test 3(Name='test45',Contact_Name__c=contactId,Opportunity__c=newOptyId );
insert oc;
if(restrictOppLineCreation == false){
System.debug('restrict oppline creation ::'+restrictOppLineCreation);
test4 ol=new test4(OpportunityId=newOptyId ,Quantity=1,UnitPrice=unitPrice,PricebookEntryId=pricebookEntryId,Creation_Source_ID__c=targetedCreationSourceId);
insert ol;
}else{
System.debug('restrict oppline creation*** ::'+restrictOppLineCreation);
}
return newOptyId;
}catch(Exception e){
return e.getmessage();
}
}
}
ANd the test class i am trying is below pls help
@isTest Class Test_webservice{
private Static TestMethod void test1(){
OpprtunityWEbservice2.test1 test = new OpprtunityWEbservice2.test1();
Getting an error (Invalid type: OpprtunityWEbservice2.test1 at line 101 column 65
Need help on the below things
global class OpprtunityWEbservice2{
webService static String test1(String year,String accId, String mheCourseId, String term, String stage, String name ,Boolean productInUseUpdate,String creationSourceId,String contactId,String productId, String pricebookEntryId,Double unitPrice, String targetedCreationSourceId, Boolean restrictOppLineCreation){
String newOptyId;
try{
test2 o = new test2(Name=name,year__c=year,accountId=accId,MHE_Course__c=mheCourseId,Term__c=term,StageName=stage,CloseDate=System.Today(),Product_in_Use_Update__c=productInUseUpdate,Creation_Source_ID__c=creationSourceId);
insert o;
newOptyId =''+o.id;
test 3 oc=new test 3(Name='test45',Contact_Name__c=contactId,Opportunity__c=newOptyId );
insert oc;
if(restrictOppLineCreation == false){
System.debug('restrict oppline creation ::'+restrictOppLineCreation);
test4 ol=new test4(OpportunityId=newOptyId ,Quantity=1,UnitPrice=unitPrice,PricebookEntryId=pricebookEntryId,Creation_Source_ID__c=targetedCreationSourceId);
insert ol;
}else{
System.debug('restrict oppline creation*** ::'+restrictOppLineCreation);
}
return newOptyId;
}catch(Exception e){
return e.getmessage();
}
}
}
ANd the test class i am trying is below pls help
@isTest Class Test_webservice{
private Static TestMethod void test1(){
OpprtunityWEbservice2.test1 test = new OpprtunityWEbservice2.test1();
Getting an error (Invalid type: OpprtunityWEbservice2.test1 at line 101 column 65
You need to call the method with class name as it is a static method .Here one thing you need to follow like you need to create testdata to pass the parameter .
Like create a account record then pass the method .Same you need to pass all parameter in the method .
For simple example I have create a test class please modifyand try to implement it any issue let me know .
Let me know if it helps !!
Thanks
Manoj