function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
FrescoFresco 

neeed to cover 85 % please help me out..

Hi I write a test class its covered 83 but i need to cover 85 can u please helpme out....
below are the classes.
--------------
class:
----------
public with sharing class GE_PRM_SubDealer_Class {
 //** Variable declarations
    public String errorMessage {get;set;}
    public string schannelAppId;
    public string sBranchId;
    public Sub_Dealer__c branchOfficeObj {get; set;}
    private final Sub_Dealer__c branchOffice;
    public Id userId;
    public Id userprofileId;
    public boolean bpartnerUser{get;set;}
    public List<Profile> parnerprof = new List<Profile>();
    public string isnew_SB_from_URL;
    public Sub_Dealer__c newBO;
    public string Cloneyes;

    //** constructor
    public GE_PRM_SubDealer_Class(ApexPages.StandardController controller) 
    {       
        isnew_SB_from_URL = ApexPages.currentPage().getParameters().get('isNew');
        schannelAppId = ApexPages.currentPage().getParameters().get('ChannelAppointmentId');
        sBranchId = ApexPages.currentPage().getParameters().get('Id');
        this.branchOffice = (Sub_Dealer__c)controller.getRecord();  
        userId= UserInfo.getUserId();  
        userprofileId = UserInfo.getProfileId();
        bpartnerUser=false;
        parnerprof = [Select Id from Profile where Name in ('Channel Partner DR/VAR/Reseller user','Channel Partner Leader user - DR','Channel Partner Leader user - SR','Channel Partner Sales Rep user')];
        for(Profile p : parnerprof)
        {
            if(p.id==userprofileId)
            {
                bpartnerUser=true; 
            }
        }
        branchOfficeObj =   [select Id, GE_PRM_Unique_Id__c,GE_PRM_Affiliate_dependent_type__c,         
                             GE_PRM_Address_line_1__c,  
                             GE_PRM_Address_line_2__c,
                             GE_PRM_Authorized_commercial_lines__c,
                             GE_PRM_Channel_Appointment__c,
                             GE_PRM_City__c,
                             GE_PRM_City_of_registration__c,                 
                             GE_PRM_Country__c,
                             GE_PRM_Email__c,
                             GE_PRM_Legal_name__c,
                             GE_PRM_Mobile__c,
                             GE_PRM_Ownership__c,
                             GE_PRM_Phone__c,     
                             GE_PRM_Postal_code__c,
                             GE_PRM_Prinicipal_Conatct_Text__c
                             from Sub_Dealer__c where id=:sBranchId];
    }
    //** saving subdealer details
    public PageReference saveSubDealerDetails()
    { 
        Cloneyes = ApexPages.currentPage().getParameters().get('clone'); 
       // isadditonal_CL_from_url=ApexPages.currentPage().getParameters().get('isadditonal');
        // clicked on Commercial line Clone 
        if(Cloneyes !=null){            
            newBO = branchOfficeObj.clone(false,true);
            newBO.GE_PRM_Channel_Appointment__c=schannelAppId;        
            insert newBO;
            System.debug('new branchoffice'+newBO);            
        }
        errorMessage = '';
        try
        {
            update branchOffice;            
        }
        catch(Exception e)
        {
            errorMessage = 'Please Fill in Required Detail';
        }
        if(errorMessage.length() >1)
        {   
            return null;
        } 
        else
        {
            PageReference pageRef;
            pageRef = new PageReference('/apex/GE_PRM_Channel_Appointment_page1?Id='+schannelAppId+'#BranchOffice');
            if(bpartnerUser)
                pageRef = new PageReference('/apex/GE_PRM_PartnerViewChannel_Appointment?Id='+schannelAppId+'&sfdc.override=1');
            return pageRef;         
        }
    }
    //** method to redirect to channel appointment page
    public PageReference backToChApp()
    {
        PageReference updChApp=new PageReference('/apex/GE_PRM_Channel_Appointment_View_Page1?Id='+schannelAppId);
        
        if(bpartnerUser)
            updChApp= new PageReference('/apex/GE_PRM_PartnerView_ChApp_page?Id='+schannelAppId+'&sfdc.override=1');
        updChApp.setRedirect(True); 
        return updChApp;
    }
    public PageReference cancel() {
        PageReference pageRef;
        try{
            system.debug('true from url'+isnew_SB_from_URL  ); system.debug('before delete'+branchOffice);
            if(isnew_SB_from_URL == 'true'){
                delete branchOffice;
            }             
            system.debug('after delete'+branchOffice);
            pageRef = new PageReference('/apex/GE_PRM_Channel_Appointment_Page1?Id='+schannelAppId);
            return pageRef;
        }   
        catch(Exception e){
            system.debug('true from url'+isnew_SB_from_URL  ); system.debug('delete'+branchOffice);
            pageRef = new PageReference('/apex/GE_PRM_Channel_Appointment_Page1?Id='+schannelAppId);
            return pageRef;
        }
    }        
}

