InMemoryPortfolioMaster extends SimpleAbstractInMemoryMaster<PortfolioDocument> implements PortfolioMaster { @Override public PortfolioDocument update(PortfolioDocument document) { ArgumentChecker.notNull(document, "document"); ArgumentChecker.notNull(document.getUniqueId(), "document.uniqueId"); ArgumentChecker.notNull(document.getPortfolio(), "document.portfolio"); final UniqueId uniqueId = document.getUniqueId(); final Instant now = Instant.now(); final PortfolioDocument storedDocument = _store.get(uniqueId.getObjectId()); if (storedDocument == null) { throw new DataNotFoundException("Portfolio not found: " + uniqueId); } final PortfolioDocument clonedDoc = clonePortfolioDocument(document); removeNodes(storedDocument.getPortfolio().getRootNode()); setVersionTimes(document, clonedDoc, now, null, now, null); if (_store.replace(uniqueId.getObjectId(), storedDocument, clonedDoc) == false) { throw new IllegalArgumentException("Concurrent modification"); } storeNodes(clonedDoc.getPortfolio().getRootNode(), document.getPortfolio().getRootNode(), uniqueId, null); _changeManager.entityChanged(ChangeType.CHANGED, document.getObjectId(), document.getVersionFromInstant(), document.getVersionToInstant(), now); updateCaches(storedDocument, clonedDoc); return document; } InMemoryPortfolioMaster();  InMemoryPortfolioMaster(final ChangeManager changeManager);  InMemoryPortfolioMaster(final Supplier<ObjectId> objectIdSupplier);  InMemoryPortfolioMaster(final Supplier<ObjectId> objectIdSupplier, final ChangeManager changeManager); @Override PortfolioDocument get(UniqueId uniqueId); @Override PortfolioDocument get(ObjectIdentifiable objectId, VersionCorrection versionCorrection); @Override PortfolioDocument add(PortfolioDocument document); @Override PortfolioDocument update(PortfolioDocument document); @Override void remove(ObjectIdentifiable objectIdentifiable); @Override PortfolioDocument correct(PortfolioDocument document); @Override PortfolioSearchResult search(PortfolioSearchRequest request); @Override PortfolioHistoryResult history(PortfolioHistoryRequest request); @Override ManageablePortfolioNode getNode(UniqueId nodeId); static final String DEFAULT_OID_SCHEME; }
@Test(expectedExceptions = DataNotFoundException.class) public void test_update_emptyMaster() { PortfolioDocument doc = new PortfolioDocument(generatePortfolio()); doc.setUniqueId(UniqueId.of("MemPos", "1")); _emptyMaster.update(doc); }