8

Can any one let me know why is this ERROR occuring as

Error   Error: Compile Error: Entity is not api accessible at line 2 column 8   

COde

@istest
Public class  TestInvoiceController{

static Testmethod void Invoicemethodtest(){

 test.startTest();

 Date closeDt = Date.Today();

//list<opportunity> opp = new list<opportunity>();

Account a = new Account();
a.Name = 'icrm test acc';

insert a;

opportunity op = new opportunity(Name='test DIE 4/6/2015' ,  AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt, Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India',
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;

  Product2 prod = new product(Product_Line__c='DIE');

  insert prod;

  Pricebook2 price = new Pricebook2(Name='DIE');

  insert price;

  PricebookEntry pbe = new PricebookEntry(unitprice=0.01,Product2Id=prod.Id,Pricebook2Id=price.Id);

 insert pbe;



// list<opportunitylineitem> ol = new list<opportunitylineitem>(); 

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=0.01,PriceBookEntryId=pbe.Id);

  insert OPplineitem;

  test.stopTest();

  InvoiceController ic = new InvoiceController();
  apexpages.currentpage().getparameters().put('opId',op.id);


  }

 static Testmethod void Invoicemethodtest1(){
 test.startTest();

 Date closeDt = Date.Today();

  //list<opportunity> opp = new list<opportunity>();
  Account a = new Account();
a.Name = 'icrm test acc';

insert a;

opportunity op = new opportunity(Name='test NonDIE 4/6/2015' , AccountId= a.Id,StageName = 'Prospecting', 
                                   CloseDate = closeDt,Shipment_Info__c='test',
                                   Shipping_Address_Line1__c='Road No 37',
                                   Shipping_Address_Line2__c='Jubilee Hills',
                                   Shipping_Address_Line3__c='Land Mark Neerus',
                                   Shipping_City__c='Hyd',
                                   Shipping_State_Province__c='TS',
                                   Shipping_Zipcode__c='500081',
                                   Shipping_Country__c ='India' , 
                                   Bill_of_Lading__c='This is waybill1 this is waybill 2 waybill3 -34958309458 waybill - 44570375');

  insert op;

  Product2 prod = new product(Product_Line__c='DIE');

  insert prod;

  Pricebook2 price = new Pricebook2(Name='DIE');

  insert price;

  PricebookEntry pbe = new PricebookEntry(unitprice=0.01,Product2Id=prod.Id,Pricebook2Id=price.Id);

  insert pbe;

 //list<opportunitylineitem> ol = new list<opportunitylineitem>(); 

 OpportunityLineItem OPplineitem= new OpportunityLineItem (Quantity=2, OpportunityId=op.Id,UnitPrice=1,PriceBookEntryId=pbe.id );

  insert OPplineitem;

  test.stopTest();

  InvoiceController ic = new InvoiceController();

  apexpages.currentpage().getparameters().put('opId',op.id);

     }                        
  }

Any help very much appreciated.

2 Answers 2

11

Product2 prod = new product(Product_Line__c='DIE');

Product isn't a valid SObject (anymore). The error is slightly misleading (appears on line 2), but this is the cause. Checks for "SObject" types come earlier in the compilation process than trying to assign the wrong data type to a variable.

2

Shouldn't it look like:

Product2 prod = new **product2**(Product_Line__c='DIE');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .