@Override protected URL asURL(String path) throws URISyntaxException { if (exceptionType != null && exceptionType.equals(URISyntaxException.class)) throw new URISyntaxException(path, "mocking"); return super.asURL(path); } @Override
@Override protected URL asURL(String path) throws URISyntaxException { if (exceptionType != null && exceptionType.equals(URISyntaxException.class)) throw new URISyntaxException(path, "mocking"); return super.asURL(path); } @Override
@Override public List<MenuOptionDescription> listOptions() throws MenuServiceException { Gson gson = new Gson(); List<MenuOptionDescription> retval = new ArrayList<MenuOptionDescription>(); try { URL url = asURL("/menuOptions.json"); retval = gson.fromJson(createReader(url), new TypeToken<List<MenuOptionDescription>>(){}.getType()); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu options json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu options json file found", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
@Override public List<MenuOptionDescription> listOptions() throws MenuServiceException { Gson gson = new Gson(); List<MenuOptionDescription> retval = new ArrayList<MenuOptionDescription>(); try { URL url = asURL("/menuOptions.json"); retval = gson.fromJson(createReader(url), new TypeToken<List<MenuOptionDescription>>(){}.getType()); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu options json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu options json file found", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
@Override public List<ValidationDescription> listValidations() throws MenuServiceException { Gson gson = new Gson(); List<ValidationDescription> retval = null; try { URL url = asURL("/validations.json"); retval = gson.fromJson(createReader(url), new TypeToken<List<ValidationDescription>>(){}.getType()); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding validations json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No validations json file found", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
@Override public List<ValidationDescription> listValidations() throws MenuServiceException { Gson gson = new Gson(); List<ValidationDescription> retval = null; try { URL url = asURL("/validations.json"); retval = gson.fromJson(createReader(url), new TypeToken<List<ValidationDescription>>(){}.getType()); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding validations json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No validations json file found", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }