Skip to content

Commit

Permalink
Organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Aug 15, 2024
1 parent 851f003 commit c85a437
Show file tree
Hide file tree
Showing 66 changed files with 450 additions and 544 deletions.
41 changes: 17 additions & 24 deletions src/main/java/hudson/tasks/junit/CaseResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,35 @@
*/
package hudson.tasks.junit;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.plugins.junit.storage.FileJunitTestResultStorage;
import io.jenkins.plugins.junit.storage.TestResultImpl;
import io.jenkins.plugins.junit.storage.JunitTestResultStorage;
import hudson.util.TextFile;
import org.apache.commons.io.FileUtils;
import org.jvnet.localizer.Localizable;

import hudson.model.Run;
import hudson.tasks.test.TestResult;

import org.dom4j.Element;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.export.Exported;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.util.TextFile;
import io.jenkins.plugins.junit.storage.FileJunitTestResultStorage;
import io.jenkins.plugins.junit.storage.JunitTestResultStorage;
import io.jenkins.plugins.junit.storage.TestResultImpl;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.commons.io.FileUtils;
import org.dom4j.Element;
import org.jvnet.localizer.Localizable;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.export.Exported;

/**
* One test result.
Expand Down Expand Up @@ -787,9 +780,9 @@ public Collection<? extends TestResult> getSkippedTests() {

private Collection<? extends hudson.tasks.test.TestResult> singletonListOfThisOrEmptyList(boolean f) {
if (f)
return singletonList(this);
return Collections.singletonList(this);
else
return emptyList();
return Collections.emptyList();

Check warning on line 785 in src/main/java/hudson/tasks/junit/CaseResult.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 783-785 are not covered by tests
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/hudson/tasks/junit/ClassResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

import hudson.model.Run;
import hudson.tasks.test.TabulatedResult;
import hudson.tasks.test.TestResult;
import hudson.tasks.test.TestObject;
import hudson.tasks.test.TestResult;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

import java.util.*;

/**
* Cumulative test result of a test class.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import hudson.Util;
import hudson.model.Run;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.TestResult;

public class HistoryTestResultSummary {

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/hudson/tasks/junit/JUnitParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
*/
package hudson.tasks.junit;

import hudson.model.TaskListener;
import hudson.tasks.test.PipelineTestDetails;
import hudson.tasks.test.TestResultParser;
import hudson.*;
import hudson.AbortException;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.tasks.test.PipelineTestDetails;
import hudson.tasks.test.TestResultParser;
import io.jenkins.plugins.junit.storage.JunitTestResultStorage;

import io.jenkins.plugins.junit.storage.JunitTestResultStorage.RemotePublisher;
import java.io.IOException;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.MasterToSlaveFileCallable;

import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;

/**
* Parse some JUnit xml files and generate a TestResult containing all the
Expand Down Expand Up @@ -225,10 +225,10 @@ protected TestResult handle(TestResult result) throws IOException {

private static final class StorageParseResultCallable extends ParseResultCallable<TestResultSummary> {

private final RemotePublisher publisher;
private final JunitTestResultStorage.RemotePublisher publisher;

StorageParseResultCallable(String testResults, Run<?,?> build, StdioRetention stdioRetention, boolean keepProperties, boolean allowEmptyResults, boolean keepTestNames,
PipelineTestDetails pipelineTestDetails, TaskListener listener, RemotePublisher publisher, boolean skipOldReports) {
PipelineTestDetails pipelineTestDetails, TaskListener listener, JunitTestResultStorage.RemotePublisher publisher, boolean skipOldReports) {
super(testResults, build, stdioRetention, keepProperties, allowEmptyResults, keepTestNames, pipelineTestDetails, listener, skipOldReports);
this.publisher = publisher;
}
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/hudson/tasks/junit/JUnitResultArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
*/
package hudson.tasks.junit;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.AbortException;
import hudson.Extension;
import hudson.FilePath;
import hudson.Functions;
import hudson.Launcher;
import hudson.Util;
import hudson.model.AbstractBuild;
Expand All @@ -42,14 +44,18 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
import hudson.tasks.Recorder;
import hudson.tasks.junit.TestResultAction.Data;
import hudson.tasks.test.PipelineTestDetails;
import hudson.util.DescribableList;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import io.jenkins.plugins.junit.checks.JUnitChecksPublisher;
import io.jenkins.plugins.junit.storage.FileJunitTestResultStorage;
import io.jenkins.plugins.junit.storage.JunitTestResultStorage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import jenkins.tasks.SimpleBuildStep;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
Expand All @@ -58,14 +64,6 @@
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Functions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;

