@Test public void testCreate() throws IOException { 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); Task task = flavorApi.create(new FlavorCreateSpec()); assertEquals(task, responseTask); }
@Override public Task create(FlavorCreateSpec flavorCreateSpec) throws IOException { HttpResponse response = this.restClient.perform( RestClient.Method.POST, getBasePath(), serializeObjectAsJson(flavorCreateSpec) ); this.restClient.checkResponse(response, HttpStatus.SC_CREATED); return parseTaskFromHttpResponse(response); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Task create(FlavorCreateSpec flavorCreateSpec) throws IOException { HttpResponse response = this.restClient.perform( RestClient.Method.POST, getBasePath(), serializeObjectAsJson(flavorCreateSpec) ); this.restClient.checkResponse(response, HttpStatus.SC_CREATED); return parseTaskFromHttpResponse(response); } }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Task create(FlavorCreateSpec flavorCreateSpec) throws IOException { HttpResponse response = this.restClient.perform( RestClient.Method.POST, getBasePath(), serializeObjectAsJson(flavorCreateSpec) ); this.restClient.checkResponse(response, HttpStatus.SC_CREATED); return parseTaskFromHttpResponse(response); } FlavorRestApi(RestClient restClient); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Task create(FlavorCreateSpec flavorCreateSpec) throws IOException { HttpResponse response = this.restClient.perform( RestClient.Method.POST, getBasePath(), serializeObjectAsJson(flavorCreateSpec) ); this.restClient.checkResponse(response, HttpStatus.SC_CREATED); return parseTaskFromHttpResponse(response); } 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 Task create(FlavorCreateSpec flavorCreateSpec) throws IOException { HttpResponse response = this.restClient.perform( RestClient.Method.POST, getBasePath(), serializeObjectAsJson(flavorCreateSpec) ); this.restClient.checkResponse(response, HttpStatus.SC_CREATED); return parseTaskFromHttpResponse(response); } 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);  }