Exchange implements Serializable { public static Exchange getExchangeFromString(String exchangeString) { for( Exchange exchange : ALL_EXCHANGES ) { if( exchangeString.equals(exchange.getExchangeName())) { return exchange; } } throw new SumZeroException("Unknown exchange " + exchangeString ); } protected  Exchange( String exchangeName ); String getExchangeName(); static Exchange getExchangeFromString(String exchangeString); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final long serialVersionUID; static final Exchange ARCA; static final Exchange GLOBEX; static final Exchange NYMEX; static final Exchange CBOE; static final Exchange ECBOT; static final Exchange NYBOT; static final Exchange CFE; static final Exchange NYSE_LIFFE; static final Exchange IDEALPRO; static final Exchange PSE; static final Exchange INTERACTIVE_BROKERS_SMART; static final Exchange NASDAQ; static final Exchange TSEJ; static final Exchange SEHKNTL; static final Exchange SEHK; static final Exchange HKFE; static final Exchange OSE; static final Exchange SGX; static final Exchange BOX; static final Exchange[] ALL_EXCHANGES; }
@Test public void testGetExchange() { assertEquals( Exchange.INTERACTIVE_BROKERS_SMART, Exchange.getExchangeFromString("SMART")); }
@Test public void testGetExchange_throwsException() { try { Exchange.getExchangeFromString("Foo"); fail(); } catch( SumZeroException ex ) { } }