• Fresco
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hi I need to write test class for this please tell me how to write.It has reports and dashboards.
public class Embedded_Analytics_Extn{
    
    public Id AccPlanId{get; set;}
    public GE_HQ_Account_Plan__c aPlan{get;set;}
    public String DashId{get; set;}
    public String Report0Id{get; set;}
    public String Report0Name{get; set;}
    public String Report1Id{get; set;}
    public String Report1Name{get; set;}
    public String Report2Id{get; set;}
    public String Report2Name{get; set;}
    public String Report3Id{get; set;}
    public String Report3Name{get; set;}
    public String Report4Id{get; set;}
    public String Report4Name{get; set;}
    public String Report5Id{get; set;}
    public String Report5Name{get; set;}
    public String Report6Id{get; set;}
    public String Report6Name{get; set;}
    
    public String AccPlanName{get; set;}
    Public String DDUNS{get; set;}
    public List<SelectOption> tiers{get;set;}
    public String tier2{get;set;}
    public String tier3{get;set;}
    public String accName{get;set;}
    public Embedded_Analytics_Extn(ApexPages.StandardController controller){
        //Report r0=[select id,name,developerName from Report where developerName='TOTAL_CurrYr_IFRU'];
        //Report0Id=r0.id;
        //Report0Name=r0.name;
        Report r1=[select id,name,developerName from Report where developerName='OG_Tier_1_O_G_Region_Current_Year'];
        Report1Id=r1.id;
        Report1Name=r1.name;
        Report r2=[select id,name,developerName from Report where developerName='OG_Forecast_by_PL_Current_Year'];
        Report2Id=r2.id;
        Report2Name=r2.name;
        Report r3=[select id,name,developerName from Report where developerName='OG_Tier_2_Account_Region_Current_Year'];
        Report3Id=r3.id;
        Report3Name=r3.name;
        Report r4=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_OPEN'];
        Report4Id=r4.id;
        Report4Name=r4.name;
        Report r5=[select id,name,developerName from Report where developerName='OG_Oppty_by_Stage_Current_Year'];
        Report5Id=r5.id;
        Report5Name=r5.name;
        Report r6=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_Forecast'];
        Report6Id=r6.id;
        Report6Name=r6.name;
                
        DashId=[select id,developerName from Dashboard where developerName='OG_Account_Plan_Dashboard'].id;
        List<DashboardComponent> comp=[select id,name from DashboardComponent where DashboardId=:DashId];
        Map<String,DashboardComponent> DashCompMap=new Map<String,DashboardComponent>();
        for(DashboardComponent c: comp){
            DashCompMap.put(c.name,c);    
        }
        this.aPlan=(GE_HQ_Account_Plan__c)controller.getRecord();
        GE_HQ_Account_Plan__c AccPlan=[select id,name,GE_HQ_DDUNS_fm__c,GE_HQ_DDUNS_Number__c from GE_HQ_Account_Plan__c where id=:aPlan.Id];
        
        AccPlanName=AccPlan.Name;
        DDUNS=AccPlan.GE_HQ_DDUNS_fm__c;
        Account acc=[select id,name from Account where id=:AccPlan.GE_HQ_DDUNS_Number__c];
        this.accName=acc.name;
        /*
        tiers=new List<SelectOption>();
        tiers.add(new SelectOption('','None'));
        tiers.add(new SelectOption('Turbo Machinery','Turbo Machinery'));
        tiers.add(new SelectOption('PII Pipeline Solutions','Pipeline Solutions'));
        tiers.add(new SelectOption('Global Services (GS)','Global Services'));
        tiers.add(new SelectOption('Mesurement & Control (M&C)','Mesurement & Control'));
        tiers.add(new SelectOption('Drilling & Surface (D&S)','Drilling & Surface'));
        tiers.add(new SelectOption('Subsea (SS)','Subsea'));
        */
    }
    
    public PageReference setTiers(){
        this.tier2=aPlan.GE_OG_Tier_2_P_L__c;
        this.tier3=aPlan.GE_OG_Tier_3_P_L__c;
        return null;
    }
    
}