Testclass:
---------------------
@istest
  public with sharing class GE_PRM_SubDealer_Class_test {
  
  static testMethod  void Testsubdealerclass(){
        Test.StartTest();
        
         Profile p = [select id from profile where name='GE_PRM_Channel_Manager'];
        
        
       User terec = new User();
       terec.firstname = 'test';
       terec.lastname = 'record';
       terec.email = 'testrecord@ge.com';
       terec.alias = 'trecord';
       terec.profileId = p.id;
       terec.Title = 'test record';
       terec.Username = 'testrecord@ge.com';
       terec.CommunityNickname = 'trec';
       terec.TimeZoneSidKey = 'America/New_York';
       terec.LocaleSidKey = 'en_US';
       terec.EmailEncodingKey= 'ISO-8859-1';
       terec.LanguageLocaleKey= 'en_US';
       
        insert terec;
        
             
            List<GE_PRM_Channel_Appointment__c > ChAppList = new List<GE_PRM_Channel_Appointment__c >();
            
                      
            RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='CMF Approved' Limit 1];          
            account acc= new account();
            acc.name= 'newaccount';
            acc.recordtype = rt;
            insert acc;
            
            GE_PRM_Channel_Appointment__c ChannelApp = new GE_PRM_Channel_Appointment__c();
            ChannelApp.GE_PRM_Account_Name__c=acc.id;
            ChannelApp.GE_PRM_Current_Status__c= 'Approved'; 
            ChannelApp.GE_PRM_Master_appointment_type__c ='New';
            ChannelApp.GE_PRM_Primary_bank_account_country__c = 'INDIA';
            ChannelApp.GE_PRM_Primary_bank_name_address__c = 'test12';
            ChannelApp.GE_PRM_Primary_bank_contact__c = 'test21';
            ChannelApp.GE_PRM_Primary_bank_account__c = 'test12';
            ChannelApp.GE_PRM_Payment_term_requested__c= '21';
            ChannelApp.GE_PRM_Commercial_quali_rationale__c='fghdd';
            ChannelApp.GE_PRM_Prior_growth_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_commission_paid__c='New';
            ChannelApp.GE_PRM_Prior_performance_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_orders__c = '<$100K';
            ChannelApp.GE_PRM_With_GE_since__c = 0;
            ChannelApp.GE_PRM_In_Business_Since__c = Date.today();
            ChannelApp.GE_PRM_Mandated_by_End_Customer__c = 'No';
            ChannelApp.GE_PRM_Convicted_of_any_felony_crims_r_s__c= 'No';
            ChannelApp.GE_PRM_Do_you_have_Officers_in_Gov__c= 'No';
            ChannelApp.GE_PRM_High_Risk_product_lines__c= 'No';
            ChannelApp.GE_PRM_Sell_to_Nuclear_industry__c= 'No';
            ChannelApp.GE_PRM_Des_Chnl_Partner_hv_sb_dea_sbagnt__c= 'No';
            ChannelApp.GE_PRM_Does_Channel_Partner_have_subsid__c= 'No';
            ChannelApp.GE_PRM_Export_Controlled_products__c= 'No';
            ChannelApp.GE_PRM_Export_outside_own_country__c= 'No';
            ChannelApp.GE_PRM_Approved_exclusivity_from_P_L__c= 'No';
            ChannelApp.GE_PRM_Primary_Sales_Channel_Manager__c=terec.id;
            ChannelApp.GE_PRM_Region_Sales_Channel_Leader__c=terec.id;       
            ChannelApp.GE_PRM_Tier_2_P_L__c='Measurement & Control (M&C)';
            insert ChannelApp; 
            System.assertEquals(ChannelApp.GE_PRM_Tier_2_P_L__c,'Measurement & Control (M&C)');  
            Sub_Dealer__c subdeal = new Sub_Dealer__c();
            subdeal.GE_PRM_Affiliate_dependent_type__c='Sub-Dealer';
            subdeal.GE_PRM_Authorized_commercial_lines__c='commercial';
            subdeal.GE_PRM_Channel_Appointment__c=ChannelApp.id;            
            subdeal.GE_PRM_City__c='aa';                
            subdeal.GE_PRM_City_of_registration__c='aa';                
            subdeal.GE_PRM_Country__c='UNITED STATES';              
            subdeal.GE_PRM_Email__c='test@test.com';
            subdeal.GE_PRM_Legal_name__c='test';             
            subdeal.GE_PRM_Mobile__c='123456789';     
            subdeal.GE_PRM_Ownership__c=50;              
            subdeal.GE_PRM_Phone__c='123456789';     
            subdeal.GE_PRM_Postal_code__c='1';             
            subdeal.GE_PRM_Prinicipal_Conatct_Text__c='test';         
            insert subdeal; 
            System.assertEquals(subdeal.GE_PRM_Prinicipal_Conatct_Text__c,'test');  
       
            Apexpages.currentpage().getparameters().put('id' ,subdeal.id);  
            Apexpages.currentpage().getparameters().put('Clone' ,'true');
            Apexpages.currentpage().getparameters().put('isNew' ,'true');  
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'true');
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'false');
            Apexpages.currentpage().getparameters().put('ChannelAppointmentId' ,ChannelApp.id);
            GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
            controller.saveSubDealerDetails();
            controller.backToChApp();
            controller.cancel();
        //}
        Test.StopTest();
    }
