+ Start a Discussion
sfg1sfg1 

Code coverage for Controller and Extensions

I have controller(PScRMAExtension_v1) with 3 extensions PScRMAExtension,PScRMATypeLTExtension and PScRMATypeStockedPARExtension declared in Constructors. please guide me in writing test class.

public class PScRMAExtension_v1 {
    public string RMAType{get;set;}
    public string type{get;set;}
    public string type1{get;set;}
    public PScRMAExtension objAdv {get;set;}
    public list<PScRMAExtWrapper> objWrap{get;set;}
    public PScRMATypeLTExtension objLT {get;set;}
    public PScRMATypeStockedPARExtension objSP {get;set;}
    public List<selectOption> typeList
    {
        get
        {
            typeList = new List<selectOption>();
            typeList.add(new selectOption('', '--None--'));
            typeList.add(new selectOption('Advance Exchange', 'Advance Exchange'));
            typeList.add(new selectOption('Depot Repair', 'Depot Repair'));
            typeList.add(new selectOption('License Transfer', 'License Transfer'));
            typeList.add(new selectOption('Receive Only', 'Receive Only'));
            typeList.add(new selectOption('Ship Only', 'Ship Only'));
            typeList.add(new selectOption('Stocked At PAR', 'Stocked At PAR'));
            return typeList;
        }
        set;
    }
    public PScRMAExtension_v1(){
        system.debug('I m calling const1');
        type1 = 'Being Null';
    }
        public PScRMAExtension_v1(PScRMAExtension objAdext){
       objAdv = new PScRMAExtension(this);
    }
        public PScRMAExtension_v1(PScRMATypeLTExtension objLText){
       objLT = new PScRMATypeLTExtension(this);
    }
        public PScRMAExtension_v1(PScRMATypeStockedPARExtension objSPPext){
        objSP = new PScRMATypeStockedPARExtension(this);
    }
        public PScRMAExtension_v1(ApexPages.StandardController controller)
    {
    }
        public void viewLineItem_SP()
    {
        system.debug('$$$ <PScRMAExtension::viewLineItem_SP>');
        if(objSP.view_line_item_id_SP != null)
        {
            system.debug('$$$ view_line_item_id_SP: ' + objSP.view_line_item_id_SP);
            system.debug('$$$ RMA Wrapper: ' + objSP.RMA_line_item_wrapper_list.size());
            if(objSP.RMA_line_item_wrapper_list != null && objSP.RMA_line_item_wrapper_list.size()>0){
              objSP.view_line_item_obj_SP = objSP.RMA_line_item_wrapper_list.get(objSP.view_line_item_id_SP).RMA_line_items;
              system.debug('$$$ view_line_item_obj_SP: ' + objSP.view_line_item_obj_SP);
            }
        }
    }
    public void viewLineItem_LT()
    {
        system.debug('$$$ <PScRMAExtension::viewLineItem_LT>:'+objLT.view_line_item_id);
        system.debug('$$$ RMA Wrapper: ' + objLT.RMA_line_item_wrapper_list.size());
        if(objLT.view_line_item_id != null)
        {
            objLT.view_line_item_obj = objLT.RMA_line_item_wrapper_list.get(objLT.view_line_item_id).RMA_line_items;
            system.debug('$$$ view_line_item_obj_LT: ' + objLT.view_line_item_obj);
        }
    }
   public void viewLineItem_AE()
    {
        system.debug('$$$ <PScRMAExtension::viewLineItem_AE>');
        if(objAdv.view_line_item_id != null)
        {
            objAdv.view_line_item_obj = objAdv.RMA_line_item_wrapper_list.get(objAdv.view_line_item_id).RMA_line_items;
            system.debug('$$$ view_line_item_obj_Adv: ' + objAdv.view_line_item_obj);
        }
    }
    public void switchPanel(){
        if(RMAtype == 'Advance Exchange'){
          objAdv = new PScRMAExtension(new PScRMAExtension_v1());
        }else if(RMAtype == 'License Transfer'){
            objLT = new PScRMATypeLTExtension(new PScRMAExtension_v1());
        }else if(RMAtype == 'Stocked At PAR'){
            objSP = new PScRMATypeStockedPARExtension(new PScRMAExtension_v1());
        }
    } 
    public class PScRMAExtWrapper
    {
        //Wrapper class variable initialization
        public RMA_Line_Items__c RMA_line_items { get; set; }    //public variable for rma line item
        public Integer line_item_no { get; set; }
        /*
        *Wrapper class constructor
        */
        public PScRMAExtWrapper()
        {
        }
    }
        public void saveMainClass (List<PScRMATypeStockedPARExtension.PScRMALineItemsWrapper> objRM){
        system.debug('Main Class:'+objRM);
        type1 = 'Being Null by me';
        list<PScRMAExtWrapper> objWrap = new list<PScRMAExtWrapper>();
        PScRMAExtWrapper objW = new PScRMAExtWrapper();
        if(objRM != null && objRM.size()>0){
            for(PScRMATypeStockedPARExtension.PScRMALineItemsWrapper RM: objRM){
              objW.line_item_no = RM.line_item_no;
              objW.RMA_line_items = RM.RMA_line_items;
                objWrap.add(objW);
            }
        }
        system.debug('Main class wrapper:'+objWrap);
    }

}
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for test class. I hope that will help you
1) http://amitsalesforce.blogspot.in/search/label/Test%20Class
2) http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html

