ManageablePortfolioNode rootNode = new ManageablePortfolioNode("Root");
ManageablePortfolioNode childNode = new ManageablePortfolioNode("Child");
childNode.addPosition(UniqueId.of("TestPos", "1234"));
rootNode.addChildNode(childNode);
ManageablePortfolio portfolio = new ManageablePortfolio("Test");
portfolio.setRootNode(rootNode);
portfolio.addAttribute("A1", "V1");
portfolio.addAttribute("A2", "V2");
PortfolioDocument doc = new PortfolioDocument();
doc.setPortfolio(portfolio);
PortfolioDocument test = _prtMaster.add(doc);
UniqueId uniqueId = test.getUniqueId();
assertNotNull(uniqueId);
assertEquals("DbPrt", 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());
ManageablePortfolio testPortfolio = test.getPortfolio();
assertEquals(uniqueId, testPortfolio.getUniqueId());
assertEquals("Test", testPortfolio.getName());
assertNotNull(testPortfolio.getAttributes());
assertEquals(2, testPortfolio.getAttributes().size());
assertEquals("V1", testPortfolio.getAttributes().get("A1"));
assertEquals("V2", testPortfolio.getAttributes().get("A2"));
ManageablePortfolioNode testRootNode = testPortfolio.getRootNode();
assertEquals("Root", testRootNode.getName());
assertEquals(null, testRootNode.getParentNodeId());
assertEquals(uniqueId, testRootNode.getPortfolioId());
assertEquals(1, testRootNode.getChildNodes().size());