SnapshotYieldCurveDataProviderFn implements YieldCurveDataProviderFn { @Override public Result<YieldCurveData> retrieveYieldCurveData(Environment env, Currency currency) { YieldCurveDataSnapshot snapshotResult = _snapshotLink.resolve(); Map<Currency, YieldCurveData> creditCurveDataMap = snapshotResult.getYieldCurves(); if (creditCurveDataMap.containsKey(currency)) { return Result.success(creditCurveDataMap.get(currency)); } else { return Result.failure(FailureStatus.MISSING_DATA, "Failed to load curve data for credit curve key {} in snapshot {}", currency, snapshotResult.getName()); } } SnapshotYieldCurveDataProviderFn(SnapshotLink<YieldCurveDataSnapshot> snapshotLink); @Override Result<YieldCurveData> retrieveYieldCurveData(Environment env, Currency currency);  }
@Test(expectedExceptions = {DataNotFoundException.class}) public void testFnWithBadLink() { Result<YieldCurveData> result = _fnWithBadLink.retrieveYieldCurveData(_env, Currency.USD); assertFalse("Link threw exception so function should fail.", result.isSuccess()); }
@Test public void testFnMissingData() { Result<YieldCurveData> result = _fnWithUSDCurve.retrieveYieldCurveData(_env, Currency.GBP); assertFalse("GBP is missing so result should be failure.", result.isSuccess()); }
@Test public void testFn() { Result<YieldCurveData> result = _fnWithUSDCurve.retrieveYieldCurveData(_env, Currency.USD); assertTrue("USD present in snapshot so should succeed.", result.isSuccess()); }