Please try below code.
@isTest 
public class ExtensionTestClass 
{
	static testMethod void testMethod1() 
	{
		Account testAccount = new Account();
		testAccount.Name='Test Account' ;
		insert testAccount;

		Test.StartTest(); 
		
			PScRMAExtension_v1 obj = new PScRMAExtension_v1();
			List<selectOption> lst = obj.getTypeList();
			obj.viewLineItem_SP();
			obj.viewLineItem_LT();
			obj.viewLineItem_AE();
			obj.viewLineItem_AE();
			obj.RMAtype = 'Advance Exchange' ;
			obj.switchPanel();
			
			obj.RMAtype = 'License Transfer' ;
			obj.switchPanel();

			obj.RMAtype = 'Stocked At PAR' ;
			obj.switchPanel();

			try
			{
				ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
				PScRMAExtension_v1 obj1 = new PScRMAExtension_v1(sc);
				
				PScRMAExtension objAdext = new PScRMAExtension();
				PScRMAExtension_v1 obj2 = new PScRMAExtension_v1(objAdext);
				
				PScRMATypeLTExtension objLText= new PScRMATypeLTExtension();
				PScRMAExtension_v1 obj3 = new PScRMAExtension_v1(objLText);
				
				PScRMATypeStockedPARExtension objSPPext= new PScRMATypeStockedPARExtension();
				PScRMAExtension_v1 obj4 = new PScRMAExtension_v1(objSPPext);

				
			}
			catch(Exception ee)
			{
			}	
		Test.StopTest();
	}
}

Please follow below salesforce Best Practice for Test Classes :-

1. Test class must start with @isTest annotation if class class version is more than 25
2. Test environment support @testVisible , @testSetUp as well
3. Unit test is to test particular piece of code working properly or not .
4. Unit test method takes no argument ,commit no data to database ,send no email ,flagged with testMethod keyword .
5. To deploy to production at-least 75% code coverage is required
6. System.debug statement are not counted as a part of apex code limit.
7. Test method and test classes are not counted as a part of code limit
9. We should not focus on the  percentage of code coverage ,we should make sure that every use case should covered including positive, negative,bulk and single record .
Single Action -To verify that the the single record produces the correct an expected result .
Bulk action -Any apex record trigger ,class or extension must be invoked for 1-200 records .
Positive behavior : Test every expected behavior occurs through every expected permutation , i,e user filled out every correctly data and not go past the limit .
Negative Testcase :-Not to add future date , Not to specify negative amount.
Restricted User :-Test whether a user with restricted access used in your code .
10. Test class should be annotated with @isTest .
11 . @isTest annotation with test method  is equivalent to testMethod keyword .
12. Test method should static and no void return type .
13. Test class and method default access is private ,no matter to add access specifier .
14. classes with @isTest annotation can't be a interface or enum .
15. Test method code can't be invoked by non test request .
16. Stating with salesforce API 28.0 test method can not reside inside non test classes .
17. @Testvisible annotation to make visible private methods inside test classes.
18. Test method can not be used to test web-service call out . Please use call out mock .
19. You can't  send email from test method.
20.User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent ,ApexPage we can access without (seeAllData=true) .
21. SeeAllData=true will not work for API 23 version eailer .
22. Accessing static resource test records in test class e,g List<Account> accList=Test.loadData(Account,SobjectType,'ResourceName').
23. Create TestFactory class with @isTest annotation to exclude from organization code size limit .
24. @testSetup to create test records once in a method  and use in every test method in the test class .
25. We can run unit test by using Salesforce Standard UI,Force.com IDE ,Console ,API.
26. Maximum number of test classes run per 24 hour of period is  not grater of 500 or 10 multiplication of test classes of your organization.
27. As apex runs in system mode so the permission and record sharing are not taken into account . So we need to use system.runAs to enforce record sharing .
28. System.runAs will not enforce user permission or field level permission .
29. Every test to runAs count against the total number of DML issued in the process .


