DestinationListenerWrapper { protected void onUnsubscribed(final CallbackService callbackService, final String topicPattern, final String share, final Exception error) { final String methodName = "onUnsubscribed"; logger.entry(this, methodName, callbackService, topicPattern, share, error); if (listener != null) { callbackService.run(new Runnable() { @Override public void run() { listener.onUnsubscribed(client, context, topicPattern, share, error); } }, client, new CallbackPromiseImpl(client, true)); } logger.exit(this, methodName); } protected  DestinationListenerWrapper(NonBlockingClientImpl client, GsonBuilder gsonBuilder, DestinationListener<T> listener, T context);   }
@Test public void onUnsubscribed() { StubClient expectedClient = new StubClient(); MockListener listener = new MockListener(MockListener.Method.ON_UNSUBSCRIBED); Object expectedContext = new Object(); String expectedPattern = "/kittens"; String expectedShare = "share"; Exception expectedError = new Exception("fail"); MockCallbackService callbackService = new MockCallbackService(); DestinationListenerWrapper<Object> wrapper = new DestinationListenerWrapper<Object>(expectedClient, new GsonBuilder(), listener, expectedContext); wrapper.onUnsubscribed(callbackService, expectedPattern, expectedShare, expectedError); listener.testClientAndContextMatch(expectedClient, expectedContext); assertSame("Expected same topic pattern", expectedPattern, listener.actualTopicPattern); assertSame("Expected same share", expectedShare, listener.actualShare); assertSame("Excepted same error", expectedError, listener.actualError); }
@Test public void onUnsubscribedNullListener() { DestinationListenerWrapper<Object> wrapper = new DestinationListenerWrapper<Object>(new StubClient(), new GsonBuilder(), null, null); wrapper.onUnsubscribed(new MockCallbackService(), "", "", null); }