TripCurrencyCodeSupplier implements CurrencyCodeSupplier { @NonNull @Override public String get() { if (trip != null) { return trip.getDefaultCurrencyCode(); } else { return userPreferenceManager.get(UserPreference.General.DefaultCurrency); } } TripCurrencyCodeSupplier(@NonNull UserPreferenceManager userPreferenceManager, @Nullable Trip trip); @NonNull @Override String get();  }
@Test public void get() throws Exception { when(userPreferenceManager.get(UserPreference.General.DefaultCurrency)).thenReturn("prefs"); when(trip.getDefaultCurrencyCode()).thenReturn("trip"); final TripCurrencyCodeSupplier nullTripSupplier = new TripCurrencyCodeSupplier(userPreferenceManager, null); final TripCurrencyCodeSupplier validTripSupplier = new TripCurrencyCodeSupplier(userPreferenceManager, trip); assertEquals(nullTripSupplier.get(), "prefs"); assertEquals(validTripSupplier.get(), "trip"); }