+ Start a Discussion
Alex YhapAlex Yhap 

How to iterate over custom class objects from Apex Cntrl in Apex Test?

Object class in Custom Controller
public transient List< PaymentList > PaymentWrapperList;

public class PaymentWrapper {
    	public Payment__c payment { get; set; }
    	public isSelected { get; set; }
    	
    	public PaymentWrapper ( payment p ){
    		payment = p;
    		isSelected = false;
    	}
}

Apex Test
CustomController cc = new CustomController();

        //for question
        for(PaymentWrapper payWrap: PaymentWrapperList) {
        	// error occurs: Save error: Invalid type: PaymentWrapper
        	// How do I reference PaymentWrapper in CustomController?
        }


How do I reference PaymentWrapper from CustomController in my Apex Test class?
Does PaymentWrapperList being a transient variable hinder me for iterating over it?
Best Answer chosen by Alex Yhap
Magesh Mani YadavMagesh Mani Yadav
HI Alex

Can you try like this
CustomController cc = new CustomController();

        //for question
        for(CustomController.PaymentWrapper payWrap: cc.PaymentWrapperList) {
        	// error occurs: Save error: Invalid type: PaymentWrapper
        	// How do I reference PaymentWrapper in CustomController?
        }


 

All Answers

Magesh Mani YadavMagesh Mani Yadav
HI Alex

Can you try like this
CustomController cc = new CustomController();

        //for question
        for(CustomController.PaymentWrapper payWrap: cc.PaymentWrapperList) {
        	// error occurs: Save error: Invalid type: PaymentWrapper
        	// How do I reference PaymentWrapper in CustomController?
        }


 
This was selected as the best answer
Alex YhapAlex Yhap
Magesh - that worked! thanks!