abstract CartExtension.SplitShipmentServiceMock

Mock executor for Split Shipment Service. Should only be used for tests.


This method should be overridden to mock the default Split Shipment Service.

ParamDescription
request

IsTest global class SplitShipmentUnitTest {

IsTest public static void splitShipmentApexThatCallsSuperShouldInvokeDefaultSplitShipmentService() { // Arrange MockDefaultSplitShipmentService mockService = new MockDefaultSplitShipmentService(); SplitShipmentCallsSuper splitShipmentService = new SplitShipmentCallsSuper(mockService); CartExtension.Cart cart = CartExtension.CartTestUtil.createCart(); CartExtension.ItemArrange itemArrange = new CartExtension.ItemArrange.Builder() .withProductId('01txx0000006iP2AAI') .withQuantity(Decimal.valueOf(5)) .withCartItemId(cart.getCartItems().get(0).getId()) .withDeliveryGroupId(cart.getCartItems().get(0).getCartDeliveryGroup().getId()) .withDeliveryGroupName(DELIVERY_GROUP1_NAME) .withDeliverToCity('Foxboro') .withDeliverToCountry('USA') .withDeliverFromFirstName('Tom') .withDeliverFromLastName('Brady') .withDeliverToName('Bill Belichick') .withDeliverToPostalCode('02035') .withDeliverToState('MA') .withDeliverToStreet('2 Patriot Place') .withDeliverToCompanyName('New England Patriots') .withDeliveryAddressId('8lW456789012679AAA') .build(); List<CartExtension.ItemArrange> itemArrangeList = new List<CartExtension.ItemArrange>(); itemArrangeList.add(itemArrange); CartExtension.ItemArrangementRequest request = new CartExtension.ItemArrangementRequest.Builder() .withCart(cart) .withItemArrangeList(itemArrangeList) .build(); // Act splitShipmentService.arrangeItems(request); // Assert Assert.isTrue(cart.getName().contains('Default Split Shipment Service was invoked')); } global class MockDefaultSplitShipmentService extends CartExtension.SplitShipmentServiceMock { global override void arrangeItems(CartExtension.ItemArrangementRequest request) { CartExtension.Cart cart = request.getCart(); cart.setName(cart.getName() + ', ' + 'Default Split Shipment Service was invoked'); } } }