+ Start a Discussion
brijender singh rathore 16brijender singh rathore 16 

CAN ANTYONE HELP ME WITH THE TEST CLASS

I HAVE TO COVER CODE (PART OF CODE).MY TEST CLASS FUNCTION COVERING FIRST THREE LINES.
static testMethod void myUnitTest() {
    Test.startTest();
    account acc= new account(Name = 'testtng');
    insert acc;  
    Country__c oCountry = new Country__c(Name = 'United States');
    insert oCountry;
    Country__c oCountry1 = new Country__c(Name = 'Canada');
    insert oCountry1;
    State_Providence__c pcSP = new State_Providence__c(Name='test', Abbreviation__c = 'te');
    insert pcSP;
    Contact pcContact = new Contact(LastName = 'tester', FirstName = 'test');
    insert pcContact;
    Background_Check_Service_Package__c bcsp = new Background_Check_Service_Package__c(HISTORIC_Package_Code__c = 'testing');
    insert bcsp;
    List<Contact> lstContact1 = new List<Contact>();
    BGC_Order__c bo = new BGC_Order__c(Subject_has_Multiple_Names__c = true, Subject_Zip_Code__c = '95256', State_Providence__c = pcSP.Id, Account__c = acc.id, BGC_Service_Package__c = bcsp.id);
    insert bo;

   // String orderid = ApexPages.currentPage().getParameters().put('tfa_2935', bo.Id);
    String orderid = ApexPages.currentPage().getParameters().put('tfa_2935', bo.Id);
    ApexPages.currentPage().getParameters().put('tfa_2181', '2');
    ApexPages.currentPage().getParameters().put('tfa_2187', '3');
    ApexPages.currentPage().getParameters().put('tfa_2964', '2');
    ApexPages.currentPage().getParameters().put('tfa_2920', '4');
    ApexPages.currentPage().getParameters().put('tfa_6793', '5');
    ApexPages.currentPage().getParameters().put('tfa_6776', '4');
    
    QuickBackgroundCheckOrderCl oQuickBackgroundCheck = new QuickBackgroundCheckOrderCl();
    oQuickBackgroundCheck.iDegCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2181'));
    oQuickBackgroundCheck.sOrderId = orderid;
    list<BGC_Order__c> oBGC = [SELECT Id, Subject_First_Name__c,Subject_Last_Name__c, Subject_Middle_Name__c, Government_ID_Type__c, Government_ID_Number__c,Subject_Email__c,Subject_Phone_Number__c,Subject_of_Order__c,Subject_Address__c,Subject_City__c,Subject_Date_of_Birth__c,Subject_Zip_Code__c,Subject_Country__c, State_Providence__c, Account__c, Notes_to_Pre_Employ__c, Order_Status__c, BGC_Service_Package__c FROM BGC_Order__c WHERE Id =: orderid limit 1];
	insert oBGC; 
    BGC_Degree_Intake__c oBGCDegree1 = new BGC_Degree_Intake__c(Background_Check_Order__c = bo.id, School_Country__c = oCountry.id) ;
    insert oBGCDegree1;
    BGC_Degree_Intake__c oBGCDegree = new BGC_Degree_Intake__c(Background_Check_Order__c = bo.id, School_Country__c = oCountry.id) ;
    insert oBGCDegree;
    BGC_Reference_Intake__c oBGCReference = new BGC_Reference_Intake__c(Background_Check_Order__c = bo.id, Is_Reference_Searches_Creation_Pending__c = true) ;
    insert oBGCReference;
    BGC_License_Intake__c oBGC_License_Intake = new BGC_License_Intake__c(Background_Check_Order__c = bo.id, Is_License_Searches_Creation_Pending__c = true) ;
    insert oBGC_License_Intake;
    String orderid11 = ApexPages.currentPage().getParameters().put('tfa_2935', bo.Id);
    List<BGC_Degree_Intake__c> lstBGCDegreeList1 = new List<BGC_Degree_Intake__c>();
    List<BGC_Reference_Intake__c> lstBGCRefList1 = new List<BGC_Reference_Intake__c>();
    List<BGC_License_Intake__c> lstBGCLicList1 = new List<BGC_License_Intake__c>();
    oQuickBackgroundCheck.getGovIdType();
    oQuickBackgroundCheck.getDegree();
    oQuickBackgroundCheck.getItems();
    oQuickBackgroundCheck.getItem();
    oQuickBackgroundCheck.getState();
    oQuickBackgroundCheck.getDLState();
    oQuickBackgroundCheck.getitemcontact();
    oQuickBackgroundCheck.getCountries();
    oQuickBackgroundCheck.scountry = oCountry.id;
    oQuickBackgroundCheck.sState = pcSP.id;
    oQuickBackgroundCheck.sDLNumber = '123';
    oQuickBackgroundCheck.sLastName = 'test';
    oQuickBackgroundCheck.sFirstName = 'test';
    oQuickBackgroundCheck.sGovermentIdType = 'test';
    oQuickBackgroundCheck.sGovermentIdNumber = 'test';
    oQuickBackgroundCheck.sEmail = 'test@dsfsd.com';
    oQuickBackgroundCheck.sPhoneNumber = 'test';
    oQuickBackgroundCheck.sAddress = 'test';
    oQuickBackgroundCheck.sDegreestate = 'test';
    oQuickBackgroundCheck.sNotesPreEmlpoy = 'test';
    oQuickBackgroundCheck.sLastAlterName = 'test';
    oQuickBackgroundCheck.sDegree = 'test';
    oQuickBackgroundCheck.sDegreeCountry = 'test';
    oQuickBackgroundCheck.sAnnualSalary = '12340';
    oQuickBackgroundCheck.bCreditReport = 'true';
    oQuickBackgroundCheck.sCity = 'test';
    oQuickBackgroundCheck.sZipCode = 'test';
    oQuickBackgroundCheck.sService = 'test';
    oQuickBackgroundCheck.bYes = true;
    oQuickBackgroundCheck.bLicCount = true;
    oQuickBackgroundCheck.bDegCount = true;
    oQuickBackgroundCheck.bEmpCount = true;
    oQuickBackgroundCheck.bRefCount = true;
    oQuickBackgroundCheck.sMiddleName = 'test';
    oQuickBackgroundCheck.lstContact = lstContact1;
    oQuickBackgroundCheck.sFirstAlterName = 'test';
    oQuickBackgroundCheck.sCurrentEmployer = 'test';
    oQuickBackgroundCheck.sEmployCountry = 'test';
    oQuickBackgroundCheck.sEmploystate = 'test';
    oQuickBackgroundCheck.sAttendance = 'test';
    oQuickBackgroundCheck.sCommonform = 'test';
    oQuickBackgroundCheck.dDateOfBirth = null;
    oQuickBackgroundCheck.lstBGCDegreeList = lstBGCDegreeList1;
    oQuickBackgroundCheck.lstBGCReferenceList = lstBGCRefList1;
    oQuickBackgroundCheck.lstBGCLicenseList = lstBGCLicList1;
    oQuickBackgroundCheck.iTotalInternationalLicense = 2;
    oQuickBackgroundCheck.bFCRAEmploymentRelatedChecks = 'true';
    oQuickBackgroundCheck.bFCRAInvestigativeConsumerReports = 'true';
    oQuickBackgroundCheck.bCertificationRegardingNoLegalAdvice = 'true';
    oQuickBackgroundCheck.sUnitNumber = '12345';
    oQuickBackgroundCheck.sUnitNumberMailing = '54321';
    oQuickBackgroundCheck.sAddressMailing = 'Test';
    oQuickBackgroundCheck.sCityMailing = 'Test';
    oQuickBackgroundCheck.stateMailing = pcSP.id;
    oQuickBackgroundCheck.sZipCodeMailing = '12345';
    oQuickBackgroundCheck.sCountryMailing = oCountry.id;
    bo.FCRA_Employment_Related_Checks__c = true;
    bo.FCRA_Investigative_Consumer_Reports__c = true;
    bo.Certification_Regarding_No_Legal_Advice__c = true;
    bo.Annual_Salary__c = 12;
    bo.Credit_History_Information_Requested__c = true;
    bo.FCRA_Certification_of_Permissible_Purpos__c = 'true';
    bo.Subject_First_Name__c = 'test';
    bo.Subject_Last_Name__c = 'test';
    bo.Subject_Email__c = 'savdf@sad.cod';
    update bo;
    pcContact.Background_Check_Order__c = orderid11;
    update pcContact;
    oQuickBackgroundCheck.placeorder();
    update pcContact;
    Test.stopTest();
  }

