}
});
Set<MarketDataValue> values = new HashSet<MarketDataValue>();
for (final ComputationTargetSpecification spec : specs) {
values.add(new MarketDataValue(spec, 123.45, "value_name"));
}
_batchMaster.addValuesToMarketData(marketData.getObjectId(), values);
marketDataValues = _batchMaster.getMarketDataValues(marketData.getObjectId(), PagingRequest.ALL).getFirst();
assertEquals(specs.size(), marketDataValues.size());
final Map<Long, MarketDataValue> marketDataValuesMap = newHashMap();
for (final MarketDataValue value : marketDataValues) {
marketDataValuesMap.put(value.getComputationTargetSpecificationId(), value);
}
for (final ComputationTargetSpecification spec : specs) {
final Long targetSpecificationId = compTargetSpecIdx.get(spec);
final MarketDataValue marketDataValue = marketDataValuesMap.get(targetSpecificationId);
assertNotNull(marketDataValue);
assertEquals(spec, reversedCompTargetSpecIdx.get(marketDataValue.getComputationTargetSpecificationId()));
assertEquals("value_name", marketDataValue.getName());
assertEquals(123.45, marketDataValue.getValue(), 0.000001);
}
// should not add anything extra
_batchMaster.addValuesToMarketData(marketData.getObjectId(), values);
marketDataValues = _batchMaster.getMarketDataValues(marketData.getObjectId(), PagingRequest.ALL).getFirst();
assertEquals(3, marketDataValues.size());
// should update 2, add 1
values = new HashSet<MarketDataValue>();
values.add(new MarketDataValue(ComputationTargetSpecification.of(UniqueId.of("BUID", "EQ12345", null)), 123.46, "value_name"));
values.add(new MarketDataValue(ComputationTargetSpecification.of(UniqueId.of("BUID", "EQ12347", "2")), 123.47, "value_name"));
values.add(new MarketDataValue(ComputationTargetSpecification.of(UniqueId.of("BUID", "EQ12348")), 123.45, "value_name"));
_batchMaster.addValuesToMarketData(marketData.getObjectId(), values);
marketDataValues = _batchMaster.getMarketDataValues(marketData.getObjectId(), PagingRequest.ALL).getFirst();
assertEquals(4, marketDataValues.size());
}