• Jim Shorkey 6
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hello,

I am neew to Apex coding and am struggling with the tresting.  I created a class to filter accounts by record type that returns the results correctly.  I have written a test class, but I am receiving an error message  that reads "Constructor not defined: [ApexPages.StandardSetController].()".  I am not able to figure out or find the solution to fix this error.  Below is the code from the test class:

@isTest
public class TestFilterAccountSummary {
 static testMethod void myAccountFilterTest() {

    Account acc = new Account(Name='Test Account');
    insert acc;
   
     Test.StartTest();
      ApexPages.StandardSetController sOC = new ApexPages.StandardSetController();
        sOC.setSelected(new List<Account>{acc});
        FilterAccountSummary fAS = new FilterAccountSummary(sOC);

     Test.StopTest();
   
    }
}

The error is in line 9 which I have ubderlined in the code above.

I have also posted the code for the Apex class that I am testing below: (This code is working as expected, but thought it may be helpful)

public class FilterAccountSummary {
    public ApexPages.StandardSetController Acc {
        get {
            if (Acc == null){
                Acc = new
                    ApexPages.StandardSetController(Database.getQueryLocator(
                        [Select
                        Id,
                        Name,
                        RecordType.Name,
                        Industry
                        From Account
                        Where RecordType.Name In ('Standard BDAP')]));
            }
            return Acc;
        }
        set;
    }
    public List <Account> getAccounts(){
        Return (List<Account>) Acc.getRecords();
    }

}

Thank you in advance for your help,
Jim
I am trying to learn Apex coding and I am unable to figure out how to write a test class for the code below:

public class FilterTasksCall {
   
    public Task[] tasks {get; private set;}
   
    public FilterTasksCall() {
        Id id = (Id) ApexPages.currentPage().getParameters().get('id');
         tasks = [Select
                    Who.Id,
                    Who.Name,
                    Id,
                    Subject,
                    What.Name,
                    ActivityDate,
                    Owner.Name,
                    Status,
                    LastModifiedDate
                    From Task
                    Where Subject Like '%Call%' and Who.Id=:ApexPages.currentPage().getParameters().get('id')];
    }

}

Thank you and your help is very much appreciated,
Jim
Hello,

I am neew to Apex coding and am struggling with the tresting.  I created a class to filter accounts by record type that returns the results correctly.  I have written a test class, but I am receiving an error message  that reads "Constructor not defined: [ApexPages.StandardSetController].()".  I am not able to figure out or find the solution to fix this error.  Below is the code from the test class:

@isTest
public class TestFilterAccountSummary {
 static testMethod void myAccountFilterTest() {

    Account acc = new Account(Name='Test Account');
    insert acc;
   
     Test.StartTest();
      ApexPages.StandardSetController sOC = new ApexPages.StandardSetController();
        sOC.setSelected(new List<Account>{acc});
        FilterAccountSummary fAS = new FilterAccountSummary(sOC);

     Test.StopTest();
   
    }
}

The error is in line 9 which I have ubderlined in the code above.

I have also posted the code for the Apex class that I am testing below: (This code is working as expected, but thought it may be helpful)

public class FilterAccountSummary {
    public ApexPages.StandardSetController Acc {
        get {
            if (Acc == null){
                Acc = new
                    ApexPages.StandardSetController(Database.getQueryLocator(
                        [Select
                        Id,
                        Name,
                        RecordType.Name,
                        Industry
                        From Account
                        Where RecordType.Name In ('Standard BDAP')]));
            }
            return Acc;
        }
        set;
    }
    public List <Account> getAccounts(){
        Return (List<Account>) Acc.getRecords();
    }

}

Thank you in advance for your help,
Jim
I am trying to learn Apex coding and I am unable to figure out how to write a test class for the code below:

public class FilterTasksCall {
   
    public Task[] tasks {get; private set;}
   
    public FilterTasksCall() {
        Id id = (Id) ApexPages.currentPage().getParameters().get('id');
         tasks = [Select
                    Who.Id,
                    Who.Name,
                    Id,
                    Subject,
                    What.Name,
                    ActivityDate,
                    Owner.Name,
                    Status,
                    LastModifiedDate
                    From Task
                    Where Subject Like '%Call%' and Who.Id=:ApexPages.currentPage().getParameters().get('id')];
    }

}

Thank you and your help is very much appreciated,
Jim