--------------------------------------------------
 
Leslie  KismartoniLeslie Kismartoni
I think you might be able to consolidate a few lines from this:
try {
 update branchOffice;            
} catch(Exception e) {
 errorMessage = 'Please Fill in Required Detail';
}

if(errorMessage.length() >1) {   
 return null;
} else {
 PageReference pageRef;
 pageRef = new PageReference('/apex/GE_PRM_Channel_Appointment_page1?Id='+schannelAppId+'#BranchOffice');
 if(bpartnerUser)
  pageRef = new PageReference('/apex/GE_PRM_PartnerViewChannel_Appointment?Id='+schannelAppId+'&sfdc.override=1');

 return pageRef;         
}

to something more concise
 
try { 
    update branchOffice; 
} catch(Exception e) { 
    errorMessage = 'Please Fill in Required Detail'; return null; 
}

 if(bpartnerUser)
    return PageReference('/apex/GE_PRM_PartnerViewChannel_Appointment?Id='+schannelAppId+'&sfdc.override=1');

 return PageReference('/apex/GE_PRM_Channel_Appointment_page1?Id='+schannelAppId+'#BranchOffice');;         
}

That removes a few lines, but might make it a bit easier since it removes some unnecessary branching...

You might also be able to return the page Reference directly during the exceptional case in "cancel" too... 

(Sorry if I forgot any "new" keywords ... just eyballing this.)

 
ManojjenaManojjena
Hi Venkat ,
please add two unit test with your test class and let me know if it helps
 
static testMethod  void negetiveTestCase(){
	 Sub_Dealer__c subdeal = new Sub_Dealer__c();
	  GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
	   controller.cancel();
	}
	static testMethod  void negetiveTestCaseOne(){
	 Sub_Dealer__c subdeal = new Sub_Dealer__c();
	  GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
	   controller.saveSubDealerDetails();
	}

Thnaks

Manoj

 

FrescoFresco
Hi manoj,

One method is already there , again i need to add one more method or 2 methods?
can you please cahnge the code and reply me please its urjent//
ManojjenaManojjena
HI venkat ,
Add first one and check the result ,then add second on e,I have given the code basically to cover catch block .

Try and let me know .
 
Leslie  KismartoniLeslie Kismartoni
Sorry man... I'm limited (phone) right now... 

 
ManojjenaManojjena
HI Vankat ,

Add one more test method in test class ,the code I have given and run test an dlet me know any changes .

 
ManojjenaManojjena
Ok try with below .
 
