public void newSecurityWithOtcUnderlying() {
UniqueId tradeId = _builder.addTrade(createTradeData(),
BlotterTestUtils.SWAPTION_DATA_SOURCE,
BlotterTestUtils.SWAP_DATA_SOURCE,
_nodeId);
ManageableTrade trade = _positionMaster.getTrade(tradeId);
UniqueId positionId = trade.getParentPositionId();
ManageablePosition position = _positionMaster.get(positionId).getPosition();
assertEquals(BigDecimal.ONE, trade.getQuantity());
assertEquals(BigDecimal.ONE, position.getQuantity());
SwaptionSecurity security = (SwaptionSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
VersionCorrection.LATEST).getSecurity();
assertNotNull(security);
// check this later
ExternalId underlyingId = security.getUnderlyingId();
security.setUniqueId(null); // so it can be tested for equality against the unsaved version
security.setUnderlyingId(BlotterTestUtils.SWAPTION.getUnderlyingId()); // will need this later
assertEquals(BlotterTestUtils.SWAPTION, security);
assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
assertEquals(PREMIUM, trade.getPremium());
assertEquals(Currency.GBP, trade.getPremiumCurrency());
assertEquals(PREMIUM_DATE, trade.getPremiumDate());
assertEquals(TRADE_DATE, trade.getTradeDate());
assertEquals(PREMIUM_TIME, trade.getPremiumTime());
assertEquals(TRADE_TIME, trade.getTradeTime());
assertEquals(ATTRIBUTES, trade.getAttributes());
// can't check the node ID as nodes are completely replaced
ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio().getRootNode();
ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0);
assertEquals(1, loadedNode.getPositionIds().size());