+ Start a Discussion
viswadaviswada 

Test Coverage of StandradSetcontroller

HI all ,

 

            I  have class with standardset controller   and written test class for that Class , I am getting erroe like"  if I pass sc1  i am getting error like   Compile Error: Constructor not defined: [IdeaListController].<Constructor>(ApexPages.StandardSetController) at line 27 column 33 amd  code Coverage 44% .  the standardsetcontroller is not covering , any one would help me

 

public class IdeaListController extends IdeaController {

Integer IdeaCountWhenMerged = 0;
public Idea[] mergeList {
get {
if (mergeList == null){
mergeList = [select Id from Idea where ParentIdeaId!=null];
}
return mergeList;
}
set;
}
public Idea[] ideas;
private static final Integer MAX_NUMBER_OF_IDEAS_PER_PAGE = 20;

public ApexPages.IdeaStandardSetController controller;
public Integer total {get;set;}
public String catName {get;set;}

// Page number variables
public Integer totalNumPages{get;set;}
public Integer numPages { get; set; }

public Boolean View {get;set;}
public Boolean ArcView {get;set;}
public Boolean ProView {get;set;}

public String reqWorkspaceBtnList {get;set;}
public String accessWorkspaceBtnList {get;set;}
public String hasAccesstoWorkspace {get;set;}
public Map<String,Integer> participantsList {get;set;}


public List<Id> accessWorkspaceList {get;set;}

public IdeaListController() {

}

public IdeaListController(ApexPages.IdeaStandardSetController controller) {
this.controller = controller;
accessWorkspaceBtnList = '';
reqWorkspaceBtnList = '';
hasAccesstoWorkspace ='';
accessWorkspaceList = new List<Id>();
participantsList = new Map<String, Integer>();
List<SObject> sobj = [SELECT Id,Status, (SELECT Id FROM Votes WHERE Type = 'Up' LIMIT 51),(SELECT Id,Number_Of_Participants__c from WorkspaceList__r)
FROM Idea WHERE Id IN :controller.getIdeaList() AND Categories != 'DevSummit 2012'];
List<Idea> tempIdeaList = (List<Idea>)sobj;
for(Idea obj: tempIdeaList) {
String mapId = obj.Id;
mapId = mapId.substring(0,15);
if (obj.Votes.size() > 50 && obj.Status == NULL) {
if(obj.WorkspaceList__r.size()==0){
reqWorkspaceBtnList += obj.Id + ',';
}
else{
accessWorkspaceBtnList += obj.Id + ',';
accessWorkspaceList.add(obj.Id);
participantsList.put(mapId,Integer.valueOf(obj.WorkspaceList__r[0].Number_Of_Participants__c));
}
}
else{
if(obj.WorkspaceList__r.size()>0){
accessWorkspaceBtnList += obj.Id + ',';
accessWorkspaceList.add(obj.Id);
participantsList.put(mapId,Integer.valueOf(obj.WorkspaceList__r[0].Number_Of_Participants__c));
}
}
}
List<WorkspaceUser__c> workspaceUserList = [Select WorkspaceList__c, WorkspaceList__r.Idea__c, UserName__c From WorkspaceUser__c where UserName__c = :userinfo.getUserId() and WorkspaceList__r.Idea__c IN :accessWorkspaceList];
for(WorkspaceUser__c wu : workspaceUserList){
hasAccesstoWorkspace += wu.WorkspaceList__r.Idea__c +',';
}

}

public String feedName {
get {
if (feedName == null) {
if (IdeaController.SORT_POPULAR.equals(sortParam)) {
feedName = IdeaFeedController.TYPE_POPULAR;

} else if (IdeaController.SORT_RECENT.equals(sortParam)) {
feedName = IdeaFeedController.TYPE_RECENT;

} else if (IdeaController.SORT_TOP.equals(sortParam)) {
feedName = IdeaFeedController.TYPE_TOP;

} else if (IdeaController.SORT_COMMENTS.equals(sortParam)) {
feedName = IdeaFeedController.TYPE_RECENT_COMMENTS;

} else {
feedName = IdeaFeedController.TYPE_POPULAR;

}
}
return feedName;
}
set;
}

public IdeaWithVote[] ideasWithVotes {
get {
if (ideasWithVotes == null) {
ideasWithVotes = IdeaWithVote.getIdeasWithVotes(getIdeas());


}
return ideasWithVotes;
}
set;
}

public String cat {get;set;}
public Integer catSize {get;set;}

public Idea[] getIdeas() {
if (ideas == null) {
if (controller != null) {
ideas = controller.getIdeaList();

}
}
return ideas;
}


public String getPageName() {
return PAGE_LIST;
}

public Boolean getHasPreviousPage() {
return getPageParamInt() > 1;

}

public Boolean getHasNextPage() {
return (ideas.size() == MAX_NUMBER_OF_IDEAS_PER_PAGE);
}

public Integer getPageNumber(){
return getPageParamInt();
}



//Caluculate total number of pages
public Integer gettotalpages(){
Integer tot;

for(Idea I : mergeList){
IdeaCountWhenMerged++;
}

//counting ideas for each category
if(categoryParam=='ArcGIS Server')
{
tot = getServerIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcGIS Desktop')
{
tot = getDesktopIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcGIS Desktop Extensions')
{
tot = getArcGISDesktopExtensions();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcGIS Engine')
{
tot = getEngineIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcGIS Explorer')
{
tot = getExplorerIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}

else if(categoryParam=='ArcGIS Online')
{
tot = getOnlineIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcLogistics')
{
tot = getArcLogistics();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}

else if(categoryParam=='Geodatabase')
{
tot = getGeoDatabase();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Imagery')
{
tot = getImagery();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Maps and Content')
{
tot = getMaps();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Mobile GIS')
{
tot = getMobilegis();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}

else if(categoryParam=='Business Analyst')
{
tot = getBusinessAnalyst();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Esri CityEngine')
{
tot = getCityEngine();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Other Products')
{
tot = getOtherProducts ();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Web Apps and APIs')
{
tot =getWebApps();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Production Mapping (PLTS)')
{
tot = getProdMap();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Service Ideas')
{
tot = getServiceIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Defense and Intelligence')
{
tot = getDefenseandIntelligence();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Education')
{
tot = getEducation();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Local Government')
{
tot = getLocalGovernment();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Mining')
{
tot = getMining();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Federal Government')
{
tot = getFederalGovernment();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Natural Resources')
{
tot = getNaturalResources();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Petroleum')
{
tot = getPetroleum();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}

else if(categoryParam=='Public Safety')
{
tot = getPublicSafety();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Utilities')
{
tot = getUtilities();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Telecommunications')
{
tot = getTelecommunications();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Transportation')
{
tot = getTransportation();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Other Industries')
{
tot = getOtherIndustries();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Water and Wastewater')
{
tot = getWaterandWastewater();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
/*else if(categoryParam=='EGUG 2010')
{
tot=getEGUG2010();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='DevSummit 2012')
{
tot=getDevSummit();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}*/
else if(categoryParam=='Training Ideas')
{
tot=getTrainingIdeas();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='ArcGIS Runtime')
{
tot=getArcGISRuntime();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else if(categoryParam=='Oceans and Maritime')
{
tot=getOceansMaritime();
totalNumPages = Math.round(Math.ceil(tot / ( 1.0 * this.controller.getPageSize())));
}
else
{
totalNumPages = Math.round(Math.ceil((this.controller.getResultSize()-IdeaCountWhenMerged) / ( 1.0 * this.controller.getPageSize())));
//this.controller.getResultSize()
}
return totalNumPages;
}
public String getSort(){
return sortParam;
}

//Do not display the page numbers for comments

public Boolean getcheckSort(){
if(sortParam=='Comments'||statusParam=='Under Consideration'||statusParam=='Implemented'||statusParam=='Deferred')
return false;
else
return true;
}

/* public integer getTest(){
integer intTotal ;

return intTotal;
} */

/*
public string pNUM {get;set;}
public String fullURL;
public String getURL(){
return ApexPages.CurrentPage().getURL();
}
public PageReference goToPage(){
PageReference pageRef = new PageReference(ApexPages.CurrentPage().getURL());
pageRef.getParameters().clear();
pageRef.getParameters().put('p',pNUM);
// pageRef.setRedirect(true);
return pageRef+;
} */

}

 this code not covering ...... How to cover this code  , My  test class is

 

static testMethod void testidealist controller()
{

IdeaTestUtil.setupTest();
TestIdeaController controller = new TestIdeaController();
Community cm=[select id from community];
idea Testideas=new idea(Tags__c='aaaaa',Status_Changed_By__c='bbbb',CommunityId=Cm.id,title='hii');
insert Testideas;
List<Idea> ideas= new List<Idea>();
ideas.add(Testideas);
//IdeaListController Ilc1=New IdeaListController();

ApexPages.StandardsetController sc1= new ApexPages.StandardsetController(Ideas);


IdeaListController Ilc=New IdeaListController() if I pass sc1  i am getting error like   Compile Error: Constructor not defined: [IdeaListController].<Constructor>(ApexPages.StandardSetController) at line 27 column 33

checkFeedName(IdeaController.SORT_POPULAR, IdeaFeedController.TYPE_POPULAR);
checkFeedName(IdeaController.SORT_RECENT, IdeaFeedController.TYPE_RECENT);
checkFeedName(IdeaController.SORT_TOP, IdeaFeedController.TYPE_TOP);
checkFeedName(IdeaController.SORT_COMMENTS, IdeaFeedController.TYPE_RECENT_COMMENTS);
checkFeedName('foo', IdeaFeedController.TYPE_POPULAR);

Ilc.getIdeas();
ILC.getPageNumber();
integer i=integer.valueof(ILC.gettotalpages());
string s= Ilc.getSort();
Boolean b=ILc.getcheckSort();


}

 

any one help tp reslove this proble,

bob_buzzardbob_buzzard

You can't have a standardsetcontroller managing ideas - you have to use the ideastandardsetcontroller.  More info at:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_ideastandardsetcontroller.htm

viswadaviswada

Hi thanks Reply  Bob,

 

        

idea Testideas=new idea(Tags__c='aaaaa',Status_Changed_By__c='bbbb',CommunityId=Cm.id,title='hii');
insert Testideas;

List<Idea> ideas= new List<Idea>();

ideas.add(Testideas);

 ApexPages.ideaStandardsetController sc= new ApexPages.ideaStandardsetController(ideas);     Eventhough  tried  in this way  i am getting same error   like  Constructor not defined: [ApexPages.IdeaStandardSetController].<Constructor>() 

 

How to resolve this  issue  

bob_buzzardbob_buzzard

Have you read the doc I pointed you towards?  That states that you have to contact salesforce to enable the ideastandardsetcontroller, and that it can't be instantiated.

viswadaviswada

Hi  Bob,

 

        I   raised the Case  to salesforce  team   for enbling  IdeasStandardset Controller and IdeaStandardcontroller. As you said  We can 't create an d instances for  ideastandardsetConterlloer and  IdeastandardController. 

I  Found  in the documents " An instance can be obtained through a constructor of a custom extension controller when using the standard list controller for ideas"

 

How can we get instance  of  ideaStandardSetController and ideaStandarfcontroller   from the above point