@SuppressWarnings("unchecked")
  public DynamicDestinations<UserT, DestinationT, OutputT> getDynamicDestinations() {
    return (DynamicDestinations<UserT, DestinationT, OutputT>) dynamicDestinations;
  }
@Test
  public void testCopyToOutputFiles() throws Exception {
    SimpleSink.SimpleWriteOperation<Void> writeOp = buildWriteOperation();
    List<String> inputFilenames = Arrays.asList("input-1", "input-2", "input-3");
    List<String> inputContents = Arrays.asList("1", "2", "3");
    List<String> expectedOutputFilenames =
        Arrays.asList("file-00-of-03.test", "file-01-of-03.test", "file-02-of-03.test");

    List<KV<FileResult<Void>, ResourceId>> resultsToFinalFilenames = Lists.newArrayList();
    List<ResourceId> expectedOutputPaths = Lists.newArrayList();

    for (int i = 0; i < inputFilenames.size(); i++) {
      // Generate output paths.
      expectedOutputPaths.add(
          getBaseOutputDirectory()
              .resolve(expectedOutputFilenames.get(i), StandardResolveOptions.RESOLVE_FILE));

      // Generate and write to input paths.
      File inputTmpFile = tmpFolder.newFile(inputFilenames.get(i));
      List<String> lines = Collections.singletonList(inputContents.get(i));
      writeFile(lines, inputTmpFile);
      ResourceId finalFilename =
          writeOp
              .getSink()
              .getDynamicDestinations()
              .getFilenamePolicy(null)
              .unwindowedFilename(i, inputFilenames.size(), CompressionType.UNCOMPRESSED);
      resultsToFinalFilenames.add(
          KV.of(
              new FileResult<>(
                  LocalResources.fromFile(inputTmpFile, false),
                  UNKNOWN_SHARDNUM,
                  GlobalWindow.INSTANCE,
                  PaneInfo.ON_TIME_AND_ONLY_FIRING,
                  null),
              finalFilename));
    }

    // Copy input files to output files.
    writeOp.moveToOutputFiles(resultsToFinalFilenames);

    // Assert that the contents were copied.
    for (int i = 0; i < expectedOutputPaths.size(); i++) {
      assertFileContains(
          Collections.singletonList(inputContents.get(i)), expectedOutputPaths.get(i));
    }
  }