DistanceCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (distance != null) { return distance.getPrice().getCurrencyCode(); } else { return trip.getDefaultCurrencyCode(); } } DistanceCurrencyCodeSupplier(@NonNull Trip trip, @Nullable Distance distance); @NonNull @Override String get();  }
@Test public void get() throws Exception { when(trip.getDefaultCurrencyCode()).thenReturn("trip"); when(price.getCurrencyCode()).thenReturn("distance"); final DistanceCurrencyCodeSupplier nullDistanceSupplier = new DistanceCurrencyCodeSupplier(trip, null); final DistanceCurrencyCodeSupplier validDistanceSupplier = new DistanceCurrencyCodeSupplier(trip, distance); assertEquals(nullDistanceSupplier.get(), "trip"); assertEquals(validDistanceSupplier.get(), "distance"); }