]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10138 remove deprecated API AbstractSumChildrenDecorator
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 10 Jan 2018 19:41:48 +0000 (20:41 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 14 Jan 2018 19:37:37 +0000 (20:37 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractSumChildrenDecoratorTest.java [deleted file]

diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java
deleted file mode 100644 (file)
index bec9fca..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import java.util.List;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-/**
- * Sum measures of child resources.
- *
- * @since 1.10
- * @deprecated since 5.2 there's no more decorator on batch side
- */
-@Deprecated
-public abstract class AbstractSumChildrenDecorator implements Decorator {
-
-  /**
-   * Each metric is used individually. There are as many generated measures than metrics.
-   * <p><b>Important</b> : annotations are not inherited, so you have to copy the @DependedUpon annotation
-   * when implementing this method.
-   *
-   * @return not null list of metrics
-   */
-  @DependedUpon
-  public abstract List<Metric> generatesMetrics();
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean shouldExecuteOnProject(Project project) {
-    return true;
-  }
-
-  /**
-   * @return whether it should save zero if no child measures
-   */
-  protected abstract boolean shouldSaveZeroIfNoChildMeasures();
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void decorate(Resource resource, DecoratorContext context) {
-    if (!shouldDecorateResource(resource)) {
-      return;
-    }
-    for (Metric metric : generatesMetrics()) {
-      if (context.getMeasure(metric) == null) {
-        Double sum = MeasureUtils.sum(shouldSaveZeroIfNoChildMeasures(), context.getChildrenMeasures(metric));
-        if (sum != null) {
-          context.saveMeasure(new Measure(metric, sum));
-        }
-      }
-    }
-  }
-
-  /**
-   * @return whether the resource should be decorated or not
-   */
-  public boolean shouldDecorateResource(Resource resource) {
-    return true;
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractSumChildrenDecoratorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractSumChildrenDecoratorTest.java
deleted file mode 100644 (file)
index a2e4c89..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.batch;
-
-import org.junit.Test;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.test.IsMeasure;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class AbstractSumChildrenDecoratorTest {
-
-  @Test
-  public void sumChildren() {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getChildrenMeasures(CoreMetrics.LINES)).thenReturn(Arrays.<Measure>asList(
-      new Measure(CoreMetrics.LINES, 100.0),
-      new Measure(CoreMetrics.LINES, 50.0)));
-
-    create(false).decorate(null, context);
-
-    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.LINES, 150.0)));
-  }
-
-  @Test
-  public void doNotSaveZeroIfNoChildren() {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getChildrenMeasures(CoreMetrics.LINES)).thenReturn(Arrays.<Measure>asList());
-
-    create(false).decorate(null, context);
-
-    verify(context, never()).saveMeasure(any(Measure.class));
-  }
-
-  @Test
-  public void saveZeroIfNoChildren() {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getChildrenMeasures(CoreMetrics.LINES)).thenReturn(Arrays.<Measure>asList());
-
-    create(true).decorate(null, context);
-
-    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.LINES, 0.0)));
-  }
-
-  private AbstractSumChildrenDecorator create(final boolean zeroIfNoChildMeasures) {
-    return new AbstractSumChildrenDecorator() {
-
-      @Override
-      @DependedUpon
-      public List<Metric> generatesMetrics() {
-        return Arrays.<Metric>asList(CoreMetrics.LINES);
-      }
-
-      @Override
-      protected boolean shouldSaveZeroIfNoChildMeasures() {
-        return zeroIfNoChildMeasures;
-      }
-    };
-  }
-}