Graphite extends ServiceImpl implements EventTrackingService { @Override public void enable(String url) { if(utils.isNotBlank(url) && url.contains(":") && url.split(":").length == 2) { String first = url.split(":")[0]; String second = url.split(":")[1]; if (first.contains("@")) { this.apiKey = first.split("@")[0]; this.host = first.split("@")[1]; } else { this.host = url.split(":")[0]; } try { this.port = Integer.parseInt(second); } catch (NumberFormatException ex) { utils.logIssue("Invalid port in Graphite URL [" + second + "]", ex); } } else { utils.logIssue("Invalid Graphite URL. Expecting \"[key@]host:port\" format.", null); } } Graphite(Context context); @Override void enable(String url); @Override boolean isEnabled(); @Override ServiceType getServiceType(); @Override void logEvent(Context context, String event);  }
@Test public void testEnable() { Graphite graphite = new Graphite(null); assertFalse(graphite.isEnabled()); graphite.enable("unit_test_url:8080"); assertTrue(graphite.isEnabled()); assertEquals("unit_test_url", graphite.host); assertEquals(8080, graphite.port); assertNull(graphite.apiKey); }