Public class GE_OG_CalcCustomerCreditLimit
{
//AfterInsert
public void calcCustomerCreditLimitAfterInsert(List<Opportunity>  newOpptyList)
{

    List<Opportunity>  newOpptyList1= (List<Opportunity>)newOpptyList;
    Set<Id> setAccId = new Set<Id>();
    List<GE_HQ_CUST_CREDIT_HIST__c> lstCustCreditHistoryUpdate = new List<GE_HQ_CUST_CREDIT_HIST__c>();
    
    for (Opportunity Opp : newOpptyList1) 
    {
        
        
            if((Opp.StageName=='Active - Commit' || Opp.StageName=='Closed Won')&& (Opp.GE_ES_R_Status__c !=null)  && (Opp.GE_ES_R_Status__c != 'R0') && Opp.GE_HQ_Business_Tier1__c == 'Oil & Gas (O&G)')
            {
                if(Opp.AccountId != null)
                {
                setAccId.add(Opp.AccountId);
                }
            }
                
    } 
    if(!setAccId.isEmpty())
    {
        
        for(GE_HQ_CUST_CREDIT_HIST__c Cch: [select Id, GE_HQ_Acct_Cr_Limit__c, GE_HQ_Cr_Limit_Exceeded__c, GE_HQ_Tot_AR_s__c, GE_HQ_Acc__c from GE_HQ_CUST_CREDIT_HIST__c where GE_HQ_Acc__c in: setAccId])
        {
            GE_HQ_CUST_CREDIT_HIST__c CchUpdate = new GE_HQ_CUST_CREDIT_HIST__c(Id=Cch.Id);
            CchUpdate.GE_HQ_Acct_Cr_Limit__c = Cch.GE_HQ_Acct_Cr_Limit__c;
            lstCustCreditHistoryUpdate.add(CchUpdate);
        }
    }
    if(!lstCustCreditHistoryUpdate.isEmpty())
    {
        update lstCustCreditHistoryUpdate ;
    }
        
   


}
//afterInser closed

//for AfterUpdate
public void calcCustomerCreditLimitAfterUpdate(List<Opportunity>  newOpptyList,Map<Id,Opportunity>  OldMapOpportunity)
{
            List<Opportunity>  newOpptyList1= (List<Opportunity>)newOpptyList;
             
             Map<Id,Opportunity>  oldMapOpportunity1=(Map<Id,Opportunity>)  OldMapOpportunity; 
             
             
    Set<Id> setAccId = new Set<Id>();
    List<GE_HQ_CUST_CREDIT_HIST__c> lstCustCreditHistoryUpdate = new List<GE_HQ_CUST_CREDIT_HIST__c>();
    
    for (Opportunity Opp : newOpptyList1) 
    {
        
        
            Opportunity OppBeforeUpdate = oldMapOpportunity1.get(Opp.Id); 
            if(OppBeforeUpdate.Amount != Opp.Amount || OppBeforeUpdate.StageName != Opp.StageName || OppBeforeUpdate.GE_ES_R_Status__c != Opp.GE_ES_R_Status__c)
            {
                System.debug('In Update====');
                if(Opp.AccountId != null){setAccId.add(Opp.AccountId);}
            }        
        
             
    } 
    if(!setAccId.isEmpty())
    {
        
        for(GE_HQ_CUST_CREDIT_HIST__c Cch: [select Id, GE_HQ_Acct_Cr_Limit__c, GE_HQ_Cr_Limit_Exceeded__c, GE_HQ_Tot_AR_s__c, GE_HQ_Acc__c from GE_HQ_CUST_CREDIT_HIST__c where GE_HQ_Acc__c in: setAccId])
        {
            GE_HQ_CUST_CREDIT_HIST__c CchUpdate = new GE_HQ_CUST_CREDIT_HIST__c(Id=Cch.Id);
            CchUpdate.GE_HQ_Acct_Cr_Limit__c = Cch.GE_HQ_Acct_Cr_Limit__c;
            lstCustCreditHistoryUpdate.add(CchUpdate);
        }
    }
    if(!lstCustCreditHistoryUpdate.isEmpty())
    {
        update lstCustCreditHistoryUpdate ;
    }


}
// for AfterUpdate close
}
---------------------
@isTest
private class GEOGCalcCustomerCreditLimit_Test{
static testMethod void GEOGCalcCustomerCreditLimit_Test(){ 

    //User usr = new User(LastName='test user',Alias='tuser',DefaultGroupNotificationFrequency='N',DigestFrequency='N',Email='testuser@ge.com',Username='testuserr2@ge.com',EmailEncodingKey='UTF-8',LanguageLocaleKey='en_US',LocaleSidKey='IN',ProfileId= ProfId,TimeZoneSidKey='Asia/Kolkata',UserPermissionsCallCenterAutoLogin=false,UserPermissionsMarketingUser=false,UserPermissionsOfflineUser=false);
    //Insert usr;
    Account Acc = new Account();
    Acc.Name = 'Test account';
    Acc.BillingCountry = 'USA';
    Acc.ShippingCountry = 'USA';
    Acc.ShippingState = 'AT';
    Acc.ShippingCity = 'TestShipping City';
    Acc.ShippingStreet = 'Test Shipping Street';
    Acc.ShippingPostalCode = '101010';
    Acc.GE_HQ_Request_Status__c = 'CMF Approved';
    insert Acc;  
    
    GE_HQ_CUST_CREDIT_HIST__c Cch = new GE_HQ_CUST_CREDIT_HIST__c();
    Cch.GE_HQ_Acc__c = Acc.Id;
    Cch.GE_HQ_Acct_Cr_Limit__c = 2500000;
    Cch.GE_HQ_Cr_Limit_Remaining__c = 1000;
    Cch.GE_HQ_Tot_AR_s__c = 2000; 
    insert Cch;
 
 GE_Configuration_Setting__c cs= new GE_Configuration_Setting__c();
 cs.GE_OG_DTS_OpptyID__c=5490;
 cs.GE_PWNUC_Oppty_ID__c=5490;
 cs.GE_OGGS_Oppty_Id__c=5490;
 cs.GE_OG_Oppty_Id_Counter__c=5490;
 cs.GE_OG_PII_OIDCnt__c=5490;
 cs.GE_OG_SS_WSIDCntr__c=5490;
 cs.name='OG Counter';
 
 insert cs;
 
 
    
    GE_ES_Project__c prj = new GE_ES_Project__c();
    prj.Name = 'TestProject1';
    prj.GE_OG_SS_First_Oil_Date__c=Date.today();
    insert prj;
    
  
     Opportunity oppty = new Opportunity();
    oppty.RecordTypeId =[select id,name from recordtype where name like 'Grouped Flow' limit 1].id;
    oppty.Name= 'Test Oppty1';
    oppty.GE_ES_Project__c = prj.Id;
    oppty.AccountId = Acc.Id;
    oppty.Type = 'Primary';
    oppty.StageName = 'Active - Commit';
    oppty.GE_ES_R_Status__c = 'R1 Submitted';
    oppty.GE_HQ_Business_Tier1__c = 'Oil & Gas (O&G)';
    oppty.CurrencyIsoCode = 'USD';
    oppty.GE_ES_Bid_Due_Date__c = Date.today();
    oppty.CloseDate= Date.today();
    oppty.Amount= 1000;
    oppty.GE_OG_TM_Commercial_Center__c= 'Bari';
    oppty.GE_OG_Stream__c = 'Core Services - Aberdeen';
    oppty.GE_OG_TM_Quote_Type__c = 'Budget';
    oppty.GE_OG_TM_Industrial_Sector__c = 'LNG';
    oppty.GE_OG_TM_Subsector__c = 'CCR';
    oppty.GE_OG_TM_Application_Center__c = 'Bari';
    oppty.GE_OG_TM_RFQ_Received_Date__c = Date.today();
    oppty.GE_OG_TM_Proposal_Assesment__c = 'Tech & Comm With Same Due Date';
    //oppty.GE_OG_Oppty_End_User__c = buyer.Id;
    oppty.End_User__c = Acc.Id;
    oppty.GE_ES_OPPTY_CM__c = 35;
    insert oppty;
    
test.startTest();

 GE_Configuration_Setting__c cs1= new GE_Configuration_Setting__c();
 cs1.GE_OG_DTS_OpptyID__c=5490;
 cs1.GE_PWNUC_Oppty_ID__c=5490;
 cs1.GE_OGGS_Oppty_Id__c=5490;
 cs1.GE_OG_Oppty_Id_Counter__c=5490;
 cs1.GE_OG_PII_OIDCnt__c=5490;
 cs1.GE_OG_SS_WSIDCntr__c=5490;
 cs1.name='OG Counter';
 
 insert cs1;
}

}

