• S Taman
  • NEWBIE
  • 30 Points
  • Member since 2015
  • Tech Lead


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi All,

Need to increase the code coverage of the below Test Class to 75% from 70%.
Test Class :
@isTest
private class updateVisitorActionTest {
  
  
  
  static testMethod void testVisitorAction(){
    
    salyticsusa__Visitor_Action__c sal = new salyticsusa__Visitor_Action__c();
        sal.salyticsusa__Action_ID__c='5360F9BA5AFB4CF79D675C380D7A31FA1';
       sal.salyticsusa__URL__c='https://c.cs14.visual.force.com/apex/Supplierforce_Client_acc_page?id=001i0000006D2vL&sfdc.override=1';
  //      sal.salyticsusa__Visitor_Session__c='a1Si0000001IQsPEAW';
        salyticsusa__Visitor_Session__c ses= new salyticsusa__Visitor_Session__c();
        ses.salyticsusa__Non_Persistent_Session__c='123456756790';
        ses.salyticsusa__Persistent_Session__c='123456ADCVBHFDHKKNG5';
        salyticsusa__Visitor__c visitor= new salyticsusa__Visitor__c();
        visitor.salyticsusa__User_ID__c='005i0000000MgOkAAK';
        insert visitor;
        ses.salyticsusa__Visitor__c=visitor.Id;
        insert ses;
        sal.salyticsusa__Visitor_Session__c=ses.Id;
    insert sal;
    
     
    
  }

}
Trigger :
trigger updateVisitorAction on salyticsusa__Visitor_Action__c (before insert) {

  
 for(salyticsusa__Visitor_Action__c va : trigger.new) {
   string acctId;
   string contactId;
   string url = va.salyticsusa__URL__c;
   System.debug(url);
  if(url!=null){
   if(url.contains('Test_Ext_Cont_page?id=003')&&va.salyticsusa__Contact__c==null){
     System.debug('User viewing Contact with Custom Visual Force Page');
     contactId=url.substring(url.lastIndexOf('?id=')+4, url.lastIndexOf('?id=')+19);
     System.debug(contactId);
       va.salyticsusa__Contact__c= contactId;
           if(va.salyticsusa__Current_Action__c==null&&va.salyticsusa__Current_Object__c==null){
             System.debug('Visitor action and object');
          va.salyticsusa__Current_Action__c='View';
         va.salyticsusa__Current_Object__c='VF Contact Page';
           }
     
   }else if(url.contains('Test_Client_acc_page?id=001')&&va.salyticsusa__Account__c==null){
     System.debug('User viewing Account with Custom visual force Page');
     acctId=url.substring(url.lastIndexOf('?id=')+4, url.lastIndexOf('?id=')+19);
     System.debug(acctId);
     va.salyticsusa__Account__c= acctId;
        if(va.salyticsusa__Current_Action__c==null&&va.salyticsusa__Current_Object__c==null){
          System.debug('Visitor action and object');
        va.salyticsusa__Current_Action__c='View';
          va.salyticsusa__Current_Object__c='VF Account Page';
        }
     
   }

}

}

}
Thanks for any help in Advance...!


 
Hi All,

Need to increase the code coverage of the below Test Class to 75% from 70%.
Test Class :
@isTest
private class updateVisitorActionTest {
  
  
  
  static testMethod void testVisitorAction(){
    
    salyticsusa__Visitor_Action__c sal = new salyticsusa__Visitor_Action__c();
        sal.salyticsusa__Action_ID__c='5360F9BA5AFB4CF79D675C380D7A31FA1';
       sal.salyticsusa__URL__c='https://c.cs14.visual.force.com/apex/Supplierforce_Client_acc_page?id=001i0000006D2vL&sfdc.override=1';
  //      sal.salyticsusa__Visitor_Session__c='a1Si0000001IQsPEAW';
        salyticsusa__Visitor_Session__c ses= new salyticsusa__Visitor_Session__c();
        ses.salyticsusa__Non_Persistent_Session__c='123456756790';
        ses.salyticsusa__Persistent_Session__c='123456ADCVBHFDHKKNG5';
        salyticsusa__Visitor__c visitor= new salyticsusa__Visitor__c();
        visitor.salyticsusa__User_ID__c='005i0000000MgOkAAK';
        insert visitor;
        ses.salyticsusa__Visitor__c=visitor.Id;
        insert ses;
        sal.salyticsusa__Visitor_Session__c=ses.Id;
    insert sal;
    
     
    
  }

}
Trigger :
trigger updateVisitorAction on salyticsusa__Visitor_Action__c (before insert) {

  
 for(salyticsusa__Visitor_Action__c va : trigger.new) {
   string acctId;
   string contactId;
   string url = va.salyticsusa__URL__c;
   System.debug(url);
  if(url!=null){
   if(url.contains('Test_Ext_Cont_page?id=003')&&va.salyticsusa__Contact__c==null){
     System.debug('User viewing Contact with Custom Visual Force Page');
     contactId=url.substring(url.lastIndexOf('?id=')+4, url.lastIndexOf('?id=')+19);
     System.debug(contactId);
       va.salyticsusa__Contact__c= contactId;
           if(va.salyticsusa__Current_Action__c==null&&va.salyticsusa__Current_Object__c==null){
             System.debug('Visitor action and object');
          va.salyticsusa__Current_Action__c='View';
         va.salyticsusa__Current_Object__c='VF Contact Page';
           }
     
   }else if(url.contains('Test_Client_acc_page?id=001')&&va.salyticsusa__Account__c==null){
     System.debug('User viewing Account with Custom visual force Page');
     acctId=url.substring(url.lastIndexOf('?id=')+4, url.lastIndexOf('?id=')+19);
     System.debug(acctId);
     va.salyticsusa__Account__c= acctId;
        if(va.salyticsusa__Current_Action__c==null&&va.salyticsusa__Current_Object__c==null){
          System.debug('Visitor action and object');
        va.salyticsusa__Current_Action__c='View';
          va.salyticsusa__Current_Object__c='VF Account Page';
        }
     
   }

}

}

}
Thanks for any help in Advance...!


 
I have a drop down with fiscal year  as follows
2012-2013
2013-2014
2014-2015
2015-2016.

On section of particular option like 2015-2016.
It should populate data from april 2015 to march 2016.
how this can be achieved.
by formula or by controller class or by creating objects which stores corresponding values like april 2015,may 2015 .....to march 2016.
 

I have a current Apex class in my production, I would like to do a simple tweek to one of the labels used in the Public Group.

I have done the simple change on Sandbox, and its working on Sandbox.

Somehow, I would like to do the same for my Production, but i cannot. I'm not familiar with Apex coding, but i remember it needs some deployment steps from Sandbox into Production.

I need all the guidance as I can get on this.... Any step by step guide would be really great!