-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new test for calculator and comply to folder structure
- Loading branch information
1 parent
83e4f91
commit cb0fa18
Showing
13 changed files
with
371 additions
and
193 deletions.
There are no files selected for viewing
180 changes: 0 additions & 180 deletions
180
commerce/domain/inventory/CommerceInventoryServiceSample.cls
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
commerce/domain/inventory/cart/calculator/classes/InventoryCartCalculatorSample.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
public class InventoryCartCalculatorSample extends CartExtension.InventoryCartCalculator { | ||
|
||
public InventoryCartCalculatorSample() { | ||
super(); | ||
} | ||
|
||
/** | ||
* @description Constructor used by unit tests only. | ||
* @param apexExecutor Executor which executes various calculators. Can be used to stub calculation results or delegate calculations to actual Calculator. See <<CartCalculateExecutorMock>>. | ||
*/ | ||
public InventoryCartCalculatorSample(CartExtension.CartCalculateExecutorMock apexExecutor) { | ||
// Must call super constructor in order for provided Executor to be used for calculations | ||
super(apexExecutor); | ||
} | ||
|
||
public virtual override void calculate(CartExtension.CartCalculateCalculatorRequest request) { | ||
|
||
CartExtension.Cart cart = request.getCart(); | ||
|
||
if (cart.getStatus() != CartExtension.CartStatusEnum.CHECKOUT) { | ||
return; | ||
} | ||
|
||
removeAllCVOsOfType(cart, CartExtension.CartValidationOutputTypeEnum.INVENTORY); | ||
super.calculate(request); | ||
|
||
} | ||
|
||
private void removeAllCVOsOfType(CartExtension.Cart cart, CartExtension.CartValidationOutputTypeEnum type) { | ||
CartExtension.CartValidationOutputList cartValidationOutputList = cart.getCartValidationOutputs(); | ||
for (Integer i = (cartValidationOutputList.size() - 1); i >= 0; i--) { | ||
CartExtension.CartValidationOutput cvo = cartValidationOutputList.get(i); | ||
if (cvo.getType() == type) { | ||
cartValidationOutputList.remove(cvo); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
5 changes: 5 additions & 0 deletions
5
commerce/domain/inventory/cart/calculator/classes/InventoryCartCalculatorSample.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>61.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
Oops, something went wrong.
cb0fa18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I have a problem in the
testUpsertReservation()
method, when I do a deploy thecommerce_inventory.UpsertItemReservationRequest itemRequest = new commerce_inventory.UpsertItemReservationRequest(double.valueOf('10.0'), Id.valueOf('0ghSG0000000JFbYAM'), Id .valueOf('0a9SG000003AfY1YAK'), Id.valueOf('01tSG000001NNgKYAW'));
has an error that says:Undefined constructor: [commerce_inventory.UpsertItemReservationRequest].<Constructor>(Double, Id, Id, Id) (6:71)
I tried to instance different the object but I keep getting the same error.
I also get other errors when I use other methods that use objects called Request at the end.