Package hudson.plugins.analysis.core

Examples of hudson.plugins.analysis.core.BuildResult


     * @return a series of values per build
     */
    @SuppressWarnings("rawtypes")
    private Map<AbstractBuild, List<Integer>> createSeriesPerBuild(
            final GraphConfiguration configuration, final BuildResult lastBuildResult) {
        BuildResult current = lastBuildResult;

        int buildCount = 0;
        Map<AbstractBuild, List<Integer>> valuesPerBuild = Maps.newHashMap();
        while (true) {
            if (isBuildTooOld(configuration, current)) {
                break;
            }

            valuesPerBuild.put(current.getOwner(), computeSeries(current));

            if (current.hasPreviousResult()) {
                current = current.getPreviousResult();
                if (current == null) {
                    break; // see: HUDSON-6613
                }
            }
            else {
View Full Code Here


     *            list of pairs with the points for the new warnings
     */
    private void extractPoints(final GraphConfiguration configuration, final ResultAction<? extends BuildResult> action,
            final List<Pair<Integer, Integer>> fixedWarnings, final List<Pair<Integer, Integer>> newWarnings) {
        int buildCount = 0;
        BuildResult current = action.getResult();
        while (true) {
            if (isBuildTooOld(configuration, current)) {
                break;
            }

            int build = current.getOwner().getNumber();
            fixedWarnings.add(new Pair<Integer, Integer>(build, current.getNumberOfFixedWarnings()));
            newWarnings.add(new Pair<Integer, Integer>(build, current.getNumberOfNewWarnings()));

            if (current.hasPreviousResult()) {
                current = current.getPreviousResult();
            }
            else {
                break;
            }

View Full Code Here

    public String getDetails(final Job<?, ?> project) {
        HtmlPrinter printer = new HtmlPrinter();
        printer.append("<table>");
        T action = getProjectAction(project);
        if (action != null && action.hasValidResults()) {
            BuildResult result = getResult(action);
            if (result.isSuccessfulTouched()) {
                printer.append(printer.line(Messages.ResultAction_Status() + result.getResultIcon()));
            }
            if (result.getNumberOfNewWarnings() > 0) {
                print(printer, Messages.NewWarningsDetail_Name(), result.getNumberOfNewWarnings());
            }

            print(printer, Priority.HIGH, result.getNumberOfHighPriorityWarnings());
            print(printer, Priority.NORMAL, result.getNumberOfNormalPriorityWarnings());
            print(printer, Priority.LOW, result.getNumberOfLowPriorityWarnings());
        }
        else {
            return Messages.Column_NoResults();
        }
        printer.append("</table>");
View Full Code Here

    @SuppressWarnings({"rawtypes", "unchecked"})
    public Main(final BuildResultGraph graph) {
        super(graph.getLabel());

        GraphConfiguration configuration = new GraphConfiguration(new ArrayList<BuildResultGraph>());
        BuildResult result1 = createResult(1, 5, 10);
        when(result1.hasPreviousResult()).thenReturn(false);
        BuildResult result2 = createResult(2, 15, 10);
        when(result2.hasPreviousResult()).thenReturn(true);
        when(result2.getPreviousResult()).thenReturn(result1);
        BuildResult result3 = createResult(3, 25, 20);
        when(result3.hasPreviousResult()).thenReturn(true);
        when(result3.getPreviousResult()).thenReturn(result2);
        BuildResult result4 = createResult(4, 5, 15);
        when(result4.hasPreviousResult()).thenReturn(true);
        when(result4.getPreviousResult()).thenReturn(result3);

        ResultAction action = mock(ResultAction.class);
        when(action.getResult()).thenReturn(result4);
        ToolTipProvider toolTipProvider = mock(ToolTipProvider.class);
        when(action.getToolTipProvider()).thenReturn(toolTipProvider);
View Full Code Here

     *            number of new warnings
     * @return a {@link ResultAction} mock.
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    private BuildResult createResult(final int buildNumber, final int fixedWarnings, final int newWarnings) {
        BuildResult result = mock(BuildResult.class);

        when(result.getNumberOfWarnings()).thenReturn(newWarnings + 1000);
        when(result.getNumberOfAnnotations(Priority.HIGH)).thenReturn(newWarnings);
        when(result.getNumberOfAnnotations(Priority.NORMAL)).thenReturn(fixedWarnings);
        when(result.getNumberOfAnnotations(Priority.LOW)).thenReturn(Math.abs(newWarnings - fixedWarnings));
        when(result.getNumberOfFixedWarnings()).thenReturn(fixedWarnings);
        when(result.getNumberOfNewWarnings()).thenReturn(newWarnings);

        AbstractBuild build = mock(AbstractBuild.class);

        when(build.getTimestamp()).thenReturn(new GregorianCalendar(2010, 02, buildNumber));
        when(build.getNumber()).thenReturn(buildNumber);
        when(build.getDisplayName()).thenReturn("#" + buildNumber);

        when(result.getOwner()).thenReturn(build);

        return result;
    }
View Full Code Here

    @Test
    public void testHealthySeriesCalculator() {
        AbstractHealthDescriptor healthDescriptor = createHealthBuilder(true, 0, true, 10, 30);

        CategoryBuildResultGraph builder = new HealthGraph(healthDescriptor);
        BuildResult result = mock(BuildResult.class);

        List<Integer> series;
        when(result.getNumberOfAnnotations()).thenReturn(5);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 5, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));

        when(result.getNumberOfAnnotations()).thenReturn(10);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));

        when(result.getNumberOfAnnotations()).thenReturn(11);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 1, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));

        when(result.getNumberOfAnnotations()).thenReturn(30);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 20, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));

        when(result.getNumberOfAnnotations()).thenReturn(31);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 20, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 1, (int)series.get(2));
