@Test public void testGetProviderList() throws InvalidArgumentsException, DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(200); pa.getProviderList("A0r0", 0, 1); Mockito.when(response.readEntity(new GenericType<List<DataProvider>>() {})).thenReturn( new ArrayList<DataProvider>()); }
public List<DataProvider> getProviderList(String aggregatorId, int offset, int number) throws InvalidArgumentsException, DoesNotExistException { WebTarget target = client.target(restUrl + "/" + ProviderOptionListContainer.PROVIDERS) .queryParam(ProviderOptionListContainer.AGGREGATORID, aggregatorId) .queryParam(ProviderOptionListContainer.OFFSET, offset) .queryParam(ProviderOptionListContainer.NUMBER, number); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } List<DataProvider> subList = response.readEntity(new GenericType<List<DataProvider>>() {}); LOGGER.info("getProviderList(..) success!"); return subList; }
ProvidersAccessor { public List<DataProvider> getProviderList(String aggregatorId, int offset, int number) throws InvalidArgumentsException, DoesNotExistException { WebTarget target = client.target(restUrl + "/" + ProviderOptionListContainer.PROVIDERS) .queryParam(ProviderOptionListContainer.AGGREGATORID, aggregatorId) .queryParam(ProviderOptionListContainer.OFFSET, offset) .queryParam(ProviderOptionListContainer.NUMBER, number); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } List<DataProvider> subList = response.readEntity(new GenericType<List<DataProvider>>() {}); LOGGER.info("getProviderList(..) success!"); return subList; } }
ProvidersAccessor { public List<DataProvider> getProviderList(String aggregatorId, int offset, int number) throws InvalidArgumentsException, DoesNotExistException { WebTarget target = client.target(restUrl + "/" + ProviderOptionListContainer.PROVIDERS) .queryParam(ProviderOptionListContainer.AGGREGATORID, aggregatorId) .queryParam(ProviderOptionListContainer.OFFSET, offset) .queryParam(ProviderOptionListContainer.NUMBER, number); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } List<DataProvider> subList = response.readEntity(new GenericType<List<DataProvider>>() {}); LOGGER.info("getProviderList(..) success!"); return subList; } ProvidersAccessor(URL restUrl, String username, String password);   ProvidersAccessor(URL restUrl, String username, String password, Client client); }
ProvidersAccessor { public List<DataProvider> getProviderList(String aggregatorId, int offset, int number) throws InvalidArgumentsException, DoesNotExistException { WebTarget target = client.target(restUrl + "/" + ProviderOptionListContainer.PROVIDERS) .queryParam(ProviderOptionListContainer.AGGREGATORID, aggregatorId) .queryParam(ProviderOptionListContainer.OFFSET, offset) .queryParam(ProviderOptionListContainer.NUMBER, number); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } List<DataProvider> subList = response.readEntity(new GenericType<List<DataProvider>>() {}); LOGGER.info("getProviderList(..) success!"); return subList; } ProvidersAccessor(URL restUrl, String username, String password);   ProvidersAccessor(URL restUrl, String username, String password, Client client); DataProvider getProvider(String providerId); void deleteProvider(String providerId); List<DataProvider> getProviderList(String aggregatorId, int offset, int number); String createProvider(String aggregatorId, String id, String name, String country, String countryCode, 
      String description, String nameCode, String homepage, ProviderType providerType, String email); void updateProvider(String id, String newId, String newAggregatorId, String name, String country, String countryCode,
      String description, String nameCode, String homepage, ProviderType providerType, String email); }
ProvidersAccessor { public List<DataProvider> getProviderList(String aggregatorId, int offset, int number) throws InvalidArgumentsException, DoesNotExistException { WebTarget target = client.target(restUrl + "/" + ProviderOptionListContainer.PROVIDERS) .queryParam(ProviderOptionListContainer.AGGREGATORID, aggregatorId) .queryParam(ProviderOptionListContainer.OFFSET, offset) .queryParam(ProviderOptionListContainer.NUMBER, number); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 400) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); } else if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getProviderList(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } List<DataProvider> subList = response.readEntity(new GenericType<List<DataProvider>>() {}); LOGGER.info("getProviderList(..) success!"); return subList; } ProvidersAccessor(URL restUrl, String username, String password);   ProvidersAccessor(URL restUrl, String username, String password, Client client); DataProvider getProvider(String providerId); void deleteProvider(String providerId); List<DataProvider> getProviderList(String aggregatorId, int offset, int number); String createProvider(String aggregatorId, String id, String name, String country, String countryCode, 
      String description, String nameCode, String homepage, ProviderType providerType, String email); void updateProvider(String id, String newId, String newAggregatorId, String name, String country, String countryCode,
      String description, String nameCode, String homepage, ProviderType providerType, String email);  }