/** * Returns a copy of this market data with the specified value. * <p> * When the result is queried for the specified identifier, the specified value will be returned. * <p> * The number of scenarios in the box must match this market data. * <p> * For example, this method could be used to replace a curve with a bumped curve. * * @param <T> the type of the market data value * @param id the identifier * @param value the value to associate with the identifier * @return the derived market data with the specified identifier and value * @throws IllegalArgumentException if the scenario count does not match */ public default <T> ScenarioMarketData withValue(MarketDataId<T> id, MarketDataBox<T> value) { return ExtendedScenarioMarketData.of(id, value, this); }
public void serialization() { ExtendedScenarioMarketData<String> test = ExtendedScenarioMarketData.of(ID1, VAL3, BASE_DATA); assertSerialization(test); }
public void coverage() { ExtendedScenarioMarketData<String> test = ExtendedScenarioMarketData.of(ID1, VAL1, BASE_DATA); coverImmutableBean(test); ExtendedScenarioMarketData<String> test2 = ExtendedScenarioMarketData.of( ID2, VAL2, ImmutableScenarioMarketData.of(3, VAL_DATE, ImmutableMap.of(), ImmutableMap.of())); coverBeanEquals(test, test2); }
public void of_override() { ExtendedScenarioMarketData<String> test = ExtendedScenarioMarketData.of(ID1, VAL3, BASE_DATA); assertEquals(test.getId(), ID1); assertEquals(test.getValue(), VAL3); assertEquals(test.getValuationDate(), MarketDataBox.ofSingleValue(VAL_DATE)); assertEquals(test.containsValue(ID1), true); assertEquals(test.containsValue(ID2), true); assertEquals(test.containsValue(ID3), false); assertEquals(test.getValue(ID1), VAL3); assertEquals(test.getValue(ID2), VAL2); assertThrows(() -> test.getValue(ID3), MarketDataNotFoundException.class); assertEquals(test.getIds(), ImmutableSet.of(ID1, ID2)); assertEquals(test.findValue(ID1), Optional.of(VAL3)); assertEquals(test.findValue(ID2), Optional.of(VAL2)); assertEquals(test.findValue(ID3), Optional.empty()); assertEquals(test.getTimeSeries(ID4), TIME_SERIES); }
public void of_addition() { ExtendedScenarioMarketData<String> test = ExtendedScenarioMarketData.of(ID3, VAL3, BASE_DATA); assertEquals(test.getId(), ID3); assertEquals(test.getValue(), VAL3); assertEquals(test.getValuationDate(), MarketDataBox.ofSingleValue(VAL_DATE)); assertEquals(test.containsValue(ID1), true); assertEquals(test.containsValue(ID2), true); assertEquals(test.containsValue(ID3), true); assertEquals(test.containsValue(ID4), false); assertEquals(test.getValue(ID1), VAL1); assertEquals(test.getValue(ID2), VAL2); assertEquals(test.getValue(ID3), VAL3); assertThrows(() -> test.getValue(ID4), MarketDataNotFoundException.class); assertEquals(test.findValue(ID1), Optional.of(VAL1)); assertEquals(test.findValue(ID2), Optional.of(VAL2)); assertEquals(test.findValue(ID3), Optional.of(VAL3)); assertEquals(test.findValue(ID4), Optional.empty()); assertEquals(test.getIds(), ImmutableSet.of(ID1, ID2, ID3)); assertEquals(test.findIds(ID1.getMarketDataName()), ImmutableSet.of(ID1)); assertEquals(test.findIds(ID3.getMarketDataName()), ImmutableSet.of(ID3)); assertEquals(test.getTimeSeries(ID4), TIME_SERIES); }