assertEquals(expected, test);
}
@Test
public void test_getTradePosition_withPremium() {
final ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
final LocalDate tradeDate = _now.toLocalDate();
final OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
final ManageableTrade trade1 = new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV"));
trade1.setPremium(1000000.00);
trade1.setPremiumCurrency(Currency.USD);
trade1.setPremiumDate(tradeDate.plusDays(1));
trade1.setPremiumTime(tradeTime);
position.getTrades().add(trade1);
final ManageableTrade trade2 = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
trade2.setPremium(100.00);
trade2.setPremiumCurrency(Currency.GBP);
trade2.setPremiumDate(tradeDate.plusDays(10));
trade2.setPremiumTime(tradeTime.plusHours(1));
position.getTrades().add(trade2);
final PositionDocument doc = new PositionDocument();
doc.setPosition(position);
_posMaster.add(doc);
assertNotNull(trade1.getUniqueId());
assertNotNull(trade2.getUniqueId());
assertEquals(trade1, _posMaster.getTrade(trade1.getUniqueId()));
assertEquals(trade2, _posMaster.getTrade(trade2.getUniqueId()));
final PositionDocument storedDoc = _posMaster.get(position.getUniqueId());
assertNotNull(storedDoc);
assertNotNull(storedDoc.getPosition());
assertNotNull(storedDoc.getPosition().getTrades());
assertEquals(2, storedDoc.getPosition().getTrades().size());
assertTrue(storedDoc.getPosition().getTrades().contains(trade1));