Trigger Handler functionality
A trigger handler based on trigger actions configured via custom metadata. It separates the trigger logic per class, and is utilizing the fflib_UnitOfWork to execute the trigger actions. Signed-off-by: WimVelzeboer <wimvelzeboer@protonmail.com>
This commit is contained in:
@@ -101,7 +101,7 @@ private class fflib_UnitOfWorkTest
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldExecuteAllItemsInTheCorrectOrder()
|
||||
static void itShouldExecuteAllItemsInTheCorrectOrderOfPriority()
|
||||
{
|
||||
// GIVEN - Three different work items added to the fflib_DoWork
|
||||
Work workA = (Work) new WorkA().setPriority(1);
|
||||
@@ -122,6 +122,28 @@ private class fflib_UnitOfWorkTest
|
||||
System.assert(orderOfExecution.get(2).contains('WorkA'), 'Expected Work B with priority 1 to be executed last');
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldExecuteAllItemsInTheCorrectOrderOfSequence()
|
||||
{
|
||||
// GIVEN - Three different work items added to the fflib_DoWork
|
||||
Work workA = (Work) new WorkA().setSequence(3);
|
||||
Work workB = (Work) new WorkB().setSequence(2);
|
||||
Work workC = (Work) new WorkC().setSequence(1);
|
||||
fflib_UnitOfWork myWork = new fflib_UnitOfWork().addWork(
|
||||
new List<fflib_IDoWork> {workA, workB, workC}
|
||||
);
|
||||
|
||||
// WHEN - The work is being executed
|
||||
System.Test.startTest();
|
||||
myWork.doWork();
|
||||
System.Test.stopTest();
|
||||
|
||||
// THEN - Then all three work items should be executed
|
||||
System.assert(orderOfExecution.get(0).contains('WorkC'), 'Expected Work C with priority 3 to be executed first');
|
||||
System.assert(orderOfExecution.get(1).contains('WorkB'), 'Expected Work B with priority 2 to be executed second');
|
||||
System.assert(orderOfExecution.get(2).contains('WorkA'), 'Expected Work B with priority 1 to be executed last');
|
||||
}
|
||||
|
||||
private virtual class Work extends fflib_DoWork
|
||||
{
|
||||
public Boolean didWork = false;
|
||||
|
||||
Reference in New Issue
Block a user