IbUtils { public static String getAction(TradeDirection direction) { if (direction == TradeDirection.BUY) { return "BUY"; } else if (direction == TradeDirection.SELL) { return "SELL"; } else if (direction == TradeDirection.SELL_SHORT) { return "SELL"; } else if (direction == TradeDirection.BUY_TO_COVER) { return "BUY"; } else { throw new IllegalStateException("Unknown trade direction: " + direction); } }  static String translateToIbFuturesSymbol(String symbol); static String getOrderType(TradeOrder.Type orderType); static String getTif(TradeOrder.Duration duration); static String getSecurityType(InstrumentType instrumentType); static String getAction(TradeDirection direction); static QuoteType getQuoteType(int field); static OrderStatus.Status getOrderStatus(String status); static String getExpiryString(int expiryMonth, int expiryYear); static String getExpiryString(int expiryDay, int expiryMonth, int expiryYear); static String getOptionRight( OptionTicker.Right right ); static Image getIconImage(); static BigDecimal getIbMultiplier( Ticker ticker ); static Vector<TagValue> getDefaultTagVector(); static List<TagValue> getDefaultTagList();  }
@Test public void testGetAction() { TradeDirection[] values = TradeDirection.values(); for (TradeDirection value : values) { assertNotNull(IbUtils.getAction(value)); } assertEquals("BUY", IbUtils.getAction(TradeDirection.BUY)); assertEquals("SELL", IbUtils.getAction(TradeDirection.SELL)); assertEquals("SELL", IbUtils.getAction(TradeDirection.SELL_SHORT)); assertEquals("BUY", IbUtils.getAction(TradeDirection.BUY_TO_COVER)); try { IbUtils.getAction(null); fail(); } catch (IllegalStateException ex) { } }