Skip to content

Commit

Permalink
Rename visitor result to FileVisitorResult.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Nov 20, 2022
1 parent 7fa3366 commit 7ab4980
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/main/java/io/jenkins/plugins/util/AgentFileVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import hudson.remoting.VirtualChannel;
import jenkins.MasterToSlaveFileCallable;

import io.jenkins.plugins.util.AgentFileVisitor.ScannerResult;
import io.jenkins.plugins.util.AgentFileVisitor.FileVisitorResult;

/**
* Finds all files that match a specified Ant file pattern and visits these files with the processing method
Expand All @@ -36,7 +36,7 @@
* @author Ullrich Hafner
*/
public abstract class AgentFileVisitor<T extends Serializable>
extends MasterToSlaveFileCallable<ScannerResult<T>> {
extends MasterToSlaveFileCallable<FileVisitorResult<T>> {
private static final long serialVersionUID = 2216842481400265078L;

private final String filePattern;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected AgentFileVisitor(final String filePattern, final String encoding, fina
}

@Override
public final ScannerResult<T> invoke(final File workspace, final VirtualChannel channel) {
public final FileVisitorResult<T> invoke(final File workspace, final VirtualChannel channel) {
FilteredLog log = new FilteredLog("Errors during parsing");
log.logInfo("Searching for all files in '%s' that match the pattern '%s'",
fileSystemFacade.getAbsolutePath(workspace), filePattern);
Expand All @@ -80,12 +80,12 @@ public final ScannerResult<T> invoke(final File workspace, final VirtualChannel
if (fileNames.length == 0) {
log.logError("No files found for pattern '%s'. Configuration error?", filePattern);

return new ScannerResult<>(log);
return new FileVisitorResult<>(log);
}
else {
log.logInfo("-> found %s", plural(fileNames.length, "file"));

return new ScannerResult<>(log, scanFiles(workspace, fileNames, log));
return new FileVisitorResult<>(log, scanFiles(workspace, fileNames, log));
}
}

Expand Down Expand Up @@ -235,17 +235,17 @@ public String[] find(final File workspace) {
* @param <T>
* the type of the results
*/
public static class ScannerResult<T extends Serializable> implements Serializable {
public static class FileVisitorResult<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 2122230867938547733L;

private final FilteredLog log;
private final List<T> results;

ScannerResult(final FilteredLog log) {
FileVisitorResult(final FilteredLog log) {
this(log, Collections.emptyList());
}

ScannerResult(final FilteredLog log, final List<T> results) {
FileVisitorResult(final FilteredLog log, final List<T> results) {
this.log = log;
this.results = new ArrayList<>(results);
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/io/jenkins/plugins/util/AgentFileVisitorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import io.jenkins.plugins.util.AgentFileVisitor.FileSystemFacade;
import io.jenkins.plugins.util.AgentFileVisitor.ScannerResult;
import io.jenkins.plugins.util.AgentFileVisitor.FileVisitorResult;
import io.jenkins.plugins.util.AgentFileVisitorTest.StringScanner;

import static org.assertj.core.api.Assertions.*;
Expand All @@ -41,7 +41,7 @@ void shouldReportErrorOnEmptyResults(final boolean followLinks, final String mes
StringScanner scanner = new StringScanner(PATTERN, "UTF-8", followLinks,
createFileSystemFacade(followLinks));

ScannerResult<String> actualResult = scanner.invoke(workspace, null);
FileVisitorResult<String> actualResult = scanner.invoke(workspace, null);

assertThat(actualResult.getResults()).isEmpty();
assertThat(actualResult.getLog().getInfoMessages()).containsExactly(
Expand All @@ -60,7 +60,7 @@ void shouldReturnSingleResult(final boolean followLinks, final String message) {
StringScanner scanner = new StringScanner(PATTERN, "UTF-8", followLinks,
createFileSystemFacade(followLinks, "/one.txt"));

ScannerResult<String> actualResult = scanner.invoke(workspace, null);
FileVisitorResult<String> actualResult = scanner.invoke(workspace, null);
assertThat(actualResult.getResults()).containsExactly(CONTENT + 1);
assertThat(actualResult.getLog().getInfoMessages()).containsExactly(
"Searching for all files in '/absolute/path' that match the pattern '**/*.txt'",
Expand All @@ -78,7 +78,7 @@ void shouldReturnMultipleResults(final boolean followLinks, final String message
StringScanner scanner = new StringScanner(PATTERN, "UTF-8", followLinks,
createFileSystemFacade(followLinks, "/one.txt", "/two.txt"));

ScannerResult<String> actualResult = scanner.invoke(workspace, null);
FileVisitorResult<String> actualResult = scanner.invoke(workspace, null);
assertThat(actualResult.getResults()).containsExactly(CONTENT + 1, CONTENT + 2);
assertThat(actualResult.getLog().getInfoMessages()).containsExactly(
"Searching for all files in '/absolute/path' that match the pattern '**/*.txt'",
Expand Down Expand Up @@ -107,7 +107,7 @@ void shouldReturnMultipleResults() {
StringScanner scanner = new StringScanner(PATTERN, "UTF-8", true,
fileSystemFacade);

ScannerResult<String> actualResult = scanner.invoke(workspace, null);
FileVisitorResult<String> actualResult = scanner.invoke(workspace, null);
assertThat(actualResult.getResults()).containsExactly(CONTENT + 1, CONTENT + 2);
assertThat(actualResult.getLog().getInfoMessages()).contains(
"Searching for all files in '/absolute/path' that match the pattern '**/*.txt'",
Expand Down

0 comments on commit 7ab4980

Please sign in to comment.