/** * Loads one or more CSV format FX rate files for a specific date. * <p> * Only those rates that match the specified date will be loaded. * <p> * If the files contain a duplicate entry an exception will be thrown. * * @param marketDataDate the date to load * @param resources the CSV resources * @return the loaded FX rates, mapped by {@linkplain FxRateId rate ID} * @throws IllegalArgumentException if the files contain a duplicate entry */ public static ImmutableMap<FxRateId, FxRate> load(LocalDate marketDataDate, ResourceLocator... resources) { return load(marketDataDate, Arrays.asList(resources)); }
/** * Loads one or more CSV format FX rate files for a set of dates. * <p> * Only those rates that match one of the specified dates will be loaded. * <p> * If the files contain a duplicate entry an exception will be thrown. * * @param marketDataDates the set of dates to load * @param resources the CSV resources * @return the loaded FX rates, mapped by {@link LocalDate} and {@linkplain FxRateId rate ID} * @throws IllegalArgumentException if the files contain a duplicate entry */ public static ImmutableMap<LocalDate, ImmutableMap<FxRateId, FxRate>> load( Set<LocalDate> marketDataDates, ResourceLocator... resources) { return load(marketDataDates, Arrays.asList(resources)); }
public void test_load_oneDate_file1_date2() { Map<FxRateId, FxRate> map = FxRatesCsvLoader.load(DATE2, ImmutableList.of(RATES_1)); assertEquals(map.size(), 2); assertFile1Date2(map); }
public void test_load_oneDate_file1_date1() { Map<FxRateId, FxRate> map = FxRatesCsvLoader.load(DATE1, RATES_1); assertEquals(map.size(), 2); assertFile1Date1(map); }
public void test_invalidDuplicate() { assertThrowsIllegalArg(() -> FxRatesCsvLoader.load(DATE1, RATES_INVALID_DUPLICATE)); }
public void test_load_dateSet_file1_date1() { Map<LocalDate, ImmutableMap<FxRateId, FxRate>> map = FxRatesCsvLoader.load(ImmutableSet.of(DATE1, DATE2), RATES_1); assertEquals(map.size(), 2); assertFile1Date1(map.get(DATE1)); assertFile1Date2(map.get(DATE2)); }
public void test_load_oneDate_file1file2_date1() { Map<FxRateId, FxRate> map = FxRatesCsvLoader.load(DATE1, ImmutableList.of(RATES_1, RATES_2)); assertEquals(map.size(), 3); assertFile1Date1(map); assertFile2Date1(map); }
public void test_load_oneDate_invalidDate() { assertThrows( () -> FxRatesCsvLoader.load(date(2015, 10, 2), RATES_INVALID_DATE), IllegalArgumentException.class, "Error processing resource as CSV file: .*"); }