Can't access wrapper list in test method

What is the color of artificial intelligence?

Who won a Game of Bar Dice?

Is an entry level DSLR going to shoot nice portrait pictures?

Extreme flexible working hours: how to get to know people and activities?

How did old MS-DOS games utilize various graphic cards?

Why is a common reference string needed in zero knowledge proofs?

Getting UPS Power from One Room to Another

English word for "product of tinkering"

Is White controlling this game?

US doctor working in Tripoli wants me to open online account

What is inside of the 200 star chest?

What is the maximum number of net attacks that one can make in a round?

How do you say "homebrewer" in Spanish?

How can I get an unreasonable manager to approve time off?

How to ensure color fidelity of the same file on two computers?

Writing an augmented sixth chord on the flattened supertonic

Heap allocation on microcontroller

Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?

Is it expected that a reader will skip parts of what you write?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Ability To Change Root User Password (Vulnerability?)

How do you identify file type/compression in a TIFF file?

Non-aqueous eyes?

Fermat's statement about the ancients: How serious was he?



Can't access wrapper list in test method







.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a helper class that has a wrapper class in it. I use the wrapper to return two lists in a method.



Example:



public static revenueWrapper createRevenue(List<Project_Submission__c> projSubList, Map<String, Period> periodMap)
{
revenueWrapper rev = new revenueWrapper();

for(Project_Submission__c ps : projSubList)

Revenue_Pipeline__c revPipe = new Revenue_Pipeline__c();
revPipe.External_Id__c = extCom;
revPipe.NPD_Forecast_Category__c = 'Commercial Budget';
revPipe.CurrencyIsoCode = ps.CurrencyIsoCode;
revPipe.Project_Submission__c = ps.Id;
rev.revPipe.add(revPipe);

rev.revPipeSchedule.addAll(createschedule(ps.Id, launch));


public class revenueWrapper

List<Revenue_Pipeline__c> revPipe = new List<Revenue_Pipeline__c>();
List<Revenue_Pipeline_Schedule__c> revPipeSchedule = new List<Revenue_Pipeline_Schedule__c>();



Now in my test I'm sending info to the method and returning a result:



 @isTest static void testcreateRevenue_B1()

List<Project_Submission__c> ps = [
SELECT Id,
CurrencyISOCode,
Year_1_Commercial_Budget__c
FROM Project_Submission__c];
ps[0].Target_Launch_Date__c = System.Date.today();
ps[0].Year_1_Commercial_Budget__c = 1000;

List<Period> periodList = NPD_ProjectSubmissionHelper.getfiscalPeriod();
Map<String, Period> periodMap = NPD_ProjectSubmissionHelper.makeMap(periodList);

Test.startTest();
NPD_ProjectSubmissionHelper.revenueWrapper results = new NPD_ProjectSubmissionHelper.revenueWrapper();
results = NPD_ProjectSubmissionHelper.createRevenue(ps, periodMap);

System.debug('results are:: ' + results);

//System.assertEquals(1, results,
//'The revenue should have been created');
Test.stopTest();



In the dev console in the debug log I can see that the the revPipe list is populated from the wrapper




|DEBUG|results are:: revenueWrapper:[revPipe=(Revenue_Pipeline__c:External_Id__c=a0Gm00000037U18EAE-CommercialBudget, NPD_Forecast_Category__c=Commercial Budget, CurrencyIsoCode=USD, Project_Submission__c=a0Gm00000037U18EAE)...




My problem is when I try to reference the list I get the error:




Variable is not visible: NPD_ProjectSubmissionHelper.revenueWrapper.revPipe




How can I get to the wrapper list to assert on? Changing the class to @testVisible does nothing










share|improve this question




























    1















    I have a helper class that has a wrapper class in it. I use the wrapper to return two lists in a method.



    Example:



    public static revenueWrapper createRevenue(List<Project_Submission__c> projSubList, Map<String, Period> periodMap)
    {
    revenueWrapper rev = new revenueWrapper();

    for(Project_Submission__c ps : projSubList)

    Revenue_Pipeline__c revPipe = new Revenue_Pipeline__c();
    revPipe.External_Id__c = extCom;
    revPipe.NPD_Forecast_Category__c = 'Commercial Budget';
    revPipe.CurrencyIsoCode = ps.CurrencyIsoCode;
    revPipe.Project_Submission__c = ps.Id;
    rev.revPipe.add(revPipe);

    rev.revPipeSchedule.addAll(createschedule(ps.Id, launch));


    public class revenueWrapper

    List<Revenue_Pipeline__c> revPipe = new List<Revenue_Pipeline__c>();
    List<Revenue_Pipeline_Schedule__c> revPipeSchedule = new List<Revenue_Pipeline_Schedule__c>();



    Now in my test I'm sending info to the method and returning a result:



     @isTest static void testcreateRevenue_B1()

    List<Project_Submission__c> ps = [
    SELECT Id,
    CurrencyISOCode,
    Year_1_Commercial_Budget__c
    FROM Project_Submission__c];
    ps[0].Target_Launch_Date__c = System.Date.today();
    ps[0].Year_1_Commercial_Budget__c = 1000;

    List<Period> periodList = NPD_ProjectSubmissionHelper.getfiscalPeriod();
    Map<String, Period> periodMap = NPD_ProjectSubmissionHelper.makeMap(periodList);

    Test.startTest();
    NPD_ProjectSubmissionHelper.revenueWrapper results = new NPD_ProjectSubmissionHelper.revenueWrapper();
    results = NPD_ProjectSubmissionHelper.createRevenue(ps, periodMap);

    System.debug('results are:: ' + results);

    //System.assertEquals(1, results,
    //'The revenue should have been created');
    Test.stopTest();



    In the dev console in the debug log I can see that the the revPipe list is populated from the wrapper




    |DEBUG|results are:: revenueWrapper:[revPipe=(Revenue_Pipeline__c:External_Id__c=a0Gm00000037U18EAE-CommercialBudget, NPD_Forecast_Category__c=Commercial Budget, CurrencyIsoCode=USD, Project_Submission__c=a0Gm00000037U18EAE)...




    My problem is when I try to reference the list I get the error:




    Variable is not visible: NPD_ProjectSubmissionHelper.revenueWrapper.revPipe




    How can I get to the wrapper list to assert on? Changing the class to @testVisible does nothing










    share|improve this question
























      1












      1








      1








      I have a helper class that has a wrapper class in it. I use the wrapper to return two lists in a method.



      Example:



      public static revenueWrapper createRevenue(List<Project_Submission__c> projSubList, Map<String, Period> periodMap)
      {
      revenueWrapper rev = new revenueWrapper();

      for(Project_Submission__c ps : projSubList)

      Revenue_Pipeline__c revPipe = new Revenue_Pipeline__c();
      revPipe.External_Id__c = extCom;
      revPipe.NPD_Forecast_Category__c = 'Commercial Budget';
      revPipe.CurrencyIsoCode = ps.CurrencyIsoCode;
      revPipe.Project_Submission__c = ps.Id;
      rev.revPipe.add(revPipe);

      rev.revPipeSchedule.addAll(createschedule(ps.Id, launch));


      public class revenueWrapper

      List<Revenue_Pipeline__c> revPipe = new List<Revenue_Pipeline__c>();
      List<Revenue_Pipeline_Schedule__c> revPipeSchedule = new List<Revenue_Pipeline_Schedule__c>();



      Now in my test I'm sending info to the method and returning a result:



       @isTest static void testcreateRevenue_B1()

      List<Project_Submission__c> ps = [
      SELECT Id,
      CurrencyISOCode,
      Year_1_Commercial_Budget__c
      FROM Project_Submission__c];
      ps[0].Target_Launch_Date__c = System.Date.today();
      ps[0].Year_1_Commercial_Budget__c = 1000;

      List<Period> periodList = NPD_ProjectSubmissionHelper.getfiscalPeriod();
      Map<String, Period> periodMap = NPD_ProjectSubmissionHelper.makeMap(periodList);

      Test.startTest();
      NPD_ProjectSubmissionHelper.revenueWrapper results = new NPD_ProjectSubmissionHelper.revenueWrapper();
      results = NPD_ProjectSubmissionHelper.createRevenue(ps, periodMap);

      System.debug('results are:: ' + results);

      //System.assertEquals(1, results,
      //'The revenue should have been created');
      Test.stopTest();



      In the dev console in the debug log I can see that the the revPipe list is populated from the wrapper




      |DEBUG|results are:: revenueWrapper:[revPipe=(Revenue_Pipeline__c:External_Id__c=a0Gm00000037U18EAE-CommercialBudget, NPD_Forecast_Category__c=Commercial Budget, CurrencyIsoCode=USD, Project_Submission__c=a0Gm00000037U18EAE)...




      My problem is when I try to reference the list I get the error:




      Variable is not visible: NPD_ProjectSubmissionHelper.revenueWrapper.revPipe




      How can I get to the wrapper list to assert on? Changing the class to @testVisible does nothing










      share|improve this question














      I have a helper class that has a wrapper class in it. I use the wrapper to return two lists in a method.



      Example:



      public static revenueWrapper createRevenue(List<Project_Submission__c> projSubList, Map<String, Period> periodMap)
      {
      revenueWrapper rev = new revenueWrapper();

      for(Project_Submission__c ps : projSubList)

      Revenue_Pipeline__c revPipe = new Revenue_Pipeline__c();
      revPipe.External_Id__c = extCom;
      revPipe.NPD_Forecast_Category__c = 'Commercial Budget';
      revPipe.CurrencyIsoCode = ps.CurrencyIsoCode;
      revPipe.Project_Submission__c = ps.Id;
      rev.revPipe.add(revPipe);

      rev.revPipeSchedule.addAll(createschedule(ps.Id, launch));


      public class revenueWrapper

      List<Revenue_Pipeline__c> revPipe = new List<Revenue_Pipeline__c>();
      List<Revenue_Pipeline_Schedule__c> revPipeSchedule = new List<Revenue_Pipeline_Schedule__c>();



      Now in my test I'm sending info to the method and returning a result:



       @isTest static void testcreateRevenue_B1()

      List<Project_Submission__c> ps = [
      SELECT Id,
      CurrencyISOCode,
      Year_1_Commercial_Budget__c
      FROM Project_Submission__c];
      ps[0].Target_Launch_Date__c = System.Date.today();
      ps[0].Year_1_Commercial_Budget__c = 1000;

      List<Period> periodList = NPD_ProjectSubmissionHelper.getfiscalPeriod();
      Map<String, Period> periodMap = NPD_ProjectSubmissionHelper.makeMap(periodList);

      Test.startTest();
      NPD_ProjectSubmissionHelper.revenueWrapper results = new NPD_ProjectSubmissionHelper.revenueWrapper();
      results = NPD_ProjectSubmissionHelper.createRevenue(ps, periodMap);

      System.debug('results are:: ' + results);

      //System.assertEquals(1, results,
      //'The revenue should have been created');
      Test.stopTest();



      In the dev console in the debug log I can see that the the revPipe list is populated from the wrapper




      |DEBUG|results are:: revenueWrapper:[revPipe=(Revenue_Pipeline__c:External_Id__c=a0Gm00000037U18EAE-CommercialBudget, NPD_Forecast_Category__c=Commercial Budget, CurrencyIsoCode=USD, Project_Submission__c=a0Gm00000037U18EAE)...




      My problem is when I try to reference the list I get the error:




      Variable is not visible: NPD_ProjectSubmissionHelper.revenueWrapper.revPipe




      How can I get to the wrapper list to assert on? Changing the class to @testVisible does nothing







      apex unit-test






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 31 at 20:23









      Dan WoodingDan Wooding

      1,9951539




      1,9951539




















          1 Answer
          1






          active

          oldest

          votes


















          4














          The wrapper class's instance variables have no access specifier, meaning that they get private as the default:



          [private] List<Revenue_Pipeline__c> revPipe = ;
          [private] List<Revenue_Pipeline_Schedule__c> = ;


          It's the instance variables that need the @TestVisible annotation, rather than their enclosing class. That will make them available in test code.






          share|improve this answer

























          • Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

            – sfdcfox
            May 31 at 20:34











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            May 31 at 20:35











          • I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

            – Dan Wooding
            May 31 at 20:43






          • 2





            @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

            – David Reed
            May 31 at 20:51












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f264421%2fcant-access-wrapper-list-in-test-method%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          The wrapper class's instance variables have no access specifier, meaning that they get private as the default:



          [private] List<Revenue_Pipeline__c> revPipe = ;
          [private] List<Revenue_Pipeline_Schedule__c> = ;


          It's the instance variables that need the @TestVisible annotation, rather than their enclosing class. That will make them available in test code.






          share|improve this answer

























          • Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

            – sfdcfox
            May 31 at 20:34











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            May 31 at 20:35











          • I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

            – Dan Wooding
            May 31 at 20:43






          • 2





            @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

            – David Reed
            May 31 at 20:51
















          4














          The wrapper class's instance variables have no access specifier, meaning that they get private as the default:



          [private] List<Revenue_Pipeline__c> revPipe = ;
          [private] List<Revenue_Pipeline_Schedule__c> = ;


          It's the instance variables that need the @TestVisible annotation, rather than their enclosing class. That will make them available in test code.






          share|improve this answer

























          • Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

            – sfdcfox
            May 31 at 20:34











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            May 31 at 20:35











          • I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

            – Dan Wooding
            May 31 at 20:43






          • 2





            @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

            – David Reed
            May 31 at 20:51














          4












          4








          4







          The wrapper class's instance variables have no access specifier, meaning that they get private as the default:



          [private] List<Revenue_Pipeline__c> revPipe = ;
          [private] List<Revenue_Pipeline_Schedule__c> = ;


          It's the instance variables that need the @TestVisible annotation, rather than their enclosing class. That will make them available in test code.






          share|improve this answer















          The wrapper class's instance variables have no access specifier, meaning that they get private as the default:



          [private] List<Revenue_Pipeline__c> revPipe = ;
          [private] List<Revenue_Pipeline_Schedule__c> = ;


          It's the instance variables that need the @TestVisible annotation, rather than their enclosing class. That will make them available in test code.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 31 at 20:34

























          answered May 31 at 20:31









          David ReedDavid Reed

          44k82564




          44k82564












          • Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

            – sfdcfox
            May 31 at 20:34











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            May 31 at 20:35











          • I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

            – Dan Wooding
            May 31 at 20:43






          • 2





            @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

            – David Reed
            May 31 at 20:51


















          • Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

            – sfdcfox
            May 31 at 20:34











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            May 31 at 20:35











          • I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

            – Dan Wooding
            May 31 at 20:43






          • 2





            @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

            – David Reed
            May 31 at 20:51

















          Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

          – sfdcfox
          May 31 at 20:34





          Link to doc, in case you want to put that in: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…

          – sfdcfox
          May 31 at 20:34













          Thanks, @sfdcfox! Added inline.

          – David Reed
          May 31 at 20:35





          Thanks, @sfdcfox! Added inline.

          – David Reed
          May 31 at 20:35













          I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

          – Dan Wooding
          May 31 at 20:43





          I read a few posts where someone wrote making @testVisible is a last resort. In theory I can make it public list<revenue pipeline>.. and get the same results?

          – Dan Wooding
          May 31 at 20:43




          2




          2





          @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

          – David Reed
          May 31 at 20:51






          @DanWooding Yeah, that'll work fine. The only reason I am aware of not to use @TestVisible is based on (a) ideological purity about OOP encapsulation or (b) concern about making the tests fragile by inspecting the inner state of your classes that are felt to be implementation details. public of course has a much broader effect.

          – David Reed
          May 31 at 20:51


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f264421%2fcant-access-wrapper-list-in-test-method%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form