package hudson.plugins.warnings;

import com.thoughtworks.xstream.XStream;

import hudson.model.AbstractBuild;

import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.warnings.parser.Warning;

/**
 * Represents the results of the whole warning analysis. One instance of this class is persisted for
 * each build via an XML file.

 *
 * @author Marvin Schtz
 * @author Sebastian Hansbauer
 */
public class WarningsTotalResult extends BuildResult{

     /** Unique identifier of this class. */
     private static final long serialVersionUID = 4572019928324067680L;

    /**
     * Creates a new instance of {@link WarningsTotalResult}.
     * @param build
     * @param history
     * @param result
     * @param defaultEncoding
     */
    public WarningsTotalResult(final AbstractBuild<?, ?> build, final BuildHistory history, final ParserResult result,
            final String defaultEncoding) {
        super(build, history, result, defaultEncoding);
    }

    @Override
    protected void configure(final XStream xstream) {
        xstream.alias("warning", Warning.class);
    }

    @Override
    public String getHeader() {
        return "warningsTotal";
    }

    @Override
    public String getSummary() {
        return "warningsTotal: " + createDefaultSummary(getUrl(), getNumberOfAnnotations(), getNumberOfModules());
    }

    private String getUrl() {
        return "warningsTotal";
    }

    @Override
    protected String createDeltaMessage() {
        return createDefaultDeltaMessage(getUrl(), getNumberOfNewWarnings(), getNumberOfFixedWarnings());
    }

    @Override
    protected String getSerializationFileName() {
        return "warningsTotal.xml";
    }

    /** {@inheritDoc} */
    public String getDisplayName() {
        return Messages.Warnings_ProjectAction_Name();
    }

    @Override
    protected Class<? extends ResultAction<? extends BuildResult>> getResultActionType() {
        return WarningsTotalResultAction.class;
    }
}


@@ -27,16 +27,38 @@
 nings;%0A%0A
+import java.io.File;%0A%0A
 import c
@@ -2150,12 +2150,1158 @@
 s;%0A    %7D
+%0A%0A    //bernommen aus WarningsResult%0A%0A    private static final String FILENAME_SUFFIX = %22-totalWarnings.xml%22;%0A    static final String ORIGINAL_COMPILER_WARNINGS_XML = %22totalCompiler-warnings.xml%22;%0A%0A%0A    String getFileName(final FileChecker fileChecker, final int groupUrl) %7B%0A        String fileName = ORIGINAL_COMPILER_WARNINGS_XML;%0A        if (fileChecker.canRead(fileName)) %7B%0A            return fileName;%0A        %7D%0A%0A        fileName = createFileName(groupUrl);%0A        if (fileChecker.canRead(fileName)) %7B%0A            return fileName;%0A        %7D%0A%0A        //return group.replaceAll(%22%5C%5CW+%22, %22%22) + FILENAME_SUFFIX;%0A        return %22totalWarningsGrp%22;%0A    %7D%0A%0A    String createFileName(final int groupUrl) %7B%0A        return %22compiler-%22 + groupUrl + FILENAME_SUFFIX;%0A    %7D%0A%0A    /**%0A     * Provides a way to hide file system access during testing.%0A     *%0A     * @author Ulli Hafner%0A     */%0A    static class FileChecker %7B%0A        private final File root;%0A%0A        FileChecker(final File root) %7B%0A            this.root = root;%0A        %7D%0A%0A        boolean canRead(final String fileName) %7B%0A            return new File(root, fileName).canRead();%0A        %7D%0A    %7D
 %0A%7D%0A%0A

Test File Methoden hinzugefügt