@Override public Collection<? extends CopyEntity> getCopyableFiles(FileSystem targetFs, CopyConfiguration configuration) throws IOException { List<CopyableFile> copyableFiles = Lists.newArrayList(); for (FileStatus fileStatus : this.files) { if (this.shouldAddToCopyableFiles(fileStatus)) { log.debug("Adding copyable file " + fileStatus.getPath() + "for " + identifier + " in " + this.rootPath); Path targetPath = this.getTargetPath(configuration.getPublishDir(), fileStatus.getPath(), this.identifier); copyableFiles.add(CopyableFile.fromOriginAndDestination(this.fs, fileStatus, targetPath, configuration) .destinationOwnerAndPermission(this.getDestinationOwnerAndPermission()).fileSet(this.fileSet(fileStatus)) .build()); } } return DatasetUtils.instantiateCopyableFileFilter(this.props, this.state, this) .filter(this.fs, targetFs, copyableFiles); }
copyableFiles.add(copyableFile); copyEntities.addAll(this.copyableFileFilter.filter(this.fs, targetFs, copyableFiles));
@Test public void testFilter() throws Exception { CopyableFileFilter readyFilter = new ReadyCopyableFileFilter(); List<CopyableFile> copyableFiles = Lists.newArrayList(); copyableFiles.add(CopyableFileUtils.getTestCopyableFile()); copyableFiles.add(CopyableFileUtils.getTestCopyableFile()); copyableFiles.add(CopyableFileUtils.getTestCopyableFile()); FileSystem sourceFs = Mockito.mock(FileSystem.class); Mockito.when(sourceFs.exists(PathUtils.addExtension(copyableFiles.get(0).getOrigin().getPath(), ".ready"))) .thenReturn(false); Mockito.when(sourceFs.exists(PathUtils.addExtension(copyableFiles.get(1).getOrigin().getPath(), ".ready"))) .thenReturn(true); Mockito.when(sourceFs.exists(PathUtils.addExtension(copyableFiles.get(2).getOrigin().getPath(), ".ready"))) .thenReturn(false); Collection<CopyableFile> filtered = readyFilter.filter(sourceFs, null, copyableFiles); Assert.assertEquals(filtered.size(), 1); }
@Override public Collection<? extends CopyEntity> getCopyableFiles(FileSystem targetFs, CopyConfiguration configuration) throws IOException { List<CopyableFile> copyableFiles = Lists.newArrayList(); for (FileStatus fileStatus : this.files) { if (this.shouldAddToCopyableFiles(fileStatus)) { log.debug("Adding copyable file " + fileStatus.getPath() + "for " + identifier + " in " + this.rootPath); Path targetPath = this.getTargetPath(configuration.getPublishDir(), fileStatus.getPath(), this.identifier); copyableFiles.add(CopyableFile.fromOriginAndDestination(this.fs, fileStatus, targetPath, configuration) .destinationOwnerAndPermission(this.getDestinationOwnerAndPermission()).fileSet(this.fileSet(fileStatus)) .build()); } } return DatasetUtils.instantiateCopyableFileFilter(this.props, this.state, this) .filter(this.fs, targetFs, copyableFiles); }
copyableFiles.add(copyableFile); copyEntities.addAll(this.copyableFileFilter.filter(this.fs, targetFs, copyableFiles));