public static Write write() {
    return Write.create();
  }
@Test
  public void testWritingFailsAtWriteRecord() throws IOException {
    FailureBigtableService failureService =
        new FailureBigtableService(FailureOptions.builder().setFailAtWriteRecord(true).build());

    FakeServiceFactory failureFactory = new FakeServiceFactory(failureService);

    BigtableIO.Write failureWrite =
        BigtableIO.write().withInstanceId("instance").withProjectId("project");

    final String table = "table";
    final String key = "key";
    final String value = "value";

    failureService.createTable(table);

    p.apply("single row", Create.of(makeWrite(key, value)).withCoder(bigtableCoder))
        .apply("write", failureWrite.withTableId(table).withServiceFactory(failureFactory));

    // Exception will be thrown by writer.writeRecord() when BigtableWriterFn is applied.
    thrown.expect(IOException.class);
    thrown.expectMessage("Fake IOException in writeRecord()");

    try {
      p.run();
    } catch (PipelineExecutionException e) {
      // throwing inner exception helps assert that first exception is thrown from writeRecord()
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }
    }
  }