@Test public void testCreateAsync() throws Exception { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); FlavorApi flavorApi = new FlavorRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); flavorApi.createAsync(new FlavorCreateSpec(), new FutureCallback<Task>() { @Override public void onSuccess(@Nullable Task result) { assertEquals(result, responseTask); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
@Override public void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { createObjectAsync(getBasePath(), serializeObjectAsJson(flavorCreateSpec), responseCallback); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { createObjectAsync(getBasePath(), serializeObjectAsJson(flavorCreateSpec), responseCallback); } }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { createObjectAsync(getBasePath(), serializeObjectAsJson(flavorCreateSpec), responseCallback); } FlavorRestApi(RestClient restClient); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { createObjectAsync(getBasePath(), serializeObjectAsJson(flavorCreateSpec), responseCallback); } FlavorRestApi(RestClient restClient); @Override String getBasePath(); @Override Task create(FlavorCreateSpec flavorCreateSpec); @Override void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback); @Override ResourceList<Flavor> listAll(); @Override ResourceList<Flavor> listAll(Map<String, String> queryParams); @Override void listAllAsync(final FutureCallback<ResourceList<Flavor>> responseCallback); @Override Flavor getFlavor(String flavorId); @Override void getFlavorAsync(final String flavorId, final FutureCallback<Flavor> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String flavorId, final FutureCallback<Task> responseCallback); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback) throws IOException { createObjectAsync(getBasePath(), serializeObjectAsJson(flavorCreateSpec), responseCallback); } FlavorRestApi(RestClient restClient); @Override String getBasePath(); @Override Task create(FlavorCreateSpec flavorCreateSpec); @Override void createAsync(final FlavorCreateSpec flavorCreateSpec, final FutureCallback<Task> responseCallback); @Override ResourceList<Flavor> listAll(); @Override ResourceList<Flavor> listAll(Map<String, String> queryParams); @Override void listAllAsync(final FutureCallback<ResourceList<Flavor>> responseCallback); @Override Flavor getFlavor(String flavorId); @Override void getFlavorAsync(final String flavorId, final FutureCallback<Flavor> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String flavorId, final FutureCallback<Task> responseCallback);  }