@Test public void testGetFlavor() throws IOException { Flavor flavor1 = new Flavor(); flavor1.setId("flavor1"); flavor1.setKind("vm"); ObjectMapper mapper = new ObjectMapper(); String serializedResponse = mapper.writeValueAsString(flavor1); setupMocks(serializedResponse, HttpStatus.SC_OK); FlavorApi flavorApi = new FlavorRestApi(restClient); Flavor response = flavorApi.getFlavor("flavor1"); assertEquals(response, flavor1); }
@Override public Flavor getFlavor(String flavorId) throws IOException { String path = String.format("%s/%s", getBasePath(), flavorId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Flavor>() { } ); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Flavor getFlavor(String flavorId) throws IOException { String path = String.format("%s/%s", getBasePath(), flavorId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Flavor>() { } ); } }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Flavor getFlavor(String flavorId) throws IOException { String path = String.format("%s/%s", getBasePath(), flavorId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Flavor>() { } ); } FlavorRestApi(RestClient restClient); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public Flavor getFlavor(String flavorId) throws IOException { String path = String.format("%s/%s", getBasePath(), flavorId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Flavor>() { } ); } 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 Flavor getFlavor(String flavorId) throws IOException { String path = String.format("%s/%s", getBasePath(), flavorId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse( httpResponse, new TypeReference<Flavor>() { } ); } 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);  }