use of com.github.jnidzwetzki.bitfinex.v2.callback.command.SubscribedCallback in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class CommandsCallbackTest method testSubscribeAndUnsubscribeCallback.
/**
* Test the subscribed callback
* @throws APIException
*/
@Test
public void testSubscribeAndUnsubscribeCallback() throws APIException {
final String jsonString = "{\"event\":\"subscribed\",\"channel\":\"ticker\",\"chanId\":30,\"symbol\":\"tNEOUSD\",\"pair\":\"NEOUSD\"}";
final JSONObject jsonObject = new JSONObject(jsonString);
final BitfinexApiBroker bitfinexApiBroker = new BitfinexApiBroker();
Assert.assertTrue(bitfinexApiBroker.getFromChannelSymbolMap(30) == null);
final SubscribedCallback subscribedCallback = new SubscribedCallback();
subscribedCallback.handleChannelData(bitfinexApiBroker, jsonObject);
Assert.assertTrue(bitfinexApiBroker.getFromChannelSymbolMap(30) instanceof BitfinexTickerSymbol);
final String unsubscribedJsonString = "{\"event\":\"unsubscribed\",\"status\":\"OK\",\"chanId\":30}";
final JSONObject jsonUnsubscribedObject = new JSONObject(unsubscribedJsonString);
final UnsubscribedCallback unsubscribedCallback = new UnsubscribedCallback();
unsubscribedCallback.handleChannelData(bitfinexApiBroker, jsonUnsubscribedObject);
Assert.assertTrue(bitfinexApiBroker.getFromChannelSymbolMap(30) == null);
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.command.SubscribedCallback in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexApiBroker method setupCommandCallbacks.
/**
* Setup the command callbacks
*/
private void setupCommandCallbacks() {
commandCallbacks = new HashMap<>();
commandCallbacks.put("info", new DoNothingCommandCallback());
commandCallbacks.put("subscribed", new SubscribedCallback());
commandCallbacks.put("pong", new ConnectionHeartbeatCallback());
commandCallbacks.put("unsubscribed", new UnsubscribedCallback());
commandCallbacks.put("auth", new AuthCallbackHandler());
}
Aggregations