@Test public void voidCallbackGetForFailure() throws Exception { server.enqueue(new MockResponse().setStatus("404")); MyApiVoid myApi = new Wasp.Builder(context) .setEndpoint(server.url("/v1").toString()) .setNetworkStack(VolleyNetworkStack.newInstance(requestQueue)) .build() .create(MyApiVoid.class); final CountDownLatch latch = new CountDownLatch(1); myApi.getUser(new Callback<User>() { @Override public void onSuccess(Response response, User user) { fail("should fail"); } @Override public void onError(WaspError error) { assertTrue(true); assertThat(error).isNotNull(); assertThat(error.getResponse()).isNotNull(); latch.countDown(); } }); RecordedRequest request = server.takeRequest(); assertThat(request.getPath()).isEqualTo("/v1/user"); assertThat(request.getMethod()).isEqualTo("GET"); assertTrue(latch.await(TIMEOUT, TimeUnit.SECONDS)); verify(executor).execute(any(Runnable.class)); verifyNoMoreInteractions(executor); }
@SuppressWarnings("unchecked") public <T> T create(Class<T> service) { if (service == null) { throw new NullPointerException("service param may not be null"); } if (!service.isInterface()) { throw new IllegalArgumentException("Only interface type is supported"); } NetworkHandler handler = NetworkHandler.newInstance(service, builder); return (T) handler.getProxyClass(); }
Wasp { @SuppressWarnings("unchecked") public <T> T create(Class<T> service) { if (service == null) { throw new NullPointerException("service param may not be null"); } if (!service.isInterface()) { throw new IllegalArgumentException("Only interface type is supported"); } NetworkHandler handler = NetworkHandler.newInstance(service, builder); return (T) handler.getProxyClass(); } }
Wasp { @SuppressWarnings("unchecked") public <T> T create(Class<T> service) { if (service == null) { throw new NullPointerException("service param may not be null"); } if (!service.isInterface()) { throw new IllegalArgumentException("Only interface type is supported"); } NetworkHandler handler = NetworkHandler.newInstance(service, builder); return (T) handler.getProxyClass(); } private  Wasp(Builder builder); }
Wasp { @SuppressWarnings("unchecked") public <T> T create(Class<T> service) { if (service == null) { throw new NullPointerException("service param may not be null"); } if (!service.isInterface()) { throw new IllegalArgumentException("Only interface type is supported"); } NetworkHandler handler = NetworkHandler.newInstance(service, builder); return (T) handler.getProxyClass(); } private  Wasp(Builder builder); static Parser getParser(); @SuppressWarnings("unchecked") T create(Class<T> service); }
Wasp { @SuppressWarnings("unchecked") public <T> T create(Class<T> service) { if (service == null) { throw new NullPointerException("service param may not be null"); } if (!service.isInterface()) { throw new IllegalArgumentException("Only interface type is supported"); } NetworkHandler handler = NetworkHandler.newInstance(service, builder); return (T) handler.getProxyClass(); } private  Wasp(Builder builder); static Parser getParser(); @SuppressWarnings("unchecked") T create(Class<T> service);  }