PositionDocument doc = new PositionDocument();
doc.setPosition(position);
PositionDocument test = _posMaster.add(doc);
UniqueId portfolioId = test.getUniqueId();
assertNotNull(portfolioId);
assertEquals("DbPos", portfolioId.getScheme());
assertTrue(portfolioId.isVersioned());
assertTrue(Long.parseLong(portfolioId.getValue()) >= 1000);
assertEquals("0", portfolioId.getVersion());
assertEquals(now, test.getVersionFromInstant());
assertEquals(null, test.getVersionToInstant());
assertEquals(now, test.getCorrectionFromInstant());
assertEquals(null, test.getCorrectionToInstant());
ManageablePosition testPosition = test.getPosition();
assertNotNull(testPosition);
assertEquals(portfolioId, testPosition.getUniqueId());
assertEquals(BigDecimal.TEN, testPosition.getQuantity());
ExternalIdBundle secKey = testPosition.getSecurityLink().getExternalId();
assertEquals(1, secKey.size());
assertTrue(secKey.getExternalIds().contains(ExternalId.of("A", "B")));
assertNotNull(testPosition.getTrades());
assertTrue(testPosition.getTrades().size() == 2);
for (ManageableTrade testTrade : testPosition.getTrades()) {
assertNotNull(testTrade);
UniqueId tradeId = testTrade.getUniqueId();
assertNotNull(tradeId);
assertEquals("DbPos", portfolioId.getScheme());
assertTrue(portfolioId.isVersioned());
assertTrue(Long.parseLong(portfolioId.getValue()) >= 1000);
assertEquals("0", portfolioId.getVersion());