/**
* Generates HTML report from JUnit test result XML files.
*
Expand Down Expand Up @@ -226,7 +224,7 @@ public static TestResultAction parseAndAttach(@NonNull JUnitTask task, PipelineT
// TODO: Move into JUnitParser [BUG 3123310]

Check warning on line 224 in src/main/java/hudson/tasks/junit/JUnitResultArchiver.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: Move into JUnitParser [BUG 3123310]
if (task.getTestDataPublishers() != null) {
for (TestDataPublisher tdp : task.getTestDataPublishers()) {
Data d = tdp.contributeTestData(build, workspace, launcher, listener, result);
TestResultAction.Data d = tdp.contributeTestData(build, workspace, launcher, listener, result);

Check warning on line 227 in src/main/java/hudson/tasks/junit/JUnitResultArchiver.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 227 is not covered by tests
if (d != null) {
action.addData(d);
}
Expand Down Expand Up @@ -294,7 +292,7 @@ public static TestResultSummary parseAndSummarize(@NonNull JUnitTask task, Pipel

if (task.getTestDataPublishers() != null) {
for (TestDataPublisher tdp : task.getTestDataPublishers()) {
Data d = tdp.contributeTestData(build, workspace, launcher, listener, result);
TestResultAction.Data d = tdp.contributeTestData(build, workspace, launcher, listener, result);
if (d != null) {
action.addData(d);
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/hudson/tasks/junit/PackageResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
package hudson.tasks.junit;

import hudson.model.Run;
import io.jenkins.plugins.junit.storage.TestResultImpl;
import hudson.tasks.test.MetaTabulatedResult;
import hudson.tasks.test.TestResult;
import io.jenkins.plugins.junit.storage.TestResultImpl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

import java.util.*;

/**
* Cumulative test result for a package.
*
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/hudson/tasks/junit/SuiteResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,14 @@
*/
package hudson.tasks.junit;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.tasks.test.PipelineTestDetails;
import hudson.tasks.test.TestObject;
import hudson.util.io.ParserConfigurator;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode.*;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.xml.sax.SAXException;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.ArrayList;
Expand All @@ -55,9 +44,16 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.xml.sax.SAXException;

/**
* Result of one test suite.
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/hudson/tasks/junit/TestDataPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
*/
package hudson.tasks.junit;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.ExtensionPoint;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.*;
import jenkins.model.Jenkins;

import hudson.model.AbstractBuild;
import hudson.model.AbstractDescribableImpl;
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import hudson.model.Run;
import hudson.model.TaskListener;
import java.io.IOException;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;

/**
* Contributes {@link TestAction}s to test results.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package hudson.tasks.junit;

import hudson.tasks.test.TestDurationTrendSeriesBuilder;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import static hudson.tasks.test.TestDurationTrendSeriesBuilder.SECONDS;

public class TestDurationResultSummary implements Serializable {

private final int buildNumber;
Expand All @@ -18,7 +17,7 @@ public TestDurationResultSummary(int buildNumber, float duration) {

public Map<String, Integer> toMap() {
Map<String, Integer> series = new HashMap<>();
series.put(SECONDS, duration);
series.put(TestDurationTrendSeriesBuilder.SECONDS, duration);

Check warning on line 20 in src/main/java/hudson/tasks/junit/TestDurationResultSummary.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 20 is not covered by tests
return series;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/hudson/tasks/junit/TestObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
import hudson.model.Api;
import hudson.model.Run;
import hudson.tasks.test.AbstractTestResultAction;
import org.kohsuke.stapler.export.ExportedBean;

import java.io.Serializable;
import java.util.List;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Stub of base class for all test result objects. The real implementation of
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/hudson/tasks/junit/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
*/
package hudson.tasks.junit;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.XmlFile;
import hudson.model.Run;
import io.jenkins.plugins.junit.storage.TestResultImpl;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.PipelineTestDetails;
import hudson.tasks.test.PipelineBlockWithTests;
import hudson.tasks.test.MetaTabulatedResult;
import hudson.tasks.test.PipelineBlockWithTests;
import hudson.tasks.test.PipelineTestDetails;
import hudson.tasks.test.TabulatedResult;
import hudson.tasks.test.TestObject;

import io.jenkins.plugins.junit.storage.TestResultImpl;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -49,28 +50,20 @@
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import jenkins.util.SystemProperties;
import org.apache.tools.ant.DirectoryScanner;
import org.dom4j.DocumentException;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

import com.thoughtworks.xstream.XStream;

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Root of all the test results for one build.
*
Expand Down
Loading

0 comments on commit c85a437

Please sign in to comment.