TradeInfoService { public int findNetPositionCountForCurrency(String currency) { int posCt = 0; lock.readLock().lock(); try { for (K accountId : this.tradesCache.keySet()) { posCt += findNetPositionCountForCurrency(currency, accountId); } } finally { lock.readLock().unlock(); } return posCt; } TradeInfoService(TradeManagementProvider<M, N, K> tradeManagementProvider,
			AccountDataProvider<K> accountDataProvider); Collection<K> findAllAccountsWithInstrumentTrades(TradeableInstrument<N> instrument); @PostConstruct void init(); int findNetPositionCountForCurrency(String currency); Collection<Trade<M, N, K>> getAllTrades(); Collection<Trade<M, N, K>> getTradesForAccountAndInstrument(K accountId, TradeableInstrument<N> instrument); Collection<Trade<M, N, K>> getTradesForAccount(K accountId); void refreshTradesForAccount(K accountId); boolean isTradeExistsForInstrument(TradeableInstrument<N> instrument);  }
@Test public void netPositionCountForCurrencyTest() { TradeInfoService<Long, String, Long> service = createService(); int jpyCt = service.findNetPositionCountForCurrency("JPY"); assertEquals(0, jpyCt); int nzdCt = service.findNetPositionCountForCurrency("NZD"); assertEquals(1, nzdCt); int audCt = service.findNetPositionCountForCurrency("AUD"); assertEquals(-1, audCt); }