Can't access wrapper list in test method

How certain is a caster of when their spell will end?

Does Peach's float negate shorthop knockback multipliers?

Bent spoke design wheels — feasible?

Why is c4 bad when playing the London against a King's Indian?

Secure offsite backup, even in the case of hacker root access

Pronoun introduced before its antecedent

Company is asking me to work from overseas, but wants me to take a paycut

Did Darth Vader wear the same suit for 20+ years?

1980s (or earlier) book where people live a long time but they have short memories

Word for a small burst of laughter that can't be held back

Is it a problem that pull requests are approved without any comments

How much water is needed to create a Katana capable of cutting flesh, bones and wood?

How to make thick Asian sauces?

correct term describing the action of sending a brand-new ship out into its first seafaring trip

How bad would a partial hash leak be, realistically?

Can you please explain this joke: "I'm going bananas is what I tell my bananas before I leave the house"?

How to pass a regex when finding a directory path in bash?

Why do guitarists wave their guitars?

What's the correct term for a waitress in the Middle Ages?

Did thousands of women die every year due to illegal abortions before Roe v. Wade?

What's the logic behind the the organization of Hamburg's bus transport into "rings"?

Do adult Russians normally hand-write Cyrillic as cursive or as block letters?

Movie where a boy is transported into the future by an alien spaceship

PhD student with mental health issues and bad performance



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 9 hours ago









      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
            8 hours ago











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            8 hours ago











          • 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
            8 hours ago






          • 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
            8 hours ago












          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
            8 hours ago











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            8 hours ago











          • 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
            8 hours ago






          • 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
            8 hours ago
















          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
            8 hours ago











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            8 hours ago











          • 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
            8 hours ago






          • 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
            8 hours ago














          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 8 hours ago

























          answered 9 hours ago









          David ReedDavid Reed

          43.5k82564




          43.5k82564












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

            – sfdcfox
            8 hours ago











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            8 hours ago











          • 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
            8 hours ago






          • 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
            8 hours ago


















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

            – sfdcfox
            8 hours ago











          • Thanks, @sfdcfox! Added inline.

            – David Reed
            8 hours ago











          • 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
            8 hours ago






          • 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
            8 hours ago

















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

          – sfdcfox
          8 hours ago





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

          – sfdcfox
          8 hours ago













          Thanks, @sfdcfox! Added inline.

          – David Reed
          8 hours ago





          Thanks, @sfdcfox! Added inline.

          – David Reed
          8 hours ago













          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
          8 hours ago





          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
          8 hours ago




          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
          8 hours ago






          @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
          8 hours ago


















          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

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її