GraphiteProtocolConverter implements Converter<GraphiteProtocol> { @Override public GraphiteProtocol convertFrom(String value) { try { return GraphiteProtocol.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new ParameterException("Couldn't convert value \"" + value + "\" to Graphite protocol.", e); } }  @Override GraphiteProtocol convertFrom(String value); @Override String convertTo(GraphiteProtocol value);  }
@Test public void convertFromValidString() throws Exception { Assert.assertEquals(GraphiteProtocol.TCP, new GraphiteProtocolConverter().convertFrom("TCP")); }
@Test public void convertFromValidLowerCaseString() throws Exception { assertEquals(GraphiteProtocol.TCP, new GraphiteProtocolConverter().convertFrom("tcp")); }
@Test public void convertFromInvalidString() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert value \"Foobar\" to Graphite protocol."); new GraphiteProtocolConverter().convertFrom("Foobar"); }
@Test public void convertFromNull() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert value \"null\" to Graphite protocol."); new GraphiteProtocolConverter().convertFrom(null); }