OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV")));
PositionDocument doc = new PositionDocument();
doc.setPosition(position);
PositionDocument test = _posMaster.add(doc);
Instant now = Instant.now(_posMaster.getClock());
UniqueId uniqueId = test.getUniqueId();
assertNotNull(uniqueId);
assertEquals("DbPos", uniqueId.getScheme());
assertTrue(uniqueId.isVersioned());
assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
assertEquals("0", uniqueId.getVersion());
assertEquals(now, test.getVersionFromInstant());
assertEquals(null, test.getVersionToInstant());
assertEquals(now, test.getCorrectionFromInstant());
assertEquals(null, test.getCorrectionToInstant());
ManageablePosition testPosition = test.getPosition();
assertNotNull(testPosition);
assertEquals(uniqueId, testPosition.getUniqueId());
assertEquals(BigDecimal.TEN, testPosition.getQuantity());
ExternalIdBundle secKey = testPosition.getSecurityLink().getExternalId();
assertEquals(1, secKey.size());