Please let us know if this post will help you
 
sfg1sfg1
Thanks Amit. But i am getting error 'Compile Error: Method does not exist or incorrect signature: [PScRMAExtension_v1].getTypeList() at line 13 column 38'
Kindly explain me use of ' List<selectOption> lst = obj.getTypeList();'
sfg1sfg1
Hi Amit,
Still i am getting error "Error: Compile Error: Method does not exist or incorrect signature: [PScRMAExtension_v1].typeList() at line".
even if i comment that line, i am unable to save the class.Getting another error "
Error: Compile Error: Constructor not defined: [PScRMAExtension].<Constructor>()". 
Please guide me.Thanks.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code.
@isTest 
public class ExtensionTestClass 
{
	static testMethod void testMethod1() 
	{
		Account testAccount = new Account();
		testAccount.Name='Test Account' ;
		insert testAccount;

		Test.StartTest(); 
		
			PScRMAExtension_v1 obj = new PScRMAExtension_v1();
			List<selectOption> lst = obj.typeList;
			obj.viewLineItem_SP();
			obj.viewLineItem_LT();
			obj.viewLineItem_AE();
			obj.viewLineItem_AE();
			obj.RMAtype = 'Advance Exchange' ;
			obj.switchPanel();
			
			obj.RMAtype = 'License Transfer' ;
			obj.switchPanel();

			obj.RMAtype = 'Stocked At PAR' ;
			obj.switchPanel();

			try
			{
				ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
				PScRMAExtension_v1 obj1 = new PScRMAExtension_v1(sc);
				
				PScRMAExtension objAdext = new PScRMAExtension(this);
				PScRMAExtension_v1 obj2 = new PScRMAExtension_v1(objAdext);
				
				PScRMATypeLTExtension objLText= new PScRMATypeLTExtension(this);
				PScRMAExtension_v1 obj3 = new PScRMAExtension_v1(objLText);
				
				PScRMATypeStockedPARExtension objSPPext= new PScRMATypeStockedPARExtension(this);
				PScRMAExtension_v1 obj4 = new PScRMAExtension_v1(objSPPext);

				
			}
			catch(Exception ee)
			{
			}	
		Test.StopTest();
	}
}
if above code will not work then please post code of "PScRMAExtension" ,"PScRMATypeLTExtension" and "PScRMATypeStockedPARExtension" classes

 
sfg1sfg1
Hi Amit,
Still i am getting errors.i am unable to paste my code, because it is more than 32000 characters. Please ping me ur mailid to dhana.gowd@gmail.com. Thanks.
sfg1sfg1
Hi Amit,
By following ur blog i have covered 60% for extension controller 'PScRMAExtension'. Can you please guide me to cover the code for the below constructor. So that i can increase  more %.
  /*
    *Class constructor
    */
    public PScRMAExtension(PScRMAExtension_v1 objext)
    {
        system.debug('$$$ <PScRMAExtension::PScRMAExtension>');
        parent_case_id = ApexPages.currentPage().getParameters().get('id');
        //parent_case_id = '50011000008KcEV';
        //currentInstance = this;
        //case_list = (Case)controller.getRecord();
        RMALineItemCnt = 0;
        show_RMA_list = FALSE;
        showAdvanceExchange = FALSE;
        show_flash_alert = FALSE;
        show_expired_contract_alert = FALSE;
        accept_expired_contact = FALSE;
        show_case_detail = FALSE;
        show_fru_detail = FALSE;
        asset_exists = FALSE;
        show_cli_grid = FALSE;
        show_asset_grid = TRUE;
        disable_save_btn = FALSE;
        show_add_line_item = FALSE;
        show_expired_Asset_alert =FALSE;
        isRMASLASameDay = false;
        isshowassetExipre=FALSE;
        isshowRMAexits =FALSE;
       
        //show_replacement_part_confirmation = FALSE;
        //accept_replacement_part = FALSE;

        RMA_line_item_wrapper_list = new List<PScRMALineItemsWrapper>();
        new_line_item_obj = new RMA_Line_Items__c();
        RMA_line_item_list = new List<RMA_Line_Items__c>();
        view_line_item_obj = new RMA_Line_Items__c();
        line_save_text = 'Add Line Item';
        obj_line_item_tosave = new List<RMA_Line_Items__c>();

        rmaAssignedRtName = '';
        primaryOwnerFld = '';
        secondaryOwnerFld = '';
        default_country = 'United States';

        //replacement_part_error_msg = '';
        system.debug('show_add_line_item1' + show_add_line_item);

        //stateList = new List<selectOption>();
        //stateList.add(new selectOption('', '--None--'));

        //system.debug('$$$ parent_case_id: ' + parent_case_id);
        if(parent_case_list == null)
        {
            parent_case_list = [ SELECT Account.Name, Account.Company_Name__c, Account.ShippingStreet, Account.ShippingCity, Account.ShippingState, Account.ShippingCountry, Account.ShippingPostalCode, Account.Phone, Account.Email__c, Contact.Name, Contact.MailingStreet, Contact.MailingCity, Contact.MailingState, Contact.MailingCountry, Contact.MailingPostalCode, Contact.Phone, Contact.Email, AccountId, ContactId, AssetId, CaseNumber, Subject, Description, Status, Priority, Severity__c, Serial_No__c, Platform__c, Product_Series__c, Ship_To_Account__c FROM Case WHERE Id = :parent_case_id ];
            account_id = parent_case_list.AccountId;
            asset_serial_no = parent_case_list.Serial_No__c;

            if(parent_case_list.Account.Company_Name__c != null)
            {
                account_name = parent_case_list.Account.Company_Name__c;
            }
            else
            {
                account_name = parent_case_list.Account.Name;
            }

            populateIB();
        }
        system.debug('$$$ parent_case_list: ' + parent_case_list);

        List<CreateCaseRT__c> ccRtList = CreateCaseRT__c.getAll().values();
        if(ccRtList.size() > 0)
        {
            for(CreateCaseRT__c t : ccRtList)
            {
                if(t.Case_Trans_Type__c == system.label.RMA_Transaction_Type)
                {
                    rmaAssignedRtName = t.Name;
                }
            }
        }

        getFlashAlerts();
        RMALineItemDetails();
        getReplacementPart();
        getRMALineItemCnt();
        
        system.debug('in PScRMAExtension show_cli_grid ' + show_cli_grid);
        system.debug('in PScRMAExtension show_asset_grid ' + show_asset_grid);
    }
sfg1sfg1
@isTest 
public class TestPScRMAExtension {

    static testMethod Case unitTestCase()
    {
        Account acc = (Account)TestFactory.createSObject(new Account(), true);
        Contact cnt = (Contact) TestFactory.createSObject(new Contact(AccountID = acc.Id), true);
        Product2 prd = (Product2) TestFactory.createSObject(new Product2(), true);
        Id pricebookId = Test.getStandardPricebookId();

        Asset ass = (Asset) TestFactory.createSObject(new Asset(AccountId = acc.Id, Product2Id = prd.Id, Bill_To_Account__c = acc.Id), true);
        ServiceContract sc = (ServiceContract) TestFactory.createSObject(new ServiceContract(AccountId = acc.Id,Pricebook2Id = pricebookId,StartDate = System.today(), EndDate = System.today()), true);
        ContractLineItem cli = (ContractLineItem) TestFactory.createSObject(new ContractLineItem(assetId = ass.Id, ServiceContractId = sc.Id, Item__c = prd.Id), true);

        Case_Alert__c alrt = (Case_Alert__c)TestFactory.createSObject(new Case_Alert__c(Account__c = acc.Id, Alert__c = 'Allow Coutresy Case', Start_Date__c = System.today(),End_Date__c = System.today().addDays(2)), true);

        TestFactory.createRecordType();
        TestFactory.createQueue();
        TestFactory.createWorkGroup();
        TestFactory.csCreateCaseRT();

        Case cse = (Case) TestFactory.createSObject(new Case(AccountId = acc.Id, ContactId = cnt.Id, AssetId = ass.Id, Contract_Line_Item__c = cli.Id, Service_Contract__c = sc.Id), true);

        return cse;
    }
    static testMethod void unitTestAssetError()
    {
        Test.startTest();
        Account acc = (Account)TestFactory.createSObject(new Account(Company_Name__c = ''), true);
        Contact cnt = (Contact) TestFactory.createSObject(new Contact(AccountID = acc.Id), true);
        TestFactory.createWorkGroup();
        Case cse = (Case) TestFactory.createSObject(new Case(AccountId = acc.Id, ContactId = cnt.Id), true);
        ApexPages.currentPage().getParameters().put('id', cse.id);

        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);
        rmaExt.asset_exists = false;
        rmaExt.validateFields();

