abstract CartExtension.SplitShipmentServiceMock

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

Constructors 

global SplitShipmentServiceMock() 


Methods 

global void arrangeItems(ItemArrangementRequest request) 

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

Parameters 

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’); } } }

Example 

1global class SplitShipmentCallsSuper extends CartExtension.SplitShipmentService {
2		global SplitShipmentCallsSuper() {}
3		global SplitShipmentCallsSuper(final CartExtension.SplitShipmentServiceMock mockService) {
4  		super(mockService);
5		}
6		public override void arrangeItems(CartExtension.ItemArrangementRequest request) {
7  		super.arrangeItems(request);
8		}
9}

Developer Preview

This release is in preview. Features described in this document don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!