for after update is not covering can you please help me out

class:
------
In my class attachments are like below
List<Attachment> kycAtt=[select id,name,body,BodyLength from Attachment where parentId=:kyc.Id and BodyLength>0];
              List<Attachment> erpAtt=[select id,name,body,BodyLength from Attachment where parentId=:erp.Id and BodyLength>0];

 Messaging.EmailFileAttachment[] efaList=new Messaging.EmailFileAttachment[] {};
              
              if(kycAtt.size()>0){
                  for(Attachment att:kycAtt){
                      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                      efa.setFileName(att.name);
                      efa.setBody(att.body);
                      efaList.add(efa);
                  }
              }
              
              if(erpAtt.size()>0){
                  for(Attachment att:erpAtt){
                      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                      efa.setFileName(att.name);
                      efa.setBody(att.body);
                      efaList.add(efa);
                  }
              }
              
              if(efaList.size()>0){
                  mail.setFileAttachments(efaList);
              }

I need to cover these code in test line can you plese 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();
    }
--------------------------------------------------
 

We have devolped a site using .net in our company
and my pjct having sf instance
in that volunteer object is there
In the .net site we have a page to register volunteer ok
i have to save the details in sf volunteers how can i do this?
  • March 11, 2015
  • Like
  • 0
User-added image

