@Test public void models() { List<Model> models = restApi.models(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelsSync() throws IOException { Response<List<Model>> responseModels = restApi.models("[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]").execute(); assertTrue(responseModels.isSuccessful()); List<Model> models = responseModels.body(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelsAsync() throws Exception { final AtomicReference<Response<List<Model>>> atomicReference = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); restApi.models("[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]") .enqueue(new Callback<List<Model>>() { @Override public void onResponse(Call<List<Model>> call, Response<List<Model>> response) { atomicReference.set(response); latch.countDown(); } @Override public void onFailure(Call<List<Model>> call, Throwable t) { t.printStackTrace(); } }); assertTrue(latch.await(10, SECONDS)); Response<List<Model>> responseModels = atomicReference.get(); assertTrue(responseModels.isSuccessful()); List<Model> models = responseModels.body(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }