InfluxDbReporterFactory extends BaseReporterFactory { @Override public ScheduledReporter build(MetricRegistry registry) { try { InfluxDbReporter.Builder builder = builder(registry); switch (senderType) { case HTTP: return builder.build( new InfluxDbHttpSender( protocol, host, port, database, auth, precision.getUnit(), connectTimeout, readTimeout, prefix ) ); case TCP: return builder.build( new InfluxDbTcpSender( host, port, readTimeout, database, prefix ) ); case UDP: return builder.build( new InfluxDbUdpSender( host, port, readTimeout, database, prefix ) ); case LOGGER: return builder.build( new InfluxDbLoggerSender( database, TimeUnit.MILLISECONDS, prefix ) ); case KAFKA: return builder.build( new InfluxDBKafkaSender( database, TimeUnit.MILLISECONDS, prefix ) ); default: throw new UnsupportedDataTypeException("The Sender Type is not supported. "); } } catch (Exception e) { throw new RuntimeException(e); } }  @JsonProperty String getProtocol(); @JsonProperty void setProtocol(String protocol); @JsonProperty String getHost(); @JsonProperty void setHost(String host); @JsonProperty int getPort(); @JsonProperty void setPort(int port); @JsonProperty String getPrefix(); @JsonProperty void setPrefix(String prefix); @JsonProperty void setTags(Map<String, String> tags); @JsonProperty ImmutableMap<String, ImmutableSet<String>> getFields(); @JsonProperty void setFields(ImmutableMap<String, ImmutableSet<String>> fields); @JsonProperty String getDatabase(); @JsonProperty void setDatabase(String database); @JsonProperty String getAuth(); @JsonProperty void setAuth(String auth); @JsonProperty int getConnectTimeout(); @JsonProperty void setConnectTimeout(int connectTimeout); @JsonProperty int getReadTimeout(); @JsonProperty void setReadTimeout(int readTimeout); @JsonProperty boolean getGroupGauges(); @JsonProperty void setGroupGauges(boolean groupGauges); @JsonProperty Duration getPrecision(); @JsonProperty void setPrecision(Duration precision); @JsonProperty Map<String, String> getMeasurementMappings(); @JsonProperty void setMeasurementMappings(ImmutableMap<String, String> measurementMappings); @JsonProperty Map<String, String> getDefaultMeasurementMappings(); @JsonProperty @Override ImmutableSet<String> getExcludes(); @JsonProperty @Override void setExcludes(Set<String> excludes); @JsonProperty void setDefaultMeasurementMappings(ImmutableMap<String, String> defaultMeasurementMappings); @JsonProperty void setSenderType(SenderType senderType); @JsonProperty SenderType getSenderType(); @JsonProperty void setTagsTransformer(Transformer tagsTransformer); @JsonProperty Transformer getTagsTransformer(); @Override ScheduledReporter build(MetricRegistry registry); @ValidationMethod(message = "measurementMappings must be regular expressions") boolean isMeasurementMappingRegularExpressions();  }
@Test public void testNoAddressResolutionForInfluxDb() throws Exception { final InfluxDbReporter.Builder builderSpy = mock(InfluxDbReporter.Builder.class); new InfluxDbReporterFactory() { @Override protected InfluxDbReporter.Builder builder(MetricRegistry registry) { return builderSpy; } }.build(new MetricRegistry()); final ArgumentCaptor<InfluxDbHttpSender> argument = ArgumentCaptor.forClass(InfluxDbHttpSender.class); verify(builderSpy).build(argument.capture()); final InfluxDbHttpSender influxDb = argument.getValue(); String url = new URL("http", "localhost", 8086, "/write").toString() + "?db=&precision=m"; assertThat(getField(influxDb, InfluxDbHttpSender.class, "url")).isEqualTo(new URL(url)); assertThat(getField(influxDb, InfluxDbHttpSender.class, "connectTimeout")).isEqualTo(1500); assertThat(getField(influxDb, InfluxDbHttpSender.class, "readTimeout")).isEqualTo(1500); assertThat( getField( influxDb, InfluxDbHttpSender.class, "authStringEncoded")).isEqualTo(Base64.encodeBase64String("".getBytes(UTF_8))); }