I am trying to cover wrapper class defined in controller extension.But I am getting Error:
Compile Error: Invalid type: testinvoice.wrapperItem at line 60 column 8
Apex class:
public without sharing class IITUpdateInvoice_EXT {
public List<wrapperItem> milestoneList = new List<wrapperItem>();
public list<Payment_Schedule_CELG_IIT__c > updmilestone= new
List<Payment_Schedule_CELG_IIT__c >();
public IITUpdateInvoice_EXT(ApexPages.StandardController controller) {
}
Set<ID> mileId = new Set<Id>();
ID studID = [Select Study_CELG_IIT__c from Payments_and_Invoicing_CELG_IIT__c where id=: Apexpages.currentPage().getParameters().get(IIT_Utility.Id_Param) limit 1].Study_CELG_IIT__c ;
List<Payment_Schedule_CELG_IIT__c > payList = [Select id,name,Payment_Amount_CELG_IPS__c from Payment_Schedule_CELG_IIT__c where Study_CELG_IIT__c =: studID limit 200];
List<Payment_Milestone_Invoice_Association__c> junctionList = [Select id, Invoice_IMG__c,Payment_Milestone_IMG__c from Payment_Milestone_Invoice_Association__c where Invoice_IMG__c =:Apexpages.currentPage().getParameters().get('if')];
Public List<wrapperItem> getMilestoneObj(){
for(Payment_Milestone_Invoice_Association__c junc: junctionList ){
mileId.add(junc.Payment_Milestone_IMG__c);
}
for(Payment_Schedule_CELG_IIT__c payment : payList){
if(!mileId.contains(payment.id))
milestoneList.add(new wrapperItem(payment ,false));
}
return Milestonelist;
}
/* Wrapper Class to Display all Payment Milestones records with selected checkbox */
public class wrapperItem{
public Payment_Schedule_CELG_IIT__c milObj{get;set;}
public Boolean selectBox{get;set;}
@TestVisible public wrapperItem(Payment_Schedule_CELG_IIT__c milRec,Boolean checkBox){
milObj = milRec;
selectBox= checkBox;
}
}
/* Associate selected Payment milestones record to the Invoices */
public void saveRec(){
List<Payment_Milestone_Invoice_Association__c > juncList = new List<Payment_Milestone_Invoice_Association__c>();
for(wrapperItem wrap:Milestonelist){
if(wrap.selectBox == true){
Payment_Milestone_Invoice_Association__c junc = new Payment_Milestone_Invoice_Association__c();
junc.Invoice_IMG__c=System.currentPageReference().getParameters().get(IIT_Utility.Id_Param);
junc.Payment_Milestone_IMG__c = wrap.milObj.id;
juncList.add(junc);
updmilestone.add(wrap.milObj);
}
}
if(juncList.size()>0){
try{
database.insert( juncList,true);
}catch(Exception e){
system.debug('Exception'+e);
}
}
}
}
Test class:
@isTest(SeeAllData=false)
private class IITUpdateInvoiceTest{
static testMethod void testIITUpdateInvoice(){
Id approvedRecordTypeId = Schema.SObjectType.study_celg_ips__C.getRecordTypeInfosByName().get('Approved IIT Study').getRecordTypeId();
Id pubProfileId = [select id from profile where name ='Superuser_CELG_IPS_Pub'].id;
Id personAccountRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Health Care Professional').getRecordTypeId();
user usr = [select id from user where profileId=:pubProfileId and isActive=true limit 1];
system.RunAs(usr){
study_celg_ips__c oldStd= new study_celg_ips__C();
insert oldStd;
}
product2 prod = new product2(name ='test',Approved_for_IITs__c=true,IsActive=true);
insert prod;
ID productId = [select id from product2 where id=:prod.id].id;
Journal_Congress_CELG_IPS__c journal = new Journal_Congress_CELG_IPS__c(name='test');
insert journal;
ID journalID = [select id from Journal_Congress_CELG_IPS__c where id=:journal.id].id;
study_celg_ips__c std = new study_celg_ips__C(recordtypeid= approvedRecordTypeId,Target_journal_CELG_IIT__c=journalID, Will_support_be_requested_CELG_IPS__c='No',Outcome_CELG_IPS__c='Ready for IRC',Outcome_Full_Concept_CELG_IIT__c='Approved' );
insert std;
ID studId = [select id from study_celg_ips__c where id=:std.id].id;
Payments_and_Invoicing_CELG_IIT__c invoice = new Payments_and_Invoicing_CELG_IIT__c(Invoice_Number_CELG_IIT__c='123',Study_CELG_IIT__c=studId,Invoice_Amount_CELG_IIT__c=100);
insert invoice;
ID invoiceId = [select id from Payments_and_Invoicing_CELG_IIT__c where id=:invoice.id].id;
Payment_Schedule_CELG_IIT__c paymentMilestone = new Payment_Schedule_CELG_IIT__c(Name ='test',Study_CELG_IIT__c=studId);
insert paymentMilestone;
ID paymentMilestoneId = [select id from Payment_Schedule_CELG_IIT__c where id=:paymentMilestone.id].id;
Payment_Milestone_Invoice_Association__c association = new Payment_Milestone_Invoice_Association__c(Invoice_IMG__c=invoiceId ,Payment_Milestone_IMG__c=paymentMilestoneId );
insert association ;
PageReference pageRef = Page.IIT_Update_Invoice;
pageRef.getParameters().put('id', invoiceId );
Test.setCurrentPage(pageRef);
IITUpdateInvoice_EXT testinvoice = new IITUpdateInvoice_EXT(new ApexPages.StandardController(invoice));
Payment_Schedule_CELG_IIT__c mile = new Payment_Schedule_CELG_IIT__c();
Boolean check = true;
testinvoice.wrapperItem wrap = new testinvoice.wrapperItem(mile,check);
testinvoice.saveRec();
testinvoice.getMilestoneObj();
}
}