• csrsak
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 8
    Replies

Hi Folks,

 

Please help me to write Test class for Trigger Class below.

 

 

trigger TriggerAfterLeadConversion on Lead (after update)

{

 for(Lead lead:Trigger.new)

 {

 if (Lead.IsConverted)

{

 

 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId]; con.Birthdate = lead.Date_Of_Birth__c; con.Email=lead.Email; update con;

}

 }

 }

 

Thanks in advance

 

Thanks & Regards

Srinivas

Hi Friends,

 

I have a requirement for doing the calculation in formula field,

 

when I save the calculation of a formula field,

 

it is showing the,

 

Compiled formula is too big to execute (6,395 characters). Maximum size is 5,000 characters.

 

formula is looking like this,

[CV* ( 1+IPV/100)**( NM/12)] +[ Sum from Y= 1to Y=NY of { AC* [( 1+ INCC/100)**( NY-Y+1)] *[ (1+IPV/100)**Y]},

as our requirement i did this formula is like this,

Financial_Detail__r.Plan_current_value__c * ( ( Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c ) ^ ( CEILING( Complete_month_bwn_maturity_year_today__c / 12) ) )

+

( Complete_years_bwn_Maturity_yr_today__c )
*
(( Plan_Annual_Contribution__c )
*
(( ((1+ Rate_of_incr_in_contributions_this_plan__c ) ^CEILING ( Complete_years_bwn_Maturity_yr_today__c-( YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ) )+1 ))

*

((1+ Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c )^CEILING(YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ))))))

 

 

Can any one please tell me,how to resolve this problem?

 

Thanks in Advance,

 

Thanks and Regards,

Srinivas Chittela

Message Edited by csrsak on 09-10-2009 02:40 AM

Hi Friends,

 

I am new into this salesforce.com platform, as of my requirement I did the test class,

 

When I run the test class, it shows 35% of test coverage,

 

Please help me to resolve the remaining.

 

Trigger is:

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
      
Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;
    
      }
  }
}

 

Trigger test class is,

 

@isTest

private class TriggerAfterLeadConversionTest
{

    static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 
 Contact con = new Contact(firstName='srinivas',lastName='reddy',Email='svreddych@gmail.com');
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 update le;
 system.assertEquals('Email',le.Email);
 
    }
}

 

When I run tests for test trigger class it shows,

 

The red color code in trigger are not covered,

 

Please help me to resolve this,

 

Thanks in advance,

 

Regards,

Srinivas Chittela

Hi Folks, 

 

I wrote the trigger test class for trigger, and when I run tests for the trigger test class; 

 

It shows the exception like,

 

System.QueryException:List has no rows for assignment to SObject, 

 

Trigger is,

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
       Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;    
      }
  }
}

 

 

Trigger Test class is, 

 

 

@isTest

private class TriggerAfterLeadConversionTest
{
   static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = '00Q8000000SyVy2EAF'];
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 system.assertEquals('Email',le.Email);
    }
}

 

 

(if i wrote the trigger test class like this, in place of red color in above code, 

 

Contact con = new Contact(Id=le.ID),

 

it shows error like,

 

System.TypeException:Invalid id value for this SObject type: 008000000TCVXmEAp)

 

Please help me to resolve this issue... 

 

Thanks in Advance,

 

Regards, 

 

Srinivas Chittela

 

Message Edited by csrsak on 08-27-2009 05:49 AM
Message Edited by csrsak on 08-27-2009 05:50 AM
Message Edited by csrsak on 08-27-2009 05:51 AM
Hi Folks,  I am new into Salesforce.com; I need to write a test class for trigger, i wrote test class for the following trigger and when i run the test class,  It is showing 0% coverage and the following red color lines are not covered,  Trigger is: trigger insertIntoCustomerContactDetail on Contact (after update)
{
 
for (Contact a : Trigger.new)
     {
       
CustomerContactDetail__c ccd = new CustomerContactDetail__c
        (
           Contact__c = a.id,
           First_Name__c =a.firstName,
           Last_Name__c=a.lastName,
           Date_Of_Birth__c = a.Birthdate,
           Mobile_No__c = a.MobilePhone,
           Email__c = a.Email
         );
         insert ccd ;
      }
 }

 

Test class:

 

@isTestprivate class insertIntoCustomerContactDetailTest {     static testMethod void myUnitTest()     {        Contact a=new Contact();                        //a.id='a018000000McFcK';                        a.firstName='srinu';                        a.lastName='reddy';                        a.Birthdate=Date.newInstance(1984,10,11);                        a.MobilePhone='9711099217';                        a.Email='svreddych@gmail.com';                        try                        {                        update a;                                             CustomerContactDetail__c ccd=new CustomerContactDetail__c                        (                        Contact__c=a.id,                        First_Name__c=a.firstName,                        Last_Name__c=a.lastName,                        Date_Of_Birth__c=a.Birthdate,                        Mobile_No__c=a.MobilePhone,                        Email__c=a.Email                        );                        insert ccd;                        }                                                catch(system.DmlException e)                        {                                    System.debug('we caught a dml exception: ' + e.getDmlMessage(0));                            }    }

}

 

please help me, in this regards.... in correct way.

 

Thanks in Advance, 

 

Srinivas Chittela