CFDContractBuilder implements IContractBuilder<CFDTicker> { @Override public Contract buildContract(CFDTicker 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; }  @Override Contract buildContract(CFDTicker ticker);  }
@Test public void testBuildContract() { CFDTicker ticker = getTicker(); CFDContractBuilder builder = new CFDContractBuilder(); 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( InstrumentType.CFD, ticker.getInstrumentType()); assertNull( contract.m_primaryExch ); }
@Test public void testBuildContract_primaryExchange() { CFDTicker ticker = getTicker(); ticker.setPrimaryExchange(Exchange.NASDAQ); CFDContractBuilder builder = new CFDContractBuilder(); 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( InstrumentType.CFD, ticker.getInstrumentType()); assertEquals( ticker.getPrimaryExchange().getExchangeName(), contract.m_primaryExch ); }