assertTrue(other.getSensitivities().isEmpty());
}
@Test
public void add() {
MultipleCurrencyParameterSensitivity sensitivity1 = new MultipleCurrencyParameterSensitivity();
sensitivity1 = sensitivity1.plus(NAME_1_USD, SENSITIVITY_1_1);
sensitivity1 = sensitivity1.plus(NAME_1_USD, SENSITIVITY_1_2);
assertEquals("Add same currency, different sensitivities: ", MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2), sensitivity1.getSensitivity(NAME_1_USD));
MultipleCurrencyParameterSensitivity sensitivity2 = new MultipleCurrencyParameterSensitivity();
sensitivity2 = sensitivity2.plus(NAME_1_EUR, SENSITIVITY_1_1);
sensitivity2 = sensitivity2.plus(sensitivity1);
assertEquals("Add different currency, test size: ", 2, sensitivity2.getSensitivities().size());
final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> expected = Maps.newLinkedHashMap();
expected.put(NAME_1_EUR, SENSITIVITY_1_1);
expected.put(NAME_1_USD, (DoubleMatrix1D) MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2));
assertEquals("Add different currency, test map: ", expected, sensitivity2.getSensitivities());
sensitivity2 = new MultipleCurrencyParameterSensitivity();
sensitivity2 = sensitivity2.plus(NAME_1_USD, SENSITIVITY_1_1);
sensitivity2 = sensitivity2.plus(sensitivity1);
assertEquals("Add same currency, test sensitivities: ", MATRIX.add(SENSITIVITY_1_1, MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2)), sensitivity2.getSensitivity(NAME_1_USD));
sensitivity2 = sensitivity2.plus(NAME_2_EUR, SENSITIVITY_2_1);
assertEquals("Add different currency, test sensitivities of first currency: ", SENSITIVITY_2_1, sensitivity2.getSensitivity(NAME_2_EUR));
assertEquals("Add different currency, test sensitivities of second currency: ", MATRIX.add(SENSITIVITY_1_1, MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2)), sensitivity2.getSensitivity(NAME_1_USD));
sensitivity2 = sensitivity2.plus(NAME_2_EUR, SENSITIVITY_2_1);
assertEquals("Test add same sensitivities: ", MATRIX.scale(SENSITIVITY_2_1, 2.0), sensitivity2.getSensitivity(NAME_2_EUR));
assertEquals("Test other currency: ", MATRIX.add(SENSITIVITY_1_1, MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2)), sensitivity2.getSensitivity(NAME_1_USD));
sensitivity2 = sensitivity2.plus(NAME_1_EUR, SENSITIVITY_1_1);
assertEquals("ParameterSensitivity: add", MATRIX.scale(SENSITIVITY_2_1, 2.0), sensitivity2.getSensitivity(NAME_2_EUR));
assertEquals("ParameterSensitivity: add", MATRIX.add(SENSITIVITY_1_1, MATRIX.add(SENSITIVITY_1_1, SENSITIVITY_1_2)), sensitivity2.getSensitivity(NAME_1_USD));
assertEquals("ParameterSensitivity: add", SENSITIVITY_1_1, sensitivity2.getSensitivity(NAME_1_EUR));
}