+ Start a Discussion
Nageswara  reddyNageswara reddy 

Argument 1 cannot be null: External entry point in test Class

HI,

  while writting test clla I ma getting error like Argument 1 cannot be null: External entry point in test Class,

 

My test code is

 

@isTest
private class TestAIOlineitems
{
static TestMethod void testAI01Line()
{

AIOlineitems.wrappo w=new AIOlineitems.wrappo();

Products__c p=new Products__c(name='xxxxx',Price__c=2334.78);
insert p;
Purchase_Order__c po=new Purchase_Order__c();
insert po;
Availability_In_Order__c ava =new Availability_In_Order__c(Purchase_Order__c=po.id);
insert ava;
Availability_In_Order_Lineitems__c ao=new Availability_In_Order_Lineitems__c(Availability_In_Order__c=ava.id,Products__c=p.id);
insert ao;
ApexPages.Currentpage().getParameters().put('id',ava.ID);

ApexPages.StandardController sc = new ApexPages.StandardController(ava);
AIOlineitems ai=new AIOlineitems(sc);
ai.Cancelpoedit();
ai.getproducts1();
ai.newPoline();
ai.poedit=ApexPages.Currentpage().getParameters().put('editid',ao.ID);
ai.sno=5;
ai.editprodu();

//ai.edu='aaaa';
//PageReference pag=new PageReference();
PageReference nextPage= ai.savepoedit();
PageReference nextPage1= ai.deleteprodu();

}
}

-------------------------------

apex class is

 

public class AIOlineitems {
public boolean check{set;get;}
id pid;
public boolean Newpol{set;get;}
public Integer sno{set;get;}
public Id poedit{set;get;}
public Availability_In_Order_Lineitems__c newPO{set;get;}
public Id poid{set;get;}
public map<id,Availability_In_Order_Lineitems__c> polmap{set;get;}
public Id productname{set;get;}
public integer cou{set;get;}
public List<SelectOption> productlist{set;get;}
public Availability_In_Order_Lineitems__c edu{set;get;}
public list<wrappo> POlist{set;get;}
public class wrappo{
public Availability_In_Order_Lineitems__c pol{set;get;}
public boolean newp{set;get;}
public integer no{set;get;}
public wrappo(){
pol=new Availability_In_Order_Lineitems__c();
newp=false;
}
}
    public AIOlineitems(ApexPages.StandardController controller) {
    productlist=new List<SelectOption>();
     polmap=new map<id,Availability_In_Order_Lineitems__c>();
    for(products__c p:[select id,Name from products__c ORDER BY Name DESC limit 1000])
    productlist.add(new SelectOption(p.Id,p.Name));
NewPol=false;
PoId=Apexpages.currentpage().getParameters().get('id');
POlist=new list<wrappo>();
cou=0;
general();

    }
    public void Cancelpoedit(){
    edu=null;
    }
    public void general(){
    edu=null;
    if(polist.size()>0)
    polist.clear();
for(Availability_In_Order_Lineitems__c pol:[select Id,Name,Products__c,Products__r.name,Ordered_Quantity__c,Available_Quantity__c,Total_Product_price__c  from Availability_In_Order_Lineitems__c where Availability_In_Order__c=:poid ORDER BY Name DESC limit 1000])
{
wrappo w=new wrappo();
w.pol=pol;
w.newp=false;
w.no=cou+1;
cou=cou+1;
polmap.put(pol.id,pol);
polist.add(w);

}
for(Availability_In_Order__C a:[select id,Purchase_Order__c from Availability_In_Order__C where id=:poid])
pid=a.Purchase_Order__c;
Purchase_Order__c p1=[select id,Available_Order_Accepted_by_executive__c from Purchase_Order__c where id=:pid];
check=p1.Available_Order_Accepted_by_executive__c;
}
    public List<SelectOption> getproducts1(){
return productlist;
}
    Public void newPoline(){
   wrappo w=new wrappo();
   
    newpo=new Availability_In_Order_Lineitems__c();
    w.pol=newpo;
    w.newp=true;
    w.no=cou+1;
cou=cou+1;
    polist.add(w);
    }
    
    public void editprodu(){
     poedit=Apexpages.currentpage().getParameters().get('editid');
     edu=polmap.get(poedit);
     productname=edu.products__c;
    sno=Integer.valueof(Apexpages.currentpage().getParameters().get('sno'));
    }
public pagereference savepoedit(){
pagereference p;
if(edu!=null){
If(edu.products__c!=productname)
edu.products__c=productname;
update edu;
polist[sno-1].newp=false;
}
else{
polist[cou-1].pol.Availability_In_Order__c=poid;
polist[cou-1].pol.Products__c=productname;
insert polist[cou-1].pol;
polist[cou-1].newp=false;
}
general();
p=new pagereference('/'+poid);
return p;
}
public pagereference deleteprodu(){
pagereference p;
   poedit=Apexpages.currentpage().getParameters().get('deid');
     Availability_In_Order_Lineitems__c delpo=polmap.get(poedit);
     if(delpo!=null)
     delete delpo;
     //polist.clear();
     p=new pagereference('/'+poid);
    //general();
    return p;
}
} this  red mark  colour code is not  covering;

 

 

Praful GadgePraful Gadge
if(Apexpages.currentpage().getParameters().get('sno') != null)

Please put this line before following line and check if it works?

sno=Integer.valueof(Apexpages.currentpage().getParameters().get('sno'));

Checking if argument for Integer.valueOf() is not null.

It's just and hit and try. Let me know if this doesn't work