public static Write ingestMessages(String hl7v2Store) {
    return write(hl7v2Store).setWriteMethod(Write.WriteMethod.INGEST).build();
  }
@Test
  public void testHL7v2IOFailedWrites() {
    Message msg = new Message().setData("");
    List<HL7v2Message> emptyMessages = Collections.singletonList(HL7v2Message.fromModel(msg));

    PCollection<HL7v2Message> messages =
        pipeline.apply(Create.of(emptyMessages).withCoder(new HL7v2MessageCoder()));

    HL7v2IO.Write.Result writeResult =
        messages.apply(
            HL7v2IO.ingestMessages(
                "projects/foo/locations/us-central1/datasets/bar/hl7V2Stores/baz"));

    PCollection<HealthcareIOError<HL7v2Message>> failedInserts =
        writeResult.getFailedInsertsWithErr();

    PCollection<Long> failedMsgs = failedInserts.apply(Count.globally());

    PAssert.thatSingleton(failedMsgs).isEqualTo(1L);

    pipeline.run();
  }