@Test public void syncGetForFailure() throws Exception { server.enqueue(new MockResponse().setStatus("404")); MyApiSync myApi = new Wasp.Builder(context) .setEndpoint(server.url("/v1").toString()) .setNetworkStack(VolleyNetworkStack.newInstance(requestQueue)) .build() .create(MyApiSync.class); try { myApi.getUser(); fail(); } catch (Exception e) { assertTrue(e.getMessage(), true); } RecordedRequest request = server.takeRequest(); assertThat(request.getPath()).isEqualTo("/v1/user"); 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);  }