@Test public void testCallback() { final Consumer consumer = mock(Consumer.class); final ServiceCallback service = client.callback(consumer); final List item = mock(List.class); service.onSuccess(item); verify(consumer, atLeastOnce()).accept(item); final ClientRuntimeError error = mock(ClientRuntimeError.class); service.onError(error); verify(proxy).logWarning(error); verify(consumer, atLeastOnce()).accept(any(ArrayList.class)); }
public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy().logWarning(error); consumer.accept(new ArrayList<>()); } }; }
DMNServiceClient { public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy().logWarning(error); consumer.accept(new ArrayList<>()); } }; } }
DMNServiceClient { public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy().logWarning(error); consumer.accept(new ArrayList<>()); } }; } DMNServiceClient(final DMNClientServicesProxy clientServicesProxy); }
DMNServiceClient { public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy().logWarning(error); consumer.accept(new ArrayList<>()); } }; } DMNServiceClient(final DMNClientServicesProxy clientServicesProxy); ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer); }
DMNServiceClient { public <T> ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer) { return new ServiceCallback<List<T>>() { @Override public void onSuccess(final List<T> item) { consumer.accept(item); } @Override public void onError(final ClientRuntimeError error) { getClientServicesProxy().logWarning(error); consumer.accept(new ArrayList<>()); } }; } DMNServiceClient(final DMNClientServicesProxy clientServicesProxy); ServiceCallback<List<T>> callback(final Consumer<List<T>> consumer);  }