@Test public void getProvidersNoItemsTest() { Configuration.providerRegistryEndpoint = mBaseURL; String collection = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<collection xmlns=\"http: "<link rel=\"self\" href=\"/\" type=\"application/xml\"/>" + "</collection>"; mServer.addPath("/", collection); PRClient client = new PRClient(); assertEquals(0, client.getProviders().size()); }
public List<Provider> getProviders() { ClientResponse response = webResource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (response.getStatus() != 200) { logger.info("ERROR getting list of providers: " + response.getEntity(String.class)); return new ArrayList<Provider>(); } Collection collection; try { JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response.getEntity(String.class))); } catch(Exception exception) { logger.info("Imposible to parse this list of providers"); logger.info("Exception: " + exception.toString()); return new ArrayList<Provider>(); } if(collection != null) { Items items = collection.getItems(); if(items != null) { return items.getProviders(); } else { return new ArrayList<Provider>(); } } else { return new ArrayList<Provider>(); } }
PRClient { public List<Provider> getProviders() { ClientResponse response = webResource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (response.getStatus() != 200) { logger.info("ERROR getting list of providers: " + response.getEntity(String.class)); return new ArrayList<Provider>(); } Collection collection; try { JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response.getEntity(String.class))); } catch(Exception exception) { logger.info("Imposible to parse this list of providers"); logger.info("Exception: " + exception.toString()); return new ArrayList<Provider>(); } if(collection != null) { Items items = collection.getItems(); if(items != null) { return items.getProviders(); } else { return new ArrayList<Provider>(); } } else { return new ArrayList<Provider>(); } } }
PRClient { public List<Provider> getProviders() { ClientResponse response = webResource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (response.getStatus() != 200) { logger.info("ERROR getting list of providers: " + response.getEntity(String.class)); return new ArrayList<Provider>(); } Collection collection; try { JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response.getEntity(String.class))); } catch(Exception exception) { logger.info("Imposible to parse this list of providers"); logger.info("Exception: " + exception.toString()); return new ArrayList<Provider>(); } if(collection != null) { Items items = collection.getItems(); if(items != null) { return items.getProviders(); } else { return new ArrayList<Provider>(); } } else { return new ArrayList<Provider>(); } } PRClient(); }
PRClient { public List<Provider> getProviders() { ClientResponse response = webResource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (response.getStatus() != 200) { logger.info("ERROR getting list of providers: " + response.getEntity(String.class)); return new ArrayList<Provider>(); } Collection collection; try { JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response.getEntity(String.class))); } catch(Exception exception) { logger.info("Imposible to parse this list of providers"); logger.info("Exception: " + exception.toString()); return new ArrayList<Provider>(); } if(collection != null) { Items items = collection.getItems(); if(items != null) { return items.getProviders(); } else { return new ArrayList<Provider>(); } } else { return new ArrayList<Provider>(); } } PRClient(); List<Provider> getProviders(); VmManagerClient getVMMClient(int id); }
PRClient { public List<Provider> getProviders() { ClientResponse response = webResource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (response.getStatus() != 200) { logger.info("ERROR getting list of providers: " + response.getEntity(String.class)); return new ArrayList<Provider>(); } Collection collection; try { JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response.getEntity(String.class))); } catch(Exception exception) { logger.info("Imposible to parse this list of providers"); logger.info("Exception: " + exception.toString()); return new ArrayList<Provider>(); } if(collection != null) { Items items = collection.getItems(); if(items != null) { return items.getProviders(); } else { return new ArrayList<Provider>(); } } else { return new ArrayList<Provider>(); } } PRClient(); List<Provider> getProviders(); VmManagerClient getVMMClient(int id);  }