View Full Code Here

    @Test
    public void testThresholdSeriesCalculator() {
        AbstractHealthDescriptor healthDescriptor = createHealthBuilder(true, 10, false, 20, 50);

        CategoryBuildResultGraph builder = new HealthGraph(healthDescriptor);
        BuildResult result = mock(BuildResult.class);

        List<Integer> series;
        when(result.getNumberOfAnnotations()).thenReturn(5);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, THRESHOLD_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 5, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(1));

        when(result.getNumberOfAnnotations()).thenReturn(10);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, THRESHOLD_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(1));

        when(result.getNumberOfAnnotations()).thenReturn(11);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, THRESHOLD_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 10, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 1, (int)series.get(1));
    }
View Full Code Here

    @Test
    public void testIssue796() {
        AbstractHealthDescriptor healthDescriptor = createHealthBuilder(false, 0, true, 1, 10);

        CategoryBuildResultGraph builder = new HealthGraph(healthDescriptor);
        BuildResult result = mock(BuildResult.class);

        List<Integer> series;
        when(result.getNumberOfAnnotations()).thenReturn(1);
        series = builder.computeSeries(result);

        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 1, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));

        when(result.getNumberOfAnnotations()).thenReturn(7);
        series = builder.computeSeries(result);
        assertEquals(WRONG_NUMBER, HEALTHY_SERIES_SIZE, series.size());
        assertEquals(WRONG_SERIES_VALUE, 1, (int)series.get(0));
        assertEquals(WRONG_SERIES_VALUE, 6, (int)series.get(1));
        assertEquals(WRONG_SERIES_VALUE, 0, (int)series.get(2));
View Full Code Here

    public String getWarnings(final Job<?, ?> job) {
        AbstractProjectAction<?> action = selectAction(job);
        if (action != null) {
            ResultAction<?> lastAction = action.getLastAction();
            if (lastAction != null) {
                BuildResult result = lastAction.getResult();
                int numberOfAnnotations = result.getNumberOfAnnotations();
                String value;
                if (numberOfAnnotations > 0) {
                    value = String.format("<a href=\"%s%s\">%d</a>", job.getShortUrl(), action.getUrlName(), numberOfAnnotations);
                }
                else {
                    value = String.valueOf(numberOfAnnotations);
                }
                if (result.isSuccessfulTouched() && !result.isSuccessful()) {
                    return value + result.getResultIcon();
                }
                return value;
            }
        }
        return NO_RESULTS_FOUND;
View Full Code Here

    public String getWarnings(final Job<?, ?> job, final String priority) {
        AbstractProjectAction<?> action = selectAction(job);
        if (action != null) {
            ResultAction<?> lastAction = action.getLastAction();
            if (lastAction != null) {
                BuildResult result = lastAction.getResult();

                return String.valueOf(result.getNumberOfAnnotations(priority));
            }
        }
        return NO_RESULTS_FOUND;
    }
View Full Code Here

TOP

Related Classes of hudson.plugins.analysis.core.BuildResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.