I'm having trouble getting my test class to pass tests. Getting:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Select from Add Placeholder Dropdown.: []
Class.TestDocManDocumentTriggerHandler.emptyPlaceHolderInsertLoan: line 24, column 1
@isTest
public static void emptyPlaceHolderInsertLoan() {
User usr = createUser();
LLC_BI__DocManager__c docManager = new LLC_BI__DocManager__c(name='llc_bi_Loan__c');
insert docmanager;
LLC_BI__ClosingChecklist__c checklist = new LLC_BI__ClosingChecklist__c(
Name = 'DocCheckList',
LLC_BI__DocManager__c = docmanager.id );
insert checklist;
LLC_BI__Loan__c loan = BatchTestUtility.addLoan(false,null);
LLC_BI__LLC_LoanDocument__c doc = new LLC_BI__LLC_LoanDocument__c(
Name=BatchTestUtility.loanDocman.dClass.Name,
LLC_BI__DocType__c = BatchTestUtility.loanDocman.dType.Id,
LLC_BI__Loan__c=loan.Id);
system.debug('lll '+loan);
system.debug('doccc'+doc+docmanager+checklist);
Test.startTest();
System.runAs(usr) {
insert doc; //getting error here
}
Test.stopTest();
doc = BatchTestUtility.refresh(doc);
assertDocumentFields(doc);
}
BatchtestUtility Class
public static DocManInfo loanDocman = new DocManInfo(BatchConstants.LOAN_DOC_MANAGER_NAME);
public class DocManInfo {
public LLC_BI__DocManager__c dMan = null;
public LLC_BI__DocTab__c dTab = null;
public LLC_BI__DocType__c dType = null;
public LLC_BI__DocClass__c dClass = null;
public LLC_BI__ClosingChecklist__c checklist = null;
public DocManInfo(String docManName) {
dman = (LLC_BI__DocManager__c)assignAndSave(
[SELECT ID,Name FROM LLC_BI__DocManager__c WHERE name =: docManName LIMIT 1],
new LLC_BI__DocManager__c(Name = docManName));
dtab = (LLC_BI__DocTab__c)assignAndSave(
[SELECT ID,Name FROM LLC_BI__DocTab__c LIMIT 1],
new LLC_BI__DocTab__c(Name = 'DocTab',LLC_BI__DocManager__c = dMan.Id));
dType = (LLC_BI__DocType__c)assignAndSave(
[SELECT ID,Name FROM LLC_BI__DocType__c LIMIT 1],
new LLC_BI__DocType__c(Name = 'DocType',LLC_BI__DocManager__c = dMan.Id,LLC_BI__DocTab__c = dtab.Id));
dclass =(LLC_BI__DocClass__c)assignAndSave(
[SELECT ID,Name FROM LLC_BI__DocClass__c LIMIT 1],
new LLC_BI__DocClass__c(Name = 'DocClass',LLC_BI__DocManager__c = dMan.Id,LLC_BI__DocType__c = dtype.Id));
checklist = new LLC_BI__ClosingChecklist__c(
Name = 'DocCheckList',
LLC_BI__DocManager__c = dMan.Id,
LLC_BI__DocType__c = dtype.Id,
LLC_BI__DocClass__c = dClass.Id);
checklist.put(BatchConstants.DOCUMENT_FIELD_CATEGORY_ID,'CATID');
checklist.put(BatchConstants.DOCUMENT_FIELD_CATEGORY_NAME,'CATNAME');
checklist.put(BatchConstants.DOCUMENT_FIELD_CLASS_NAME,'CLASSNAME');
checklist.put(BatchConstants.DOCUMENT_FIELD_TYPE_ID,'TYPEID');
checklist.put(BatchConstants.DOCUMENT_FIELD_TYPE_DESCRIPTION,'TYPEDESCRIPTION');
checklist =(LLC_BI__ClosingChecklist__c)assignAndSave(
Database.query('SELECT ID, Name, Document_Category_Id__c FROM LLC_BI__ClosingChecklist__c LIMIT 1'),
checklist);
}
}
private static sObject assignAndSave(List<sObject> existing, sObject newObject) {
if (existing.size()>0) {
return existing.get(0);
}
insert newObject;
return newObject;
}
My Main Class
Class is failing because if(ccl.size()>0){-- } and it is going to else part{objList[0].adderror('select from addPlacer dropdown')}