Page:

<apex:page standardController="Opportunity" extensions="opportunityProductEntryExtension" action="{!priceBookCheck}" >

    <apex:sectionHeader Title="Manage {!$ObjectType.Product2.LabelPlural}" subtitle="{!opportunity.Name}"/>
    <apex:messages style="color:red"/>

    <style>
        .search{
            font-size:14pt;
            margin-right: 20px;    
        }
        .fyi{
            color:red;
            font-style:italic;
        }
        .label{
            margin-right:10px;
            font-weight:bold;
        }
    </style>
    
    <script type='text/javascript'>
    
        // This script assists the search bar functionality
        // It will execute a search only after the user has stopped typing for more than 1 second
        // To raise the time between when the user stops typing and the search, edit the following variable:
        
        var waitTime = 1;
        
    
        var countDown = waitTime+1;
        var started = false;
        
        function resetTimer(){
        
            countDown=waitTime+1;
            
            if(started==false){
                started=true;
                runCountDown();
            }
        }
        
        function runCountDown(){
        
            countDown--;
            
            if(countDown<=0){
                fetchResults();
                started=false;
            }
            else{
                window.setTimeout(runCountDown,1000);
            }
        }
    
    </script>
   
  
    <apex:form >
    
        <apex:outputPanel id="mainBody">
        
            <apex:outputLabel styleClass="label">PriceBook: </apex:outputLabel>
            <apex:outputText value="{!theBook.Name}"/>&nbsp;
            <apex:commandLink action="{!changePricebook}" value="change" immediate="true"/>
            <br/>
            <!-- not everyone is using multi-currency, so this section may or may not show -->
            <apex:outputPanel rendered="{!multipleCurrencies}">
                <apex:outputLabel styleClass="label">Currency: </apex:outputLabel>
                <apex:outputText value="{!chosenCurrency}"/>
                <br/>
            </apex:outputPanel>
            <br/>
            
<!-- this is the upper table... a.k.a. the "Shopping Cart"-->

            <!-- notice we use a lot of $ObjectType merge fields... I did that because if you have changed the labels of fields or objects it will reflect your own lingo -->
            <apex:pageBlock title="Selected {!$ObjectType.Product2.LabelPlural}" id="selected">
                       
                <apex:pageblockTable value="{!shoppingCart}" var="s" id="blockSection" >
                
                    <apex:column >
                        <apex:commandLink value="Remove" action="{!removeFromShoppingCart}" reRender="selected,searchResults" immediate="true">
                            <!-- this param is how we send an argument to the controller, so it knows which row we clicked 'remove' on -->
                            <apex:param value="{!s.PriceBookEntryId}" assignTo="{!toUnselect}" name="toUnselect"/>
                        </apex:commandLink>
                    </apex:column>
                    
                    <apex:column headerValue="{!$ObjectType.Product2.LabelPlural}" value="{!s.PriceBookEntry.Product2.Name}"/>
                    
                    <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Quantity.Label}">
                        <apex:inputField id="q" value="{!s.Quantity}" style="width:70px" required="false"  >
                        <apex:actionSupport event="onkeyup" reRender="total,total1"/>
                        </apex:inputField>
                                                                   
                    </apex:column>

                        <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.UnitPrice.Label}">
                        <apex:inputField id="u" value="{!s.UnitPrice}" style="width:70px" required="false" >
                        <apex:actionSupport event="onkeyup" reRender="total,total1"/>
                       
                        </apex:inputField>
                    </apex:column>
                    
                    <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Description.Label}">
                        <apex:inputField value="{!s.Description}" required="false"/>
                    </apex:column>
                    
                    
                  <apex:column headerValue="Total" >
                   <apex:outputText id="total" style="width:80px" value="{0, number, 0.00}">
                   <apex:param value="{! s.Quantity*s.UnitPrice  }"/>
                   </apex:outputText>
                   </apex:column>
                  
                  
                  
                </apex:pageblockTable>
                  
                   
                
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!onSave}" value="Save"/>
                    <apex:commandButton action="{!onCancel}" value="Cancel" immediate="true"/>
                </apex:pageBlockButtons>
            
            </apex:pageBlock>
    
<!-- this is the lower table: search bar and search results -->
    
            <apex:pageBlock >
            
                <apex:outputPanel styleClass="search">
                    Search for {!$ObjectType.Product2.LabelPlural}:
                </apex:outputPanel>

                <apex:actionRegion renderRegionOnly="false" immediate="true">
                
                    <apex:actionFunction name="fetchResults" action="{!updateAvailableList}" reRender="searchResults" status="searchStatus"/>
                    
                    <!-- here we invoke the scripting to get out fancy 'no button' search bar to work -->
                    <apex:inputText value="{!searchString}" onkeydown="if(event.keyCode==13){this.blur();}else{resetTimer();}" style="width:300px"/>
                    &nbsp;&nbsp;
                    <i>
                        <!-- actionStatus component makes it easy to let the user know when a search is underway -->
                        <apex:actionStatus id="searchStatus" startText="searching..." stopText=" "/>
                    </i>
                    
                </apex:actionRegion>
            
                <br/>
                <br/>
            
                <apex:outputPanel id="searchResults">
                
                    <apex:pageBlockTable value="{!AvailableProducts}" var="a">
                    
                        <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}" value="{!a.Product2.Name}" />
                        
                        <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}" value="{!a.Product2.Family}"/>
                        
                        <apex:column headerValue="{!$ObjectType.Product2.Fields.Description.Label}" value="{!a.Product2.Description}"/>
                        
                        <apex:column >
                            <!-- command button in a column... neato -->
                            <apex:commandButton value="Select" action="{!addToShoppingCart}" reRender="selected,searchResults" immediate="true">
                                <!-- again we use apex:param to be able to tell the controller which row we are working with -->
                                <apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>
                            </apex:commandButton>
                        </apex:column>
                        
                    </apex:pageBlockTable>
                    
                    <!-- We put up a warning if results exceed 100 rows -->
                    <apex:outputPanel styleClass="fyi" rendered="{!overLimit}">
                        <br/>
                        Your search returned over 100 results, use a more specific search string if you do not see the desired {!$ObjectType.Product2.Label}.
                        <br/>
                    </apex:outputPanel>
                    
                </apex:outputPanel>
            
            </apex:pageBlock>
            
        </apex:outputPanel>

    </apex:form>

</apex:page>
  • March 04, 2015
  • Like
  • 0
Hi I need to write test class for this please tell me how to write.It has reports and dashboards.
public class Embedded_Analytics_Extn{
    
    public Id AccPlanId{get; set;}
    public GE_HQ_Account_Plan__c aPlan{get;set;}
    public String DashId{get; set;}
    public String Report0Id{get; set;}
    public String Report0Name{get; set;}
    public String Report1Id{get; set;}
    public String Report1Name{get; set;}
    public String Report2Id{get; set;}
    public String Report2Name{get; set;}
    public String Report3Id{get; set;}
    public String Report3Name{get; set;}
    public String Report4Id{get; set;}
    public String Report4Name{get; set;}
    public String Report5Id{get; set;}
    public String Report5Name{get; set;}
    public String Report6Id{get; set;}
    public String Report6Name{get; set;}
    
