@Test public void get() throws Exception { when(trip.getDefaultCurrencyCode()).thenReturn("trip"); when(price.getCurrencyCode()).thenReturn("receipt"); final ReceiptCurrencyCodeSupplier nullReceiptSupplier = new ReceiptCurrencyCodeSupplier(trip, receiptInputCache, null); final ReceiptCurrencyCodeSupplier validReceiptSupplier = new ReceiptCurrencyCodeSupplier(trip, receiptInputCache, receipt); assertEquals(nullReceiptSupplier.get(), "trip"); assertEquals(validReceiptSupplier.get(), "receipt"); when(receiptInputCache.getCachedCurrency()).thenReturn("cache"); final ReceiptCurrencyCodeSupplier nullReceiptSupplierWithCachedCurrency = new ReceiptCurrencyCodeSupplier(trip, receiptInputCache, null); assertEquals(nullReceiptSupplierWithCachedCurrency.get(), "cache"); }
@NonNull @Override public String get() { if (receipt != null) { return receipt.getPrice().getCurrencyCode(); } else if (receiptInputCache.getCachedCurrency() != null) { return receiptInputCache.getCachedCurrency(); } else { return trip.getDefaultCurrencyCode(); } }
ReceiptCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (receipt != null) { return receipt.getPrice().getCurrencyCode(); } else if (receiptInputCache.getCachedCurrency() != null) { return receiptInputCache.getCachedCurrency(); } else { return trip.getDefaultCurrencyCode(); } } }
ReceiptCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (receipt != null) { return receipt.getPrice().getCurrencyCode(); } else if (receiptInputCache.getCachedCurrency() != null) { return receiptInputCache.getCachedCurrency(); } else { return trip.getDefaultCurrencyCode(); } } ReceiptCurrencyCodeSupplier(@NonNull Trip trip, @NonNull ReceiptInputCache receiptInputCache, @Nullable Receipt receipt); }
ReceiptCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (receipt != null) { return receipt.getPrice().getCurrencyCode(); } else if (receiptInputCache.getCachedCurrency() != null) { return receiptInputCache.getCachedCurrency(); } else { return trip.getDefaultCurrencyCode(); } } ReceiptCurrencyCodeSupplier(@NonNull Trip trip, @NonNull ReceiptInputCache receiptInputCache, @Nullable Receipt receipt); @NonNull @Override String get(); }
ReceiptCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (receipt != null) { return receipt.getPrice().getCurrencyCode(); } else if (receiptInputCache.getCachedCurrency() != null) { return receiptInputCache.getCachedCurrency(); } else { return trip.getDefaultCurrencyCode(); } } ReceiptCurrencyCodeSupplier(@NonNull Trip trip, @NonNull ReceiptInputCache receiptInputCache, @Nullable Receipt receipt); @NonNull @Override String get();  }