0

I'm having created a pretty simple test Utility Class. the utility class should create two records: an account and a related child (Legal entity). Legal entity is a master detail relationship to the account.

This is the utility class I have created.

public class LegalEntityV1{

    public static Account createOneAccount(){  
        Account testAccount = createAcct('ABC Computing inc.');     
        Legal_Entity__c testLegalEntity = createLE(testAccount); 
        return testAccount;        
    }

    // Helper methods //
    //   
    public static Account createAcct(string accountName) { 
        Account a = new Account(
            Name=accountName);
        insert a;
        return a;
    }

    public static Legal_Entity__c createLE(Account a){
        Legal_Entity__c c = new Legal_Entity__c(
            Legal_Entity_Code__c = '1',
            Name = 'name',
            Organisation__c = a.ID); // *** Error is here ***
        insert c;
        return c; 
    } 
}

I have another class which calls the method above. However I am getting the following error:

Compile Error: Method does not exist or incorrect signature: createAcct(String) at line 17 column 28

@isTest
public class bg_AMLProcessExtension_Test {


//DM Attempt // 
// Test data setup create 1 account with one Legal entity by calling utility method

public static void TestDeleteAccountWithOneOpportunity() {

     Account testAccount = createAcct('Test');
insert testAccount;

LegalEntity testEntity = createLE('Test LE', testAccount.ID);
insert testEntity;

            AML_Process__c aml = new AML_Process__c(
            //Client__c = testAccount1.Id,
            Legal_Entity__c = testEntity.Id,
            Client_Director__c = UserInfo.getUserId(), 
            Client_Executive__c = UserInfo.getUserId(), 
            Legal_Entity_Name__c = 'SIM UK',
            Stage__c = 'Checks In Progress', 
            Screening_1_Complete__c = Label.AML_Screening_1_Not_Complete, 
            Screening_2_Complete__c = Label.AML_Screening_2_Not_Complete
        );
        insert aml;

1 Answer 1

2

The method is in a different class, so you have to reference it via a static reference:

 Account testAccount = LegalEntityV1.createAcct('Test');

You can only omit the class name for a static method if the method is in the same class.

5
  • sfdcfox thanks for pointing this out. Although I have added Account testAccount = LegalEntityV1.createAcct('Test'); I am now getting another error Method does not exist or incorrect signature: createLE(String, Id)
    – user40372
    Dec 28, 2016 at 1:26
  • It's the same exact issue...
    – Adrian Larson
    Dec 28, 2016 at 1:30
  • @Adrian I thought that and changed the line to "LegalEntity testEntity = LegalEntityV1.createLE('Test LE', testAccount.ID); insert testEntity;" but I am getting this error message "Method does not exist or incorrect signature: LegalEntityV1.createLE(String, Id) at line 20 column 26"
    – user40372
    Dec 28, 2016 at 1:32
  • The method accepts just one parameter of type Account.
    – Adrian Larson
    Dec 28, 2016 at 1:34
  • @Adrian - so how do you can I populate the following line ; Legal_Entity__c = testEntity.Id, Apologises for asking basic questions. very new to apex and been reading examples but just a little confused. are you saying that the public class LegalEntityV1 only has the account and not a legal entity ?
    – user40372
    Dec 28, 2016 at 1:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .