• Teagan Glenn 9
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    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?
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?
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?