private static PriceIndex parsePriceIndex(CsvRow row) { String name = row.getField(NAME_FIELD); Currency currency = Currency.parse(row.getField(CURRENCY_FIELD)); Country region = Country.of(row.getField(COUNTRY_FIELD)); boolean active = Boolean.parseBoolean(row.getField(ACTIVE_FIELD)); Frequency frequency = Frequency.parse(row.getField(PUBLICATION_FREQUENCY_FIELD)); // build result return ImmutablePriceIndex.builder() .name(name) .currency(currency) .region(region) .active(active) .publicationFrequency(frequency) .build(); }
public void test_priceIndexValues_inactive() { PriceIndex inactiveIndex = ImmutablePriceIndex.builder() .name("GBP-XXX") .active(false) .publicationFrequency(Frequency.P1M) .currency(GBP) .region(Country.GB) .build(); LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.of(VAL_DATE, 0.62d); ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE) .timeSeries(inactiveIndex, ts) .build(); assertEquals(test.priceIndexValues(inactiveIndex).getIndex(), inactiveIndex); assertEquals(test.priceIndexValues(inactiveIndex).getFixings(), ts); assertEquals(test.getIborIndices(), ImmutableSet.of()); assertEquals(test.getTimeSeriesIndices(), ImmutableSet.of(inactiveIndex)); assertEquals(test.priceIndexValues(inactiveIndex).getClass(), HistoricPriceIndexValues.class); }
public void coverage() { coverPrivateConstructor(PriceIndices.class); coverImmutableBean((ImmutableBean) PriceIndices.US_CPI_U); coverBeanEquals((ImmutableBean) PriceIndices.US_CPI_U, ImmutablePriceIndex.builder() .name("Test") .region(Country.AR) .currency(Currency.ARS) .publicationFrequency(Frequency.P6M) .build()); }
public void test_priceIndexValues_inactiveNoTimeSeriesNotFound() { PriceIndex inactiveIndex = ImmutablePriceIndex.builder() .name("GBP-XXX") .active(false) .publicationFrequency(Frequency.P1M) .currency(GBP) .region(Country.GB) .build(); ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE) .build(); assertThrows(IllegalArgumentException.class, () -> test.priceIndexValues(inactiveIndex)); }