DefaultIsdaCompliantYieldCurveFn implements IsdaCompliantYieldCurveFn { @Override public Result<IsdaYieldCurve> buildIsdaCompliantCurve(Environment env, Currency ccy) { Result<YieldCurveData> yieldCurveData = _yieldCurveProvider.retrieveYieldCurveData(env, ccy); if (!yieldCurveData.isSuccess()) { return Result.failure(yieldCurveData); } ISDACompliantYieldCurve curve = buildCurve(env, yieldCurveData.getValue()); IsdaYieldCurve yieldCurve = IsdaYieldCurve.builder() .calibratedCurve(curve) .curveData(yieldCurveData.getValue()) .build(); return Result.success(yieldCurve); } DefaultIsdaCompliantYieldCurveFn(YieldCurveDataProviderFn yieldCurveProvider,
                                          RegionSource regionSource,
                                          HolidaySource holidaySource); @Override Result<IsdaYieldCurve> buildIsdaCompliantCurve(Environment env, Currency ccy);  }
@Test public void testProviderFailure() { Result<IsdaYieldCurve> result = _fn.buildIsdaCompliantCurve(_env, Currency.GBP); assertFalse("GBP curve data lookup failed so this call should too.", result.isSuccess()); }
@Test public void testBuildUSD() { Result<IsdaYieldCurve> usdCurve = _fn.buildIsdaCompliantCurve(_env, Currency.USD); ISDACompliantYieldCurve curve = usdCurve.getValue().getCalibratedCurve(); assertNotNull(curve); for (Map.Entry<LocalDate, Double> entry : EXPECTED.entrySet()) { double t = TimeCalculator.getTimeBetween(VALUATION_DATE, entry.getKey()); double discountFactor = curve.getDiscountFactor(t); System.out.println(entry.getKey() + " " + discountFactor + " " + (discountFactor - entry.getValue())); assertEquals(entry.getValue(), discountFactor, DELTA); } }