PresentValueSABRSensitivityDataBundle { public PresentValueSABRSensitivityDataBundle plus(final PresentValueSABRSensitivityDataBundle other) { return new PresentValueSABRSensitivityDataBundle(SurfaceValue.plus(_alpha, other._alpha), SurfaceValue.plus(_beta, other._beta), SurfaceValue.plus(_rho, other._rho), SurfaceValue.plus(_nu, other._nu)); } PresentValueSABRSensitivityDataBundle();  PresentValueSABRSensitivityDataBundle(final Map<DoublesPair, Double> alpha, final Map<DoublesPair, Double> beta, final Map<DoublesPair, Double> rho, final Map<DoublesPair, Double> nu);  PresentValueSABRSensitivityDataBundle(final SurfaceValue alpha, final SurfaceValue beta, final SurfaceValue rho, final SurfaceValue nu); void addAlpha(final DoublesPair expiryMaturity, final double sensitivity); void addBeta(final DoublesPair expiryMaturity, final double sensitivity); void addRho(final DoublesPair expiryMaturity, final double sensitivity); void addNu(final DoublesPair expiryMaturity, final double sensitivity); PresentValueSABRSensitivityDataBundle multiplyBy(final double factor); PresentValueSABRSensitivityDataBundle plus(final PresentValueSABRSensitivityDataBundle other); SurfaceValue getAlpha(); SurfaceValue getBeta(); SurfaceValue getRho(); SurfaceValue getNu(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void plus() { final Map<DoublesPair, Double> alpha1 = new HashMap<>(); final Map<DoublesPair, Double> beta1 = new HashMap<>(); final Map<DoublesPair, Double> rho1 = new HashMap<>(); final Map<DoublesPair, Double> nu1 = new HashMap<>(); alpha1.put(DoublesPair.of(0.5, 5.0), 11.0); alpha1.put(DoublesPair.of(1.5, 5.0), 12.0); rho1.put(DoublesPair.of(0.5, 5.0), 21.0); rho1.put(DoublesPair.of(1.5, 5.0), 22.0); nu1.put(DoublesPair.of(0.5, 5.0), 31.0); nu1.put(DoublesPair.of(2.5, 5.0), 32.0); final Map<DoublesPair, Double> alpha2 = new HashMap<>(); final Map<DoublesPair, Double> rho2 = new HashMap<>(); final Map<DoublesPair, Double> nu2 = new HashMap<>(); alpha2.put(DoublesPair.of(0.5, 5.0), 11.0); alpha2.put(DoublesPair.of(1.5, 5.0), 12.0); rho2.put(DoublesPair.of(0.5, 5.0), 21.0); rho2.put(DoublesPair.of(1.5, 5.0), 22.0); nu2.put(DoublesPair.of(0.5, 5.0), 31.0); nu2.put(DoublesPair.of(2.5, 5.0), 32.0); final PresentValueSABRSensitivityDataBundle sensi1 = new PresentValueSABRSensitivityDataBundle(alpha1, beta1, rho1, nu1); PresentValueSABRSensitivityDataBundle sensi2 = new PresentValueSABRSensitivityDataBundle(alpha2, beta1, rho2, nu2); final PresentValueSABRSensitivityDataBundle sensi3 = sensi1.plus(sensi1); sensi2 = sensi2.multiplyBy(2.0); assertTrue("Adding twice the same sensi", sensi3.equals(sensi2)); final Map<DoublesPair, Double> alpha3 = new HashMap<>(); final Map<DoublesPair, Double> rho3 = new HashMap<>(); final Map<DoublesPair, Double> nu3 = new HashMap<>(); alpha3.put(DoublesPair.of(2.5, 5.0), 11.0); final PresentValueSABRSensitivityDataBundle sensi4 = new PresentValueSABRSensitivityDataBundle(alpha3, beta1, rho3, nu3); final Map<DoublesPair, Double> alpha4 = new HashMap<>(); final Map<DoublesPair, Double> rho4 = new HashMap<>(); final Map<DoublesPair, Double> nu4 = new HashMap<>(); alpha4.put(DoublesPair.of(0.5, 5.0), 11.0); alpha4.put(DoublesPair.of(1.5, 5.0), 12.0); alpha4.put(DoublesPair.of(2.5, 5.0), 11.0); rho4.put(DoublesPair.of(0.5, 5.0), 21.0); rho4.put(DoublesPair.of(1.5, 5.0), 22.0); nu4.put(DoublesPair.of(0.5, 5.0), 31.0); nu4.put(DoublesPair.of(2.5, 5.0), 32.0); final PresentValueSABRSensitivityDataBundle sensi5 = new PresentValueSABRSensitivityDataBundle(alpha4, beta1, rho4, nu4); assertTrue("Adding a single alpha risk", sensi5.equals(sensi1.plus(sensi4))); }