public static <K, V> Read<K, V> read() {
    return new AutoValue_KafkaIO_Read.Builder<K, V>()
        .setTopics(new ArrayList<>())
        .setTopicPartitions(new ArrayList<>())
        .setConsumerFactoryFn(KafkaIOUtils.KAFKA_CONSUMER_FACTORY_FN)
        .setConsumerConfig(KafkaIOUtils.DEFAULT_CONSUMER_PROPERTIES)
        .setMaxNumRecords(Long.MAX_VALUE)
        .setCommitOffsetsInFinalizeEnabled(false)
        .setDynamicRead(false)
        .setTimestampPolicyFactory(TimestampPolicyFactory.withProcessingTime())
        .setConsumerPollingTimeout(2L)
        .setRedistributed(false)
        .setAllowDuplicates(false)
        .setRedistributeNumKeys(0)
        .build();
  }
@Test
  public void testUnboundedSourceWithWrongTopic() {
    // Expect an exception when provided Kafka topic doesn't exist.
    thrown.expect(PipelineExecutionException.class);
    thrown.expectCause(instanceOf(IllegalStateException.class));
    thrown.expectMessage(
        "Could not find any partitions info. Please check Kafka configuration and make sure that "
            + "provided topics exist.");

    int numElements = 1000;
    KafkaIO.Read<Integer, Long> reader =
        KafkaIO.<Integer, Long>read()
            .withBootstrapServers("none")
            .withTopic("wrong_topic") // read from topic that doesn't exist
            .withConsumerFactoryFn(
                new ConsumerFactoryFn(
                    ImmutableList.of("my_topic"), 10, numElements, OffsetResetStrategy.EARLIEST))
            .withMaxNumRecords(numElements)
            .withKeyDeserializer(IntegerDeserializer.class)
            .withValueDeserializer(LongDeserializer.class);

    p.apply(reader.withoutMetadata()).apply(Values.create());
    p.run();
  }