Testclass:
---------------------
@istest
  public with sharing class GE_PRM_SubDealer_Class_test {
  
  static testMethod  void Testsubdealerclass(){
        Test.StartTest();
        
         Profile p = [select id from profile where name='GE_PRM_Channel_Manager'];
        
        
       User terec = new User();
       terec.firstname = 'test';
       terec.lastname = 'record';
       terec.email = 'testrecord@ge.com';
       terec.alias = 'trecord';
       terec.profileId = p.id;
       terec.Title = 'test record';
       terec.Username = 'testrecord@ge.com';
       terec.CommunityNickname = 'trec';
       terec.TimeZoneSidKey = 'America/New_York';
       terec.LocaleSidKey = 'en_US';
       terec.EmailEncodingKey= 'ISO-8859-1';
       terec.LanguageLocaleKey= 'en_US';
       
        insert terec;
        
             
            List<GE_PRM_Channel_Appointment__c > ChAppList = new List<GE_PRM_Channel_Appointment__c >();
            
                      
            RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='CMF Approved' Limit 1];          
            account acc= new account();
            acc.name= 'newaccount';
            acc.recordtype = rt;
            insert acc;
            
            GE_PRM_Channel_Appointment__c ChannelApp = new GE_PRM_Channel_Appointment__c();
            ChannelApp.GE_PRM_Account_Name__c=acc.id;
            ChannelApp.GE_PRM_Current_Status__c= 'Approved'; 
            ChannelApp.GE_PRM_Master_appointment_type__c ='New';
            ChannelApp.GE_PRM_Primary_bank_account_country__c = 'INDIA';
            ChannelApp.GE_PRM_Primary_bank_name_address__c = 'test12';
            ChannelApp.GE_PRM_Primary_bank_contact__c = 'test21';
            ChannelApp.GE_PRM_Primary_bank_account__c = 'test12';
            ChannelApp.GE_PRM_Payment_term_requested__c= '21';
            ChannelApp.GE_PRM_Commercial_quali_rationale__c='fghdd';
            ChannelApp.GE_PRM_Prior_growth_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_commission_paid__c='New';
            ChannelApp.GE_PRM_Prior_performance_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_orders__c = '<$100K';
            ChannelApp.GE_PRM_With_GE_since__c = 0;
            ChannelApp.GE_PRM_In_Business_Since__c = Date.today();
            ChannelApp.GE_PRM_Mandated_by_End_Customer__c = 'No';
            ChannelApp.GE_PRM_Convicted_of_any_felony_crims_r_s__c= 'No';
            ChannelApp.GE_PRM_Do_you_have_Officers_in_Gov__c= 'No';
            ChannelApp.GE_PRM_High_Risk_product_lines__c= 'No';
            ChannelApp.GE_PRM_Sell_to_Nuclear_industry__c= 'No';
            ChannelApp.GE_PRM_Des_Chnl_Partner_hv_sb_dea_sbagnt__c= 'No';
            ChannelApp.GE_PRM_Does_Channel_Partner_have_subsid__c= 'No';
            ChannelApp.GE_PRM_Export_Controlled_products__c= 'No';
            ChannelApp.GE_PRM_Export_outside_own_country__c= 'No';
            ChannelApp.GE_PRM_Approved_exclusivity_from_P_L__c= 'No';
            ChannelApp.GE_PRM_Primary_Sales_Channel_Manager__c=terec.id;
            ChannelApp.GE_PRM_Region_Sales_Channel_Leader__c=terec.id;       
            ChannelApp.GE_PRM_Tier_2_P_L__c='Measurement & Control (M&C)';
            insert ChannelApp; 
            System.assertEquals(ChannelApp.GE_PRM_Tier_2_P_L__c,'Measurement & Control (M&C)');  
            Sub_Dealer__c subdeal = new Sub_Dealer__c();
            subdeal.GE_PRM_Affiliate_dependent_type__c='Sub-Dealer';
            subdeal.GE_PRM_Authorized_commercial_lines__c='commercial';
            subdeal.GE_PRM_Channel_Appointment__c=ChannelApp.id;            
            subdeal.GE_PRM_City__c='aa';                
            subdeal.GE_PRM_City_of_registration__c='aa';                
            subdeal.GE_PRM_Country__c='UNITED STATES';              
            subdeal.GE_PRM_Email__c='test@test.com';
            subdeal.GE_PRM_Legal_name__c='test';             
            subdeal.GE_PRM_Mobile__c='123456789';     
            subdeal.GE_PRM_Ownership__c=50;              
            subdeal.GE_PRM_Phone__c='123456789';     
            subdeal.GE_PRM_Postal_code__c='1';             
            subdeal.GE_PRM_Prinicipal_Conatct_Text__c='test';         
            insert subdeal; 
            System.assertEquals(subdeal.GE_PRM_Prinicipal_Conatct_Text__c,'test');  
       
            Apexpages.currentpage().getparameters().put('id' ,subdeal.id);  
            Apexpages.currentpage().getparameters().put('Clone' ,'true');
            Apexpages.currentpage().getparameters().put('isNew' ,'true');  
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'true');
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'false');
            Apexpages.currentpage().getparameters().put('ChannelAppointmentId' ,ChannelApp.id);
            GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
            controller.saveSubDealerDetails();
            controller.backToChApp();
            controller.cancel();
			 Test.StopTest();
        }
       static testMethod  void negetiveTestCase(){
	 Sub_Dealer__c subdeal = new Sub_Dealer__c();
	  GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
	   controller.cancel();
	}
	static testMethod  void negetiveTestCaseOne(){
	 Sub_Dealer__c subdeal = new Sub_Dealer__c();
	  GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
	   controller.saveSubDealerDetails();
	}
 }

 
