• Fresco
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies

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?