• Fabian Manzano
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Team, 

I have the following trigger on my person accounts and am trying to run the below test class with the following error. 

Error: "System.AssertException: Assertion Failed: Expected: 0, Actual: 1"  on line 40 of my test class.

Appreciate any guidance.

Trigger:
trigger LogPersonAccountChange on Account (before delete, after insert, after undelete)
{
  List<pi__ObjectChangeLog__c> logs = new List<pi__ObjectChangeLog__c>(); 

  if (Trigger.new != null) {
    for (Account account : Trigger.new) {

      if (Account.PersonEmail != null && Account.PersonEmail != '') {
        pi__ObjectChangeLog__c log = new pi__ObjectChangeLog__c();
        log.pi__ObjectFid__c = Account.PersonContactId;
        log.pi__ObjectType__c = 1;
        log.pi__ObjectEmail__c = Account.PersonEmail;

        if  (System.Trigger.isInsert) {
          log.pi__ObjectState__c = 1;
        } else if  (System.Trigger.isDelete) {
          log.pi__ObjectState__c = 2;
        } else if  (System.Trigger.isUnDelete) {
          log.pi__ObjectState__c = 3;

        }
        logs.add(log);
      }
    }
  } else if (Trigger.old != null) {
    for (Account account : Trigger.old) {
      if (Account.PersonEmail != null && Account.PersonEmail != '') {
        pi__ObjectChangeLog__c log = new pi__ObjectChangeLog__c();

        log.pi__ObjectFid__c = Account.PersonContactId

        ;
        log.pi__ObjectType__c = 1;
        log.pi__ObjectEmail__c = Account.PersonEmail;
        if  (System.Trigger.isInsert) {
          log.pi__ObjectState__c = 1;
        } else if  (System.Trigger.isDelete) {
          log.pi__ObjectState__c = 2;
        } else if  (System.Trigger.isUnDelete) {
          log.pi__ObjectState__c = 3;
        }
        logs.add(log);
      }
    }
  }

  if (logs.size() > 0) {

    insert logs;
  }
}
Here is the test class:
 
/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class TestPersonAccountChangeLog {

    static testMethod void LogPersonAccountChangeTest() {
    	
String RecTypeId= [select Id from RecordType where (Name='Ward Residential Buyers') and (SobjectType='Account')].Id;
    	   
    WE_Process__c obj=new WE_Process__c();
    obj.Name='test';
    insert obj;
     
    Account account = new Account();    
    account.FirstName='Test Acc';
    account.LastName='Last Name';
    Account.PersonEmail = 'abc@123.com';
    account.RecordTypeID=RecTypeId;
    insert Account;
        
        System.assertEquals([SELECT COUNT() FROM pi__ObjectChangeLog__c WHERE pi__ObjectEmail__c = :Account.PersonEmail AND pi__ObjectState__c = 1], 1);
        delete Account;
        System.assertEquals([SELECT COUNT() FROM pi__ObjectChangeLog__c WHERE pi__ObjectEmail__c = :Account.PersonEmail AND pi__ObjectState__c = 2], 1);
        undelete Account;
        System.assertEquals([SELECT COUNT() FROM pi__ObjectChangeLog__c WHERE pi__ObjectEmail__c = :Account.PersonEmail AND pi__ObjectState__c = 3], 1);
    }

}


 
I am trying to create a PDF version of an existing visualforce page using Bootstrap.

The visualforce page looks great until I add the renderAs="pdf" attribute to the page, which causes me to receive the following error:

"PDF generation failed. Check the page markup is valid."

When I comment out the following line of code, the pdf generates(without styling obviously)
 
<apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'css/bootstrap.min.css')}" />

Has anyone come across this issue before?
  • September 30, 2015
  • Like
  • 0