StockContractBuilder implements IContractBuilder<StockTicker> { public Contract buildContract(StockTicker ticker) { Contract contract = new Contract(); contract.m_currency = ticker.getCurrency(); contract.m_exchange = ticker.getExchange().getExchangeName(); contract.m_secType = IbUtils.getSecurityType( ticker.getInstrumentType() ); contract.m_symbol = ticker.getSymbol(); if( ticker.getPrimaryExchange() != null ) { contract.m_primaryExch = ticker.getPrimaryExchange().getExchangeName(); } return contract; }  Contract buildContract(StockTicker ticker);  }
@Test public void testBuildContract() { StockTicker ticker = getTicker(); StockContractBuilder builder = new StockContractBuilder(); Contract contract = builder.buildContract(ticker); assertEquals( ticker.getCurrency(), contract.m_currency ); assertEquals( ticker.getExchange().getExchangeName(), contract.m_exchange ); assertEquals( ticker.getSymbol(), contract.m_symbol ); assertNull( contract.m_primaryExch ); }
@Test public void testBuildContract_primaryExchange() { StockTicker ticker = getTicker(); ticker.setPrimaryExchange(Exchange.NASDAQ); StockContractBuilder builder = new StockContractBuilder(); Contract contract = builder.buildContract(ticker); assertEquals( ticker.getCurrency(), contract.m_currency ); assertEquals( ticker.getExchange().getExchangeName(), contract.m_exchange ); assertEquals( ticker.getSymbol(), contract.m_symbol ); assertEquals( ticker.getPrimaryExchange().getExchangeName(), contract.m_primaryExch ); }