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?
NPD_IdeaDashboardController
?