TradingUtils { public static String[] splitInstrumentPair(String instrument) { if (!StringUtils.isEmpty(instrument) && instrument.length() == CCY_PAIR_LEN) { return new String[] { instrument.substring(0, CCY_SEP_CHR_POS), instrument.substring(CCY_SEP_CHR_POS + 1) }; } throw new IllegalArgumentException(String.format("Instrument %s is not of expected length %d", instrument)); } private  TradingUtils(); static final String executingRequestMsg(HttpRequest request); static long toUnixTime(DateTime dateTime); static long toMillisFromNanos(long nanos); static String[] splitCcyPair(String instrument, String currencySeparator); static double calculateTakeProfitPrice(double tickSize, TradingSignal signal, double bidPrice,
			double askPrice, int pipsDesired); static final String responseToString(HttpResponse response); static final boolean isEmpty(Collection<?> collection); static final boolean isEmpty(Map<?, ?> map); static String[] splitInstrumentPair(String instrument); static final int getSign(String currencyInstrument, TradingSignal side, String currency); static void closeSilently(CloseableHttpClient httpClient); static void printErrorMsg(HttpResponse response); static String getResponse(HttpResponse response); static final int CCY_PAIR_LEN; static final int CCY_SEP_CHR_POS; }
@Test public void splitInstrumentPairTest() { String[] currencies = TradingUtils.splitInstrumentPair("EUR/USD"); assertEquals(2, currencies.length); assertEquals("EUR", currencies[0]); assertEquals("USD", currencies[1]); try { TradingUtils.splitInstrumentPair(null); fail("Expected IllegalArgumentException because null was passed in"); } catch (IllegalArgumentException e) { } try { TradingUtils.splitInstrumentPair(StringUtils.EMPTY); fail("Expected IllegalArgumentException because empty string was passed in"); } catch (IllegalArgumentException e) { } try { TradingUtils.splitInstrumentPair("foo"); fail("Expected IllegalArgumentException because unexpected string was passed in"); } catch (IllegalArgumentException e) { } }