pos1.addAttribute("A12", "V12");
LocalDate tradeDate = _now.toLocalDate();
OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
ManageableTrade tradeA = new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV"));
tradeA.addAttribute("key11", "Value11");
tradeA.addAttribute("key12", "Value12");
pos1.addTrade(tradeA);
ManageableTrade tradeB = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
tradeB.addAttribute("key21", "Value21");
tradeB.addAttribute("key22", "Value22");
pos1.addTrade(tradeB);
PositionDocument doc = new PositionDocument(pos1);
PositionDocument version1 = _posMaster.add(doc);
assertNotNull(version1.getUniqueId());
assertNotNull(tradeA.getUniqueId());
assertNotNull(tradeB.getUniqueId());
assertEquals(version1.getPosition(), _posMaster.get(pos1.getUniqueId()).getPosition());
ManageablePosition pos2 = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
pos2.setUniqueId(version1.getUniqueId());
pos1.addAttribute("A11", "V21");
pos1.addAttribute("A12", "V22");
ManageableTrade tradeC = new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV"));
tradeC.addAttribute("A", "B");
tradeC.addAttribute("C", "D");
tradeC.addAttribute("E", "F");
pos2.addTrade(tradeC);
PositionDocument version2 = _posMaster.update(new PositionDocument(pos2));
assertNotNull(version2);
assertFalse(version1.getUniqueId().equals(version2.getUniqueId()));
assertNotNull(tradeC.getUniqueId());
assertEquals(version2.getPosition(), _posMaster.get(version2.getUniqueId()).getPosition());
//reload version1
version1 = _posMaster.get(version1.getUniqueId());