Wrapper in return method for test classSplit a single field into 2 columns for a VF pageSimple Apex class to return a list of stringsFilter and search is not workingCompilation error with a unit testNeed help writing test Apex Classeschema.getglobaldescribe needs test classNot able to escape quote in visualforce page?Cannot Return a List of Strings - Void method must not return a valueTest Class Variable ErrorCan't access wrapper list in test method
Why didn't NASA launch communications relay satellites for the Apollo missions?
Pass USB 3.0 connection through D-SUB connector
Why can't a country print its own money to spend it only abroad?
How should I handle a question regarding my regrets during an interview?
Why is DC so, so, so Democratic?
Why does the salt in the oceans not sink to the bottom?
Quickest way to move a line in a text file before another line in a text file?
What kind of curve (or model) should I fit to my percentage data?
What kind of vegetable has pink and white concentric rings?
Why Lie algebras if what we care about in physics are groups?
Can a warlock shoot multiple beams from the Eldritch Blast cantrip with only a single free hand?
Considerations when providing money to only one child out of two
What would be the effects of (relatively) widespread precognition on the stock market?
Do I care if the housing market has gone up or down, if I'm moving from one house to another?
Function pointer parameter without asterisk
Killing a star safely
Question about differential signals as input of an operational amplifier
Finding Greatest Common Divisor using LuaLatex
Is it OK to accept a job opportunity while planning on not taking it?
How can electronics on board JWST survive the low operating temperature while it's difficult to survive lunar nights?
Are there any English words pronounced with consonants that aren't part of the spelling?
Is there an English word to describe when a sound "protrudes"?
What is the metal bit in the front of this propeller spinner?
Which dice game has a board with 9x9 squares that has different colors on the diagonals and midway on some edges?
Wrapper in return method for test class
Split a single field into 2 columns for a VF pageSimple Apex class to return a list of stringsFilter and search is not workingCompilation error with a unit testNeed help writing test Apex Classeschema.getglobaldescribe needs test classNot able to escape quote in visualforce page?Cannot Return a List of Strings - Void method must not return a valueTest Class Variable ErrorCan't access wrapper list in test method
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm creating a visualforce page for a Dashboard component. In the controller I have a wrapper class and in one of the methods I return a map of a list of the wrapper records. Example trimmed down:
public static Map<String, List<dashData>> makeDashMap(List<CampaignMember> memberList, List<Idea_Dashboard_Campaign__mdt> campList)
Map<String, List<dashData>> dashMap = new Map<String, List<dashData>>();
for(CampaignMember cm : memberList)
dashData d = new dashData();
d.paName = cm.Contact.Idea_Practice__c;
d.campaign1 = 0;
d.campaign2 = 0;
if(!dashMap.containsKey(d.paName))
dashMap.put(d.paName, new List<dashData>d);
else
dashMap.get(d.paName).add(d);
return dashMap;
// Wrapper class
@testVisible public class dashData
public String paName get; set;
public Integer campaign1 get; set;
public Integer campaign2 get; set;
public Integer variance get; set;
I can't compile my test method because I can't figure out the correct syntax to reference the wrapper but a list of the wrapper records. Example:
@IsTest
static void testMakeDashMap()
List<CampaignMember> memberList = [
SELECT Id,
CampaignId,
Contact.Idea_Practice__c
FROM CampaignMember];
List<Idea_Dashboard_Campaign__mdt> campList = [
SELECT MasterLabel,
Campaign_Id__c,
Campaign_Order__c
FROM Idea_Dashboard_Campaign__mdt
ORDER BY Campaign_Order__c ASC];
Test.startTest();
NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Test.stopTest();
System.debug('results are:: ' + results);
I get the error on the result line:
Invalid type: dashData
How can I get the results of the map so I can try and assert that it comes back as expected?
apex unit-test controller
add a comment |
I'm creating a visualforce page for a Dashboard component. In the controller I have a wrapper class and in one of the methods I return a map of a list of the wrapper records. Example trimmed down:
public static Map<String, List<dashData>> makeDashMap(List<CampaignMember> memberList, List<Idea_Dashboard_Campaign__mdt> campList)
Map<String, List<dashData>> dashMap = new Map<String, List<dashData>>();
for(CampaignMember cm : memberList)
dashData d = new dashData();
d.paName = cm.Contact.Idea_Practice__c;
d.campaign1 = 0;
d.campaign2 = 0;
if(!dashMap.containsKey(d.paName))
dashMap.put(d.paName, new List<dashData>d);
else
dashMap.get(d.paName).add(d);
return dashMap;
// Wrapper class
@testVisible public class dashData
public String paName get; set;
public Integer campaign1 get; set;
public Integer campaign2 get; set;
public Integer variance get; set;
I can't compile my test method because I can't figure out the correct syntax to reference the wrapper but a list of the wrapper records. Example:
@IsTest
static void testMakeDashMap()
List<CampaignMember> memberList = [
SELECT Id,
CampaignId,
Contact.Idea_Practice__c
FROM CampaignMember];
List<Idea_Dashboard_Campaign__mdt> campList = [
SELECT MasterLabel,
Campaign_Id__c,
Campaign_Order__c
FROM Idea_Dashboard_Campaign__mdt
ORDER BY Campaign_Order__c ASC];
Test.startTest();
NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Test.stopTest();
System.debug('results are:: ' + results);
I get the error on the result line:
Invalid type: dashData
How can I get the results of the map so I can try and assert that it comes back as expected?
apex unit-test controller
is the outer class namedNPD_IdeaDashboardController?
– Pranay Jaiswal
Jul 12 at 16:45
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51
add a comment |
I'm creating a visualforce page for a Dashboard component. In the controller I have a wrapper class and in one of the methods I return a map of a list of the wrapper records. Example trimmed down:
public static Map<String, List<dashData>> makeDashMap(List<CampaignMember> memberList, List<Idea_Dashboard_Campaign__mdt> campList)
Map<String, List<dashData>> dashMap = new Map<String, List<dashData>>();
for(CampaignMember cm : memberList)
dashData d = new dashData();
d.paName = cm.Contact.Idea_Practice__c;
d.campaign1 = 0;
d.campaign2 = 0;
if(!dashMap.containsKey(d.paName))
dashMap.put(d.paName, new List<dashData>d);
else
dashMap.get(d.paName).add(d);
return dashMap;
// Wrapper class
@testVisible public class dashData
public String paName get; set;
public Integer campaign1 get; set;
public Integer campaign2 get; set;
public Integer variance get; set;
I can't compile my test method because I can't figure out the correct syntax to reference the wrapper but a list of the wrapper records. Example:
@IsTest
static void testMakeDashMap()
List<CampaignMember> memberList = [
SELECT Id,
CampaignId,
Contact.Idea_Practice__c
FROM CampaignMember];
List<Idea_Dashboard_Campaign__mdt> campList = [
SELECT MasterLabel,
Campaign_Id__c,
Campaign_Order__c
FROM Idea_Dashboard_Campaign__mdt
ORDER BY Campaign_Order__c ASC];
Test.startTest();
NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Test.stopTest();
System.debug('results are:: ' + results);
I get the error on the result line:
Invalid type: dashData
How can I get the results of the map so I can try and assert that it comes back as expected?
apex unit-test controller
I'm creating a visualforce page for a Dashboard component. In the controller I have a wrapper class and in one of the methods I return a map of a list of the wrapper records. Example trimmed down:
public static Map<String, List<dashData>> makeDashMap(List<CampaignMember> memberList, List<Idea_Dashboard_Campaign__mdt> campList)
Map<String, List<dashData>> dashMap = new Map<String, List<dashData>>();
for(CampaignMember cm : memberList)
dashData d = new dashData();
d.paName = cm.Contact.Idea_Practice__c;
d.campaign1 = 0;
d.campaign2 = 0;
if(!dashMap.containsKey(d.paName))
dashMap.put(d.paName, new List<dashData>d);
else
dashMap.get(d.paName).add(d);
return dashMap;
// Wrapper class
@testVisible public class dashData
public String paName get; set;
public Integer campaign1 get; set;
public Integer campaign2 get; set;
public Integer variance get; set;
I can't compile my test method because I can't figure out the correct syntax to reference the wrapper but a list of the wrapper records. Example:
@IsTest
static void testMakeDashMap()
List<CampaignMember> memberList = [
SELECT Id,
CampaignId,
Contact.Idea_Practice__c
FROM CampaignMember];
List<Idea_Dashboard_Campaign__mdt> campList = [
SELECT MasterLabel,
Campaign_Id__c,
Campaign_Order__c
FROM Idea_Dashboard_Campaign__mdt
ORDER BY Campaign_Order__c ASC];
Test.startTest();
NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Test.stopTest();
System.debug('results are:: ' + results);
I get the error on the result line:
Invalid type: dashData
How can I get the results of the map so I can try and assert that it comes back as expected?
apex unit-test controller
apex unit-test controller
asked Jul 12 at 16:40
Dan WoodingDan Wooding
2,0601 gold badge15 silver badges41 bronze badges
2,0601 gold badge15 silver badges41 bronze badges
is the outer class namedNPD_IdeaDashboardController?
– Pranay Jaiswal
Jul 12 at 16:45
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51
add a comment |
is the outer class namedNPD_IdeaDashboardController?
– Pranay Jaiswal
Jul 12 at 16:45
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51
is the outer class named
NPD_IdeaDashboardController ?– Pranay Jaiswal
Jul 12 at 16:45
is the outer class named
NPD_IdeaDashboardController ?– Pranay Jaiswal
Jul 12 at 16:45
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51
add a comment |
1 Answer
1
active
oldest
votes
It looks like the issue is on this line
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
There is no dashDatain local namespace, its innerclash so you have to refer it as
Map<String, List<NPD_IdeaDashboardController.dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f269286%2fwrapper-in-return-method-for-test-class%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
It looks like the issue is on this line
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
There is no dashDatain local namespace, its innerclash so you have to refer it as
Map<String, List<NPD_IdeaDashboardController.dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
add a comment |
It looks like the issue is on this line
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
There is no dashDatain local namespace, its innerclash so you have to refer it as
Map<String, List<NPD_IdeaDashboardController.dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
add a comment |
It looks like the issue is on this line
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
There is no dashDatain local namespace, its innerclash so you have to refer it as
Map<String, List<NPD_IdeaDashboardController.dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
It looks like the issue is on this line
Map<String, List<dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
There is no dashDatain local namespace, its innerclash so you have to refer it as
Map<String, List<NPD_IdeaDashboardController.dashData>> results = NPD_IdeaDashboardController.makeDashMap(memberList, campList);
answered Jul 12 at 16:47
Pranay JaiswalPranay Jaiswal
22.6k5 gold badges33 silver badges73 bronze badges
22.6k5 gold badges33 silver badges73 bronze badges
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
add a comment |
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
Do I still need the line above it then? The NPD_IdeaDashboardController.dashData dashData = new NPD_IdeaDashboardController.dashData();
– Dan Wooding
Jul 12 at 17:25
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
@DanWooding yes you have to. There is no import statements in apex that will ensure the dataDash you are referring is the correct one
– Pranay Jaiswal
Jul 12 at 17:51
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f269286%2fwrapper-in-return-method-for-test-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
is the outer class named
NPD_IdeaDashboardController?– Pranay Jaiswal
Jul 12 at 16:45
Yes. That's the main class name.
– Dan Wooding
Jul 12 at 16:51