@Test public void testParseInvalidValue() { try { FAVORITE_FISH.parseValue("anchovy"); fail("Invalid EnumGuacamoleProperty values should fail to parse with an exception."); } catch (GuacamoleException e) { String message = e.getMessage(); assertTrue(message.contains("\"mackerel\", \"salmon\", \"sardine\", \"trout\", \"tuna\"")); } }
@Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); @Override T parseValue(String value); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); @Override T parseValue(String value);  }