/** Test logging when order shipment method is changed. */ @Test public void testLogOrderShipmentMethodChanged() { // Given final ShippingServiceLevelImpl serviceLevel = createShippingServiceLevel(); PhysicalOrderShipment physicalShipment = new PhysicalOrderShipmentImpl(); physicalShipment.setShippingServiceLevelGuid(serviceLevel.getGuid()); // Expectations context.checking( new Expectations() { { allowing(shippingLevelService).findByGuid(serviceLevel.getGuid()); will(returnValue(serviceLevel)); oneOf(order).addOrderEvent(orderEvent); } }); // When orderEventHelper.logOrderShipmentMethodChanged(order, physicalShipment); // Then assertTrue( "Message should contain shippingServLevel's display name", orderEvent.getNote().contains(serviceLevel.getDisplayName(Locale.CANADA, false))); }
private ShippingServiceLevelImpl createShippingServiceLevel() { ShippingServiceLevelImpl serviceLevel = new ShippingServiceLevelImpl(); serviceLevel.setGuid("ssl-guid"); final ShippingServiceLevelLocalizedPropertyValueImpl displayName = new ShippingServiceLevelLocalizedPropertyValueImpl(); displayName.setValue("DisplayName"); final LocalizedPropertiesImpl localizedProperties = new LocalizedPropertiesImpl(); localizedProperties.setLocalizedPropertiesMap( Collections.<String, LocalizedPropertyValue>singletonMap( ShippingServiceLevel.LOCALIZED_PROPERTY_NAME + "_en_CA", displayName), "xxx"); serviceLevel.setLocalizedProperties(localizedProperties); return serviceLevel; }