TelemetryAgent { public static void agentmain(String agentArgs, Instrumentation inst) { premain(agentArgs, inst); }  static void agentmain(String agentArgs, Instrumentation inst); static void premain(String agentArgs, Instrumentation inst);  }
@Test(expected = NullPointerException.class) public void nullArgs() { TelemetryAgent.agentmain(null, instrumentation); verifyZeroInteractions(instrumentation); }
@Test public void emptyArgs() throws Exception { TelemetryAgent.agentmain("", instrumentation); verifyZeroInteractions(instrumentation); }
@Test public void invalidArgs() throws Exception { TelemetryAgent.agentmain("woo", instrumentation); verifyZeroInteractions(instrumentation); }
@Test public void validArgsAddsServiceAnnotations() throws Exception { TelemetryAgent.agentmain(getConfigurationPath(), instrumentation); assertEquals("example", Annotations.getServiceAnnotations().getService()); }
@Test public void validArgsRegistersSinks() throws Exception { TelemetryAgent.agentmain(getConfigurationPath(), instrumentation); ImmutableList<SpanSink> registeredSinks = ImmutableList.copyOf(SpanSinkRegistry.getSpanSinks()); assertEquals(1, registeredSinks.size()); assertTrue(registeredSinks.get(0) instanceof AsynchronousSpanSink); }
@Test public void configuresSpanSampleLevels() throws Exception { assertEquals(Sampling.ON, SpanHelper.getSampler()); TelemetryAgent.agentmain(getConfigurationPath(), instrumentation); assertEquals(Sampling.OFF, SpanHelper.getSampler()); }