    public String AccPlanName{get; set;}
    Public String DDUNS{get; set;}
    public List<SelectOption> tiers{get;set;}
    public String tier2{get;set;}
    public String tier3{get;set;}
    public String accName{get;set;}
    public Embedded_Analytics_Extn(ApexPages.StandardController controller){
        //Report r0=[select id,name,developerName from Report where developerName='TOTAL_CurrYr_IFRU'];
        //Report0Id=r0.id;
        //Report0Name=r0.name;
        Report r1=[select id,name,developerName from Report where developerName='OG_Tier_1_O_G_Region_Current_Year'];
        Report1Id=r1.id;
        Report1Name=r1.name;
        Report r2=[select id,name,developerName from Report where developerName='OG_Forecast_by_PL_Current_Year'];
        Report2Id=r2.id;
        Report2Name=r2.name;
        Report r3=[select id,name,developerName from Report where developerName='OG_Tier_2_Account_Region_Current_Year'];
        Report3Id=r3.id;
        Report3Name=r3.name;
        Report r4=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_OPEN'];
        Report4Id=r4.id;
        Report4Name=r4.name;
        Report r5=[select id,name,developerName from Report where developerName='OG_Oppty_by_Stage_Current_Year'];
        Report5Id=r5.id;
        Report5Name=r5.name;
        Report r6=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_Forecast'];
        Report6Id=r6.id;
        Report6Name=r6.name;
                
        DashId=[select id,developerName from Dashboard where developerName='OG_Account_Plan_Dashboard'].id;
        List<DashboardComponent> comp=[select id,name from DashboardComponent where DashboardId=:DashId];
        Map<String,DashboardComponent> DashCompMap=new Map<String,DashboardComponent>();
        for(DashboardComponent c: comp){
            DashCompMap.put(c.name,c);    
        }
        this.aPlan=(GE_HQ_Account_Plan__c)controller.getRecord();
        GE_HQ_Account_Plan__c AccPlan=[select id,name,GE_HQ_DDUNS_fm__c,GE_HQ_DDUNS_Number__c from GE_HQ_Account_Plan__c where id=:aPlan.Id];
        
        AccPlanName=AccPlan.Name;
        DDUNS=AccPlan.GE_HQ_DDUNS_fm__c;
        Account acc=[select id,name from Account where id=:AccPlan.GE_HQ_DDUNS_Number__c];
        this.accName=acc.name;
        /*
        tiers=new List<SelectOption>();
        tiers.add(new SelectOption('','None'));
        tiers.add(new SelectOption('Turbo Machinery','Turbo Machinery'));
        tiers.add(new SelectOption('PII Pipeline Solutions','Pipeline Solutions'));
        tiers.add(new SelectOption('Global Services (GS)','Global Services'));
        tiers.add(new SelectOption('Mesurement & Control (M&C)','Mesurement & Control'));
        tiers.add(new SelectOption('Drilling & Surface (D&S)','Drilling & Surface'));
        tiers.add(new SelectOption('Subsea (SS)','Subsea'));
        */
    }
    
    public PageReference setTiers(){
        this.tier2=aPlan.GE_OG_Tier_2_P_L__c;
        this.tier3=aPlan.GE_OG_Tier_3_P_L__c;
        return null;
    }
    
}

