InterestRateCurveSensitivity { public Map<String, Double> totalSensitivityByCurve() { final HashMap<String, Double> s = new HashMap<>(); for (final Map.Entry<String, List<DoublesPair>> entry : _sensitivity.entrySet()) { double total = 0.0; for (final DoublesPair p : entry.getValue()) { total += p.second; } s.put(entry.getKey(), total); } return s; } 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 public void testTotalSensitivityByCurve() { 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 Map<String, Double> actual = sensitivity1.plus(sensitivity2).plus(sensitivity3).plus(sensitivity4).totalSensitivityByCurve(); final Map<String, Double> expected = new HashMap<>(); expected.put(CURVE_NAME_1, 200.); expected.put(CURVE_NAME_2, 100.); expected.put(CURVE_NAME_3, 100.); assertEquals(expected, actual); }