ManojjenaManojjena
Ok ,can you add two line in your class ,It will not impact your functionality  ?
ManojjenaManojjena
Ok ,Only two line if you add in your class then it will cover catch block .

if(Test.isRunningTest())
     Integer intTest =5/0;   

Check the fisibility ,If you can then let me know I will tell you where you can add .
ManojjenaManojjena
Hi Venkat try with below code it will help !
 
Testclass:
---------------------
@istest
  public with sharing class GE_PRM_SubDealer_Class_test {
  
  static testMethod  void Testsubdealerclass(){
        Test.StartTest();
        
         Profile p = [select id from profile where name='Channel Partner DR/VAR/Reseller user'];
        
        
       User terec = new User();
       terec.firstname = 'test';
       terec.lastname = 'record';
       terec.email = 'testrecord@ge.com';
       terec.alias = 'trecord';
       terec.profileId = p.id;
       terec.Title = 'test record';
       terec.Username = 'testrecord@ge.com';
       terec.CommunityNickname = 'trec';
       terec.TimeZoneSidKey = 'America/New_York';
       terec.LocaleSidKey = 'en_US';
       terec.EmailEncodingKey= 'ISO-8859-1';
       terec.LanguageLocaleKey= 'en_US';
       
        insert terec;
		System.runAs(terec){
        
             
            List<GE_PRM_Channel_Appointment__c > ChAppList = new List<GE_PRM_Channel_Appointment__c >();
            
                      
            RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='CMF Approved' Limit 1];          
            account acc= new account();
            acc.name= 'newaccount';
            acc.recordtype = rt;
            insert acc;
            
            GE_PRM_Channel_Appointment__c ChannelApp = new GE_PRM_Channel_Appointment__c();
            ChannelApp.GE_PRM_Account_Name__c=acc.id;
            ChannelApp.GE_PRM_Current_Status__c= 'Approved'; 
            ChannelApp.GE_PRM_Master_appointment_type__c ='New';
            ChannelApp.GE_PRM_Primary_bank_account_country__c = 'INDIA';
            ChannelApp.GE_PRM_Primary_bank_name_address__c = 'test12';
            ChannelApp.GE_PRM_Primary_bank_contact__c = 'test21';
            ChannelApp.GE_PRM_Primary_bank_account__c = 'test12';
            ChannelApp.GE_PRM_Payment_term_requested__c= '21';
            ChannelApp.GE_PRM_Commercial_quali_rationale__c='fghdd';
            ChannelApp.GE_PRM_Prior_growth_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_commission_paid__c='New';
            ChannelApp.GE_PRM_Prior_performance_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_orders__c = '<$100K';
            ChannelApp.GE_PRM_With_GE_since__c = 0;
            ChannelApp.GE_PRM_In_Business_Since__c = Date.today();
            ChannelApp.GE_PRM_Mandated_by_End_Customer__c = 'No';
            ChannelApp.GE_PRM_Convicted_of_any_felony_crims_r_s__c= 'No';
            ChannelApp.GE_PRM_Do_you_have_Officers_in_Gov__c= 'No';
            ChannelApp.GE_PRM_High_Risk_product_lines__c= 'No';
            ChannelApp.GE_PRM_Sell_to_Nuclear_industry__c= 'No';
            ChannelApp.GE_PRM_Des_Chnl_Partner_hv_sb_dea_sbagnt__c= 'No';
            ChannelApp.GE_PRM_Does_Channel_Partner_have_subsid__c= 'No';
            ChannelApp.GE_PRM_Export_Controlled_products__c= 'No';
            ChannelApp.GE_PRM_Export_outside_own_country__c= 'No';
            ChannelApp.GE_PRM_Approved_exclusivity_from_P_L__c= 'No';
            ChannelApp.GE_PRM_Primary_Sales_Channel_Manager__c=terec.id;
            ChannelApp.GE_PRM_Region_Sales_Channel_Leader__c=terec.id;       
            ChannelApp.GE_PRM_Tier_2_P_L__c='Measurement & Control (M&C)';
            insert ChannelApp; 
            System.assertEquals(ChannelApp.GE_PRM_Tier_2_P_L__c,'Measurement & Control (M&C)');  
            Sub_Dealer__c subdeal = new Sub_Dealer__c();
            subdeal.GE_PRM_Affiliate_dependent_type__c='Sub-Dealer';
            subdeal.GE_PRM_Authorized_commercial_lines__c='commercial';
            subdeal.GE_PRM_Channel_Appointment__c=ChannelApp.id;            
            subdeal.GE_PRM_City__c='aa';                
            subdeal.GE_PRM_City_of_registration__c='aa';                
            subdeal.GE_PRM_Country__c='UNITED STATES';              
            subdeal.GE_PRM_Email__c='test@test.com';
            subdeal.GE_PRM_Legal_name__c='test';             
            subdeal.GE_PRM_Mobile__c='123456789';     
            subdeal.GE_PRM_Ownership__c=50;              
            subdeal.GE_PRM_Phone__c='123456789';     
            subdeal.GE_PRM_Postal_code__c='1';             
            subdeal.GE_PRM_Prinicipal_Conatct_Text__c='test';         
            insert subdeal; 
            System.assertEquals(subdeal.GE_PRM_Prinicipal_Conatct_Text__c,'test');  
       
            Apexpages.currentpage().getparameters().put('id' ,subdeal.id);  
            Apexpages.currentpage().getparameters().put('Clone' ,'true');
            Apexpages.currentpage().getparameters().put('isNew' ,'true');  
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'true');
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'false');
            Apexpages.currentpage().getparameters().put('ChannelAppointmentId' ,ChannelApp.id);
            GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
            controller.saveSubDealerDetails();
            controller.backToChApp();
            controller.cancel();
			 Test.StopTest();
			}
        }
 }
