@Test(expected = MissingArgumentsException.class) public void testUpdateAggregatorMissingArguments() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException, DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(406); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Invalid argument!")); aa.updateAggregator("Id", "newId", "Greece", "GR", "http: }
public void updateAggregator(String id, String newId, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + id); Aggregator aggregator = new Aggregator(newId, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).put( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("updateAggregator(..) success!"); }
AggregatorsAccessor { public void updateAggregator(String id, String newId, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + id); Aggregator aggregator = new Aggregator(newId, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).put( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("updateAggregator(..) success!"); } }
AggregatorsAccessor { public void updateAggregator(String id, String newId, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + id); Aggregator aggregator = new Aggregator(newId, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).put( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("updateAggregator(..) success!"); } AggregatorsAccessor(URL restUrl, String username, String password);   AggregatorsAccessor(URL restUrl, String username, String password, Client client); }
AggregatorsAccessor { public void updateAggregator(String id, String newId, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + id); Aggregator aggregator = new Aggregator(newId, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).put( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("updateAggregator(..) success!"); } 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 void updateAggregator(String id, String newId, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, DoesNotExistException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS + "/" + id); Aggregator aggregator = new Aggregator(newId, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).put( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 404: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("updateAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("updateAggregator(..) success!"); } 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);  }