This file contains hidden or 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
| private static final double DISCOUNT_UNIT_PRICE = 6.5d; | |
| private static final String UNIT_LABEL = "Liter"; | |
| private static final double BASE_PRICE = 5.0d; | |
| private static final double UNIT_PRICE = 3.5d; | |
| private static final double DISCOUNT_PRICE = 1.5d; | |
| @Mock private PriceRepository priceRepository; | |
| @Test | |
| public void testBasePriceIsReturned_When_DiscountAndUnitPriceNotPresent() { |
This file contains hidden or 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
| public class Customer { | |
| private final Name name; | |
| private final WishList wishList; | |
| public Customer(final Name name, final WishList wishList) { | |
| this.name = name; | |
| this.wishList = wishList; | |
| } | |
| public String name() { |
This file contains hidden or 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
| public class ShippingAddresses { | |
| private final ShippingAddress shippingAddress; | |
| public ShippingAddresses(final ShippingAddress shippingAddress) { | |
| this.shippingAddress = shippingAddress; | |
| } | |
| public void add(ShippingAddressRequest request) { | |
| shippingAddress.create(request); |
This file contains hidden or 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
| public class Customer { | |
| private final ShippingAddresses shippingAddresses; | |
| public Customer(final ShippingAddresses shippingAddresses) { | |
| this.shippingAddresses = shippingAddresses; | |
| } | |
| public void createShippingAddress(CustomerRequest customerRequest) { | |
| shippingAddresses.add(customerRequest.getShippingAddress()); | |
| } |
This file contains hidden or 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
| public class ShippingAddressRequest { | |
| private String streetName; | |
| private String postalCode; | |
| private String cityName; | |
| private String countryName; | |
| private String landmark; | |
| } |
This file contains hidden or 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
| public class Product { | |
| private final Price price; | |
| public Product(final Price price) { | |
| this.price = price; | |
| } | |
| double calculatePrice() { | |
| return price.find(); | |
| } |
This file contains hidden or 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
| public class Product { | |
| private final ProductPrice productPrice; | |
| public Product(final ProductPrice productPrice) { | |
| this.productPrice = productPrice; | |
| } | |
| double calculateProductPrice(){ | |
| return productPrice.getPrice(); | |
| } |
This file contains hidden or 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
| getMessengers().findMatchingMessenger(type, message).send(type, message); |
This file contains hidden or 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
| public class Skype implements Action, Rule { | |
| @Override | |
| public void send(final String message) { | |
| System.out.println("Sending message to Skype"); | |
| } | |
| @Override | |
| public OptionalMessenger matches(final String type, final String message) { | |
| return getType().equalsIgnoreCase(type) && isValid(message) |
This file contains hidden or 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
| public class OptionalMessenger { | |
| private final Optional<Action> messenger; | |
| private OptionalMessenger(Optional<Action> messenger) { | |
| this.messenger = messenger; | |
| } | |
| public static OptionalMessenger of(Action messenger) { | |
| return new OptionalMessenger(Optional.of(messenger)); | |
| } |
NewerOlder