• DT Developer
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Having issues deloying this Trigger.  The Apex class has 100% coverage but Eclipse requires at least 1% test coverage for the Trigger.  Please help.
 
Trigger:
 

trigger ContractTriggerUpdate on Contract (after update) {

ContractUpdate.AddeCon(trigger.new);

}

Class:

public class ContractUpdate {

public static void AddeCon(Contract [] UpdateContract) {

List<Account> accountsToUpdate = new List<Account>();

for(Contract c: UpdateContract)

{

if ((c.Stage__c=='Completed') && (c.RecordTypeId == '0123000000002Hr') && (c.Status == 'Active')){

Account acc = new Account(Id=c.AccountId,eCon_Completed__c=TRUE);

accountsToUpdate.add(acc);

}

else { Account acc = new Account(Id=c.AccountId,eCon_Completed__c=FALSE);

accountsToUpdate.add(acc);

}

}

update accountsToUpdate;

}

 

public static testMethod void test_AddeCon(){

Account test1 = new Account(Name = 'one', eCon_Completed__c=FALSE);

Account test2 = new Account(Name = 'two',eCon_Completed__c=TRUE);

Account test3 = new Account(Name = 'three',eCon_Completed__c=FALSE);

Account test4 = new Account(Name = 'four',eCon_Completed__c=TRUE);

Account[] accts = new Account[] { test1, test2, test3, test4 };

insert accts;

Contract TestCon1 = new Contract (AccountId = test1.Id, Stage__c = 'Completed',Status = 'Active',RecordTypeId = '0123000000002Hr');

Contract TestCon2 = new Contract (AccountId = test2.Id, Stage__c = 'Install on Hold', Status = 'Active');

Contract TestCon3 = new Contract (AccountId = test3.Id, Stage__c = 'Completed', Status = 'Cancelled', RecordTypeId = '0123000000002Hr');

Contract TestCon4 = new Contract (AccountId = test4.Id, Stage__c = 'Completed',Status = 'Active', RecordTypeId = '0123000000002Hr');

Contract[] con = new Contract[] {TestCon1, TestCon2, TestCon3, TestCon4};

AddeCon(con);

// Execute trigger with test data set

// Confirm results

Account[] acctQuery = [SELECT eCon_Completed__c FROM Account WHERE Id = :accts[0].Id OR Id = :accts[1].Id OR Id = :accts[2].Id OR Id = :accts[3].Id];

System.assertEquals(TRUE, acctQuery[0].eCon_Completed__c);

System.assertEquals(FALSE, acctQuery[1].eCon_Completed__c);

System.assertEquals(FALSE, acctQuery[2].eCon_Completed__c);

System.assertEquals(TRUE, acctQuery[3].eCon_Completed__c);

}

}

 

Thanks in advance

First time creating a Apex Class  and the Trigger and I'm getting a error message:

Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

I have 100% coverage for the Apex Class but can't find any information on getting Apex Trigger Coverage.

Any help is appreciated

Class:

public class ContractUpdate {

public static void AddeCon(Contract [] UpdateContract) {
    List<Account> accountsToUpdate = new List<Account>();
    for(Contract c: UpdateContract)
   
{
    if ((c.Stage__c=='Completed') && (c.RecordTypeId == '0123000000002Hr') && (c.Status == 'Active')){
   Account acc = new Account(Id=c.AccountId,eCon_Completed__c=TRUE);
   accountsToUpdate.add(acc);
  }
 else { Account acc = new Account(Id=c.AccountId,eCon_Completed__c=FALSE);
     accountsToUpdate.add(acc);
 }
 }
 update accountsToUpdate;
}


    public static testMethod void test_AddeCon(){
   

      Account test1 = new Account(Name = 'one', eCon_Completed__c=FALSE);   
      Account test2 = new Account(Name = 'two',eCon_Completed__c=TRUE);
      Account test3 = new Account(Name = 'three',eCon_Completed__c=FALSE);
      Account test4 = new Account(Name = 'four',eCon_Completed__c=TRUE);
      Account[] accts = new Account[] { test1, test2, test3, test4 };
          
       insert accts;
     
      Contract TestCon1 = new Contract (AccountId = test1.Id, Stage__c = 'Completed',Status = 'Active',RecordTypeId = '0123000000002Hr');
      Contract TestCon2 = new Contract (AccountId = test2.Id, Stage__c = 'Install on Hold', Status = 'Active');
      Contract TestCon3 = new Contract (AccountId = test3.Id, Stage__c = 'Completed', Status = 'Cancelled', RecordTypeId = '0123000000002Hr');
      Contract TestCon4 = new Contract (AccountId = test4.Id, Stage__c = 'Completed',Status = 'Active', RecordTypeId = '0123000000002Hr');
      Contract[] con = new Contract[] {TestCon1, TestCon2, TestCon3, TestCon4};
     
      AddeCon(con);
          
      // Execute trigger with test data set
    
      // Confirm results
      Account[] acctQuery = [SELECT eCon_Completed__c FROM Account WHERE Id = :accts[0].Id OR Id = :accts[1].Id OR Id = :accts[2].Id OR Id = :accts[3].Id];
      System.assertEquals(TRUE, acctQuery[0].eCon_Completed__c);
      System.assertEquals(FALSE, acctQuery[1].eCon_Completed__c);
      System.assertEquals(FALSE, acctQuery[2].eCon_Completed__c);
      System.assertEquals(TRUE, acctQuery[3].eCon_Completed__c);
   }
  
}

Trigger:

trigger ContractUpdate on Contract (after update) {

ContractUpdate.AddeCon(Trigger.new);
 
}


Message Edited by DT Developer on 09-16-2008 02:32 PM

Message Edited by DT Developer on 09-16-2008 02:43 PM
Is there a way to transfer data from a Contract to a Account?  The issue we are having is that we need to know if the setup for a Contract that is attached to a Account is Completed.  We currently have a check box on the Contract called "Name of Product" Setup Completed and need that data to show up on the Account.
 
Thanks,
Howard
Is there a way in Salesforce to have the ability to Search a Text Area (Long) field type?  We have a string that comes in from our website that contains 3 letter codes that are seperated a ; and ranges from 4 to 2000 charectors.  Only solution we can come up with is to either seperate the field into 8 - 10 Text Area fields or create around 500 check boxes 1 for each code.
 
Thanks in advance.
Is there a way to transfer data from a Contract to a Account?  The issue we are having is that we need to know if the setup for a Contract that is attached to a Account is Completed.  We currently have a check box on the Contract called "Name of Product" Setup Completed and need that data to show up on the Account.
 
Thanks,
Howard
Can someone please assist me with a formula to block anyone except for the Sys. Admin to close out an Oppt. to a Win.