• Naveen Kumar Reddy Yerram
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Method does not exist or incorrect signature: void addAll(List<Account>) from the type List<Opportunity>

AccoutWrapper_Tests.apxc


@isTest
private class AccountWrapper_Tests {
  @testSetup
  static void loadTestData(){
    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
    List<Opportunity> opps = new List<Opportunity>();
    for(Account a : accounts){
      opps.addAll(TestDataFactory.createAccountsWithOpps(a.Id, 1000));

ERROR:Method does not exist or incorrect signature: void addAll(List<Account>) from the type List<Opportunity>

    } 
    insert opps;
  }

  @isTest static void testPositiveRoundedAveragePrice() {
    List<AccountWrapper> accounts = new List<AccountWrapper>();
    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
      accounts.add(new AccountWrapper(a));
    }
    // sanity check asserting that we have opportunities before executing our tested method.
    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
    Test.startTest();
    for(AccountWrapper a : accounts){
      System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
    }
    Test.stopTest();
  }
    

      @isTest static void testHighPriority() {
        List<AccountWrapper> accounts = new List<AccountWrapper>();
        for(Account a : [SELECT ID, Name FROM ACCOUNT]){
            accounts.add(new AccountWrapper(a));}

          
            List<Opportunity> opps = new List<Opportunity>();
            opps = [SELECT Id,Amount FROM Opportunity];
              for(Opportunity opp :opps ) {
                  opp.amount =2000000;
              }
          update opps;
    
    Test.startTest();
      for(AccountWrapper a : accounts){
      System.assertEquals(a.isHighPriority(), true, 'Priority expected to be high');
      System.debug('get rounded price of opps for accounts b:'+ a.getRoundedAvgPriceOfOpps());
    }
    Test.stopTest();
  }
}

TestDataFactory.apxc

@isTest
public class TestDataFactory {
    public static List<Account> createAccountsWithOpps(Id AccountId, Integer Amount) {
        List<Account> accounts = new List<Account>();
        
        for(Integer numAccts, i=0;i<numAccts;i++) {
            Account a = new Account(Name='TestAccount' + i);
            accounts.add(a);
        }
        insert accounts;
        
        List<Opportunity> opps = new List<Opportunity>();
        for (Integer numAccts, j=0;j<numAccts;j++) {
            Account a = accounts[j];
            // For each account just inserted, add opportunities
            for (Integer numOppsPerAcct, k=0;k<numOppsPerAcct;k++) {
                opps.add(new Opportunity(AccountId=a.Id,
                                       Amount=1000));
            }
        }
        // Insert all opportunities for all accounts.
        insert opps;
        
        return accounts;
    }
}

 
@isTest
private class AccountWrapper_Tests {
  @testSetup
  static void loadTestData(){
    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
    List<Opportunity> opps = new List<Opportunity>();
    for(Account a : accounts){
      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
// anyone tell me where to see for that variable wether it is there are not?
    } 
    insert opps;
  }

  @isTest static void testPositiveRoundedAveragePrice() {
    List<AccountWrapper> accounts = new List<AccountWrapper>();
    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
      accounts.add(new AccountWrapper(a));
    }
    // sanity check asserting that we have opportunities before executing our tested method.
    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
    Test.startTest();
    for(AccountWrapper a : accounts){
      System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
    }
    Test.stopTest();
  }
    

      @isTest static void testHighPriority() {
        List<AccountWrapper> accounts = new List<AccountWrapper>();
        for(Account a : [SELECT ID, Name FROM ACCOUNT]){
            accounts.add(new AccountWrapper(a));}

          
            List<Opportunity> opps = new List<Opportunity>();
            opps = [SELECT Id,Amount FROM Opportunity];
              for(Opportunity opp :opps ) {
                  opp.amount =2000000;
              }
          update opps;
    
    Test.startTest();
      for(AccountWrapper a : accounts){
      System.assertEquals(a.isHighPriority(), true, 'Priority expected to be high');
      System.debug('get rounded price of opps for accounts b:'+ a.getRoundedAvgPriceOfOpps());
    }
    Test.stopTest();
  }
}
@isTest
 

private class AccountWrapper_Tests {
 

  @testSetup
 

  static void loadTestData(){
 

    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
 

    List<Opportunity> opps = new List<Opportunity>();
 

    for(Account a : accounts){
 

      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
 

// Variable does not exist: TestFactory (getting this error)
    }
 

    insert opps;
 

  }
 

  @isTest static void testPositiveRoundedAveragePrice() {
 

    List<AccountWrapper> accounts = new List<AccountWrapper>();
 

    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
 

      accounts.add(new AccountWrapper(a));
 

    }
 

    // sanity check asserting that we have opportunities before executing our tested method.
 

    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
 

    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
 

    Test.startTest();
 

    for(AccountWrapper a : accounts){
 

        
 

        System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
 

        System.assert(!a.isHighPriority());
 

    }
 

    Test.stopTest();
 

  }
 

}
@isTest
private class AccountWrapper_Tests {
  @testSetup
  static void loadTestData(){
    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
    List<Opportunity> opps = new List<Opportunity>();
    for(Account a : accounts){
      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
// anyone tell me where to see for that variable wether it is there are not?
    } 
    insert opps;
  }

  @isTest static void testPositiveRoundedAveragePrice() {
    List<AccountWrapper> accounts = new List<AccountWrapper>();
    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
      accounts.add(new AccountWrapper(a));
    }
    // sanity check asserting that we have opportunities before executing our tested method.
    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
    Test.startTest();
    for(AccountWrapper a : accounts){
      System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
    }
    Test.stopTest();
  }
    

      @isTest static void testHighPriority() {
        List<AccountWrapper> accounts = new List<AccountWrapper>();
        for(Account a : [SELECT ID, Name FROM ACCOUNT]){
            accounts.add(new AccountWrapper(a));}

          
            List<Opportunity> opps = new List<Opportunity>();
            opps = [SELECT Id,Amount FROM Opportunity];
              for(Opportunity opp :opps ) {
                  opp.amount =2000000;
              }
          update opps;
    
    Test.startTest();
      for(AccountWrapper a : accounts){
      System.assertEquals(a.isHighPriority(), true, 'Priority expected to be high');
      System.debug('get rounded price of opps for accounts b:'+ a.getRoundedAvgPriceOfOpps());
    }
    Test.stopTest();
  }
}