public void test_ofBusinessDays3_null() { assertThrowsIllegalArg(() -> DaysAdjustment.ofBusinessDays(3, null, BDA_FOLLOW_SAT_SUN)); assertThrowsIllegalArg(() -> DaysAdjustment.ofBusinessDays(3, SAT_SUN, null)); assertThrowsIllegalArg(() -> DaysAdjustment.ofBusinessDays(3, null, null)); }
public void test_of_LocalDateEom_null() { assertThrowsIllegalArg(() -> PeriodicSchedule.of(null, SEP_17, P1M, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, null, P1M, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, null, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, null, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, null, false)); }
public void test_sortPairs_doubledouble_sizeDifferent() { double[] keys = {3d, 2d, 5d, 4d}; double[] values = {6d, 4d}; assertThrowsIllegalArg(() -> DoubleArrayMath.sortPairs(keys, values)); }
public void test_of_notZero() { assertThrowsIllegalArg(() -> Tenor.of(Period.ofDays(0))); assertThrowsIllegalArg(() -> Tenor.ofDays(0)); assertThrowsIllegalArg(() -> Tenor.ofWeeks(0)); assertThrowsIllegalArg(() -> Tenor.ofMonths(0)); assertThrowsIllegalArg(() -> Tenor.ofYears(0)); }
public void test_of_tooBig() { assertThrowsIllegalArg(() -> Frequency.of(Period.ofMonths(12001))); assertThrowsIllegalArg(() -> Frequency.of(Period.ofMonths(Integer.MAX_VALUE))); assertThrowsIllegalArg(() -> Frequency.of(Period.ofYears(1001))); assertThrowsIllegalArg(() -> Frequency.of(Period.ofYears(Integer.MAX_VALUE))); assertThrowsIllegalArg(() -> Frequency.ofMonths(12001), "Months must not exceed 12,000"); assertThrowsIllegalArg(() -> Frequency.ofMonths(Integer.MAX_VALUE)); assertThrowsIllegalArg(() -> Frequency.ofYears(1001), "Years must not exceed 1,000"); assertThrowsIllegalArg(() -> Frequency.ofYears(Integer.MAX_VALUE)); assertThrowsIllegalArg(() -> Frequency.of(Period.of(10000, 0, 1))); }
public void test_parseDoublePercent() { assertEquals(LoaderUtils.parseDoublePercent("1.2"), 0.012d, 1e-10); assertThrowsIllegalArg( () -> LoaderUtils.parseDoublePercent("Rubbish"), "Unable to parse percentage from 'Rubbish'"); }
public void test_of_map_dateNull() { Map<LocalDate, Double> map = new HashMap<>(); map.put(DATE_2011_01_01, 2d); map.put(null, 3d); assertThrowsIllegalArg(() -> LocalDateDoubleTimeSeries.builder().putAll(map).build()); }
public void test_collector_null() { List<CurrencyAmount> amount = Arrays.asList( CurrencyAmount.of(CCY1, 100), null, CurrencyAmount.of(CCY2, 100)); assertThrowsIllegalArg(() -> amount.stream().collect(toMultiCurrencyAmount())); }
@Test(dataProvider = "types") public void test_null(PeriodAdditionConvention type) { assertThrowsIllegalArg(() -> type.adjust(null, Period.ofMonths(3), HolidayCalendars.NO_HOLIDAYS)); assertThrowsIllegalArg(() -> type.adjust(date(2014, 7, 11), null, HolidayCalendars.NO_HOLIDAYS)); assertThrowsIllegalArg(() -> type.adjust(date(2014, 7, 11), Period.ofMonths(3), null)); assertThrowsIllegalArg(() -> type.adjust(null, null, null)); }
public void test_parse() { assertEquals(FloatingRateName.parse("GBP-LIBOR"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.parse("GBP-LIBOR-3M"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.parse("GBP-SONIA"), FloatingRateNames.GBP_SONIA); assertEquals(FloatingRateName.parse("GB-RPI"), FloatingRateNames.GB_RPI); assertThrowsIllegalArg(() -> FloatingRateName.parse(null)); assertThrowsIllegalArg(() -> FloatingRateName.parse("NotAnIndex")); }
@Test(dataProvider = "types") public void test_null(StubConvention type) { assertThrowsIllegalArg(() -> type.toRollConvention(null, date(2014, JULY, 1), Frequency.P3M, true)); assertThrowsIllegalArg(() -> type.toRollConvention(date(2014, JULY, 1), null, Frequency.P3M, true)); assertThrowsIllegalArg(() -> type.toRollConvention(date(2014, JULY, 1), date(2014, OCTOBER, 1), null, true)); }
public void test_nextOrSame_range() { assertEquals(HOLCAL_MON_WED.nextOrSame(date(2010, 1, 1)), date(2010, 1, 1)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.nextOrSame(LocalDate.MIN)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.nextOrSame(LocalDate.MAX)); }
public void success() { Result<String> test = Result.success("success"); assertEquals(test.isSuccess(), true); assertEquals(test.isFailure(), false); assertEquals(test.getValue(), "success"); assertEquals(test.getValueOrElse("blue"), "success"); assertThrowsIllegalArg(() -> test.getValueOrElse(null)); assertThrowsIllegalArg(() -> test.getValueOrElseApply(null)); }
public void test_convertedTo_explicitRate() { assertEquals(CCY_AMOUNT.convertedTo(CCY2, 2.5d), CurrencyAmount.of(CCY2, AMT1 * 2.5d)); assertEquals(CCY_AMOUNT.convertedTo(CCY1, 1d), CCY_AMOUNT); assertThrowsIllegalArg(() -> CCY_AMOUNT.convertedTo(CCY1, 1.5d)); }
public void test_defaultByCurrency() { assertEquals(HolidayCalendarId.defaultByCurrency(Currency.GBP), HolidayCalendarIds.GBLO); assertEquals(HolidayCalendarId.defaultByCurrency(Currency.CZK), HolidayCalendarIds.CZPR); assertEquals(HolidayCalendarId.defaultByCurrency(Currency.HKD), HolidayCalendarId.of("HKHK")); assertThrowsIllegalArg(() -> HolidayCalendarId.defaultByCurrency(Currency.XAG)); }
public void test_shift_range() { assertEquals(HOLCAL_MON_WED.shift(date(2010, 1, 1), 1), date(2010, 1, 4)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.shift(LocalDate.MIN, 1)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.shift(LocalDate.MAX.minusDays(1), 1)); }
public void test_next_range() { assertEquals(HOLCAL_MON_WED.next(date(2010, 1, 1)), date(2010, 1, 4)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.next(LocalDate.MIN)); assertThrowsIllegalArg(() -> HOLCAL_MON_WED.next(LocalDate.MAX.minusDays(1))); }
public void test_parseBuySell() { assertEquals(LoaderUtils.parseBuySell("BUY"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("Buy"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("buy"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("b"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("SELL"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("Sell"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("sell"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("s"), BuySell.SELL); assertThrowsIllegalArg(() -> LoaderUtils.parseBoolean("Rubbish")); }
public void test_of_simple_with_header_access_by_invalid_field() { CsvFile csvFile = CsvFile.of(CharSource.wrap(CSV1), true); assertEquals(csvFile.row(0).findField("h3"), Optional.empty()); assertThrowsIllegalArg(() -> csvFile.row(0).getField("h3")); }
public void test_combinedWithIncompatibleScenarioCount() { ImmutableScenarioMarketData marketData1 = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)) .addBox(TEST_ID1, MarketDataBox.ofScenarioValues(1.0, 1.1, 1.2)) .build(); ImmutableScenarioMarketData marketData2 = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)) .addBox(TEST_ID2, MarketDataBox.ofScenarioValues(1.0, 1.1)) .build(); assertThrowsIllegalArg(() -> marketData1.combinedWith(marketData2), ".* same number of scenarios .* 3 and 2"); }