Thnaks
Manoj
 
ManojjenaManojjena
Hi vankat ,

Are you working in community ?
 
ManojjenaManojjena
Hi venkat ,

If you are working on community then try with below code .
Testclass:
---------------------
@istest
  public with sharing class GE_PRM_SubDealer_Class_test {
  
  static testMethod  void Testsubdealerclass(){
        Test.StartTest();
		Account acc=new Account();
		acc.Name='TestAccount';
		Insert acc;
		Contact con=new Contact();
		con.Accountid=acc.Id;
		con.LastName='TestContact';
		Insert con;
        
         Profile p = [select id from profile where name='Channel Partner DR/VAR/Reseller user'];
        
        
       User terec = new User();
       terec.firstname = 'test';
       terec.lastname = 'record';
       terec.email = 'testrecord@ge.com';
       terec.alias = 'trecord';
       terec.profileId = p.id;
       terec.Title = 'test record';
       terec.Username = 'testrecord@ge.com';
	   terec.ContactId=con.Id;
       terec.CommunityNickname = 'trec';
       terec.TimeZoneSidKey = 'America/New_York';
       terec.LocaleSidKey = 'en_US';
       terec.EmailEncodingKey= 'ISO-8859-1';
       terec.LanguageLocaleKey= 'en_US';
       
        insert terec;
		System.runAs(terec){
        
             
            List<GE_PRM_Channel_Appointment__c > ChAppList = new List<GE_PRM_Channel_Appointment__c >();
            
                      
            RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='CMF Approved' Limit 1];          
            account acc= new account();
            acc.name= 'newaccount';
            acc.recordtype = rt;
            insert acc;
            
            GE_PRM_Channel_Appointment__c ChannelApp = new GE_PRM_Channel_Appointment__c();
            ChannelApp.GE_PRM_Account_Name__c=acc.id;
            ChannelApp.GE_PRM_Current_Status__c= 'Approved'; 
            ChannelApp.GE_PRM_Master_appointment_type__c ='New';
            ChannelApp.GE_PRM_Primary_bank_account_country__c = 'INDIA';
            ChannelApp.GE_PRM_Primary_bank_name_address__c = 'test12';
            ChannelApp.GE_PRM_Primary_bank_contact__c = 'test21';
            ChannelApp.GE_PRM_Primary_bank_account__c = 'test12';
            ChannelApp.GE_PRM_Payment_term_requested__c= '21';
            ChannelApp.GE_PRM_Commercial_quali_rationale__c='fghdd';
            ChannelApp.GE_PRM_Prior_growth_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_commission_paid__c='New';
            ChannelApp.GE_PRM_Prior_performance_rating__c = 'Medium';
            ChannelApp.GE_PRM_Prior_year_orders__c = '<$100K';
            ChannelApp.GE_PRM_With_GE_since__c = 0;
            ChannelApp.GE_PRM_In_Business_Since__c = Date.today();
            ChannelApp.GE_PRM_Mandated_by_End_Customer__c = 'No';
            ChannelApp.GE_PRM_Convicted_of_any_felony_crims_r_s__c= 'No';
            ChannelApp.GE_PRM_Do_you_have_Officers_in_Gov__c= 'No';
            ChannelApp.GE_PRM_High_Risk_product_lines__c= 'No';
            ChannelApp.GE_PRM_Sell_to_Nuclear_industry__c= 'No';
            ChannelApp.GE_PRM_Des_Chnl_Partner_hv_sb_dea_sbagnt__c= 'No';
            ChannelApp.GE_PRM_Does_Channel_Partner_have_subsid__c= 'No';
            ChannelApp.GE_PRM_Export_Controlled_products__c= 'No';
            ChannelApp.GE_PRM_Export_outside_own_country__c= 'No';
            ChannelApp.GE_PRM_Approved_exclusivity_from_P_L__c= 'No';
            ChannelApp.GE_PRM_Primary_Sales_Channel_Manager__c=terec.id;
            ChannelApp.GE_PRM_Region_Sales_Channel_Leader__c=terec.id;       
            ChannelApp.GE_PRM_Tier_2_P_L__c='Measurement & Control (M&C)';
            insert ChannelApp; 
            System.assertEquals(ChannelApp.GE_PRM_Tier_2_P_L__c,'Measurement & Control (M&C)');  
            Sub_Dealer__c subdeal = new Sub_Dealer__c();
            subdeal.GE_PRM_Affiliate_dependent_type__c='Sub-Dealer';
            subdeal.GE_PRM_Authorized_commercial_lines__c='commercial';
            subdeal.GE_PRM_Channel_Appointment__c=ChannelApp.id;            
            subdeal.GE_PRM_City__c='aa';                
            subdeal.GE_PRM_City_of_registration__c='aa';                
            subdeal.GE_PRM_Country__c='UNITED STATES';              
            subdeal.GE_PRM_Email__c='test@test.com';
            subdeal.GE_PRM_Legal_name__c='test';             
            subdeal.GE_PRM_Mobile__c='123456789';     
            subdeal.GE_PRM_Ownership__c=50;              
            subdeal.GE_PRM_Phone__c='123456789';     
            subdeal.GE_PRM_Postal_code__c='1';             
            subdeal.GE_PRM_Prinicipal_Conatct_Text__c='test';         
            insert subdeal; 
            System.assertEquals(subdeal.GE_PRM_Prinicipal_Conatct_Text__c,'test');  
       
            Apexpages.currentpage().getparameters().put('id' ,subdeal.id);  
            Apexpages.currentpage().getparameters().put('Clone' ,'true');
            Apexpages.currentpage().getparameters().put('isNew' ,'true');  
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'true');
            Apexpages.currentpage().getparameters().put('bpartnerUser' ,'false');
            Apexpages.currentpage().getparameters().put('ChannelAppointmentId' ,ChannelApp.id);
            GE_PRM_SubDealer_Class controller=new GE_PRM_SubDealer_Class(new ApexPages.StandardController(subdeal));
            controller.saveSubDealerDetails();
            controller.backToChApp();
            controller.cancel();
			 Test.StopTest();
			}
        }
 }
In case any mandatory fields in account and contact then please add those to your test class .

Thnaks
Manoj