• CAD Administrator
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2
    Replies
We are trying to put some code coverage on our triggers, but finding the triggers are not firing.

We started with just a trigger on the ContentDocument SObject (after insert, before delete). The unit test creates a FeedItem that is linked to a custom SObject. We take that feed item, use FeedItem.RelatedRecordId (relates to a ContentVersion), the ContentVersion.ContentDocumentId (relates to ContentDocument) and then deletes that ContentDocument. When reviewing the log for this unit test, the code execution stops and no Trigger is fired on the delete DML.
 
private static testMethod void deleteContentDocument()
{
    Property__c property = TestSObjectFactory.buildAndInsertProperty(); //Builds with required data, returns the property requeried after insert)

    FeedItem feedItem = TestSObjectFactory.buildAndInsertFeedItem(property.Id, '.png'); // Builds a feed item with the specified extension and parentId, returns the feed item requeried after insert

    ContentVersion contentVersion = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :feedItem.RelatedRecordId]; //Gets the associated ContentVersion for the specified FeedItem

    ContentDocument contentDocument = [SELECT Id FROM ContentDocument WHERE Id = :contentVersion.ContentDocumentId]; //Gets the associated ContentDocument for this ContentVersion

   delete contentDocument;    
}

We have reviewed the debug log and even added debug statements. The test method completes but the trigger is never fired. Ideas?

Hey Plz chk the Error i want to display the AggregateResult on my Visualforce page but it is generating Error " Invalid field Email for SObject AggregateResult" the code is given below

public with sharing class searchDuplicate {
   public   AggregateResult[] con{get;set;}
   
   public searchDuplicate()
   {
       find();
   }
    public void find(){
      con = [select Email from Contact group by Email having count(Email) > 1];
        System.debug(con);
    }
}

 and Visual Force code is

<apex:page controller="searchDuplicate">
    <apex:pageBlock title="Searching for Duplicate Contacts Record"> 
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!con}" var="c" border="2" cellspacing="5" cellpadding="5">
            <apex:column headerValue="Email" value="{!c['Email']}" />
        </apex:dataTable>
    </apex:pageBlock>     
</apex:page>

 

Hi,

 

I'm trying to write unit tests for Content. It seems that it is impossible to create a Workspace record in Apex, so I guess we have to use an existing one in the org?

 

Bigger question: If I create a Content record, relate it to an existing workspace using FirstPublishLocationId, and insert it, and then try to make an update to that Content record, I get this error:

 

Document with ID: 06930000000YPbp already has an owning Workspace

 

I get the same error whether or not this is in a test class. If I do it outside of a test class, and just use the record Id a few seconds later to do my update, it will work. So, it seems to be time-based... Is it not possible to update a newly created Content record from within a test class?

 

Thanks,

Tom