test_class.file: proxy/src/test/java/com/wavefront/agent/channel/SharedGraphiteHostAnnotatorTest.java
test_class.identifier: SharedGraphiteHostAnnotatorTest
test_case.body: @Test
    public void testHostAnnotator() throws Exception {
      ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class);
      Channel channel = createMock(Channel.class);
      InetSocketAddress remote = new InetSocketAddress(InetAddress.getLocalHost(), 2878);
      expect(ctx.channel()).andReturn(channel).anyTimes();
      expect(channel.remoteAddress()).andReturn(remote).anyTimes();
      replay(channel, ctx);
      SharedGraphiteHostAnnotator annotator = new SharedGraphiteHostAnnotator(
          ImmutableList.of("tag1", "tag2", "tag3"), x -> "default");
  
      String point;
      point = "request.count 1 source=test.wavefront.com";
      assertEquals(point, annotator.apply(ctx, point));
      point = "\"request.count\" 1 \"source\"=\"test.wavefront.com\"";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 host=test.wavefront.com";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 \"host\"=test.wavefront.com";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 tag1=test.wavefront.com";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 tag2=\"test.wavefront.com\"";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 tag3=test.wavefront.com";
      assertEquals(point, annotator.apply(ctx, point));
      point = "request.count 1 tag4=test.wavefront.com";
      assertEquals("request.count 1 tag4=test.wavefront.com source=\"default\"",
          annotator.apply(ctx, point));
    }
test_case.class_method_signature: SharedGraphiteHostAnnotatorTest.testHostAnnotator()
test_case.full_signature: @Test public void testHostAnnotator()
test_case.identifier: testHostAnnotator
test_case.invocations: createMock createMock getLocalHost anyTimes andReturn expect channel anyTimes andReturn expect remoteAddress replay of assertEquals apply assertEquals apply assertEquals apply assertEquals apply assertEquals apply assertEquals apply assertEquals apply assertEquals apply
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHostAnnotator()
focal_class.declarator: DEFAULT_SOURCE_TAGS = ImmutableList.of("source",
        "host", "\"source\"", "\"host\"")
focal_class.modifier: private static final
focal_class.original_string: private static final List<String> DEFAULT_SOURCE_TAGS = ImmutableList.of("source",
        "host", "\"source\"", "\"host\"");
focal_class.type: List<String>
focal_class.var_name: DEFAULT_SOURCE_TAGS
focal_class.declarator: hostnameResolver
focal_class.modifier: private final
focal_class.original_string: private final Function<InetAddress, String> hostnameResolver;
focal_class.type: Function<InetAddress, String>
focal_class.var_name: hostnameResolver
focal_class.declarator: sourceTags
focal_class.modifier: private final
focal_class.original_string: private final List<String> sourceTags;
focal_class.type: List<String>
focal_class.var_name: sourceTags
focal_class.file: proxy/src/main/java/com/wavefront/agent/channel/SharedGraphiteHostAnnotator.java
focal_class.identifier: SharedGraphiteHostAnnotator
focal_class.class_method_signature: SharedGraphiteHostAnnotator.SharedGraphiteHostAnnotator(@Nullable List<String> customSourceTags,
                                       @Nonnull Function<InetAddress, String> hostnameResolver)
focal_class.full_signature: public  SharedGraphiteHostAnnotator(@Nullable List<String> customSourceTags,
                                       @Nonnull Function<InetAddress, String> hostnameResolver)
focal_class.identifier: SharedGraphiteHostAnnotator
focal_class.modifiers: public
focal_class.parameters: (@Nullable List<String> customSourceTags,
                                       @Nonnull Function<InetAddress, String> hostnameResolver)
focal_class.signature:  SharedGraphiteHostAnnotator(@Nullable List<String> customSourceTags,
                                       @Nonnull Function<InetAddress, String> hostnameResolver)
focal_class.class_method_signature: SharedGraphiteHostAnnotator.apply(ChannelHandlerContext ctx, String msg)
focal_class.full_signature: public String apply(ChannelHandlerContext ctx, String msg)
focal_class.identifier: apply
focal_class.modifiers: public
focal_class.parameters: (ChannelHandlerContext ctx, String msg)
focal_class.return: String
focal_class.signature: String apply(ChannelHandlerContext ctx, String msg)
focal_method.body: public String apply(ChannelHandlerContext ctx, String msg) {
      for (int i = 0; i < sourceTags.size(); i++) {
        String tag = sourceTags.get(i);
        int strIndex = msg.indexOf(tag);
        // if a source tags is found and is followed by a non-whitespace tag value, add without change
        if (strIndex > -1 && msg.length() - strIndex - tag.length() > 0 &&
            msg.charAt(strIndex + tag.length()) > ' ') {
          return msg;
        }
      }
      return msg + " source=\"" + hostnameResolver.apply(getRemoteAddress(ctx)) + "\"";
    }
focal_method.class_method_signature: SharedGraphiteHostAnnotator.apply(ChannelHandlerContext ctx, String msg)
focal_method.full_signature: public String apply(ChannelHandlerContext ctx, String msg)
focal_method.identifier: apply
focal_method.invocations: size get indexOf length length charAt length apply getRemoteAddress
focal_method.modifiers: public
focal_method.parameters: (ChannelHandlerContext ctx, String msg)
focal_method.return: String
focal_method.signature: String apply(ChannelHandlerContext ctx, String msg)