InterestRateCurveSensitivity { public InterestRateCurveSensitivity plus(final InterestRateCurveSensitivity other) { ArgumentChecker.notNull(other, "Curve sensitivity"); return new InterestRateCurveSensitivity(addSensitivity(_sensitivity, other._sensitivity)); } 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 testPlusNullName() { new InterestRateCurveSensitivity().plus(null, SENSITIVITY_DATA_1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testPlusNullList() { new InterestRateCurveSensitivity().plus(CURVE_NAME_1, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testPlusNullSensitivity() { new InterestRateCurveSensitivity().plus(null); }
@Test public void testPlusDifferentCurves() { final InterestRateCurveSensitivity sensitivity1 = new InterestRateCurveSensitivity(SENSITIVITY_11); final InterestRateCurveSensitivity sensitivity2 = new InterestRateCurveSensitivity(SENSITIVITY_22); final Map<String, List<DoublesPair>> map = new HashMap<>(); map.put(CURVE_NAME_1, SENSITIVITY_DATA_1); map.put(CURVE_NAME_2, SENSITIVITY_DATA_2); final InterestRateCurveSensitivity expected = new InterestRateCurveSensitivity(map); InterestRateCurveSensitivity actual = sensitivity1.plus(sensitivity2); assertFalse(sensitivity1 == actual); assertFalse(sensitivity2 == actual); assertEquals(expected, actual); actual = sensitivity1.plus(CURVE_NAME_2, SENSITIVITY_DATA_2); assertEquals(expected, actual); }
@Test public void testPlusSameCurves() { final InterestRateCurveSensitivity sensitivity1 = new InterestRateCurveSensitivity(SENSITIVITY_11); final InterestRateCurveSensitivity sensitivity2 = new InterestRateCurveSensitivity(SENSITIVITY_12); final List<DoublesPair> data = new ArrayList<>(); data.addAll(SENSITIVITY_DATA_1); data.addAll(SENSITIVITY_DATA_2); final Map<String, List<DoublesPair>> map = new HashMap<>(); map.put(CURVE_NAME_1, data); final InterestRateCurveSensitivity expected = new InterestRateCurveSensitivity(map); InterestRateCurveSensitivity actual = sensitivity1.plus(sensitivity2); assertFalse(sensitivity1 == actual); assertFalse(sensitivity2 == actual); assertEquals(expected, actual); actual = sensitivity1.plus(CURVE_NAME_1, SENSITIVITY_DATA_2); assertEquals(expected, actual); }
@Test public void testPlusMultiCurve() { final InterestRateCurveSensitivity sensitivity1 = new InterestRateCurveSensitivity(SENSITIVITY_11); final InterestRateCurveSensitivity sensitivity2 = new InterestRateCurveSensitivity(SENSITIVITY_12); final InterestRateCurveSensitivity sensitivity3 = new InterestRateCurveSensitivity(SENSITIVITY_22); final InterestRateCurveSensitivity sensitivity4 = new InterestRateCurveSensitivity(SENSITIVITY_33); final List<DoublesPair> list = new ArrayList<>(); list.addAll(SENSITIVITY_DATA_1); list.addAll(SENSITIVITY_DATA_2); final Map<String, List<DoublesPair>> map = new HashMap<>(); map.put(CURVE_NAME_1, list); map.put(CURVE_NAME_2, SENSITIVITY_DATA_2); map.put(CURVE_NAME_3, SENSITIVITY_DATA_3); final InterestRateCurveSensitivity expected = new InterestRateCurveSensitivity(map); InterestRateCurveSensitivity actual = sensitivity1.plus(sensitivity2).plus(sensitivity3).plus(sensitivity4); assertEquals(expected, actual); actual = sensitivity1.plus(CURVE_NAME_1, SENSITIVITY_DATA_2).plus(CURVE_NAME_2, SENSITIVITY_DATA_2).plus(CURVE_NAME_3, SENSITIVITY_DATA_3); assertEquals(expected, actual); }