• Harrison Linn
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
New to coding and would really appreciate any help that can be provided.

I am trying to write a test class for a function I have written that creates Opportunities for each account in a list.  On compile I am receiving the error 'Method does not exist or incorrect signture: void CreateOpptys(Id, List) from the type multiPicklistCtrl.  Can someone please tell me what I am doing wrong?

This is my test class:

static testmethod void CreateOpptysTest(){
        Id RecordTypeIdPropAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Property').getRecordTypeId();
        
        Account pAcct = new Account(Name = 'Test Property account', RecordTypeId=RecordTypeIdPropAccount);
        insert pAcct;
        
        PropertySpace__c pSpace = new PropertySpace__c(Name='Test Property Space', Property__c = pAcct.Id, SquareFootage__c = 2000);
        insert pSpace;

        List<Account> accts = new List<Account>();
        for (Integer i=0; i<20; i++) {
            accts.add(new Account(Name = 'Test Account -' +i, RecordTypeId=RecordTypeIdPropAccount));
        }
        insert accts;
        
        accts = [Select Id from Account];
        
        Test.startTest();
          multiPicklistCtrl.CreateOpptys(pSpace.id,accts);
          Test.stopTest();
    }

Here is the function I am trying to write the test for:

@AuraEnabled
    public static void CreateOpptys(Id propertyId, List<Id> selectedAccts){
        system.debug('From Create Oppty propertyId1>>>'+propertyId);
        system.debug('From Create Oppty selectedAccts>>>'+selectedAccts);
        //Need to search through existing Opportunities and if there is an active Opty created for the Account and Property, do not create another Oppty.
        PropertySpace__c propSpace = new PropertySpace__c();
        Id propSpaceId;
        if(string.valueof(propertyId).startsWith('006')){
            opportunity opp= [SELECT PropertySpace__c FROM Opportunity WHERE Id = :propertyId];
               propSpace= getProp(opp.PropertySpace__c);
            propSpaceId = opp.PropertySpace__c;
        }
        else{
            propSpace = [SELECT Name,SquareFootage__c, Property__c FROM PropertySpace__c WHERE Id = :propertyId];
            propSpaceId = propertyId; 
        }
            
        Id recTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Vacancy Fill').getRecordTypeId();
        
         
        list<Opportunity> lstOpptys = new List<Opportunity>();
        for(integer i=0; i< selectedAccts.size(); i++){
            Opportunity o = new Opportunity(Name = propSpace.Name +i,
                                            CloseDate = date.today().addDays(90),
                                            StageName = 'Prospect',
                                            RecordTypeId = recTypeId,
                                            AccountId = selectedAccts[i]);

        lstOpptys.add(o);
        }    
        insert lstOpptys;
        
            
    }

 
New to coding and would really appreciate any help that can be provided.

I am trying to write a test class for a function I have written that creates Opportunities for each account in a list.  On compile I am receiving the error 'Method does not exist or incorrect signture: void CreateOpptys(Id, List) from the type multiPicklistCtrl.  Can someone please tell me what I am doing wrong?

This is my test class:

static testmethod void CreateOpptysTest(){
        Id RecordTypeIdPropAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Property').getRecordTypeId();
        
        Account pAcct = new Account(Name = 'Test Property account', RecordTypeId=RecordTypeIdPropAccount);
        insert pAcct;
        
        PropertySpace__c pSpace = new PropertySpace__c(Name='Test Property Space', Property__c = pAcct.Id, SquareFootage__c = 2000);
        insert pSpace;

        List<Account> accts = new List<Account>();
        for (Integer i=0; i<20; i++) {
            accts.add(new Account(Name = 'Test Account -' +i, RecordTypeId=RecordTypeIdPropAccount));
        }
        insert accts;
        
        accts = [Select Id from Account];
        
        Test.startTest();
          multiPicklistCtrl.CreateOpptys(pSpace.id,accts);
          Test.stopTest();
    }

Here is the function I am trying to write the test for:

@AuraEnabled
    public static void CreateOpptys(Id propertyId, List<Id> selectedAccts){
        system.debug('From Create Oppty propertyId1>>>'+propertyId);
        system.debug('From Create Oppty selectedAccts>>>'+selectedAccts);
        //Need to search through existing Opportunities and if there is an active Opty created for the Account and Property, do not create another Oppty.
        PropertySpace__c propSpace = new PropertySpace__c();
        Id propSpaceId;
        if(string.valueof(propertyId).startsWith('006')){
            opportunity opp= [SELECT PropertySpace__c FROM Opportunity WHERE Id = :propertyId];
               propSpace= getProp(opp.PropertySpace__c);
            propSpaceId = opp.PropertySpace__c;
        }
        else{
            propSpace = [SELECT Name,SquareFootage__c, Property__c FROM PropertySpace__c WHERE Id = :propertyId];
            propSpaceId = propertyId; 
        }
            
        Id recTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Vacancy Fill').getRecordTypeId();
        
         
        list<Opportunity> lstOpptys = new List<Opportunity>();
        for(integer i=0; i< selectedAccts.size(); i++){
            Opportunity o = new Opportunity(Name = propSpace.Name +i,
                                            CloseDate = date.today().addDays(90),
                                            StageName = 'Prospect',
                                            RecordTypeId = recTypeId,
                                            AccountId = selectedAccts[i]);

        lstOpptys.add(o);
        }    
        insert lstOpptys;
        
            
    }