public PageReference placeorder(){
    Alternate_Names__c oAlternateNames = new Alternate_Names__c();
    contact ocon = new contact();
    if(sOrderId != null){
      if(sUnitNumber != null && sUnitNumber != '') {
        sAddress = sAddress + ', ' + sUnitNumber;
      }
      if(sAddressMailing != null && sAddressMailing != '') {
        List<Zip_Code__c> lstZipCounty = [SELECT Id, Zip_Code__c, AssociatedCounty__c FROM Zip_Code__c WHERE Zip_Code__c = :sZipCode LIMIT 1];
        Additional_Address__c oAdditionalAddress = new Additional_Address__c();
        oAdditionalAddress.Address__c = sAddress;
        oAdditionalAddress.Background_Check_Order__c = sOrderId;
        oAdditionalAddress.City__c = sCity;
        oAdditionalAddress.Country__c = scountry;
        if(lstZipCounty.size() > 0 && lstZipCounty.get(0).AssociatedCounty__c != null) {
          oAdditionalAddress.County__c = lstZipCounty.get(0).AssociatedCounty__c;
        }
        oAdditionalAddress.State_Providence__c = sState;
        oAdditionalAddress.Type_of_Address__c = 'Other';
        oAdditionalAddress.Zip_Code__c = sZipCode;
        insert oAdditionalAddress;
        if(sUnitNumberMailing != null && sUnitNumberMailing != '') {
          sAddressMailing = sAddressMailing + ', ' + sUnitNumberMailing;
        }
        sAddress = sAddressMailing;
        sCity = sCityMailing;
        scountry = sCountryMailing;
        sState = stateMailing;
        sZipCode = sZipCodeMailing;
      }
      
      if(sFirstAlterName != null && sFirstAlterName != '' && sLastAlterName != null && sLastAlterName != '')
      {
        oAlternateNames.Alternate_First_Name__c = sFirstAlterName;
        oAlternateNames.Alternate_last_Name__c = sLastAlterName;
        oAlternateNames.Background_Check_Order__c = sOrderId;
        insert oAlternateNames;
      }
      ocon.mailingcity = sCity;
      ocon.MailingStreet = sAddress;
      ocon.State__c = sState;
      ocon.Government_ID_Number__c = sGovermentIdNumber;
      ocon.FirstName = sFirstName;
      ocon.LastName = sLastName;
      ocon.mailingpostalcode = sZipCode;
      ocon.mailingcountry = scountry;
      ocon.Birthdate = dDateOfBirth;
      ocon.MobilePhone = sPhoneNumber;
      ocon.Email = sEmail;
      ocon.Unauthenticated_Government_ID_Number__c = sGovermentIdNumber;
      ocon.Background_Check_Order__c = sOrderId;
      List<User> lstUser = [SELECT Id, Name FROM User WHERE NAME = 'Tara Noble' LIMIT 1];
      if(lstUser.size() > 0) {
        ocon.OwnerId = lstUser.get(0).Id; //--Set Tara Noble's Id as contact owner in the scope of T-28033: Defect ID: 8659
      }
      lstContact = [SELECT Id FROM contact WHERE Background_Check_Order__c =: sOrderId limit 1];
      if(lstContact.size() > 0){
        ocon.id = lstContact.get(0).id;
        update ocon;
      }
      else{
        insert ocon;
      }
      List<RecordType> lstRecordType = [SELECT Id, Name, SobjectType, IsActive FROM RecordType WHERE Name = 'Pending' AND SobjectType = 'BGC_Order__c' LIMIT 1];
      lstBGCOrder = [SELECT Id, Subject_First_Name__c,Subject_Last_Name__c, Subject_Middle_Name__c, Government_ID_Type__c, Government_ID_Number__c,Subject_Email__c,Subject_Phone_Number__c,Subject_of_Order__c,Subject_Address__c,Subject_City__c,Subject_Date_of_Birth__c,Subject_Zip_Code__c, Subject_Country__c, State_Providence__c, Account__c, Notes_to_Pre_Employ__c, Order_Status__c, BGC_Service_Package__c, Method_of_Data_Supply__c, DL_or_ID_Number__c, FCRA_Certification_of_Permissible_Purpos__c, Credit_History_Information_Requested__c, Annual_Salary__c, Certification_Regarding_No_Legal_Advice__c, FCRA_Investigative_Consumer_Reports__c, FCRA_Employment_Related_Checks__c, Joe_s_Account__c, Subject_has_Multiple_Names__c, Drivers_License_ID_State__c, County__c, Package_A_Name__c FROM BGC_Order__c WHERE Id =: sOrderId limit 1];
      if(lstBGCOrder.size() > 0){
        lstBGCOrder.get(0).Subject_First_Name__c = sFirstName;
        lstBGCOrder.get(0).Subject_Last_Name__c = sLastName;
        lstBGCOrder.get(0).Subject_Middle_Name__c= sMiddleName;
        lstBGCOrder.get(0).Subject_Email__c = sEmail;
        lstBGCOrder.get(0).Subject_Phone_Number__c = sPhoneNumber;
        lstBGCOrder.get(0).Subject_Address__c = sAddress;
        lstBGCOrder.get(0).Subject_City__c = sCity;
        lstBGCOrder.get(0).Subject_of_Order__c = ocon.id;
        lstBGCOrder.get(0).Subject_Date_of_Birth__c = dDateOfBirth;
        lstBGCOrder.get(0).Subject_Zip_Code__c = sZipCode;
        lstBGCOrder.get(0).Subject_Country__c = scountry;
        lstBGCOrder.get(0).State_Providence__c = sState;
        if(lstRecordType.size() > 0) {
          lstBGCOrder.get(0).RecordTypeId = lstRecordType.get(0).Id;  // 012800000003oG3
        }
        lstBGCOrder.get(0).Government_ID_Number__c = sGovermentIdNumber;
        lstBGCOrder.get(0).Government_ID_Type__c = sGovermentIdType;
        lstBGCOrder.get(0).Notes_to_Pre_Employ__c = sNotesPreEmlpoy;
        lstBGCOrder.get(0).Account__c = sAccountId;
        lstBGCOrder.get(0).Drivers_License_or_ID_State__c = sDLState;
        lstBGCOrder.get(0).Order_Status__c = 'Approved for Formation';
        lstBGCOrder.get(0).Method_of_Data_Supply__c = 'Client - Manual Data Entry';
        lstBGCOrder.get(0).DL_or_ID_Number__c = sDLNumber;
        lstBGCOrder.get(0).Subject_has_Multiple_Names__c = bYes;
        lstBGCOrder.get(0).Joe_s_Account__c = sAccountId;
        lstBGCOrder.get(0).FCRA_Employment_Related_Checks__c = boolean.valueof(bFCRAEmploymentRelatedChecks);
        lstBGCOrder.get(0).FCRA_Investigative_Consumer_Reports__c = boolean.valueof(bFCRAInvestigativeConsumerReports);
        lstBGCOrder.get(0).Certification_Regarding_No_Legal_Advice__c = boolean.valueof(bCertificationRegardingNoLegalAdvice);
        lstBGCOrder.get(0).Annual_Salary__c = integer.valueof(sAnnualSalary);
        lstBGCOrder.get(0).Credit_History_Information_Requested__c = boolean.valueof(bCreditReport);
        lstBGCOrder.get(0).FCRA_Certification_of_Permissible_Purpos__c = bFCRAPermissble;
        if(lstBGCOrder.get(0).County__c == null && sZipCode != null && sZipCode != '') {
          List<Zip_Code__c> lstAssociatedCounty = [SELECT Id, Zip_Code__c, AssociatedCounty__c FROM Zip_Code__c WHERE Zip_Code__c = :sZipCode LIMIT 1];
          if(lstAssociatedCounty.size() > 0 && lstAssociatedCounty.get(0).AssociatedCounty__c != null) {
            lstBGCOrder.get(0).County__c = lstAssociatedCounty.get(0).AssociatedCounty__c;
          }
        }
        update lstBGCOrder;

Thanks in advance