You need to sign in to do that
Don't have an account?

Test Class for Invocable Apex
Hi All,
I am facing a known issue. As per salesforce documentation "Process Flows are deactivated upon deployment". Now I have a scenario where a checkbox toggles from False to True in parent record , process flow fires and invokes an apex class, that class creates a child record related to that parent. Now at the time of deployment my process flow is deactivated , so when I query the child records in my test class I get the error "List has no rows for assignment".
Now to compensate for the inactive flow how can I imitate the exact firing logic in my apex test class?
Test Class sample is given below:
@isTest
public class Test_PrasApexCode {
static testMethod void testDoGet1() {
Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
testCostpointProject.Business_Unit__c='SSES';
testCostpointProject.Unit__c='EHS';
testCostpointProject.Division__c='Environment';
testCostpointProject.Review_Required__c=False;
testCostpointProject.Project_Manager__c=u1[0].Id;
insert testCostpointProject;
Awarded_Project__c ap= new Awarded_Project__c();
ap.Opportunity__c=testOpp.Id;
ap.Project__c=testCostpointProject.Id;
insert ap;
///////////////////////Process flow fires here//////////////////////////////////
testCostpointProject.Review_Required__c=True;
update testCostpointProject;
///////////////////////////////////////////////////////////////////////////////////////////////////
//Fetch related Project Risk Review form.
//This is where the error is thrown
Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c
from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id Limit 1];
ProRiskRev.Chair_Reviewer__c=u1[0].Id;
ProRiskRev.DVP__c=u1[1].Id;
Update ProRiskRev;
}
}
I am facing a known issue. As per salesforce documentation "Process Flows are deactivated upon deployment". Now I have a scenario where a checkbox toggles from False to True in parent record , process flow fires and invokes an apex class, that class creates a child record related to that parent. Now at the time of deployment my process flow is deactivated , so when I query the child records in my test class I get the error "List has no rows for assignment".
Now to compensate for the inactive flow how can I imitate the exact firing logic in my apex test class?
Test Class sample is given below:
@isTest
public class Test_PrasApexCode {
static testMethod void testDoGet1() {
Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
testCostpointProject.Business_Unit__c='SSES';
testCostpointProject.Unit__c='EHS';
testCostpointProject.Division__c='Environment';
testCostpointProject.Review_Required__c=False;
testCostpointProject.Project_Manager__c=u1[0].Id;
insert testCostpointProject;
Awarded_Project__c ap= new Awarded_Project__c();
ap.Opportunity__c=testOpp.Id;
ap.Project__c=testCostpointProject.Id;
insert ap;
///////////////////////Process flow fires here//////////////////////////////////
testCostpointProject.Review_Required__c=True;
update testCostpointProject;
///////////////////////////////////////////////////////////////////////////////////////////////////
//Fetch related Project Risk Review form.
//This is where the error is thrown
Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c
from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id Limit 1];
ProRiskRev.Chair_Reviewer__c=u1[0].Id;
ProRiskRev.DVP__c=u1[1].Id;
Update ProRiskRev;
}
}