SnapshotCreditCurveDataProviderFn implements CreditCurveDataProviderFn { @Override public Result<CreditCurveData> retrieveCreditCurveData(Environment env, CreditCurveDataKey key) { CreditCurveDataSnapshot snapshotResult = _snapshotLink.resolve(); Map<CreditCurveDataKey, CreditCurveData> creditCurveDataMap = snapshotResult.getCreditCurves(); if (creditCurveDataMap.containsKey(key)) { return Result.success(creditCurveDataMap.get(key)); } else { return Result.failure(FailureStatus.MISSING_DATA, "Failed to load curve data for credit curve key {} in snapshot {}", key, snapshotResult.getName()); } } SnapshotCreditCurveDataProviderFn(SnapshotLink<CreditCurveDataSnapshot> snapshotLink); @Override Result<CreditCurveData> retrieveCreditCurveData(Environment env, CreditCurveDataKey key);  }
@Test(expectedExceptions = {DataNotFoundException.class}) public void testFnWithBadLink() { Result<CreditCurveData> result = _fnWithBadLink.retrieveCreditCurveData(_env, _goodKey); assertFalse("Link threw exception so function should fail.", result.isSuccess()); }
@Test public void testFnMissingData() { Result<CreditCurveData> result = _fnWithUSDCurve.retrieveCreditCurveData(_env, _badKey); assertFalse(_badKey + " is missing so result should be failure.", result.isSuccess()); }
@Test public void testFn() { Result<CreditCurveData> result = _fnWithUSDCurve.retrieveCreditCurveData(_env, _goodKey); assertTrue(_goodKey + " present in snapshot so should succeed.", result.isSuccess()); }