@Test(expectedExceptions = IllegalArgumentException.class) public void test_invalid_curve_duplicate_points() { LegalEntityRatesCurvesCsvLoader.loadAllDates( ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS), ImmutableList.of(ResourceLocator.of(CURVES_1_DEUPLICATE_POINTS), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Unsupported Value Type in curve settings: Forward") public void test_invalid_settings_value_type_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(0), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS_INVALID_VALUE), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Unsupported curve type: Forward") public void test_invalid_curve_type() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(6), ResourceLocator.of(GROUPS_INVALID_CURVE_TYPE), ResourceLocator.of(SETTINGS), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Unknown DayCount value.*") public void test_invalid_settings_day_count_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(1), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS_INVALID_DCC), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "CurveInterpolator name not found: Polynomial") public void test_invalid_settings_interpolator_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(6), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS_INVALID_INTERP), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "CurveExtrapolator name not found: Polynomial") public void test_invalid_settings_left_extrapolator_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(2), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS_INVALID_LEFT), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "CurveExtrapolator name not found: Cubic") public void test_invalid_settings_right_extrapolator_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(4), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS_INVALID_RIGHT), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_missing_groups_file() { LegalEntityRatesCurvesCsvLoader.load( ALL_DATES.get(6), ResourceLocator.of(GROUPS), ResourceLocator.of("classpath:invalid"), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); }
public void test_date_outside_range() { ImmutableList<LegalEntityCurveGroup> result = LegalEntityRatesCurvesCsvLoader.load( LocalDate.of(2017, 1, 24), ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); assertTrue(result.isEmpty()); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Missing settings for curve: .*") public void test_noSettings() { List<RatesCurveGroup> curveGroups = RatesCurvesCsvLoader.load( CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_EMPTY), ImmutableList.of(ResourceLocator.of(CURVES_1))); assertEquals(curveGroups.size(), 1); RatesCurveGroup curveGroup = Iterables.getOnlyElement(curveGroups); assertUsdDisc(curveGroup.findDiscountCurve(Currency.USD).get()); }
public void test_loadSeasonalityDefinition() { Map<CurveName, SeasonalityDefinition> defns = SeasonalityDefinitionCsvLoader.loadSeasonalityDefinitions(ResourceLocator.of(GROUPS_1)); assertEquals(defns.size(), 1); SeasonalityDefinition defn = defns.get(CurveName.of("USD-CPI")); assertEquals(defn.getAdjustmentType(), ShiftType.SCALED); assertEquals(defn.getSeasonalityMonthOnMonth().size(), 12); }
@Test(dataProvider = "parse") public void parse(String location) { ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); }
public void test_of_fileNoPrefix() throws Exception { ResourceLocator test = ResourceLocator.of("src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); assertEquals(test.getLocator(), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); assertEquals(test.getByteSource().read()[0], 'H'); assertEquals(test.getCharSource().readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.toString(), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); }
public void badSelector() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); FpmlDocumentParser parser = FpmlDocumentParser.of(allParties -> ImmutableList.of("rubbish")); assertThrows( () -> parser.parseTrades(resource), FpmlParseException.class, "Selector returned an ID .*"); }
public void fra() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fra_namespace() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-namespace.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }