FileBasedSink implements Serializable, HasDisplayData { public abstract WriteOperation<DestinationT, OutputT> createWriteOperation(); @Experimental(Kind.FILESYSTEM)  FileBasedSink(
      ValueProvider<ResourceId> tempDirectoryProvider,
      DynamicDestinations<?, DestinationT, OutputT> dynamicDestinations); @Experimental(Kind.FILESYSTEM)  FileBasedSink(
      ValueProvider<ResourceId> tempDirectoryProvider,
      DynamicDestinations<?, DestinationT, OutputT> dynamicDestinations,
      WritableByteChannelFactory writableByteChannelFactory); @Experimental(Kind.FILESYSTEM)  FileBasedSink(
      ValueProvider<ResourceId> tempDirectoryProvider,
      DynamicDestinations<?, DestinationT, OutputT> dynamicDestinations,
      Compression compression); @Experimental(Kind.FILESYSTEM) static ResourceId convertToFileResourceIfPossible(String outputPrefix); @SuppressWarnings("unchecked") DynamicDestinations<UserT, DestinationT, OutputT> getDynamicDestinations(); @Experimental(Kind.FILESYSTEM) ValueProvider<ResourceId> getTempDirectoryProvider(); void validate(PipelineOptions options); abstract WriteOperation<DestinationT, OutputT> createWriteOperation(); @Override void populateDisplayData(DisplayData.Builder builder);  }
@Test public void testFileBasedWriterWithWritableByteChannelFactory() throws Exception { final String testUid = "testId"; ResourceId root = getBaseOutputDirectory(); WriteOperation<Void, String> writeOp = SimpleSink.makeSimpleSink( root, "file", "-SS-of-NN", "txt", new DrunkWritableByteChannelFactory()) .createWriteOperation(); final Writer<Void, String> writer = writeOp.createWriter(); final ResourceId expectedFile = writeOp.tempDirectory.get().resolve(testUid, StandardResolveOptions.RESOLVE_FILE); final List<String> expected = new ArrayList<>(); expected.add("header"); expected.add("header"); expected.add("a"); expected.add("a"); expected.add("b"); expected.add("b"); expected.add("footer"); expected.add("footer"); writer.open(testUid); writer.write("a"); writer.write("b"); writer.close(); assertEquals(expectedFile, writer.getOutputFile()); assertFileContains(expected, expectedFile); }