@Test(expected = DoesNotExistException.class) public void testGetAggregatorDoesNotExist() throws DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); aa.getAggregator("A0r0"); }
public Aggregator getAggregator(String aggregatorId) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + aggregatorId); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } Aggregator aggregator = response.readEntity(Aggregator.class); LOGGER.info("getAggregator(..) success!"); return aggregator; }
AggregatorsAccessor { public Aggregator getAggregator(String aggregatorId) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + aggregatorId); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } Aggregator aggregator = response.readEntity(Aggregator.class); LOGGER.info("getAggregator(..) success!"); return aggregator; } }
AggregatorsAccessor { public Aggregator getAggregator(String aggregatorId) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + aggregatorId); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } Aggregator aggregator = response.readEntity(Aggregator.class); LOGGER.info("getAggregator(..) success!"); return aggregator; } AggregatorsAccessor(URL restUrl, String username, String password);   AggregatorsAccessor(URL restUrl, String username, String password, Client client); }
AggregatorsAccessor { public Aggregator getAggregator(String aggregatorId) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + aggregatorId); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } Aggregator aggregator = response.readEntity(Aggregator.class); LOGGER.info("getAggregator(..) success!"); return aggregator; } AggregatorsAccessor(URL restUrl, String username, String password);   AggregatorsAccessor(URL restUrl, String username, String password, Client client); Aggregator getAggregator(String aggregatorId); void deleteAggregator(String aggregatorId); List<Aggregator> getAggregatorList(int offset, int number); void createAggregator(String id, String name, String nameCode, String homepage); void updateAggregator(String id, String newId, String name, String nameCode,
      String homepage); URL getRestUrl(); void setRestUrl(URL restUrl); }
AggregatorsAccessor { public Aggregator getAggregator(String aggregatorId) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + aggregatorId); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } Aggregator aggregator = response.readEntity(Aggregator.class); LOGGER.info("getAggregator(..) success!"); return aggregator; } AggregatorsAccessor(URL restUrl, String username, String password);   AggregatorsAccessor(URL restUrl, String username, String password, Client client); Aggregator getAggregator(String aggregatorId); void deleteAggregator(String aggregatorId); List<Aggregator> getAggregatorList(int offset, int number); void createAggregator(String id, String name, String nameCode, String homepage); void updateAggregator(String id, String newId, String name, String nameCode,
      String homepage); URL getRestUrl(); void setRestUrl(URL restUrl);  }