Can someone help me to understand why I am getting below error message?
It is referring to the lines with DocumentQUoteEmailController
and List<contact>
.
It seems that I already entered these objects so it shouldn't be null
System.QueryException: List has no rows for assignment to SObject
Class.DocumentQuoteEmailController.: line 19, column 1
Class.DocumentQuoteEmailControllerTestfromApp.test_sendDoc_UseCase1: line 28, column
Class Code:
@isTest
private class DocumentQuoteEmailControllerTestfromApp{
@testSetup
static void setupTestData(){
test.startTest();
Quote quote_Obj = new Quote(Name = 'Name841', OpportunityId='0060n000002f0x7', Estimated_Close_date__c=Date.today());
Insert quote_Obj;
Contact contact_Obj = new Contact(LastName = 'LastName924', Email = 'Email34@test.com', MailingStreet='123 Oak St', MailingCity='Wesfield', MailingState='IN', MailingPostalCode='41311', MailingCountry='USA');
Insert contact_Obj;
OrgWideEmailAddress orgwideemailaddress_Obj = new OrgWideEmailAddress(Address = 'Email7@test.com');
// Insert orgwideemailaddress_Obj;
Attachment attachment_Obj = new Attachment(ParentId = quote_Obj.id, Name = 'Name569', Body=blob.valueof('abc'));
Insert attachment_Obj;
test.stopTest();
}
static testMethod void test_sendDoc_UseCase1(){
List<Quote> quote_Obj = [SELECT Id,Assay_from_Op__c,Owner_Email__c,Sponsor_s_of_Won_Proposals__c,Sponsor_Email__c,Is_Proposal_a_Change_Order__c from Quote];
System.assertEquals(true,quote_Obj.size()>0);
List<Contact> contact_Obj = [SELECT Id, Email from Contact];
System.assertEquals(true,contact_Obj.size()>0);
List<OrgWideEmailAddress> orgwideemailaddress_Obj = [SELECT Id from OrgWideEmailAddress];
System.assertEquals(true,orgwideemailaddress_Obj.size()>0);
List<Attachment> attachment_Obj = [SELECT ParentId,Name,BodyLength,Body,CreatedDate from Attachment];
System.assertEquals(true,attachment_Obj.size()>0);
PageReference pageRef = Page.EmailQuotewithAttachment;
pageRef.getParameters().put('Id','test');
Test.setCurrentPage(pageRef);
DocumentQuoteEmailController obj01 = new DocumentQuoteEmailController(new ApexPages.StandardController(quote_Obj[0]));
obj01.email = 'test data';
obj01.attachment = new Attachment();
obj01.quoteId = 'test data';
obj01.qte = new Quote();
obj01.abc = new Quote();
obj01.q = 'test data';
obj01.sendDoc();
}
}