@Test public void testReadConfigDefault() throws IOException, LifecycleException { try (InputStream inputStream = openResource("kafka-writer-default.json")) { KafkaWriterFactory writerFactory = (KafkaWriterFactory) objectMapper.readValue(inputStream, KafkaWriterFactory.class); assertThat(writerFactory.getTopic()).isEqualTo("jmxtrans"); assertThat(writerFactory.getProducerConfig().get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)).isEqualTo("localhost:9092"); assertThat(writerFactory.getResultSerializer()).isInstanceOf(DefaultResultSerializer.class); try (KafkaWriter2 writer = writerFactory.create()) { assertThat(writer.getTopic()).isEqualTo("jmxtrans"); assertThat(writer.getProducerConfig().get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)).isEqualTo("localhost:9092"); assertThat(writer.getProducerConfig().get(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG).toString()).endsWith("StringSerializer"); assertThat(writer.getProducerConfig().get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG).toString()).endsWith("StringSerializer"); assertThat(writer.getResultSerializer()).isInstanceOf(DefaultResultSerializer.class); } } }
@Nonnull @Override public KafkaWriter2 create() { return new KafkaWriter2(producerConfig, topic, resultSerializer); }
KafkaWriterFactory implements OutputWriterFactory<KafkaWriter2> { @Nonnull @Override public KafkaWriter2 create() { return new KafkaWriter2(producerConfig, topic, resultSerializer); } }
KafkaWriterFactory implements OutputWriterFactory<KafkaWriter2> { @Nonnull @Override public KafkaWriter2 create() { return new KafkaWriter2(producerConfig, topic, resultSerializer); } @JsonCreator  KafkaWriterFactory(
			@JsonProperty("producerConfig") @Nonnull Map<String, Object> producerConfig,
			@JsonProperty("topic") @Nonnull String topic,
			@JsonProperty("resultSerializer") ResultSerializer resultSerializer); }
KafkaWriterFactory implements OutputWriterFactory<KafkaWriter2> { @Nonnull @Override public KafkaWriter2 create() { return new KafkaWriter2(producerConfig, topic, resultSerializer); } @JsonCreator  KafkaWriterFactory(
			@JsonProperty("producerConfig") @Nonnull Map<String, Object> producerConfig,
			@JsonProperty("topic") @Nonnull String topic,
			@JsonProperty("resultSerializer") ResultSerializer resultSerializer); @Nonnull @Override KafkaWriter2 create(); }
KafkaWriterFactory implements OutputWriterFactory<KafkaWriter2> { @Nonnull @Override public KafkaWriter2 create() { return new KafkaWriter2(producerConfig, topic, resultSerializer); } @JsonCreator  KafkaWriterFactory(
			@JsonProperty("producerConfig") @Nonnull Map<String, Object> producerConfig,
			@JsonProperty("topic") @Nonnull String topic,
			@JsonProperty("resultSerializer") ResultSerializer resultSerializer); @Nonnull @Override KafkaWriter2 create();  }