Public class GE_OG_CalcCustomerCreditLimit
{
//AfterInsert
public void calcCustomerCreditLimitAfterInsert(List<Opportunity>  newOpptyList)
{

    List<Opportunity>  newOpptyList1= (List<Opportunity>)newOpptyList;
    Set<Id> setAccId = new Set<Id>();
    List<GE_HQ_CUST_CREDIT_HIST__c> lstCustCreditHistoryUpdate = new List<GE_HQ_CUST_CREDIT_HIST__c>();
    
    for (Opportunity Opp : newOpptyList1) 
    {
        
        
            if((Opp.StageName=='Active - Commit' || Opp.StageName=='Closed Won')&& (Opp.GE_ES_R_Status__c !=null)  && (Opp.GE_ES_R_Status__c != 'R0') && Opp.GE_HQ_Business_Tier1__c == 'Oil & Gas (O&G)')
            {
                if(Opp.AccountId != null)
                {
                setAccId.add(Opp.AccountId);
                }
            }
                
    } 
    if(!setAccId.isEmpty())
    {
        
        for(GE_HQ_CUST_CREDIT_HIST__c Cch: [select Id, GE_HQ_Acct_Cr_Limit__c, GE_HQ_Cr_Limit_Exceeded__c, GE_HQ_Tot_AR_s__c, GE_HQ_Acc__c from GE_HQ_CUST_CREDIT_HIST__c where GE_HQ_Acc__c in: setAccId])
        {
            GE_HQ_CUST_CREDIT_HIST__c CchUpdate = new GE_HQ_CUST_CREDIT_HIST__c(Id=Cch.Id);
            CchUpdate.GE_HQ_Acct_Cr_Limit__c = Cch.GE_HQ_Acct_Cr_Limit__c;
            lstCustCreditHistoryUpdate.add(CchUpdate);
        }
    }
    if(!lstCustCreditHistoryUpdate.isEmpty())
    {
        update lstCustCreditHistoryUpdate ;
    }
        
   


}
//afterInser closed

//for AfterUpdate
public void calcCustomerCreditLimitAfterUpdate(List<Opportunity>  newOpptyList,Map<Id,Opportunity>  OldMapOpportunity)
{
            List<Opportunity>  newOpptyList1= (List<Opportunity>)newOpptyList;
             
             Map<Id,Opportunity>  oldMapOpportunity1=(Map<Id,Opportunity>)  OldMapOpportunity; 
             
             
    Set<Id> setAccId = new Set<Id>();
    List<GE_HQ_CUST_CREDIT_HIST__c> lstCustCreditHistoryUpdate = new List<GE_HQ_CUST_CREDIT_HIST__c>();
    
    for (Opportunity Opp : newOpptyList1) 
    {
        
        
            Opportunity OppBeforeUpdate = oldMapOpportunity1.get(Opp.Id); 
            if(OppBeforeUpdate.Amount != Opp.Amount || OppBeforeUpdate.StageName != Opp.StageName || OppBeforeUpdate.GE_ES_R_Status__c != Opp.GE_ES_R_Status__c)
            {
                System.debug('In Update====');
                if(Opp.AccountId != null){setAccId.add(Opp.AccountId);}
            }        
        
             
    } 
    if(!setAccId.isEmpty())
    {
        
        for(GE_HQ_CUST_CREDIT_HIST__c Cch: [select Id, GE_HQ_Acct_Cr_Limit__c, GE_HQ_Cr_Limit_Exceeded__c, GE_HQ_Tot_AR_s__c, GE_HQ_Acc__c from GE_HQ_CUST_CREDIT_HIST__c where GE_HQ_Acc__c in: setAccId])
        {
            GE_HQ_CUST_CREDIT_HIST__c CchUpdate = new GE_HQ_CUST_CREDIT_HIST__c(Id=Cch.Id);
            CchUpdate.GE_HQ_Acct_Cr_Limit__c = Cch.GE_HQ_Acct_Cr_Limit__c;
            lstCustCreditHistoryUpdate.add(CchUpdate);
        }
    }
    if(!lstCustCreditHistoryUpdate.isEmpty())
    {
        update lstCustCreditHistoryUpdate ;
    }


}
// for AfterUpdate close
}
---------------------
@isTest
private class GEOGCalcCustomerCreditLimit_Test{
static testMethod void GEOGCalcCustomerCreditLimit_Test(){ 

    //User usr = new User(LastName='test user',Alias='tuser',DefaultGroupNotificationFrequency='N',DigestFrequency='N',Email='testuser@ge.com',Username='testuserr2@ge.com',EmailEncodingKey='UTF-8',LanguageLocaleKey='en_US',LocaleSidKey='IN',ProfileId= ProfId,TimeZoneSidKey='Asia/Kolkata',UserPermissionsCallCenterAutoLogin=false,UserPermissionsMarketingUser=false,UserPermissionsOfflineUser=false);
    //Insert usr;
    Account Acc = new Account();
    Acc.Name = 'Test account';
    Acc.BillingCountry = 'USA';
    Acc.ShippingCountry = 'USA';
    Acc.ShippingState = 'AT';
    Acc.ShippingCity = 'TestShipping City';
    Acc.ShippingStreet = 'Test Shipping Street';
    Acc.ShippingPostalCode = '101010';
    Acc.GE_HQ_Request_Status__c = 'CMF Approved';
    insert Acc;  
    
    GE_HQ_CUST_CREDIT_HIST__c Cch = new GE_HQ_CUST_CREDIT_HIST__c();
    Cch.GE_HQ_Acc__c = Acc.Id;
    Cch.GE_HQ_Acct_Cr_Limit__c = 2500000;
    Cch.GE_HQ_Cr_Limit_Remaining__c = 1000;
    Cch.GE_HQ_Tot_AR_s__c = 2000; 
    insert Cch;
 
 GE_Configuration_Setting__c cs= new GE_Configuration_Setting__c();
 cs.GE_OG_DTS_OpptyID__c=5490;
 cs.GE_PWNUC_Oppty_ID__c=5490;
 cs.GE_OGGS_Oppty_Id__c=5490;
 cs.GE_OG_Oppty_Id_Counter__c=5490;
 cs.GE_OG_PII_OIDCnt__c=5490;
 cs.GE_OG_SS_WSIDCntr__c=5490;
 cs.name='OG Counter';
 
 insert cs;
 
 
    
    GE_ES_Project__c prj = new GE_ES_Project__c();
    prj.Name = 'TestProject1';
    prj.GE_OG_SS_First_Oil_Date__c=Date.today();
    insert prj;
    
  
     Opportunity oppty = new Opportunity();
    oppty.RecordTypeId =[select id,name from recordtype where name like 'Grouped Flow' limit 1].id;
    oppty.Name= 'Test Oppty1';
    oppty.GE_ES_Project__c = prj.Id;
    oppty.AccountId = Acc.Id;
    oppty.Type = 'Primary';
    oppty.StageName = 'Active - Commit';
    oppty.GE_ES_R_Status__c = 'R1 Submitted';
    oppty.GE_HQ_Business_Tier1__c = 'Oil & Gas (O&G)';
    oppty.CurrencyIsoCode = 'USD';
    oppty.GE_ES_Bid_Due_Date__c = Date.today();
    oppty.CloseDate= Date.today();
    oppty.Amount= 1000;
    oppty.GE_OG_TM_Commercial_Center__c= 'Bari';
    oppty.GE_OG_Stream__c = 'Core Services - Aberdeen';
    oppty.GE_OG_TM_Quote_Type__c = 'Budget';
    oppty.GE_OG_TM_Industrial_Sector__c = 'LNG';
    oppty.GE_OG_TM_Subsector__c = 'CCR';
    oppty.GE_OG_TM_Application_Center__c = 'Bari';
    oppty.GE_OG_TM_RFQ_Received_Date__c = Date.today();
    oppty.GE_OG_TM_Proposal_Assesment__c = 'Tech & Comm With Same Due Date';
    //oppty.GE_OG_Oppty_End_User__c = buyer.Id;
    oppty.End_User__c = Acc.Id;
    oppty.GE_ES_OPPTY_CM__c = 35;
    insert oppty;
    
test.startTest();

 GE_Configuration_Setting__c cs1= new GE_Configuration_Setting__c();
 cs1.GE_OG_DTS_OpptyID__c=5490;
 cs1.GE_PWNUC_Oppty_ID__c=5490;
 cs1.GE_OGGS_Oppty_Id__c=5490;
 cs1.GE_OG_Oppty_Id_Counter__c=5490;
 cs1.GE_OG_PII_OIDCnt__c=5490;
 cs1.GE_OG_SS_WSIDCntr__c=5490;
 cs1.name='OG Counter';
 
 insert cs1;
}

}

for after update is not covering can you please help me out

class:
------
In my class attachments are like below
List<Attachment> kycAtt=[select id,name,body,BodyLength from Attachment where parentId=:kyc.Id and BodyLength>0];
              List<Attachment> erpAtt=[select id,name,body,BodyLength from Attachment where parentId=:erp.Id and BodyLength>0];

 Messaging.EmailFileAttachment[] efaList=new Messaging.EmailFileAttachment[] {};
              
              if(kycAtt.size()>0){
                  for(Attachment att:kycAtt){
                      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                      efa.setFileName(att.name);
                      efa.setBody(att.body);
                      efaList.add(efa);
                  }
              }
              
              if(erpAtt.size()>0){
                  for(Attachment att:erpAtt){
                      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                      efa.setFileName(att.name);
                      efa.setBody(att.body);
                      efaList.add(efa);
                  }
              }
              
              if(efaList.size()>0){
                  mail.setFileAttachments(efaList);
              }

I need to cover these code in test line can you plese 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();
    }
--------------------------------------------------
 

We have devolped a site using .net in our company
and my pjct having sf instance
in that volunteer object is there
In the .net site we have a page to register volunteer ok
i have to save the details in sf volunteers how can i do this?
  • March 11, 2015
  • Like
  • 0