@Test public void testListAll() throws IOException { Flavor flavor1 = new Flavor(); flavor1.setId("flavor1"); flavor1.setKind("vm"); Flavor flavor2 = new Flavor(); flavor2.setId("flavor2"); flavor2.setKind("vm"); ResourceList<Flavor> flavorResourceList = new ResourceList<>(Arrays.asList(flavor1, flavor2)); ObjectMapper mapper = new ObjectMapper(); String serializedResponse = mapper.writeValueAsString(flavorResourceList); setupMocks(serializedResponse, HttpStatus.SC_OK); FlavorApi flavorApi = new FlavorRestApi(restClient); ResourceList<Flavor> response = flavorApi.listAll(); assertEquals(response.getItems().size(), flavorResourceList.getItems().size()); assertTrue(response.getItems().containsAll(flavorResourceList.getItems())); }
@Override public ResourceList<Flavor> listAll() throws IOException { ResourceList<Flavor> flavorResourceList = new ResourceList<>(); ResourceList<Flavor> resourceList = getFlavorResourceList(getBasePath()); flavorResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getFlavorResourceList(resourceList.getNextPageLink()); flavorResourceList.getItems().addAll(resourceList.getItems()); } return flavorResourceList; }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public ResourceList<Flavor> listAll() throws IOException { ResourceList<Flavor> flavorResourceList = new ResourceList<>(); ResourceList<Flavor> resourceList = getFlavorResourceList(getBasePath()); flavorResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getFlavorResourceList(resourceList.getNextPageLink()); flavorResourceList.getItems().addAll(resourceList.getItems()); } return flavorResourceList; } }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public ResourceList<Flavor> listAll() throws IOException { ResourceList<Flavor> flavorResourceList = new ResourceList<>(); ResourceList<Flavor> resourceList = getFlavorResourceList(getBasePath()); flavorResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getFlavorResourceList(resourceList.getNextPageLink()); flavorResourceList.getItems().addAll(resourceList.getItems()); } return flavorResourceList; } FlavorRestApi(RestClient restClient); }
FlavorRestApi extends ApiBase implements FlavorApi { @Override public ResourceList<Flavor> listAll() throws IOException { ResourceList<Flavor> flavorResourceList = new ResourceList<>(); ResourceList<Flavor> resourceList = getFlavorResourceList(getBasePath()); flavorResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getFlavorResourceList(resourceList.getNextPageLink()); flavorResourceList.getItems().addAll(resourceList.getItems()); } return flavorResourceList; } 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 ResourceList<Flavor> listAll() throws IOException { ResourceList<Flavor> flavorResourceList = new ResourceList<>(); ResourceList<Flavor> resourceList = getFlavorResourceList(getBasePath()); flavorResourceList.setItems(resourceList.getItems()); while (resourceList.getNextPageLink() != null && !resourceList.getNextPageLink().isEmpty()) { resourceList = getFlavorResourceList(resourceList.getNextPageLink()); flavorResourceList.getItems().addAll(resourceList.getItems()); } return flavorResourceList; } 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);  }