LgoStreamingService extends JsonNettyStreamingService { @Override protected String getChannelNameFromMessage(JsonNode message) { String channel = message.get("channel").asText(); if (channel.equals("trades") || channel.equals("level2") || channel.equals("user")) { return channel + "-" + message.get("product_id").textValue(); } return channel; } LgoStreamingService(LgoSignatureService signatureService, String apiUrl); @Override String getSubscribeMessage(String channelName, Object... args); @Override String getUnsubscribeMessage(String channelName);  }
@Test public void it_returns_the_right_channel_name_for_trades() throws IOException { JsonNode message = getJsonContent("/marketdata/trades-update.json"); String name = service.getChannelNameFromMessage(message); assertThat(name).isEqualTo("trades-BTC-USD"); }
@Test public void it_returns_the_right_channel_name_for_level2() throws IOException { JsonNode message = getJsonContent("/marketdata/level2-snapshot.json"); String name = service.getChannelNameFromMessage(message); assertThat(name).isEqualTo("level2-BTC-USD"); }
@Test public void it_returns_the_right_channel_name_for_balances() throws IOException { JsonNode message = getJsonContent("/account/balance-snapshot.json"); String name = service.getChannelNameFromMessage(message); assertThat(name).isEqualTo("balance"); }
@Test public void it_returns_the_right_channel_name_for_user() throws IOException { JsonNode message = getJsonContent("/trade/orders-snapshot.json"); String name = service.getChannelNameFromMessage(message); assertThat(name).isEqualTo("user-BTC-USD"); }