]> source.dussan.org Git - sonarqube.git/commitdiff
Replace some Guava usages by Java 8 functions
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 23 Jan 2017 21:11:32 +0000 (22:11 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 24 Jan 2017 08:39:30 +0000 (09:39 +0100)
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java
server/sonar-server/src/main/java/org/sonar/server/measure/ws/MetricDtoWithBestValue.java
sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java [deleted file]
sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java
sonar-db/src/test/java/org/sonar/db/component/ComponentLinkDaoTest.java
sonar-db/src/test/java/org/sonar/db/metric/MetricDtoFunctionsTest.java

index f3ff13a3669ccfa2ef0ef520e69641aa3e055458..dfd151a35cd777f10a342ce2beb6cfa00aa63479 100644 (file)
@@ -38,12 +38,12 @@ import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.util.stream.Collectors;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.MeasureDto;
-import org.sonar.db.measure.MeasureDtoFunctions;
 import org.sonar.db.measure.MeasureQuery;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.metric.MetricDtoFunctions;
@@ -56,7 +56,6 @@ import org.sonarqube.ws.WsMeasures.ComponentWsResponse;
 import org.sonarqube.ws.client.measure.ComponentWsRequest;
 
 import static com.google.common.base.MoreObjects.firstNonNull;
-import static com.google.common.collect.FluentIterable.from;
 import static java.lang.String.format;
 import static java.util.Collections.emptyList;
 import static java.util.Collections.emptyMap;
@@ -169,7 +168,7 @@ public class ComponentAction implements MeasuresWsAction {
   private static ComponentWsResponse buildResponse(ComponentWsRequest request, ComponentDto component, Optional<ComponentDto> refComponent, List<MeasureDto> measures,
     List<MetricDto> metrics, List<WsMeasures.Period> periods) {
     ComponentWsResponse.Builder response = ComponentWsResponse.newBuilder();
-    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDtoFunctions.toId());
+    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDto::getId);
     Map<MetricDto, MeasureDto> measuresByMetric = new HashMap<>();
     for (MeasureDto measure : measures) {
       MetricDto metric = metricsById.get(measure.getMetricId());
@@ -199,7 +198,7 @@ public class ComponentAction implements MeasuresWsAction {
   private List<MetricDto> searchMetrics(DbSession dbSession, ComponentWsRequest request) {
     List<MetricDto> metrics = dbClient.metricDao().selectByKeys(dbSession, request.getMetricKeys());
     if (metrics.size() < request.getMetricKeys().size()) {
-      List<String> foundMetricKeys = Lists.transform(metrics, MetricDtoFunctions.toKey());
+      List<String> foundMetricKeys = Lists.transform(metrics, MetricDto::getKey);
       Set<String> missingMetricKeys = Sets.difference(
         new LinkedHashSet<>(request.getMetricKeys()),
         new LinkedHashSet<>(foundMetricKeys));
@@ -240,11 +239,11 @@ public class ComponentAction implements MeasuresWsAction {
       return;
     }
 
-    List<MetricDtoWithBestValue> metricWithBestValueList = from(metrics)
+    List<MetricDtoWithBestValue> metricWithBestValueList = metrics.stream()
       .filter(MetricDtoFunctions.isOptimizedForBestValue())
-      .transform(new MetricDtoToMetricDtoWithBestValueFunction(periods))
-      .toList();
-    Map<Integer, MeasureDto> measuresByMetricId = Maps.uniqueIndex(measures, MeasureDtoFunctions.toMetricId());
+      .map(new MetricDtoToMetricDtoWithBestValueFunction(periods))
+      .collect(Collectors.toList(metrics.size()));
+    Map<Integer, MeasureDto> measuresByMetricId = Maps.uniqueIndex(measures, MeasureDto::getMetricId);
 
     for (MetricDtoWithBestValue metricWithBestValue : metricWithBestValueList) {
       if (measuresByMetricId.get(metricWithBestValue.getMetric().getId()) == null) {
index 201b1f2a6a97acad60517515cdb279343fa2233b..911e31500bf5e3987291147a4ee44f91d5b3bf6e 100644 (file)
  */
 package org.sonar.server.measure.ws;
 
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.HashBasedTable;
 import com.google.common.collect.Lists;
@@ -37,14 +33,19 @@ import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
-import java.util.stream.Collectors;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.web.UserRole;
+import org.sonar.core.util.stream.Collectors;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
@@ -62,7 +63,6 @@ import org.sonarqube.ws.client.measure.ComponentTreeWsRequest;
 
 import static com.google.common.base.MoreObjects.firstNonNull;
 import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.FluentIterable.from;
 import static com.google.common.collect.Sets.newHashSet;
 import static java.lang.String.format;
 import static java.util.Collections.emptyMap;
@@ -96,7 +96,7 @@ public class ComponentTreeDataLoader {
     try {
       ComponentDto baseComponent = componentFinder.getByUuidOrKey(dbSession, wsRequest.getBaseComponentId(), wsRequest.getBaseComponentKey(), BASE_COMPONENT_ID_AND_KEY);
       checkPermissions(baseComponent);
-      java.util.Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, baseComponent.projectUuid());
+      Optional<SnapshotDto> baseSnapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, baseComponent.projectUuid());
       if (!baseSnapshot.isPresent()) {
         return ComponentTreeData.builder()
           .setBaseComponent(baseComponent)
@@ -141,10 +141,10 @@ public class ComponentTreeDataLoader {
   }
 
   private Map<String, ComponentDto> searchReferenceComponentsById(DbSession dbSession, List<ComponentDto> components) {
-    List<String> referenceComponentUUids = from(components)
-      .transform(ComponentDto::getCopyResourceUuid)
-      .filter(Predicates.<String>notNull())
-      .toList();
+    List<String> referenceComponentUUids = components.stream()
+      .map(ComponentDto::getCopyResourceUuid)
+      .filter(Objects::nonNull)
+      .collect(Collectors.toList(components.size()));
     if (referenceComponentUUids.isEmpty()) {
       return emptyMap();
     }
@@ -165,7 +165,7 @@ public class ComponentTreeDataLoader {
     List<String> metricKeys = requireNonNull(request.getMetricKeys());
     List<MetricDto> metrics = dbClient.metricDao().selectByKeys(dbSession, metricKeys);
     if (metrics.size() < metricKeys.size()) {
-      List<String> foundMetricKeys = Lists.transform(metrics, MetricDtoFunctions.toKey());
+      List<String> foundMetricKeys = Lists.transform(metrics, MetricDto::getKey);
       Set<String> missingMetricKeys = Sets.difference(
         new LinkedHashSet<>(metricKeys),
         new LinkedHashSet<>(foundMetricKeys));
@@ -179,7 +179,7 @@ public class ComponentTreeDataLoader {
   private Table<String, MetricDto, MeasureDto> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent, ComponentTreeQuery componentTreeQuery,
     List<ComponentDto> components, List<MetricDto> metrics, List<WsMeasures.Period> periods, @Nullable Long developerId) {
 
-    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDtoFunctions.toId());
+    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDto::getId);
     MeasureTreeQuery measureQuery = MeasureTreeQuery.builder()
       .setStrategy(MeasureTreeQuery.Strategy.valueOf(componentTreeQuery.getStrategy().name()))
       .setNameOrKeyQuery(componentTreeQuery.getNameOrKeyQuery())
@@ -211,22 +211,22 @@ public class ComponentTreeDataLoader {
    */
   private static void addBestValuesToMeasures(Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric, List<ComponentDto> components,
     List<MetricDto> metrics, List<WsMeasures.Period> periods) {
-    List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = from(metrics)
+    List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = metrics.stream()
       .filter(MetricDtoFunctions.isOptimizedForBestValue())
-      .transform(new MetricDtoToMetricDtoWithBestValue(periods))
-      .toList();
+      .map(new MetricDtoToMetricDtoWithBestValue(periods))
+      .collect(Collectors.toList(metrics.size()));
     if (metricDtosWithBestValueMeasure.isEmpty()) {
       return;
     }
 
-    List<ComponentDto> componentsEligibleForBestValue = from(components).filter(IsFileComponent.INSTANCE).toList();
-    for (ComponentDto component : componentsEligibleForBestValue) {
+    Stream<ComponentDto> componentsEligibleForBestValue = components.stream().filter(IsFileComponent.INSTANCE);
+    componentsEligibleForBestValue.forEach(component -> {
       for (MetricDtoWithBestValue metricWithBestValue : metricDtosWithBestValueMeasure) {
         if (measuresByComponentUuidAndMetric.get(component.uuid(), metricWithBestValue.getMetric()) == null) {
           measuresByComponentUuidAndMetric.put(component.uuid(), metricWithBestValue.getMetric(), metricWithBestValue.getBestValue());
         }
       }
-    }
+    });
   }
 
   private static List<ComponentDto> filterComponents(List<ComponentDto> components,
@@ -235,14 +235,14 @@ public class ComponentTreeDataLoader {
       return components;
     }
 
-    final String metricKeyToSort = wsRequest.getMetricSort();
-    Optional<MetricDto> metricToSort = from(metrics).firstMatch(new MatchMetricKey(metricKeyToSort));
+    String metricKeyToSort = wsRequest.getMetricSort();
+    Optional<MetricDto> metricToSort = metrics.stream().filter(m -> metricKeyToSort.equals(m.getKey())).findFirst();
     checkState(metricToSort.isPresent(), "Metric '%s' not found", metricKeyToSort, wsRequest.getMetricKeys());
 
     return components
       .stream()
       .filter(new HasMeasure(measuresByComponentUuidAndMetric, metricToSort.get(), wsRequest))
-      .collect(Collectors.toList());
+      .collect(Collectors.toList(components.size()));
   }
 
   private static boolean componentWithMeasuresOnly(ComponentTreeWsRequest wsRequest) {
@@ -255,10 +255,10 @@ public class ComponentTreeDataLoader {
   }
 
   private static List<ComponentDto> paginateComponents(List<ComponentDto> components, ComponentTreeWsRequest wsRequest) {
-    return from(components)
+    return components.stream()
       .skip(offset(wsRequest.getPage(), wsRequest.getPageSize()))
       .limit(wsRequest.getPageSize())
-      .toList();
+      .collect(Collectors.toList(wsRequest.getPageSize()));
   }
 
   @CheckForNull
@@ -310,7 +310,7 @@ public class ComponentTreeDataLoader {
     INSTANCE;
 
     @Override
-    public boolean apply(@Nonnull ComponentDto input) {
+    public boolean test(@Nonnull ComponentDto input) {
       return QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE.contains(input.qualifier());
     }
   }
@@ -319,7 +319,7 @@ public class ComponentTreeDataLoader {
     private final List<Integer> periodIndexes;
 
     MetricDtoToMetricDtoWithBestValue(List<WsMeasures.Period> periods) {
-      this.periodIndexes = Lists.transform(periods, WsPeriodToIndex.INSTANCE);
+      this.periodIndexes = Lists.transform(periods, WsMeasures.Period::getIndex);
     }
 
     @Override
@@ -327,26 +327,4 @@ public class ComponentTreeDataLoader {
       return new MetricDtoWithBestValue(input, periodIndexes);
     }
   }
-
-  private enum WsPeriodToIndex implements Function<WsMeasures.Period, Integer> {
-    INSTANCE;
-
-    @Override
-    public Integer apply(@Nonnull WsMeasures.Period input) {
-      return input.getIndex();
-    }
-  }
-
-  private static class MatchMetricKey implements Predicate<MetricDto> {
-    private final String metricKeyToSort;
-
-    private MatchMetricKey(String metricKeyToSort) {
-      this.metricKeyToSort = metricKeyToSort;
-    }
-
-    @Override
-    public boolean apply(@Nonnull MetricDto input) {
-      return input.getKey().equals(metricKeyToSort);
-    }
-  }
 }
index be1d15aaf9788eb1b0299ef30b9194c0be84fdba..6167295a3e6bea3ea7ec9115aa07d9921eeeb343 100644 (file)
@@ -35,7 +35,6 @@ import org.sonar.api.measures.Metric.ValueType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.metric.MetricDto;
-import org.sonar.db.metric.MetricDtoFunctions;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonarqube.ws.client.measure.ComponentTreeWsRequest;
 
@@ -120,7 +119,7 @@ public class ComponentTreeSort {
     if (wsRequest.getMetricSort() == null) {
       return componentNameOrdering(wsRequest.getAsc());
     }
-    Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDtoFunctions.toKey());
+    Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDto::getKey);
     MetricDto metric = metricsByKey.get(wsRequest.getMetricSort());
 
     boolean isAscending = wsRequest.getAsc();
@@ -141,7 +140,7 @@ public class ComponentTreeSort {
     if (wsRequest.getMetricSort() == null || wsRequest.getMetricPeriodSort() == null) {
       return componentNameOrdering(wsRequest.getAsc());
     }
-    Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDtoFunctions.toKey());
+    Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDto::getKey);
     MetricDto metric = metricsByKey.get(wsRequest.getMetricSort());
 
     ValueType metricValueType = ValueType.valueOf(metric.getValueType());
index 1f73dcb010996efde5e504d59e51b43e0649542b..bef88a5bd8cc5795de77d0e11b1de0a2dddf5544 100644 (file)
  */
 package org.sonar.server.measure.ws;
 
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSortedSet;
-import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
-import java.util.Set;
-import java.util.function.Predicate;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.db.component.ComponentDto;
 import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonarqube.ws.WsMeasures;
 
 class MetricDtoWithBestValue {
   private static final String LOWER_CASE_NEW_METRIC_PREFIX = "new_";
-  private static final Set<String> QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE);
 
   private final MetricDto metric;
   private final MeasureDto bestValue;
@@ -64,27 +57,6 @@ class MetricDtoWithBestValue {
     return bestValue;
   }
 
-  static java.util.function.Function<MetricDto, MeasureDto> buildBestMeasure(ComponentDto component, Collection<WsMeasures.Period> periods) {
-    return metric -> {
-      MeasureDto measure = new MeasureDto()
-        .setMetricId(metric.getId())
-        .setComponentUuid(component.uuid());
-      boolean isNewTypeMetric = metric.getKey().toLowerCase(Locale.ENGLISH).startsWith(LOWER_CASE_NEW_METRIC_PREFIX);
-      if (isNewTypeMetric) {
-        periods.stream()
-          .map(WsMeasures.Period::getIndex)
-          .forEach(index -> measure.setVariation(index, 0.0d));
-      } else {
-        measure.setValue(metric.getBestValue());
-      }
-      return measure;
-    };
-  }
-
-  static Predicate<ComponentDto> isEligibleForBestValue() {
-    return component -> QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE.contains(component.qualifier());
-  }
-
   static class MetricDtoToMetricDtoWithBestValueFunction implements Function<MetricDto, MetricDtoWithBestValue> {
     private final List<Integer> periodIndexes;
 
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java
deleted file mode 100644 (file)
index 6a189b5..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.measure;
-
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
-
-public class MeasureDtoFunctions {
-  private MeasureDtoFunctions() {
-    // prevent instantiation
-  }
-
-  public static Function<MeasureDto, Integer> toMetricId() {
-    return ToMetricId.INSTANCE;
-  }
-
-  private enum ToMetricId implements Function<MeasureDto, Integer> {
-    INSTANCE;
-
-    @Override
-    public Integer apply(@Nonnull MeasureDto input) {
-      return input.getMetricId();
-    }
-  }
-}
index f2111f7066f4772824925f0c88def00864853493..f19fed07105e8be3672efbaa92793cc28c498ea1 100644 (file)
@@ -19,8 +19,7 @@
  */
 package org.sonar.db.metric;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
+import java.util.function.Predicate;
 import javax.annotation.Nonnull;
 
 /**
@@ -31,41 +30,16 @@ public class MetricDtoFunctions {
     // prevents instantiation
   }
 
-  public static Function<MetricDto, Integer> toId() {
-    return ToId.INSTANCE;
-  }
-
-  public static Function<MetricDto, String> toKey() {
-    return ToKey.INSTANCE;
-  }
 
   public static Predicate<MetricDto> isOptimizedForBestValue() {
     return IsMetricOptimizedForBestValue.INSTANCE;
   }
 
-  private enum ToId implements Function<MetricDto, Integer> {
-    INSTANCE;
-
-    @Override
-    public Integer apply(@Nonnull MetricDto input) {
-      return input.getId();
-    }
-  }
-
-  private enum ToKey implements Function<MetricDto, String> {
-    INSTANCE;
-
-    @Override
-    public String apply(@Nonnull MetricDto input) {
-      return input.getKey();
-    }
-  }
-
   private enum IsMetricOptimizedForBestValue implements Predicate<MetricDto> {
     INSTANCE;
 
     @Override
-    public boolean apply(@Nonnull MetricDto input) {
+    public boolean test(@Nonnull MetricDto input) {
       return input.isOptimizedBestValue() && input.getBestValue() != null;
     }
   }
index c24788ceabedd3514d58568b492aff8e0bfcef13..45ce6d1eed1fb4feb089cb37431988a4a5e3c50b 100644 (file)
@@ -39,10 +39,10 @@ public class ComponentLinkDaoTest {
 
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
-  DbClient dbClient = db.getDbClient();
-  DbSession dbSession = db.getSession();
+  private DbClient dbClient = db.getDbClient();
+  private DbSession dbSession = db.getSession();
 
-  ComponentLinkDao underTest = db.getDbClient().componentLinkDao();
+  private ComponentLinkDao underTest = db.getDbClient().componentLinkDao();
 
   @Test
   public void select_by_component_uuid() {
index 386b6b604c6dd9f37602b3826cdfb76cd9fcfbd9..69b676fc88600e3df99a542aea2c6e510fbfec33 100644 (file)
@@ -26,25 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 public class MetricDtoFunctionsTest {
 
-  MetricDto metric;
-
-  @Test
-  public void toId() {
-    metric = new MetricDto().setId(42);
-
-    Integer result = MetricDtoFunctions.toId().apply(metric);
-
-    assertThat(result).isEqualTo(42);
-  }
-
-  @Test
-  public void toKey() {
-    metric = new MetricDto().setKey("my-metric-key");
-
-    String result = MetricDtoFunctions.toKey().apply(metric);
-
-    assertThat(result).isEqualTo("my-metric-key");
-  }
+  private MetricDto metric;
 
   @Test
   public void isOptimizedForBestValue_at_true() {
@@ -52,7 +34,7 @@ public class MetricDtoFunctionsTest {
       .setBestValue(42.0d)
       .setOptimizedBestValue(true);
 
-    boolean result = MetricDtoFunctions.isOptimizedForBestValue().apply(metric);
+    boolean result = MetricDtoFunctions.isOptimizedForBestValue().test(metric);
 
     assertThat(result).isTrue();
   }
@@ -63,7 +45,7 @@ public class MetricDtoFunctionsTest {
       .setBestValue(null)
       .setOptimizedBestValue(true);
 
-    boolean result = MetricDtoFunctions.isOptimizedForBestValue().apply(metric);
+    boolean result = MetricDtoFunctions.isOptimizedForBestValue().test(metric);
 
     assertThat(result).isFalse();
   }
@@ -74,7 +56,7 @@ public class MetricDtoFunctionsTest {
       .setBestValue(42.0d)
       .setOptimizedBestValue(false);
 
-    boolean result = MetricDtoFunctions.isOptimizedForBestValue().apply(metric);
+    boolean result = MetricDtoFunctions.isOptimizedForBestValue().test(metric);
 
     assertThat(result).isFalse();
   }