+ Start a Discussion
Shruti VishShruti Vish 

Please can any one help me out t write Test Class for this

public without sharing class ReleaseNotesController {
    @AuraEnabled public static String getReleaseNoteUrl ()
        String label = System.Label.P360CommunityReleaseNoteDocumentName; 
        String docId=null,url=null,DocumentId=null,urlId=null;
        System.debug('Custom Label'+label);
        List <Document> doc=[SELECT Id, Name, NamespacePrefix FROM Document where Name=:label limit 1];
        if (doc != null && doc.size()>0)
            docId = doc[0].Id;
            url = System.Label.P360CommunityDocURL; 
            DocumentId=docId.substring(0, 15);
            System.debug('Document Id '+ DocumentId);     
        urlId=url + DocumentId;
        System.debug('URL' +urlId);
        return urlId;
Vivian Charlie 1208Vivian Charlie 1208

Hi Shradha,

Tryu this. The document name must match the Label (P360CommunityReleaseNoteDocumentName) value.


private class testDocClass{
	private testMethod static void(){
		Document doc = new Document();
		doc.Body = Blob.valueOf('Test Document');
		doc.ContentType = 'application/pdf';
		doc.DeveloperName = 'new_doc';
		doc.IsPublic = true;
		doc.Name = 'My Document'; // System.Label.P360CommunityReleaseNoteDocumentName; 
		doc.FolderId = [select id from folder where name = 'My Folder'].id;
		insert document;
		// assert your urlId value here