        Test.stopTest();
    }

    static testMethod void unitTestRMACaseValidation()
    {
        Test.startTest();
        Case cse = unitTestCaseOther();

        ApexPages.currentPage().getParameters().put('id', cse.id);
        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);
        rmaExt.RMA_line_item_wrapper_list = new List<PScRMAExtension.PScRMALineItemsWrapper>();

        rmaExt.case_list = new case();
        rmaExt.new_line_item_obj = new RMA_Line_Items__c();
        rmaExt.RMA_line_item_list = new List<RMA_Line_Items__c>();

        rmaExt.asset_exists = true;
        rmaExt.case_list.Is_CE_Required__c = true;

        rmaExt.acceptExpiredContactRMA_AD();
        rmaExt.getRMALineItemCnt();
        rmaExt.getLineItemWrapperCnt();
        rmaExt.addLineItem();
   //     rmaExt.viewLineItem();
        rmaExt.clearLineItem();
        rmaExt.cancel();
        
        rmaExt.saveCeInfo();
        rmaExt.save();
    
        rmaExt.case_list.RMA_SLA__c = 'AR5';
        rmaExt.case_list.Shipping_Customer_E_Mail__c = 'test@test.com,test1';
        rmaExt.save();

        Profile P = [select Name from Profile where Name = 'System Administrator' Limit 1];
        User usr = (User)TestFactory.createSObject(new User(ProfileId = P.Id), true);
        
        rmaExt.primaryOwnerFld = usr.Name;
        rmaExt.secondaryOwnerFld = usr.Name;
        rmaExt.saveCeInfo();
        List<selectOption> countryList;
        rmaExt.countryList=null;
        List<selectOption>stateList = rmaExt.stateList;

        Test.stopTest();

    }

    static testMethod void unitTestRMASearchAsset()
    {
        Test.startTest();
        Case cse = unitTestCase();

        ApexPages.currentPage().getParameters().put('id', cse.id);
        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);

        rmaExt.asset_serial_no = cse.Serial_No__c;
        rmaExt.populateIB();

        //rmaExt.serial_no = cse.Serial_No__c;
        //rmaExt.populateIB();

        rmaExt.replacement_serial_no = cse.Serial_No__c;
        rmaExt.populateIB();

        rmaExt.serial_no = 'RTU123';
        //rmaExt.populateIB();

        Test.stopTest();
    }

    static testMethod void unitTestRMASelectCliCase()
    {
        Test.startTest();
        Case cse = unitTestCase();

        ApexPages.currentPage().getParameters().put('id', cse.id);
        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);

        rmaExt.asset_serial_no = cse.Serial_No__c;
        rmaExt.populateIB();

        rmaExt.selected_asset = cse.AssetId;
        rmaExt.populateServiceContract();

        SerialNo_Part__c sp = new SerialNo_Part__c(Part__c = 'SA2500', Name = 'RTU0');
        insert sp;

        rmaExt.selected_cli = cse.Contract_Line_Item__c;
        rmaExt.populateCaseDetail();

        Test.stopTest();
    }

    static testMethod void unitTestRMALineItem()
    {
        Test.startTest();

        Case cse = unitTestCase();
        ApexPages.currentPage().getParameters().put('id', cse.id);

        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);
        rmaExt.new_line_item_obj = new RMA_Line_Items__c();
        rmaExt.RMA_line_item_wrapper_list = new list<PScRMAExtension.PScRMALineItemsWrapper>();
        
        rmaExt.asset_serial_no = cse.Serial_No__c;
        rmaExt.populateIB();

        rmaExt.selected_asset = cse.AssetId;
        rmaExt.populateServiceContract();

        rmaExt.selected_cli = cse.Contract_Line_Item__c;
        rmaExt.populateCaseDetail();

        rmaExt.case_list.Product_Series__c = 'CONNECT-SECURE';
        rmaExt.case_list.Platform__c = 'SA2500';
        rmaExt.case_list.Serial_No__c = '0239052008000071';

        rmaExt.new_line_item_obj.Product_Series__c = 'CONNECT-SECURE';
        rmaExt.new_line_item_obj.Defective_Part__c = 'SA2500';
        rmaExt.new_line_item_obj.Serial_No__c = '0239052008000071';
        rmaExt.new_line_item_obj.Qty__c = 2;
        rmaExt.selectedReplacementPart = 'SA2500';
        rmaExt.new_line_item_obj.Is_a_Fru__c = true;
        rmaExt.new_line_item_obj.Fru__c = 'OTHER';
        rmaExt.selected_part = 'SA2500';
        rmaExt.selected_rma = 'Test';
        rmaExt.installed_at_name = 'Test';
        rmaExt.addLineItem();

  //      rmaExt.view_line_item_id = rmaExt.RMA_line_item_wrapper_list.size() - 1;
  //      rmaExt.viewLineItem();
        if(rmaExt.RMA_line_item_wrapper_list!=null && rmaExt.RMA_line_item_wrapper_list.size()>0){
            rmaExt.edit_line_item_id = rmaExt.RMA_line_item_wrapper_list.size() - 1;
            rmaExt.editLineItem();
        }
        rmaExt.new_line_item_obj.Is_a_Fru__c = false;
        rmaExt.addLineItem();
        rmaExt.clearLineItem();

        rmaExt.delete_line_item_id = rmaExt.RMA_line_item_wrapper_list.size() - 1;
        rmaExt.deleteLineItem();
        rmaExt.populate_country_state();
        PageReference pageRef = Page.PSvRMAExtension;
        Test.setCurrentPage(pageRef); 
        Test.stopTest();
    }

    static testMethod void unitTestCreateRMACase()
    {
        Test.startTest();

        User u = [SELECT Id, Name FROM User WHERE IsActive = TRUE AND IsPortalEnabled = FALSE AND Profile.Name = 'Pulse Tier 1 Support' LIMIT 1];

        Case cse = unitTestCase();
        ApexPages.currentPage().getParameters().put('id', cse.id);

        ApexPages.StandardController cc1 = new ApexPages.StandardController(cse);
        PScRMAExtension rmaExt = new PScRMAExtension(cc1);
        rmaExt.new_line_item_obj = new RMA_Line_Items__c();

        rmaExt.asset_serial_no = cse.Serial_No__c;
        rmaExt.populateIB();

        rmaExt.selected_asset = cse.AssetId;
        rmaExt.populateServiceContract();

        rmaExt.selected_cli = cse.Contract_Line_Item__c;
        rmaExt.populateCaseDetail();

        rmaExt.case_list.Product_Series__c = 'CONNECT-SECURE';
        rmaExt.case_list.Platform__c = 'SA2500';
        rmaExt.case_list.Serial_No__c = '0239052008000071';
        rmaExt.case_list.Ship_To_Account__c = u.Id;
        rmaExt.case_list.ShipTo_Contact_Name__c = 'Test';
        rmaExt.case_list.ShipTo_Contact_Phone__c = '2342342341';
        rmaExt.case_list.Shipping_Address1__c = 'test';
        rmaExt.case_list.Shipping_City__c = 'test';
        rmaExt.case_list.Shipping_Zipcode__c = '23232';
        rmaExt.case_list.Shipping_Country__c = 'India';

        rmaExt.case_list.Subject = 'Test RMA Subject';
        rmaExt.case_list.Description = 'Test RMA Description';
        rmaExt.case_list.RMA_SLA__c = 'Same Day';
        rmaExt.case_list.RMA_Transaction_Type__c = 'Advance Exchange';
        rmaExt.case_list.Shipping_Customer_E_Mail__c = 'smunisami@pulsesecure.net';
        rmaExt.case_list.Shipping_Address2__c = 'Shipping address 2';
        rmaExt.case_list.Is_CE_Required__c = true;
        rmaExt.primaryOwnerFld = u.Name;
        rmaExt.secondaryOwnerFld = u.Name;
        rmaExt.case_list.Primary_Site_Contact_Names__c = 'Primary Site Contact Names';
        rmaExt.case_list.Primary_Site_Telephone_Numbers__c = 'Primary Site Telephone Numbers';
        rmaExt.case_list.Primary_Telephone_Numbers__c = 'Primary Telephone Numbers';
        rmaExt.case_list.Problem_Summary__c = 'Problem Summary';
        rmaExt.case_list.Scope_of_work__c = 'Scope of work';

        rmaExt.new_line_item_obj.Product_Series__c = 'CONNECT-SECURE';
        rmaExt.new_line_item_obj.Defective_Part__c = 'SA2500';
        rmaExt.new_line_item_obj.Serial_No__c = '0239052008000071';
        rmaExt.new_line_item_obj.Qty__c = 2;
        rmaExt.selectedReplacementPart = 'SA2500';
        rmaExt.new_line_item_obj.Is_a_Fru__c = true;
        rmaExt.new_line_item_obj.Fru__c = 'OTHER';
        rmaExt.selected_part = 'SA2500';
        rmaExt.addLineItem();

        rmaExt.saveCeInfo();
        rmaExt.save();
        rmaExt.populateRMALineItemInfo();
        
        rmaExt.getFlashAlerts();
         rmaExt.RMALineItemDetails();
        rmaExt.getReplacementPart();
        rmaExt.getRMALineItemCnt();
        rmaExt.renderPanel();
        rmaExt.renderExpectedDateTime_AD();
        

        ApexPages.StandardController cc2 = new ApexPages.StandardController(rmaExt.case_list);
        PScRMAExtension rmaExt1 = new PScRMAExtension(cc2);

        PageReference rmaPageRef = Page.PSvRMAExtension;
        Test.setCurrentPage(rmaPageRef);

        if(rmaExt.obj_line_item_tosave.size() > 0)
        {
            rmaExt1.parent_case_id = rmaExt.obj_line_item_tosave[0].Id;
            rmaExt1.RMALineItemDetails();

            rmaExt1.selected_rma = rmaExt.obj_line_item_tosave[0].Id;
            rmaExt1.populateRMALineItemInfo();

   //         rmaExt1.asset_id = cse.AssetId;
            rmaExt1.populateIB();

            rmaExt1.selected_asset = cse.AssetId;
            rmaExt1.populateServiceContract();

            rmaExt1.selected_cli = cse.Contract_Line_Item__c;
            rmaExt1.populateCaseDetail();

            rmaExt1.case_list.Product_Series__c = 'CONNECT-SECURE';
            rmaExt1.case_list.Platform__c = 'SA2500';
            rmaExt1.case_list.Serial_No__c = '0239052008000071';
            rmaExt1.case_list.Ship_To_Account__c = u.Id;
            rmaExt1.case_list.ShipTo_Contact_Name__c = 'Test';
            rmaExt1.case_list.ShipTo_Contact_Phone__c = '2342342341';
            rmaExt1.case_list.Shipping_Address1__c = 'test';
            rmaExt1.case_list.Shipping_City__c = 'test';
            rmaExt1.case_list.Shipping_Zipcode__c = '23232';
            rmaExt1.case_list.Shipping_Country__c = 'India';

            rmaExt1.case_list.Subject = 'Test RMA Subject';
            rmaExt1.case_list.Description = 'Test RMA Description';
            rmaExt1.case_list.RMA_SLA__c = 'Same Day';
            rmaExt1.case_list.RMA_Transaction_Type__c = 'Advance Exchange';
            rmaExt1.case_list.Shipping_Customer_E_Mail__c = 'smunisami@pulsesecure.net';
            rmaExt1.case_list.Shipping_Address2__c = 'Shipping address 2';

            rmaExt1.new_line_item_obj.Product_Series__c = 'CONNECT-SECURE';
            rmaExt1.new_line_item_obj.Defective_Part__c = 'SA2500';
            rmaExt1.new_line_item_obj.Serial_No__c = '0239052008000071';
            rmaExt1.new_line_item_obj.Qty__c = 2;
            rmaExt1.selectedReplacementPart = 'SA2500';
            rmaExt1.new_line_item_obj.Is_a_Fru__c = true;
            rmaExt1.new_line_item_obj.Fru__c = 'OTHER';
            rmaExt1.selected_part = 'SA2500';
            rmaExt1.addLineItem();

            rmaExt1.save();
        }

        Test.stopTest();
        }
       }