InterestRateCurveSensitivity { public static InterestRateCurveSensitivity of(final String name, final List<DoublesPair> sensitivityCurve) { ArgumentChecker.notNull(name, "Curve name"); ArgumentChecker.notNull(sensitivityCurve, "sensitivity"); final HashMap<String, List<DoublesPair>> ircs = new HashMap<>(); ircs.put(name, sensitivityCurve); return new InterestRateCurveSensitivity(ircs); } InterestRateCurveSensitivity();  InterestRateCurveSensitivity(final Map<String, List<DoublesPair>> sensitivity); static InterestRateCurveSensitivity of(final String name, final List<DoublesPair> sensitivityCurve); Map<String, List<DoublesPair>> getSensitivities(); Set<String> getCurves(); InterestRateCurveSensitivity plus(final InterestRateCurveSensitivity other); InterestRateCurveSensitivity plus(final String curveName, final List<DoublesPair> list); InterestRateCurveSensitivity multipliedBy(final double factor); InterestRateCurveSensitivity cleaned(); InterestRateCurveSensitivity cleaned(final double relTol, final double absTol); Map<String, Double> totalSensitivityByCurve(); double totalSensitivity(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullSensitivity2() { InterestRateCurveSensitivity.of(CURVE_NAME_1, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurveName() { InterestRateCurveSensitivity.of(null, SENSITIVITY_DATA_1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullSensitivities() { InterestRateCurveSensitivity.of("Name", null); }
@Test public void testCompareDifferentTimes() { AssertSensitivityObjects.assertEquals("", new InterestRateCurveSensitivity(), new InterestRateCurveSensitivity(), EPS); final TreeMap<String, List<DoublesPair>> sortedMap = new TreeMap<>(SENSITIVITY_11); final InterestRateCurveSensitivity sensitivity1 = new InterestRateCurveSensitivity(sortedMap); final InterestRateCurveSensitivity sensitivity2 = new InterestRateCurveSensitivity(SENSITIVITY_12); AssertSensitivityObjects.assertDoesNotEqual("", sensitivity1, sensitivity2, EPS); final Map<String, List<DoublesPair>> map = Maps.newTreeMap(); final double eps = 1e-4; for (final Map.Entry<String, List<DoublesPair>> entry : sortedMap.entrySet()) { final List<DoublesPair> list = new ArrayList<>(); for (final DoublesPair pair : entry.getValue()) { list.add(DoublesPair.of(pair.first + 0.01 * eps, pair.second)); } map.put(entry.getKey(), list); } final InterestRateCurveSensitivity sensitivity3 = new InterestRateCurveSensitivity(map); AssertSensitivityObjects.assertEquals("", sensitivity1, sensitivity3, eps); AssertSensitivityObjects.assertDoesNotEqual("", sensitivity1, sensitivity3, EPS); }
@Test public void testCompareDifferentValues() { AssertSensitivityObjects.assertEquals("", new InterestRateCurveSensitivity(), new InterestRateCurveSensitivity(), EPS); final TreeMap<String, List<DoublesPair>> sortedMap = new TreeMap<>(SENSITIVITY_11); final InterestRateCurveSensitivity sensitivity1 = new InterestRateCurveSensitivity(sortedMap); final InterestRateCurveSensitivity sensitivity2 = new InterestRateCurveSensitivity(SENSITIVITY_12); AssertSensitivityObjects.assertDoesNotEqual("", sensitivity1, sensitivity2, EPS); final Map<String, List<DoublesPair>> map = Maps.newTreeMap(); final double eps = 1e-4; for (final Map.Entry<String, List<DoublesPair>> entry : sortedMap.entrySet()) { final List<DoublesPair> list = new ArrayList<>(); for (final DoublesPair pair : entry.getValue()) { list.add(DoublesPair.of(pair.first, pair.second + 0.01 * eps)); } map.put(entry.getKey(), list); } final InterestRateCurveSensitivity sensitivity3 = new InterestRateCurveSensitivity(map); AssertSensitivityObjects.assertEquals("", sensitivity1, sensitivity3, eps); AssertSensitivityObjects.assertDoesNotEqual("", sensitivity1, sensitivity3, EPS); }