+ Start a Discussion
Peter BölkePeter Bölke 

Problem testing a Trigger on Knowledge

Hello,

i have trigger on Knowledge_kav but i can not test it properly.

This my Test:
@isTest(SeeAllData=True)
public class TrgKnowledgeSendNotificationTest {
	
    public testMethod static void testAircraftKnowledge(){

        Knowledge__kav art = new Knowledge__kav();
        art.Title = 'Test';
        art.Summary = 'Test Summary';

        art.RecordTypeId = [Select RecordTypeId From Knowledge__kav WHERE RecordType.DeveloperName= 'Plane' Limit 1].RecordTypeId;
        //art.ValidationStatus = 'Validated';
        art.IsVisibleInCsp = true;
        art.IsVisibleInPkb = true;
        art.IsVisibleInPrm = true;
        art.UrlName = 'ttttttttttttttt';
        art.Article_Body__c = 'wergwgwegq rfewrg aerg ear ge r';
        insert art;
        Knowledge__kav art2 = [Select Id, PublishStatus, KnowledgeArticleId, Language, ValidationStatus, RecordType.DeveloperName  FROM Knowledge__kav WHERE Id = :art.Id];
        art2.ValidationStatus = 'Validated';
        update art2;
        System.debug('TEST2 :: ' + art2);
        Knowledge__kav art3 = [Select Id, PublishStatus, KnowledgeArticleId, Language, ValidationStatus, RecordType.DeveloperName  FROM Knowledge__kav WHERE Id = :art2.Id];
        System.debug('TEST3 :: ' + art3);
        update art3;
        KbManagement.PublishingService.publishArticle(art2.KnowledgeArticleId, true);

        Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
        req.setObjectId(art2.KnowledgeArticleId);
        req.setProcessDefinitionNameOrId(UserInfo.getUserId());
        Knowledge__kav art4 = [Select Id, PublishStatus, KnowledgeArticleId, Language, ValidationStatus, RecordType.DeveloperName  FROM Knowledge__kav WHERE Id = :art3.Id];
        //Approval.ProcessResult result =  Approval.process(req);
        //System.debug(result);
		System.debug('TEST4 :: ' +art4);
        
    }
    
}

My problem ist, that the field ValidationStatus is not changed to 'Validated' after i save "art2". When i do a debug for art3 ValidationStatus is 'Not Validated' again.

How can i solve this?

regards
Peter