• srikanth maheshwaram
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies

I got this error when i save my test class:

Error: Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>() 

 CLASS:

public class ContentVersionAlt {
private List<ContentVersion> ContentVersions;
public string host{get;set;}

    public ContentVersionAlt(ApexPages.StandardController controller) {
           host=URL.getSalesforceBaseUrl().toExternalForm();
    }


    public List<ContentVersion> getContentVersions() {

    ContentVersions= [Select c.id ,c.Software_Download__c,c.title,c.description,c.FileType From ContentVersion c where c.Software_Download__c=:System.currentPagereference().getParameters().get('id')];
        return ContentVersions;
    }

}

 

 

TEST CLASS:

@istest
private class ContentVersionAltTest {
 static testMethod void ContentVersionsTest(){

          PageReference pageRef = Page.SoftwareDownloadFiles;
          Test.setCurrentPageReference(pageRef);

        ApexPages.StandardController sc = new ApexPages.standardController();
        //create an instance of the controller
        ContentVersionAlt myPageCon = new ContentVersionAlt(sc);
        myPageCon.getContentVersions();       

         ContentVersion testContentInsert =new ContentVersion(); 
         testContentInsert.ContentURL='http://www.google.com/'; 
         testContentInsert.Title ='Google.com'; 

         insert testContentInsert;   


         ContentVersion testContent = [SELECT ContentDocumentId FROM ContentVersion where Id = :testContentInsert.Id]; 

         ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace WHERE Name='Opportunity Documents ']; 
         ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc(); 
         newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id; 
         newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId; 
         insert newWorkspaceDoc;

         update testContent; 



 }

}

 

 

 

How can i solve this?

Thanks in advantage for any advice.

 

 

 

 

  • August 22, 2013
  • Like
  • 0
Platform Developer I Certification Maintenance (Summer '19)  Challenege code
********************************************************************************
Modify an existing batch Apex job to raise BatchApexErrorEvents

Take an existing batch Apex job class and update it to implement the Database.RaisesPlatformEvents interface. Then, add a trigger on BatchApexErrorEvent that logs exceptions in the batch job to a custom object.
Update the BatchLeadConvert class to implement the Database.RaisesPlatformEvents marker interface.

Create an Apex trigger called BatchApexErrorTrigger on the BatchApexErrorEvent SObject type. For each event record, capture the following fields and save them to the corresponding fields in a new BatchLeadConvertErrors__c record.
AsyncApexJobId: AsyncApexJobId__c
JobScope: Records__c
StackTrace: StackTrace__c
To make the trigger bulk safe, use a single DML statement to insert a list of new records at the end.
****************************************************************



trigger BatchApexErrorTrigger on BatchApexErrorEvent (after insert) {
    
   list<BatchLeadConvertErrors__c> bcr= new List<BatchLeadConvertErrors__c>();
    
    for(BatchApexErrorEvent event: trigger.new){
        
        BatchLeadConvertErrors__c  evrterror= new BatchLeadConvertErrors__c ();
        
        evrterror.AsyncApexJobId__c= event.AsyncApexJobId;
        evrterror.Records__c=event.JobScope;
        evrterror.StackTrace__c=event.StackTrace;     
        bcr.add(evrterror);    
    }
    
    if(bcr.size()>0){
        
        insert bcr;
    }

}

*************************************************************
BatchLeadConvert Apex Batch Class

public with sharing class BatchLeadConvert implements Database.Batchable<SObject>, Database.RaisesPlatformEvents{

// Not be bothered whats here. Just Implement Raises Platform Events Interface.
}