]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11464 Only load files from Scanner Report
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 16 Nov 2018 20:44:11 +0000 (14:44 -0600)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jan 2019 08:43:01 +0000 (09:43 +0100)
101 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/Component.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentFunctions.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentKeyGenerator.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimit.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DbIdsRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DepthTraversalTypeAwareCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/MapBasedDbIdsRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/PathAwareCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/PathAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/PathAwareVisitorAdapter.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/PathAwareVisitorWrapper.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ReportAttributes.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/TreeRootHolderImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/TypeAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/TypeAwareVisitorAdapter.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/TypeAwareVisitorWrapper.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/VisitorsCrawler.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/event/EventRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/formula/FormulaExecutorComponentVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/EffortAggregator.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregator.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewReliabilityAndSecurityRatingMeasuresVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/source/LastCommitVisitor.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ComputeQProfileMeasureStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SizeMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStep.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CallRecorderPathAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CallRecorderTypeAwareVisitor.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentFunctionsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MutableDbIdsRepositoryRule.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportComponent.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportPathAwareVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportPostOrderDepthTraversalTypeAwareCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportPreOrderDepthTraversalTypeAwareCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportVisitorsCrawlerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportVisitorsCrawlerWithPathAwareVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/TreeRootHolderImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationMeasuresTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/MutableMovedFilesRepositoryImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/DistributionFormulaExecutionTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/LoadComponentUuidsHavingOpenIssuesVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/ReportMeasureComputersVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewReliabilityAndSecurityRatingMeasuresVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/ReliabilityAndSecurityRatingMeasuresVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/LastCommitVisitorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLineReadersFactoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ComputeQProfileMeasureStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistLiveMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistProjectLinksStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistTestsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportComplexityMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportNewCoverageMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistAnalysisStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportSizeMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportUnitTestMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java

index f4eb9fb6b79d092a6fd709aea31fd1d59a506136..bb90b9228d204b0cbde79f9d61e900ca9900942f 100644 (file)
@@ -26,9 +26,9 @@ import javax.annotation.CheckForNull;
 
 public interface Component {
   enum Type {
-    PROJECT(0), MODULE(1), DIRECTORY(2), FILE(3), VIEW(0), SUBVIEW(1), PROJECT_VIEW(2);
+    PROJECT(0), DIRECTORY(2), FILE(3), VIEW(0), SUBVIEW(1), PROJECT_VIEW(2);
 
-    private static final Set<Type> REPORT_TYPES = EnumSet.of(PROJECT, MODULE, DIRECTORY, FILE);
+    private static final Set<Type> REPORT_TYPES = EnumSet.of(PROJECT, DIRECTORY, FILE);
     private static final Set<Type> VIEWS_TYPES = EnumSet.of(VIEW, SUBVIEW, PROJECT_VIEW);
 
     private final int depth;
index e532dad265cb331a7d6b7740f392cef7b7663cc3..5d82485d6fe8e6bf3ecb1fab7c989e56d167b93d 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.component;
 
-import com.google.common.base.Function;
+import java.util.function.Function;
 import javax.annotation.Nonnull;
 
 public final class ComponentFunctions {
@@ -28,16 +28,16 @@ public final class ComponentFunctions {
     // prevents instantiation
   }
 
-  public static Function<Component, Integer> toReportRef() {
-    return ToReportRef.INSTANCE;
+  public static Function<Component, String> toComponentUuid() {
+    return ToComponentUuid.INSTANCE;
   }
 
-  private enum ToReportRef implements Function<Component, Integer> {
+  private enum ToComponentUuid implements Function<Component, String> {
     INSTANCE;
     @Override
     @Nonnull
-    public Integer apply(@Nonnull Component input) {
-      return input.getReportAttributes().getRef();
+    public String apply(@Nonnull Component input) {
+      return input.getUuid();
     }
 
   }
index 76765f16ccc987aedfdae8c6b57e7eba40e53521..5ad2a8fb9b917642a461b583cedd14a7ce24644a 100644 (file)
@@ -25,6 +25,6 @@ import org.sonar.scanner.protocol.output.ScannerReport;
 @FunctionalInterface
 public interface ComponentKeyGenerator {
 
-  String generateKey(ScannerReport.Component module, @Nullable ScannerReport.Component fileOrDir);
+  String generateKey(ScannerReport.Component project, @Nullable String fileOrDirPath);
 
 }
index e57cff7f81ca9a282cb1e6222b9ef8907bb7f7fa..68080a5fa07e861d34f5e9e295c71d527bf064df 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.component;
 
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.function.Function;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+import org.sonar.api.internal.apachecommons.lang.StringUtils;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
 import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.component.SnapshotDto;
@@ -62,6 +68,9 @@ public class ComponentTreeBuilder {
   @Nullable
   private final SnapshotDto baseAnalysis;
 
+  private ScannerReport.Component rootComponent;
+  private String scmBasePath;
+
   public ComponentTreeBuilder(
     ComponentKeyGenerator keyGenerator,
     ComponentKeyGenerator publicKeyGenerator,
@@ -80,69 +89,147 @@ public class ComponentTreeBuilder {
   }
 
   public Component buildProject(ScannerReport.Component project, String scmBasePath) {
-    return buildComponent(project, project, trimToNull(scmBasePath));
+    this.rootComponent = project;
+    this.scmBasePath = trimToNull(scmBasePath);
+
+    Node root = buildFolderHierarchy(project);
+    return buildNode(root, "");
   }
 
-  private List<Component> buildChildren(ScannerReport.Component component, ScannerReport.Component parentModule,
-    String projectScmPath) {
-    return component.getChildRefList()
+  private Node buildFolderHierarchy(ScannerReport.Component rootComponent) {
+    Preconditions.checkArgument(rootComponent.getType() == ScannerReport.Component.ComponentType.PROJECT, "Expected root component of type 'PROJECT'");
+
+    LinkedList<ScannerReport.Component> queue = new LinkedList<>();
+    rootComponent.getChildRefList()
       .stream()
-      .map(scannerComponentSupplier::apply)
-      .map(c -> buildComponent(c, parentModule, projectScmPath))
-      .collect(MoreCollectors.toList(component.getChildRefCount()));
+      .map(scannerComponentSupplier)
+      .forEach(queue::addLast);
+
+    Node root = new Node();
+    root.reportComponent = rootComponent;
+
+    while (!queue.isEmpty()) {
+      ScannerReport.Component component = queue.removeFirst();
+      switch (component.getType()) {
+        case FILE:
+          addFileOrDirectory(root, component);
+          break;
+        case MODULE:
+
+          component.getChildRefList().stream()
+            .map(scannerComponentSupplier)
+            .forEach(queue::addLast);
+          break;
+        case DIRECTORY:
+          addFileOrDirectory(root, component);
+          component.getChildRefList().stream()
+            .map(scannerComponentSupplier)
+            .forEach(queue::addLast);
+          break;
+        default:
+          throw new IllegalArgumentException(format("Unsupported component type '%s'", component.getType()));
+      }
+    }
+    return root;
   }
 
-  private ComponentImpl buildComponent(ScannerReport.Component component, ScannerReport.Component closestModule,
-    @Nullable String scmBasePath) {
-    switch (component.getType()) {
-      case PROJECT:
-        String projectKey = keyGenerator.generateKey(component, null);
-        String uuid = uuidSupplier.apply(projectKey);
-        String projectPublicKey = publicKeyGenerator.generateKey(component, null);
-        ComponentImpl.Builder builder = ComponentImpl.builder(Component.Type.PROJECT)
-          .setUuid(uuid)
-          .setDbKey(projectKey)
-          .setKey(projectPublicKey)
-          .setStatus(convertStatus(component.getStatus()))
-          .setProjectAttributes(new ProjectAttributes(createProjectVersion(component)))
-          .setReportAttributes(createAttributesBuilder(component, scmBasePath).build())
-          .addChildren(buildChildren(component, component, scmBasePath));
-        setNameAndDescription(component, builder);
-        return builder.build();
-
-      case MODULE:
-        String moduleKey = keyGenerator.generateKey(component, null);
-        String modulePublicKey = publicKeyGenerator.generateKey(component, null);
-        return ComponentImpl.builder(Component.Type.MODULE)
-          .setUuid(uuidSupplier.apply(moduleKey))
-          .setDbKey(moduleKey)
-          .setKey(modulePublicKey)
-          .setName(nameOfOthers(component, modulePublicKey))
-          .setStatus(convertStatus(component.getStatus()))
-          .setDescription(trimToNull(component.getDescription()))
-          .setReportAttributes(createAttributesBuilder(component, scmBasePath).build())
-          .addChildren(buildChildren(component, component, scmBasePath))
-          .build();
+  private static void addFileOrDirectory(Node root, ScannerReport.Component file) {
+    Preconditions.checkArgument(file.getType() != ScannerReport.Component.ComponentType.FILE || !StringUtils.isEmpty(file.getProjectRelativePath()),
+      "Files should have a relative path: " + file);
+    String[] split = StringUtils.split(file.getProjectRelativePath(), '/');
+    Node currentNode = root.children().computeIfAbsent("", k -> new Node());
 
-      case DIRECTORY:
-      case FILE:
-        String key = keyGenerator.generateKey(closestModule, component);
-        String publicKey = publicKeyGenerator.generateKey(closestModule, component);
-        return ComponentImpl.builder(convertDirOrFileType(component.getType()))
-          .setUuid(uuidSupplier.apply(key))
-          .setDbKey(key)
-          .setKey(publicKey)
-          .setName(nameOfOthers(component, publicKey))
-          .setStatus(convertStatus(component.getStatus()))
-          .setDescription(trimToNull(component.getDescription()))
-          .setReportAttributes(createAttributesBuilder(component, scmBasePath).build())
-          .setFileAttributes(createFileAttributes(component))
-          .addChildren(buildChildren(component, closestModule, scmBasePath))
-          .build();
+    for (int i = 0; i < split.length; i++) {
+      currentNode = currentNode.children().computeIfAbsent(split[i], k -> new Node());
+    }
+    currentNode.reportComponent = file;
+  }
 
-      default:
-        throw new IllegalArgumentException(format("Unsupported component type '%s'", component.getType()));
+  private Component buildNode(Node node, String currentPath) {
+    List<Component> childComponents = buildChildren(node, currentPath);
+    ScannerReport.Component component = node.reportComponent();
+
+    if (component != null) {
+      if (component.getType() == ScannerReport.Component.ComponentType.FILE) {
+        return buildFile(component);
+      } else if (component.getType() == ScannerReport.Component.ComponentType.PROJECT) {
+        return buildProject(childComponents);
+      }
+    }
+
+    return buildDirectory(currentPath, component, childComponents);
+  }
+
+  private List<Component> buildChildren(Node node, String currentPath) {
+    List<Component> children = new ArrayList<>();
+
+    for (Map.Entry<String, Node> e : node.children().entrySet()) {
+      String path = buildPath(currentPath, e.getKey());
+      Node n = e.getValue();
+
+      while (n.children().size() == 1 && n.children().values().iterator().next().children().size() > 0) {
+        Map.Entry<String, Node> childEntry = n.children().entrySet().iterator().next();
+        path = buildPath(path, childEntry.getKey());
+        n = childEntry.getValue();
+      }
+      children.add(buildNode(n, path));
+    }
+    return children;
+  }
+
+  private static String buildPath(String currentPath, String file) {
+    if (currentPath.isEmpty()) {
+      return file;
     }
+    return currentPath + "/" + file;
+  }
+
+  private Component buildProject(List<Component> children) {
+    String projectKey = keyGenerator.generateKey(rootComponent, null);
+    String uuid = uuidSupplier.apply(projectKey);
+    String projectPublicKey = publicKeyGenerator.generateKey(rootComponent, null);
+    ComponentImpl.Builder builder = ComponentImpl.builder(Component.Type.PROJECT)
+      .setUuid(uuid)
+      .setDbKey(projectKey)
+      .setKey(projectPublicKey)
+      .setStatus(convertStatus(rootComponent.getStatus()))
+      .setProjectAttributes(new ProjectAttributes(createProjectVersion(rootComponent)))
+      .setReportAttributes(createAttributesBuilder(rootComponent.getRef(), rootComponent.getProjectRelativePath(), scmBasePath,
+        rootComponent.getProjectRelativePath()).build())
+      .addChildren(children);
+    setNameAndDescription(rootComponent, builder);
+    return builder.build();
+  }
+
+  private ComponentImpl buildFile(ScannerReport.Component component) {
+    String key = keyGenerator.generateKey(rootComponent, component.getProjectRelativePath());
+    String publicKey = publicKeyGenerator.generateKey(rootComponent, component.getProjectRelativePath());
+    return ComponentImpl.builder(Component.Type.FILE)
+      .setUuid(uuidSupplier.apply(key))
+      .setDbKey(key)
+      .setKey(publicKey)
+      .setName(nameOfOthers(component, publicKey))
+      .setStatus(convertStatus(component.getStatus()))
+      .setDescription(trimToNull(component.getDescription()))
+      .setReportAttributes(createAttributesBuilder(component.getRef(), component.getProjectRelativePath(), scmBasePath, component.getProjectRelativePath()).build())
+      .setFileAttributes(createFileAttributes(component))
+      .build();
+  }
+
+  private ComponentImpl buildDirectory(String path, @Nullable ScannerReport.Component scannerComponent, List<Component> children) {
+    String nonEmptyPath = path.isEmpty() ? "/" : path;
+    String key = keyGenerator.generateKey(rootComponent, nonEmptyPath);
+    String publicKey = publicKeyGenerator.generateKey(rootComponent, nonEmptyPath);
+    Integer ref = scannerComponent != null ? scannerComponent.getRef() : null;
+    return ComponentImpl.builder(Component.Type.DIRECTORY)
+      .setUuid(uuidSupplier.apply(key))
+      .setDbKey(key)
+      .setKey(publicKey)
+      .setName(publicKey)
+      .setStatus(convertStatus(FileStatus.UNAVAILABLE))
+      .setReportAttributes(createAttributesBuilder(ref, nonEmptyPath, scmBasePath, path).build())
+      .addChildren(children)
+      .build();
   }
 
   public Component buildChangedComponentTreeRoot(Component project) {
@@ -165,11 +252,8 @@ public class ComponentTreeBuilder {
     switch (component.getType()) {
       case PROJECT:
         return buildChangedProject(component);
-
-      case MODULE:
       case DIRECTORY:
         return buildChangedIntermediate(component);
-
       case FILE:
         return buildChangedFile(component);
 
@@ -266,10 +350,10 @@ public class ComponentTreeBuilder {
     return DEFAULT_PROJECT_VERSION;
   }
 
-  private static ReportAttributes.Builder createAttributesBuilder(ScannerReport.Component component, @Nullable String scmBasePath) {
-    return ReportAttributes.newBuilder(component.getRef())
-      .setPath(trimToNull(component.getPath()))
-      .setScmPath(computeScmPath(scmBasePath, component.getProjectRelativePath()));
+  private static ReportAttributes.Builder createAttributesBuilder(@Nullable Integer ref, String path, @Nullable String scmBasePath, String scmRelativePath) {
+    return ReportAttributes.newBuilder(ref)
+      .setPath(trimToNull(path))
+      .setScmPath(computeScmPath(scmBasePath, scmRelativePath));
   }
 
   @CheckForNull
@@ -280,30 +364,30 @@ public class ComponentTreeBuilder {
     if (scmBasePath == null) {
       return scmRelativePath;
     }
+
     return scmBasePath + '/' + scmRelativePath;
   }
 
-  @CheckForNull
   private static FileAttributes createFileAttributes(ScannerReport.Component component) {
-    if (component.getType() != ScannerReport.Component.ComponentType.FILE) {
-      return null;
-    }
-
-    checkArgument(component.getLines() > 0, "File '%s' has no line", component.getPath());
+    checkArgument(component.getType() == ScannerReport.Component.ComponentType.FILE);
+    checkArgument(component.getLines() > 0, "File '%s' has no line", component.getProjectRelativePath());
     return new FileAttributes(
       component.getIsTest(),
       trimToNull(component.getLanguage()),
       component.getLines());
   }
 
-  private static Component.Type convertDirOrFileType(ScannerReport.Component.ComponentType type) {
-    switch (type) {
-      case DIRECTORY:
-        return Component.Type.DIRECTORY;
-      case FILE:
-        return Component.Type.FILE;
-      default:
-        throw new IllegalArgumentException("Unsupported ComponentType value " + type);
+  private static class Node {
+    private final Map<String, Node> children = new LinkedHashMap<>();
+    private ScannerReport.Component reportComponent;
+
+    private Map<String, Node> children() {
+      return children;
+    }
+
+    @CheckForNull
+    private ScannerReport.Component reportComponent() {
+      return reportComponent;
     }
   }
 }
index b0e0a282a82e7be21804fbb5dcebeb471260ed63..b4410c65c7a88daa3d1fd46239a9fa236314176f 100644 (file)
@@ -30,7 +30,7 @@ import static com.google.common.base.Preconditions.checkArgument;
  *
  * A limit can be defined for a tree of Report components, a tree of Views components or both.
  *
- * Constants are provided for limits specific to a component tree (see {@link #PROJECT}, {@link #MODULE}, etc.).
+ * Constants are provided for limits specific to a component tree (see {@link #PROJECT}).
  *
  * Limits for both trees can be created using the {@link #reportMaxDepth(Component.Type)} static method.
  */
@@ -39,7 +39,6 @@ public class CrawlerDepthLimit {
   private static final String UNSUPPORTED_TYPE_UOE_MSG = "Specified type is neither a report type nor a views type";
 
   public static final CrawlerDepthLimit PROJECT = new CrawlerDepthLimit(Component.Type.PROJECT, null);
-  public static final CrawlerDepthLimit MODULE = new CrawlerDepthLimit(Component.Type.MODULE, null);
   public static final CrawlerDepthLimit DIRECTORY = new CrawlerDepthLimit(Component.Type.DIRECTORY, null);
   public static final CrawlerDepthLimit FILE = new CrawlerDepthLimit(Component.Type.FILE, null);
   public static final CrawlerDepthLimit VIEW = new CrawlerDepthLimit(null, Component.Type.VIEW);
index f9847dd90e2869d1e3b4ebb742ae9a4541057f0b..f614ff028497e8e667d02520f416a11e90192efc 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.component;
 
-import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toReportRef;
+import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toComponentUuid;
 
 /**
  * Cache of persisted component (component id and snapshot id) that can be used in the persistence steps
  */
 public class DbIdsRepositoryImpl implements MutableDbIdsRepository {
 
-  private final MapBasedDbIdsRepository<Integer> delegate = new MapBasedDbIdsRepository<>(toReportRef());
+  private final MapBasedDbIdsRepository<String> delegate = new MapBasedDbIdsRepository<>(toComponentUuid());
 
   @Override
   public DbIdsRepository setComponentId(Component component, long componentId) {
index d4d5281facc4c4ed60cef3a8267214a4f7d96bf1..de6c19808834839cc0b8e7e9271654ccb3058639 100644 (file)
@@ -22,11 +22,11 @@ package org.sonar.ce.task.projectanalysis.component;
 import java.util.Optional;
 import javax.annotation.Nullable;
 import org.sonar.api.utils.MessageException;
+import org.sonar.ce.task.projectanalysis.analysis.Branch;
 import org.sonar.core.component.ComponentKeys;
 import org.sonar.db.component.BranchDto;
 import org.sonar.db.component.BranchType;
 import org.sonar.scanner.protocol.output.ScannerReport;
-import org.sonar.ce.task.projectanalysis.analysis.Branch;
 
 import static java.lang.String.format;
 import static org.apache.commons.lang.StringUtils.isEmpty;
@@ -91,14 +91,14 @@ public class DefaultBranchImpl implements Branch {
   }
 
   @Override
-  public String generateKey(ScannerReport.Component module, @Nullable ScannerReport.Component fileOrDir) {
-    String moduleWithBranch = module.getKey();
+  public String generateKey(ScannerReport.Component project, @Nullable String fileOrDirPath) {
+    String projectWithBranch = project.getKey();
     if (isLegacyBranch) {
-      moduleWithBranch = ComponentKeys.createKey(module.getKey(), branchName);
+      projectWithBranch = ComponentKeys.createKey(project.getKey(), branchName);
     }
-    if (fileOrDir == null || isEmpty(fileOrDir.getPath())) {
-      return moduleWithBranch;
+    if (isEmpty(fileOrDirPath)) {
+      return projectWithBranch;
     }
-    return ComponentKeys.createEffectiveKey(moduleWithBranch, trimToNull(fileOrDir.getPath()));
+    return ComponentKeys.createEffectiveKey(projectWithBranch, trimToNull(fileOrDirPath));
   }
 }
index f3d84d8d9513e84d065d61870056e6271cadfffb..2f37dd81322449b36e67c6b634d2914d9d8ed9d5 100644 (file)
@@ -69,9 +69,6 @@ public final class DepthTraversalTypeAwareCrawler implements ComponentCrawler {
       case PROJECT:
         this.visitor.visitProject(component);
         break;
-      case MODULE:
-        this.visitor.visitModule(component);
-        break;
       case DIRECTORY:
         this.visitor.visitDirectory(component);
         break;
index 8ff723a072ac35ddc115d45fffa8d9bee01cbf1f..f78194c44376f0f4543340360ab91e1ba9b52e71 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.ce.task.projectanalysis.component;
 
-import com.google.common.base.Function;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.function.Function;
 
 import static com.google.common.base.Preconditions.checkState;
 
index 2092da21f316fa2a9489ded1a36abbbc465e920a..547c326e8aef64949f058189a14c5f03141c69d6 100644 (file)
@@ -95,9 +95,6 @@ public final class PathAwareCrawler<T> implements ComponentCrawler {
       case PROJECT:
         this.visitor.visitProject(component, stack);
         break;
-      case MODULE:
-        this.visitor.visitModule(component, stack);
-        break;
       case DIRECTORY:
         this.visitor.visitDirectory(component, stack);
         break;
@@ -122,8 +119,6 @@ public final class PathAwareCrawler<T> implements ComponentCrawler {
     switch (component.getType()) {
       case PROJECT:
         return this.visitor.getFactory().createForProject(component);
-      case MODULE:
-        return this.visitor.getFactory().createForModule(component);
       case DIRECTORY:
         return this.visitor.getFactory().createForDirectory(component);
       case FILE:
index 115518769cf2420058695290060c6bca6b326288..8741ab83f56e80bb5a6ad3b1d8c85da99f6ec662 100644 (file)
@@ -35,11 +35,6 @@ public interface PathAwareVisitor<T> extends ComponentVisitor {
    */
   void visitProject(Component project, Path<T> path);
 
-  /**
-   * Called when encountering a Component of type {@link Component.Type#MODULE}
-   */
-  void visitModule(Component module, Path<T> path);
-
   /**
    * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
    */
@@ -73,8 +68,6 @@ public interface PathAwareVisitor<T> extends ComponentVisitor {
   interface StackElementFactory<T> {
     T createForProject(Component project);
 
-    T createForModule(Component module);
-
     T createForDirectory(Component directory);
 
     T createForFile(Component file);
index 11e435ec854ca3e520fe69e8b6512bfb59fc765f..1b03e64f8b4550648b4bb18d39f4f544aa02ed20 100644 (file)
@@ -55,11 +55,6 @@ public abstract class PathAwareVisitorAdapter<T> implements PathAwareVisitor<T>
     // empty implementation, meant to be override at will by subclasses
   }
 
-  @Override
-  public void visitModule(Component module, Path<T> path) {
-    // empty implementation, meant to be override at will by subclasses
-  }
-
   @Override
   public void visitDirectory(Component directory, Path<T> path) {
     // empty implementation, meant to be override at will by subclasses
@@ -103,11 +98,6 @@ public abstract class PathAwareVisitorAdapter<T> implements PathAwareVisitor<T>
       return createForAny(project);
     }
 
-    @Override
-    public T createForModule(Component module) {
-      return createForAny(module);
-    }
-
     @Override
     public T createForDirectory(Component directory) {
       return createForAny(directory);
index 8be9bb3b687a66c0059f118577c0c93c0722a8f0..4a96cee130f459fdf1bea0c265b7341804048908 100644 (file)
@@ -51,11 +51,6 @@ public class PathAwareVisitorWrapper<T> implements VisitorWrapper {
     delegate.visitProject(tree, stack);
   }
 
-  @Override
-  public void visitModule(Component tree) {
-    delegate.visitModule(tree, stack);
-  }
-
   @Override
   public void visitDirectory(Component tree) {
     delegate.visitDirectory(tree, stack);
@@ -100,8 +95,6 @@ public class PathAwareVisitorWrapper<T> implements VisitorWrapper {
     switch (component.getType()) {
       case PROJECT:
         return delegate.getFactory().createForProject(component);
-      case MODULE:
-        return delegate.getFactory().createForModule(component);
       case DIRECTORY:
         return delegate.getFactory().createForDirectory(component);
       case FILE:
index 32c68eacfa419b757f9cccdea611a9a3b98d892b..136b7504b805a5e9ae9f0f46777430c58f5b4cb1 100644 (file)
@@ -29,7 +29,8 @@ import javax.annotation.concurrent.Immutable;
  */
 @Immutable
 public class ReportAttributes {
-  private final int ref;
+  @CheckForNull
+  private final Integer ref;
   @CheckForNull
   private final String path;
   @CheckForNull
@@ -41,18 +42,19 @@ public class ReportAttributes {
     this.scmPath = builder.scmPath;
   }
 
-  public static Builder newBuilder(int ref) {
+  public static Builder newBuilder(@Nullable Integer ref) {
     return new Builder(ref);
   }
 
   public static class Builder {
-    private final int ref;
+    @CheckForNull
+    private final Integer ref;
     @CheckForNull
     private String path;
     @CheckForNull
     private String scmPath;
 
-    private Builder(int ref) {
+    private Builder(@Nullable Integer ref) {
       this.ref = ref;
     }
 
@@ -73,13 +75,15 @@ public class ReportAttributes {
 
   /**
    * The component ref in the batch report.
+   * Will be null for directories.
    */
-  public int getRef() {
+  @CheckForNull
+  public Integer getRef() {
     return ref;
   }
 
   /**
-   * The path of the report component, must be non null for module, directories and files.
+   * The path of the report component, must be non null for directories and files.
    */
   @CheckForNull
   public String getPath() {
index 49f09ab1b357f2e1de71effde2b6953b98c78fcd..4d0d38e708ff914a50353d4f9dca065be26ea0a1 100644 (file)
@@ -38,6 +38,7 @@ public class TreeRootHolderImpl implements MutableTreeRootHolder {
   @CheckForNull
   private Map<Integer, Component> extendedComponentsByRef;
 
+  private int size;
   private Component root;
   private Component extendedTreeRoot;
 
@@ -94,7 +95,7 @@ public class TreeRootHolderImpl implements MutableTreeRootHolder {
   public int getSize() {
     checkInitialized();
     ensureComponentByRefIsPopulated();
-    return componentsByRef.size();
+    return size;
   }
 
   private void ensureExtendedComponentByRefIsPopulated() {
@@ -107,7 +108,9 @@ public class TreeRootHolderImpl implements MutableTreeRootHolder {
       new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {
         @Override
         public void visitAny(Component component) {
-          builder.put(component.getReportAttributes().getRef(), component);
+          if (component.getReportAttributes().getRef() != null) {
+            builder.put(component.getReportAttributes().getRef(), component);
+          }
         }
       }).visit(this.extendedTreeRoot);
     this.extendedComponentsByRef = builder.build();
@@ -123,7 +126,10 @@ public class TreeRootHolderImpl implements MutableTreeRootHolder {
       new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {
         @Override
         public void visitAny(Component component) {
-          builder.put(component.getReportAttributes().getRef(), component);
+          size++;
+          if (component.getReportAttributes().getRef() != null) {
+            builder.put(component.getReportAttributes().getRef(), component);
+          }
         }
       }).visit(this.root);
     this.componentsByRef = builder.build();
index e5faccf3df8622409e1d6e6d414c23bdace6b509..01a07fc56c21c2aa09d46454bbe0054531d502a1 100644 (file)
@@ -28,11 +28,6 @@ public interface TypeAwareVisitor extends ComponentVisitor {
    */
   void visitProject(Component project);
 
-  /**
-   * Called when encountering a Component of type {@link Component.Type#MODULE}
-   */
-  void visitModule(Component module);
-
   /**
    * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
    */
index 0e9a2c020b954d99e31efa1bba219486ec1fc503..6fc56d0e0dae1a96e1862a41e37f5c55968f6ac1 100644 (file)
@@ -52,14 +52,6 @@ public abstract class TypeAwareVisitorAdapter implements TypeAwareVisitor {
     // empty implementation, meant to be override at will by subclasses
   }
 
-  /**
-   * Called when encountering a Component of type {@link Component.Type#MODULE}
-   */
-  @Override
-  public void visitModule(Component module) {
-    // empty implementation, meant to be override at will by subclasses
-  }
-
   /**
    * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
    */
index 85f707704847ad67664bcccc42e2caedd2cfc535..87760206ed2ad5a27746fed7788ce13c1dcfe846 100644 (file)
@@ -33,12 +33,12 @@ public class TypeAwareVisitorWrapper implements VisitorWrapper {
   }
 
   @Override
-  public void beforeComponent(Component component){
+  public void beforeComponent(Component component) {
     // Nothing to do
   }
 
   @Override
-  public void afterComponent(Component component){
+  public void afterComponent(Component component) {
     // Nothing to do
   }
 
@@ -47,11 +47,6 @@ public class TypeAwareVisitorWrapper implements VisitorWrapper {
     delegate.visitProject(tree);
   }
 
-  @Override
-  public void visitModule(Component tree) {
-    delegate.visitModule(tree);
-  }
-
   @Override
   public void visitDirectory(Component tree) {
     delegate.visitDirectory(tree);
index fc3c7da3b6db90c5deacfa76ee9bac66488de8e7..f9fbb75503ae8e1dc5f8270b8364cdde2e03748d 100644 (file)
@@ -60,7 +60,7 @@ public class VisitorsCrawler implements ComponentCrawler {
   public Map<ComponentVisitor, Long> getCumulativeDurations() {
     if (computeDuration) {
       return ImmutableMap.copyOf(
-          Maps.transformValues(this.visitorCumulativeDurations, VisitorDurationToDuration.INSTANCE)
+        Maps.transformValues(this.visitorCumulativeDurations, VisitorDurationToDuration.INSTANCE)
       );
     }
     return Collections.emptyMap();
@@ -119,9 +119,6 @@ public class VisitorsCrawler implements ComponentCrawler {
       case PROJECT:
         visitor.visitProject(component);
         break;
-      case MODULE:
-        visitor.visitModule(component);
-        break;
       case DIRECTORY:
         visitor.visitDirectory(component);
         break;
index db09b7f60aee902776de86e98c14b6a2e6744a24..a3a403c7cdfa119a6cd0c74b88a04226873c8107 100644 (file)
@@ -28,16 +28,16 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 public class EventRepositoryImpl implements EventRepository {
-  private final Multimap<Integer, Event> events = HashMultimap.create();
+  private final Multimap<String, Event> events = HashMultimap.create();
 
   @Override
   public void add(Component component, Event event) {
     checkArgument(component.getType() == Component.Type.PROJECT, "Component must be of type PROJECT");
-    events.put(component.getReportAttributes().getRef(), requireNonNull(event));
+    events.put(component.getUuid(), requireNonNull(event));
   }
 
   @Override
   public Iterable<Event> getEvents(Component component) {
-    return this.events.get(component.getReportAttributes().getRef());
+    return this.events.get(component.getUuid());
   }
 }
index 793e1a14abaf5524f03c0e80264064e1cac99d20..1580d0d7a03144d6339ed17e24a3538208574529 100644 (file)
@@ -95,11 +95,6 @@ public class FormulaExecutorComponentVisitor extends PathAwareVisitorAdapter<For
     process(project, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<FormulaExecutorComponentVisitor.Counters> path) {
-    process(module, path);
-  }
-
   @Override
   public void visitDirectory(Component directory, Path<FormulaExecutorComponentVisitor.Counters> path) {
     process(directory, path);
index 45bd62e6c91eefb0cf8d24b9bcdc632742a999b4..7997c133e7ce1bf27d0edb299d522c1d61def0ba 100644 (file)
@@ -23,12 +23,11 @@ import java.util.HashMap;
 import java.util.Map;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.ce.task.projectanalysis.component.Component;
-import org.sonar.core.issue.DefaultIssue;
-import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.measure.Measure;
 import org.sonar.ce.task.projectanalysis.measure.MeasureRepository;
 import org.sonar.ce.task.projectanalysis.metric.Metric;
 import org.sonar.ce.task.projectanalysis.metric.MetricRepository;
+import org.sonar.core.issue.DefaultIssue;
 
 import static org.sonar.api.measures.CoreMetrics.RELIABILITY_REMEDIATION_EFFORT_KEY;
 import static org.sonar.api.measures.CoreMetrics.SECURITY_REMEDIATION_EFFORT_KEY;
@@ -43,12 +42,12 @@ import static org.sonar.api.measures.CoreMetrics.TECHNICAL_DEBT_KEY;
 public class EffortAggregator extends IssueVisitor {
 
   private final MeasureRepository measureRepository;
+  private final Map<String, EffortCounter> effortsByComponentUuid = new HashMap<>();
 
   private final Metric maintainabilityEffortMetric;
   private final Metric reliabilityEffortMetric;
   private final Metric securityEffortMetric;
 
-  private final Map<Integer, EffortCounter> effortsByComponentRef = new HashMap<>();
   private EffortCounter effortCounter;
 
   public EffortAggregator(MetricRepository metricRepository, MeasureRepository measureRepository) {
@@ -61,12 +60,12 @@ public class EffortAggregator extends IssueVisitor {
   @Override
   public void beforeComponent(Component component) {
     effortCounter = new EffortCounter();
-    effortsByComponentRef.put(component.getReportAttributes().getRef(), effortCounter);
+    effortsByComponentUuid.put(component.getUuid(), effortCounter);
 
     // aggregate children counters
     for (Component child : component.getChildren()) {
       // no need to keep the children in memory. They can be garbage-collected.
-      EffortCounter childEffortCounter = effortsByComponentRef.remove(child.getReportAttributes().getRef());
+      EffortCounter childEffortCounter = effortsByComponentUuid.remove(child.getUuid());
       if (childEffortCounter != null) {
         effortCounter.add(childEffortCounter);
       }
@@ -101,7 +100,7 @@ public class EffortAggregator extends IssueVisitor {
     measureRepository.add(component, securityEffortMetric, Measure.newMeasureBuilder().create(effortCounter.securityEffort));
   }
 
-  private class EffortCounter {
+  private static class EffortCounter {
     private long maintainabilityEffort = 0L;
     private long reliabilityEffort = 0L;
     private long securityEffort = 0L;
index 4a2aa9dea6da50f86c491f574db832c81f00e4a1..6f33a516d070941460757c338d10e304e3e6cf74 100644 (file)
@@ -29,13 +29,13 @@ import javax.annotation.Nullable;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.rules.RuleType;
 import org.sonar.ce.task.projectanalysis.component.Component;
-import org.sonar.core.issue.DefaultIssue;
 import org.sonar.ce.task.projectanalysis.measure.Measure;
 import org.sonar.ce.task.projectanalysis.measure.MeasureRepository;
 import org.sonar.ce.task.projectanalysis.metric.Metric;
 import org.sonar.ce.task.projectanalysis.metric.MetricRepository;
 import org.sonar.ce.task.projectanalysis.period.Period;
 import org.sonar.ce.task.projectanalysis.period.PeriodHolder;
+import org.sonar.core.issue.DefaultIssue;
 
 import static org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE;
 import static org.sonar.api.issue.Issue.RESOLUTION_WONT_FIX;
@@ -106,8 +106,8 @@ public class IssueCounter extends IssueVisitor {
   private final PeriodHolder periodHolder;
   private final MetricRepository metricRepository;
   private final MeasureRepository measureRepository;
+  private final Map<String, Counters> countersByComponentUuid = new HashMap<>();
 
-  private final Map<Integer, Counters> countersByComponentRef = new HashMap<>();
   private Counters currentCounters;
 
   public IssueCounter(PeriodHolder periodHolder,
@@ -119,14 +119,13 @@ public class IssueCounter extends IssueVisitor {
 
   @Override
   public void beforeComponent(Component component) {
-    // TODO optimization no need to instantiate counter if no open issues
     currentCounters = new Counters();
-    countersByComponentRef.put(component.getReportAttributes().getRef(), currentCounters);
+    countersByComponentUuid.put(component.getUuid(), currentCounters);
 
     // aggregate children counters
     for (Component child : component.getChildren()) {
       // no need to keep the children in memory. They can be garbage-collected.
-      Counters childCounters = countersByComponentRef.remove(child.getReportAttributes().getRef());
+      Counters childCounters = countersByComponentUuid.remove(child.getUuid());
       currentCounters.add(childCounters);
     }
   }
index cc42497305edabee9562d23b361b971626d2a2ec..7e86b98e96f710aeb7df3122e5c667aff3449325 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.ce.task.projectanalysis.issue;
 
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.ce.task.projectanalysis.component.Component;
 
 public abstract class IssueVisitor {
 
index cbfd3bbdfdd1cea9f78cefd857ac7ca04ff02f7f..5f544b72235679009f8d2a8c585954f0f22a8032 100644 (file)
@@ -24,7 +24,6 @@ import java.util.List;
 
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.core.issue.DefaultIssue;
-import org.sonar.ce.task.projectanalysis.component.Component;
 
 /**
  * Saves issues in the ComponentIssuesRepository
index b342e51ddbbb6be02e0f4f188b3526cb595003b3..30376875414a10bd661399c17caf1cb7f736555d 100644 (file)
@@ -44,7 +44,7 @@ import static org.sonar.api.utils.DateUtils.truncateToSeconds;
  * {@link CoreMetrics#NEW_SECURITY_REMEDIATION_EFFORT_KEY}
  */
 public class NewEffortAggregator extends IssueVisitor {
-
+  private final Map<String, NewEffortCounter> counterByComponentUuid = new HashMap<>();
   private final PeriodHolder periodHolder;
   private final MeasureRepository measureRepository;
 
@@ -52,7 +52,6 @@ public class NewEffortAggregator extends IssueVisitor {
   private final Metric newReliabilityEffortMetric;
   private final Metric newSecurityEffortMetric;
 
-  private Map<Integer, NewEffortCounter> counterByComponentRef = new HashMap<>();
   private NewEffortCounter counter = null;
 
   public NewEffortAggregator(PeriodHolder periodHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
@@ -67,9 +66,9 @@ public class NewEffortAggregator extends IssueVisitor {
   @Override
   public void beforeComponent(Component component) {
     counter = new NewEffortCounter();
-    counterByComponentRef.put(component.getReportAttributes().getRef(), counter);
+    counterByComponentUuid.put(component.getUuid(), counter);
     for (Component child : component.getChildren()) {
-      NewEffortCounter childSum = counterByComponentRef.remove(child.getReportAttributes().getRef());
+      NewEffortCounter childSum = counterByComponentUuid.remove(child.getUuid());
       if (childSum != null) {
         counter.add(childSum);
       }
index a8fc7e62d1bd5b7dcaa7307cf92195d33d0855bd..2cd65c16a0a5c344d0018955ba5333330fb84bab 100644 (file)
@@ -103,6 +103,11 @@ public class TrackerRawInputFactory {
           result.add(init(commonRuleIssue));
         }
       }
+
+      if (component.getReportAttributes().getRef() == null) {
+        return result;
+      }
+
       try (CloseableIterator<ScannerReport.Issue> reportIssues = reportReader.readComponentIssues(component.getReportAttributes().getRef())) {
         // optimization - do not load line hashes if there are no issues -> getLineHashSequence() is executed
         // as late as possible
index ea66553738ae40dc541bae9879b733fe8922ea11..3bfeaf6adb856a6468b2e1a0b059c498cafcfa6d 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.ce.task.projectanalysis.measure;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableSetMultimap;
 import com.google.common.collect.SetMultimap;
 import java.util.Collections;
@@ -28,13 +26,15 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.metric.Metric;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.FluentIterable.from;
 import static java.lang.String.format;
 import static java.util.Objects.requireNonNull;
 
@@ -115,7 +115,10 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
     if (rawMeasures == null) {
       return Collections.emptySet();
     }
-    return from(rawMeasures.entrySet()).filter(new MatchMetric(metric)).transform(ToMeasure.INSTANCE).toSet();
+    return rawMeasures.entrySet().stream()
+      .filter(new MatchMetric(metric))
+      .map(ToMeasure.INSTANCE)
+      .collect(Collectors.toSet());
   }
 
   @Override
@@ -177,7 +180,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
     }
 
     @Override
-    public boolean apply(@Nonnull Map.Entry<MeasureKey, Measure> input) {
+    public boolean test(@Nonnull Map.Entry<MeasureKey, Measure> input) {
       return input.getKey().getMetricKey().equals(metric.getKey());
     }
   }
index 0f48d59abc8ed722f9d701910327ed35363bfa07..6fd9e0394baa3827133d140d57ec9f209d038549 100644 (file)
@@ -36,10 +36,10 @@ import org.sonar.db.measure.MeasureDto;
 import org.sonar.scanner.protocol.output.ScannerReport;
 
 import static java.util.Objects.requireNonNull;
-import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toReportRef;
+import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toComponentUuid;
 
 public class MeasureRepositoryImpl implements MeasureRepository {
-  private final MapBasedRawMeasureRepository<Integer> delegate = new MapBasedRawMeasureRepository<>(toReportRef());
+  private final MapBasedRawMeasureRepository<String> delegate = new MapBasedRawMeasureRepository<>(toComponentUuid());
   private final DbClient dbClient;
   private final BatchReportReader reportReader;
   private final BatchMeasureToMeasure batchMeasureToMeasure;
@@ -47,7 +47,7 @@ public class MeasureRepositoryImpl implements MeasureRepository {
   private final ReportMetricValidator reportMetricValidator;
 
   private MeasureDtoToMeasure measureTransformer = new MeasureDtoToMeasure();
-  private final Set<Integer> loadedComponents = new HashSet<>();
+  private final Set<String> loadedComponents = new HashSet<>();
 
   public MeasureRepositoryImpl(DbClient dbClient, BatchReportReader reportReader, MetricRepository metricRepository,
     ReportMetricValidator reportMetricValidator) {
@@ -108,7 +108,7 @@ public class MeasureRepositoryImpl implements MeasureRepository {
   }
 
   private void loadBatchMeasuresForComponent(Component component) {
-    if (loadedComponents.contains(component.getReportAttributes().getRef())) {
+    if (component.getReportAttributes().getRef() == null || loadedComponents.contains(component.getUuid())) {
       return;
     }
 
@@ -122,7 +122,7 @@ public class MeasureRepositoryImpl implements MeasureRepository {
         }
       }
     }
-    loadedComponents.add(component.getReportAttributes().getRef());
+    loadedComponents.add(component.getUuid());
   }
 
 }
index a77e190bc2a4cfb059e3eeb181b6408504de26b8..f6a31224c6382df8e17f1544a81efc2a91ff8cb6 100644 (file)
@@ -84,11 +84,6 @@ public class MaintainabilityMeasuresVisitor extends PathAwareVisitorAdapter<Main
     computeAndSaveMeasures(directory, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<Counter> path) {
-    computeAndSaveMeasures(module, path);
-  }
-
   @Override
   public void visitFile(Component file, Path<Counter> path) {
     path.current().addDevCosts(computeDevelopmentCost(file));
index aaa85c4e90410e285c2fed47d1ebff4271a89a91..fa0fea701b0e1124bb3bd712186ba742081329fe 100644 (file)
@@ -91,12 +91,6 @@ public class NewMaintainabilityMeasuresVisitor extends PathAwareVisitorAdapter<N
     computeAndSaveNewDebtRatioMeasure(project, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<Counter> path) {
-    computeAndSaveNewDebtRatioMeasure(module, path);
-    increaseNewDebtAndDevCostOfParent(path);
-  }
-
   @Override
   public void visitDirectory(Component directory, Path<Counter> path) {
     computeAndSaveNewDebtRatioMeasure(directory, path);
index 784da3d71512cef2c683209a9320bae18471fde5..5b8090c33916ee1e88ed76716af4e0e124ed2131 100644 (file)
@@ -97,11 +97,6 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitor extends PathAwareVis
     computeAndSaveMeasures(directory, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<Counter> path) {
-    computeAndSaveMeasures(module, path);
-  }
-
   @Override
   public void visitFile(Component file, Path<Counter> path) {
     computeAndSaveMeasures(file, path);
index f75893f504d497c31f2c95255d474038d41d6b2c..e6b27ff47b31a5161323dbf64b4a0a86e2623acb 100644 (file)
@@ -24,11 +24,6 @@ import java.util.Map;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.PathAwareVisitorAdapter;
-import org.sonar.ce.task.projectanalysis.issue.ComponentIssuesRepository;
-import org.sonar.ce.task.projectanalysis.metric.Metric;
-import org.sonar.ce.task.projectanalysis.metric.MetricRepository;
-import org.sonar.ce.task.projectanalysis.component.Component;
-import org.sonar.ce.task.projectanalysis.component.PathAwareVisitorAdapter;
 import org.sonar.ce.task.projectanalysis.formula.counter.RatingValue;
 import org.sonar.ce.task.projectanalysis.issue.ComponentIssuesRepository;
 import org.sonar.ce.task.projectanalysis.measure.MeasureRepository;
@@ -40,7 +35,6 @@ import static org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY;
 import static org.sonar.api.measures.CoreMetrics.SECURITY_RATING_KEY;
 import static org.sonar.api.rules.RuleType.BUG;
 import static org.sonar.api.rules.RuleType.VULNERABILITY;
-import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 import static org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit.FILE;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
 import static org.sonar.server.measure.Rating.RATING_BY_SEVERITY;
@@ -75,11 +69,6 @@ public class ReliabilityAndSecurityRatingMeasuresVisitor extends PathAwareVisito
     computeAndSaveMeasures(project, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<Counter> path) {
-    computeAndSaveMeasures(module, path);
-  }
-
   @Override
   public void visitDirectory(Component directory, Path<Counter> path) {
     computeAndSaveMeasures(directory, path);
index eae342522be40cbfdab5d34e1fc0b2625c6def71..f687a6d84a25ba4ce88fd5416a9f72b7c632429e 100644 (file)
@@ -67,18 +67,13 @@ public class LastCommitVisitor extends PathAwareVisitorAdapter<LastCommitVisitor
     saveAndAggregate(directory, path);
   }
 
-  @Override
-  public void visitModule(Component module, Path<LastCommit> path) {
-    saveAndAggregate(module, path);
-  }
-
   @Override
   public void visitFile(Component file, Path<LastCommit> path) {
     // load SCM blame information from report. It can be absent when the file was not touched
     // since previous analysis (optimization to decrease execution of blame commands). In this case
     // the date is loaded from database, as it did not change from previous analysis.
 
-    java.util.Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(file);
+    Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(file);
     if (scmInfoOptional.isPresent()) {
       ScmInfo scmInfo = scmInfoOptional.get();
       path.current().addDate(scmInfo.getLatestChangeset().getDate());
index d904d29db89d48fdd8bfeb20a833f9c28b65b5b5..0b2d332903187c2dd004d331e7ccae9eea6ac06e 100644 (file)
@@ -101,13 +101,6 @@ public class ComputeQProfileMeasureStep implements ComputationStep {
       addMeasure(project, path.current());
     }
 
-    @Override
-    public void visitModule(Component module, Path<QProfiles> path) {
-      QProfiles qProfiles = path.current();
-      addMeasure(module, path.current());
-      path.parent().add(qProfiles);
-    }
-
     private void addMeasure(Component component, QProfiles qProfiles) {
       if (!qProfiles.profilesByKey.isEmpty()) {
         measureRepository.add(component, qProfilesMetric, qProfiles.createMeasure());
index c8f8350da9888580b0776d1d4729b50c58ad6527..0a3b487afbfc9353e90bd073964257f3b94497d1 100644 (file)
@@ -55,7 +55,7 @@ public class CustomMeasuresCopyStep implements ComputationStep {
   @Override
   public void execute(ComputationStep.Context context) {
     try (DbSession session = dbClient.openSession(false)) {
-      CrawlerDepthLimit depthLimit = new CrawlerDepthLimit.Builder(Component.Type.MODULE)
+      CrawlerDepthLimit depthLimit = new CrawlerDepthLimit.Builder(Component.Type.PROJECT)
         .withViewsMaxDepth(Component.Type.PROJECT_VIEW);
       new DepthTraversalTypeAwareCrawler(
         new TypeAwareVisitorAdapter(depthLimit, ComponentVisitor.Order.PRE_ORDER) {
index 2384b847463d4c7665834882363d0efa36527362..749f6defa477c07389df4b71e880cb45f21568e6 100644 (file)
@@ -204,12 +204,6 @@ public class PersistComponentsStep implements ComputationStep {
       path.current().setDto(persistAndPopulateCache(project, dto));
     }
 
-    @Override
-    public void visitModule(Component module, Path<ComponentDtoHolder> path) {
-      ComponentDto dto = createForModule(module, path);
-      path.current().setDto(persistAndPopulateCache(module, dto));
-    }
-
     @Override
     public void visitDirectory(Component directory, Path<ComponentDtoHolder> path) {
       ComponentDto dto = createForDirectory(directory, path);
@@ -295,21 +289,6 @@ public class PersistComponentsStep implements ComputationStep {
       return res;
     }
 
-    public ComponentDto createForModule(Component module, PathAwareVisitor.Path<ComponentDtoHolder> path) {
-      ComponentDto res = createBase(module);
-
-      res.setScope(Scopes.PROJECT);
-      res.setQualifier(Qualifiers.MODULE);
-      res.setName(module.getName());
-      res.setLongName(res.name());
-      res.setPath(module.getReportAttributes().getPath());
-      res.setDescription(module.getDescription());
-
-      setRootAndParentModule(res, path);
-
-      return res;
-    }
-
     public ComponentDto createForDirectory(Component directory, PathAwareVisitor.Path<ComponentDtoHolder> path) {
       ComponentDto res = createBase(directory);
 
@@ -477,8 +456,7 @@ public class PersistComponentsStep implements ComputationStep {
 
     @Override
     public boolean apply(@Nonnull PathAwareVisitor.PathElement<ComponentDtoHolder> input) {
-      return input.getComponent().getType() == Component.Type.MODULE
-        || input.getComponent().getType() == Component.Type.PROJECT;
+      return input.getComponent().getType() == Component.Type.PROJECT;
     }
   }
 
index 18d27343ab91f80a66c75ef689fab193514e39e1..222aa7a35f9696f78e52f1dca0e6872c8e698499 100644 (file)
@@ -100,11 +100,6 @@ public class PersistMeasuresStep implements ComputationStep {
       persistMeasures(project);
     }
 
-    @Override
-    public void visitModule(Component module) {
-      persistMeasures(module);
-    }
-
     @Override
     public void visitDirectory(Component directory) {
       if (persistDirectories) {
index 0d05c04fc41eef5017f83c6ce6cab58ccd3723c0..a9b791a64d64b723d2c3234b219b0049b163872f 100644 (file)
@@ -106,12 +106,6 @@ public class SizeMeasuresStep implements ComputationStep {
       createMeasures(project, path.current());
     }
 
-    @Override
-    public void visitModule(Component module, Path<Counter> path) {
-      createMeasures(module, path.current());
-      path.parent().aggregate(path.current());
-    }
-
     @Override
     public void visitDirectory(Component directory, Path<Counter> path) {
       int fileCount = path.current().files;
index 7bf9d96f1b2302ba96a08702ec6abe920c51172c..9e1d810b927b4255fcbdc4e0531bf764369220b2 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Map;
 import java.util.Optional;
 import org.sonar.api.utils.MessageException;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
-import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.ComponentVisitor;
 import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit;
@@ -35,7 +34,6 @@ import org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawle
 import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
 import org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter;
 import org.sonar.ce.task.step.ComputationStep;
-import org.sonar.core.component.ComponentKeys;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDao;
@@ -60,14 +58,11 @@ public class ValidateProjectStep implements ComputationStep {
   private static final Joiner MESSAGES_JOINER = Joiner.on("\n  o ");
 
   private final DbClient dbClient;
-  private final BatchReportReader reportReader;
   private final TreeRootHolder treeRootHolder;
   private final AnalysisMetadataHolder analysisMetadataHolder;
 
-  public ValidateProjectStep(DbClient dbClient, BatchReportReader reportReader, TreeRootHolder treeRootHolder,
-    AnalysisMetadataHolder analysisMetadataHolder) {
+  public ValidateProjectStep(DbClient dbClient, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder) {
     this.dbClient = dbClient;
-    this.reportReader = reportReader;
     this.treeRootHolder = treeRootHolder;
     this.analysisMetadataHolder = analysisMetadataHolder;
   }
@@ -98,10 +93,8 @@ public class ValidateProjectStep implements ComputationStep {
     private final Map<String, ComponentDto> baseModulesByKey;
     private final List<String> validationMessages = new ArrayList<>();
 
-    private Component rawProject;
-
     public ValidateProjectsVisitor(DbSession session, ComponentDao componentDao, Map<String, ComponentDto> baseModulesByKey) {
-      super(CrawlerDepthLimit.MODULE, ComponentVisitor.Order.PRE_ORDER);
+      super(CrawlerDepthLimit.PROJECT, ComponentVisitor.Order.PRE_ORDER);
       this.session = session;
       this.componentDao = componentDao;
 
@@ -110,7 +103,6 @@ public class ValidateProjectStep implements ComputationStep {
 
     @Override
     public void visitProject(Component rawProject) {
-      this.rawProject = rawProject;
       String rawProjectKey = rawProject.getDbKey();
 
       Optional<ComponentDto> baseProject = loadBaseComponent(rawProjectKey);
@@ -124,50 +116,12 @@ public class ValidateProjectStep implements ComputationStep {
         Long lastAnalysisDate = snapshotDto.map(SnapshotDto::getCreatedAt).orElse(null);
         if (lastAnalysisDate != null && currentAnalysisDate <= lastAnalysisDate) {
           validationMessages.add(format("Date of analysis cannot be older than the date of the last known analysis on this project. Value: \"%s\". " +
-            "Latest analysis: \"%s\". It's only possible to rebuild the past in a chronological order.",
+              "Latest analysis: \"%s\". It's only possible to rebuild the past in a chronological order.",
             formatDateTime(new Date(currentAnalysisDate)), formatDateTime(new Date(lastAnalysisDate))));
         }
       }
     }
 
-    @Override
-    public void visitModule(Component rawModule) {
-      String rawProjectKey = rawProject.getDbKey();
-      String rawModuleKey = rawModule.getDbKey();
-      validateBatchKey(rawModule);
-
-      Optional<ComponentDto> baseModule = loadBaseComponent(rawModuleKey);
-      if (!baseModule.isPresent()) {
-        return;
-      }
-      validateModuleIsNotAlreadyUsedAsProject(baseModule.get(), rawProjectKey, rawModuleKey);
-      validateModuleKeyIsNotAlreadyUsedInAnotherProject(baseModule.get(), rawModuleKey);
-    }
-
-    private void validateModuleIsNotAlreadyUsedAsProject(ComponentDto baseModule, String rawProjectKey, String rawModuleKey) {
-      if (baseModule.projectUuid().equals(baseModule.uuid())) {
-        // module is actually a project
-        validationMessages.add(format("The project \"%s\" is already defined in SonarQube but not as a module of project \"%s\". "
-          + "If you really want to stop directly analysing project \"%s\", please first delete it from SonarQube and then relaunch the analysis of project \"%s\".",
-          rawModuleKey, rawProjectKey, rawModuleKey, rawProjectKey));
-      }
-    }
-
-    private void validateModuleKeyIsNotAlreadyUsedInAnotherProject(ComponentDto baseModule, String rawModuleKey) {
-      if (!baseModule.projectUuid().equals(baseModule.uuid()) && !baseModule.projectUuid().equals(rawProject.getUuid())) {
-        ComponentDto projectModule = componentDao.selectOrFailByUuid(session, baseModule.projectUuid());
-        validationMessages.add(format("Module \"%s\" is already part of project \"%s\"", rawModuleKey, projectModule.getDbKey()));
-      }
-    }
-
-    private void validateBatchKey(Component rawComponent) {
-      String batchKey = reportReader.readComponent(rawComponent.getReportAttributes().getRef()).getKey();
-      if (!ComponentKeys.isValidModuleKey(batchKey)) {
-        validationMessages.add(format("\"%s\" is not a valid project or module key. "
-          + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", batchKey));
-      }
-    }
-
     private Optional<ComponentDto> loadBaseComponent(String rawComponentKey) {
       ComponentDto baseComponent = baseModulesByKey.get(rawComponentKey);
       if (baseComponent == null) {
index 2f578d0701b3f652b4ef9a65f2514394adcd2f20..425c1d9d657f1859d7dd1d82f93d6ff9f233ad76 100644 (file)
@@ -309,7 +309,7 @@ public class PostProjectAnalysisTasksExecutorTest {
       }
 
       @Override
-      public String generateKey(ScannerReport.Component module, @Nullable ScannerReport.Component fileOrDir) {
+      public String generateKey(ScannerReport.Component project, @Nullable String fileOrDirPath) {
         throw new UnsupportedOperationException();
       }
     });
index 8be5dde98224429b86748ff887138f5b0f288a6e..1d009b59b4a9215dd886936dc76e27bb3a9723b2 100644 (file)
@@ -45,11 +45,6 @@ class CallRecorderPathAwareVisitor extends PathAwareVisitorAdapter<Integer> {
     callsRecords.add(reportCallRecord(project, path, "visitProject"));
   }
 
-  @Override
-  public void visitModule(Component module, Path<Integer> path) {
-    callsRecords.add(reportCallRecord(module, path, "visitModule"));
-  }
-
   @Override
   public void visitDirectory(Component directory, Path<Integer> path) {
     callsRecords.add(reportCallRecord(directory, path, "visitDirectory"));
index b359f38ae1822c83ba1fc7af9473634a3c1f06f7..b86a9af6c514ffdd7cbf7c4e340a254917a629e9 100644 (file)
@@ -34,11 +34,6 @@ class CallRecorderTypeAwareVisitor extends TypeAwareVisitorAdapter {
     callsRecords.add(reportCallRecord(project, "visitProject"));
   }
 
-  @Override
-  public void visitModule(Component module) {
-    callsRecords.add(reportCallRecord(module, "visitModule"));
-  }
-
   @Override
   public void visitDirectory(Component directory) {
     callsRecords.add(reportCallRecord(directory, "visitDirectory"));
index 4398bdb1f85567766142359ab4d42f145c209b1b..b5670aadf48f92045f0c700999edd7661f738dc9 100644 (file)
@@ -24,20 +24,14 @@ import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.VIEW;
-import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toReportRef;
+import static org.sonar.ce.task.projectanalysis.component.ComponentFunctions.toComponentUuid;
 
 public class ComponentFunctionsTest {
 
   private static final int SOME_INT = new Random().nextInt();
 
-  @Test(expected = IllegalStateException.class)
-  public void toReportRef_throws_ISE_if_Component_has_no_ReportAttributes() {
-    toReportRef().apply(ViewsComponent.builder(VIEW, 1).build());
-  }
-
   @Test
-  public void toReportRef_returns_the_ref_of_the_Component() {
-    assertThat(toReportRef().apply(ReportComponent.builder(PROJECT, SOME_INT).build())).isEqualTo(SOME_INT);
+  public void toComponentUuid_returns_the_ref_of_the_Component() {
+    assertThat(toComponentUuid().apply(ReportComponent.builder(PROJECT, SOME_INT).setUuid("uuid_" + SOME_INT).build())).isEqualTo("uuid_" + SOME_INT);
   }
 }
index 330d6090da73144068a67c76912c43629aaaa273..ff34a60fb674f2bddf2a8228bac64915aef6ec14 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.component;
 
-import com.google.common.collect.ImmutableList;
+import java.util.Arrays;
 import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -42,25 +41,17 @@ public class ComponentTest {
   @Test
   public void FILE_type_is_deeper_than_all_other_types() {
     assertThat(Component.Type.FILE.isDeeperThan(DIRECTORY)).isTrue();
-    assertThat(Component.Type.FILE.isDeeperThan(MODULE)).isTrue();
     assertThat(Component.Type.FILE.isDeeperThan(PROJECT)).isTrue();
   }
 
   @Test
-  public void DIRECTORY_type_is_deeper_than_MODULE_and_PROJECT() {
-    assertThat(Component.Type.DIRECTORY.isDeeperThan(MODULE)).isTrue();
+  public void DIRECTORY_type_is_deeper_than_PROJECT() {
     assertThat(Component.Type.DIRECTORY.isDeeperThan(PROJECT)).isTrue();
   }
 
-  @Test
-  public void MODULE_type_is_deeper_than_PROJECT() {
-    assertThat(Component.Type.MODULE.isDeeperThan(PROJECT)).isTrue();
-  }
-
   @Test
   public void FILE_type_is_higher_than_no_other_types() {
     assertThat(Component.Type.FILE.isHigherThan(DIRECTORY)).isFalse();
-    assertThat(Component.Type.FILE.isHigherThan(MODULE)).isFalse();
     assertThat(Component.Type.FILE.isHigherThan(PROJECT)).isFalse();
   }
 
@@ -69,30 +60,22 @@ public class ComponentTest {
     assertThat(Component.Type.DIRECTORY.isHigherThan(FILE)).isTrue();
   }
 
-  @Test
-  public void MODULE_type_is_higher_than_FILE_AND_DIRECTORY() {
-    assertThat(Component.Type.MODULE.isHigherThan(FILE)).isTrue();
-    assertThat(Component.Type.MODULE.isHigherThan(DIRECTORY)).isTrue();
-  }
-
   @Test
   public void PROJECT_type_is_higher_than_all_other_types() {
     assertThat(Component.Type.PROJECT.isHigherThan(FILE)).isTrue();
     assertThat(Component.Type.PROJECT.isHigherThan(DIRECTORY)).isTrue();
-    assertThat(Component.Type.PROJECT.isHigherThan(MODULE)).isTrue();
   }
 
   @Test
   public void any_type_is_not_higher_than_itself() {
     assertThat(Component.Type.FILE.isHigherThan(FILE)).isFalse();
     assertThat(Component.Type.DIRECTORY.isHigherThan(DIRECTORY)).isFalse();
-    assertThat(Component.Type.MODULE.isHigherThan(MODULE)).isFalse();
     assertThat(Component.Type.PROJECT.isHigherThan(PROJECT)).isFalse();
   }
 
   @Test
   public void PROJECT_MODULE_DIRECTORY_and_FILE_are_report_types_and_not_views_types() {
-    for (Component.Type type : ImmutableList.of(PROJECT, MODULE, DIRECTORY, FILE)) {
+    for (Component.Type type : Arrays.asList(PROJECT, DIRECTORY, FILE)) {
       assertThat(type.isReportType()).isTrue();
       assertThat(type.isViewsType()).isFalse();
     }
@@ -100,7 +83,7 @@ public class ComponentTest {
 
   @Test
   public void VIEW_SUBVIEW_and_PROJECT_VIEW_are_views_types_and_not_report_types() {
-    for (Component.Type type : ImmutableList.of(VIEW, SUBVIEW, PROJECT_VIEW)) {
+    for (Component.Type type : Arrays.asList(VIEW, SUBVIEW, PROJECT_VIEW)) {
       assertThat(type.isViewsType()).isTrue();
       assertThat(type.isReportType()).isFalse();
     }
index b1f62119178bfaab038083eda6d0608dcc87c861..f5fe6f8ab543017e976a908ce6f779e940e70a3e 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.ce.task.projectanalysis.component;
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.function.Function;
@@ -30,8 +31,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.ExternalResource;
-import org.mockito.Mockito;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
+import org.sonar.ce.task.projectanalysis.issue.IssueRelocationToRoot;
 import org.sonar.core.component.ComponentKeys;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -41,23 +42,24 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
-import static org.sonar.scanner.protocol.output.ScannerReport.Component.newBuilder;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.DIRECTORY;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.MODULE;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.PROJECT;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.UNRECOGNIZED;
+import static org.sonar.scanner.protocol.output.ScannerReport.Component.newBuilder;
 
 public class ComponentTreeBuilderTest {
 
-  private static final ComponentKeyGenerator KEY_GENERATOR = (module, component) -> "generated_"
-    + ComponentKeys.createEffectiveKey(module.getKey(), component != null ? component.getPath() : null);
-  private static final ComponentKeyGenerator PUBLIC_KEY_GENERATOR = (module, component) -> "public_"
-    + ComponentKeys.createEffectiveKey(module.getKey(), component != null ? component.getPath() : null);
+  private static final ComponentKeyGenerator KEY_GENERATOR = (project, path) -> "generated_"
+    + ComponentKeys.createEffectiveKey(project.getKey(), path);
+  private static final ComponentKeyGenerator PUBLIC_KEY_GENERATOR = (project, path) -> "public_"
+    + ComponentKeys.createEffectiveKey(project.getKey(), path);
   private static final Function<String, String> UUID_SUPPLIER = (componentKey) -> componentKey + "_uuid";
   private static final EnumSet<ScannerReport.Component.ComponentType> REPORT_TYPES = EnumSet.of(PROJECT, MODULE, DIRECTORY, FILE);
   private static final String NO_SCM_BASE_PATH = "";
@@ -71,7 +73,35 @@ public class ComponentTreeBuilderTest {
   private Project projectInDb = Project.from(newPrivateProjectDto(newOrganizationDto(), UUID_SUPPLIER.apply("K1")).setDbKey("K1").setDescription(null));
 
   @Test
-  public void build_throws_IAE_for_all_types_but_PROJECT_MODULE_DIRECTORY_FILE() {
+  public void build_throws_IAE_for_all_types_except_PROJECT_MODULE_DIRECTORY_FILE() {
+    Arrays.stream(ScannerReport.Component.ComponentType.values())
+      .filter((type) -> type != UNRECOGNIZED)
+      .filter((type) -> !REPORT_TYPES.contains(type))
+      .forEach(
+        (type) -> {
+          ScannerReport.Component project = newBuilder()
+            .setType(PROJECT)
+            .setKey(projectInDb.getKey())
+            .setRef(1)
+            .addChildRef(2)
+            .setProjectRelativePath("root")
+            .build();
+          scannerComponentProvider.add(newBuilder()
+            .setRef(2)
+            .setType(type)
+            .setProjectRelativePath("src")
+            .setLines(1));
+          try {
+            call(project);
+            fail("Should have thrown a IllegalArgumentException");
+          } catch (IllegalArgumentException e) {
+            assertThat(e).hasMessage("Unsupported component type '" + type + "'");
+          }
+        });
+  }
+
+  @Test
+  public void build_throws_IAE_if_root_is_not_PROJECT() {
     Arrays.stream(ScannerReport.Component.ComponentType.values())
       .filter((type) -> type != UNRECOGNIZED)
       .filter((type) -> !REPORT_TYPES.contains(type))
@@ -82,7 +112,7 @@ public class ComponentTreeBuilderTest {
             call(component);
             fail("Should have thrown a IllegalArgumentException");
           } catch (IllegalArgumentException e) {
-            assertThat(e).hasMessage("Unsupported component type '" + type + "'");
+            assertThat(e).hasMessage("Expected root component of type 'PROJECT'");
           }
         });
   }
@@ -223,150 +253,157 @@ public class ComponentTreeBuilderTest {
 
   @Test
   public void any_component_with_projectRelativePath_has_this_value_as_scmPath_if_scmBasePath_is_empty() {
-    String[] projectRelativePaths = {
-      randomAlphabetic(4),
-      randomAlphabetic(5),
-      randomAlphabetic(6),
-      randomAlphabetic(7)
-    };
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
       .setRef(1)
       .addChildRef(2)
-      .setProjectRelativePath(projectRelativePaths[0])
+      .setProjectRelativePath("root")
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
-      .setType(MODULE)
-      .setKey("M")
-      .setProjectRelativePath(projectRelativePaths[1])
-      .addChildRef(3));
-    scannerComponentProvider.add(newBuilder()
-      .setRef(3)
-      .setType(DIRECTORY)
-      .setPath("src/js")
-      .setProjectRelativePath(projectRelativePaths[2])
-      .addChildRef(4));
-    scannerComponentProvider.add(newBuilder()
-      .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
-      .setProjectRelativePath(projectRelativePaths[3])
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project, NO_SCM_BASE_PATH);
 
     assertThat(root.getReportAttributes().getScmPath())
-      .contains(projectRelativePaths[0]);
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getReportAttributes().getScmPath())
-      .contains(projectRelativePaths[1]);
-    Component directory = module.getChildren().iterator().next();
+      .contains("root");
+    Component directory = root.getChildren().iterator().next();
     assertThat(directory.getReportAttributes().getScmPath())
-      .contains(projectRelativePaths[2]);
+      .contains("src/js");
     Component file = directory.getChildren().iterator().next();
     assertThat(file.getReportAttributes().getScmPath())
-      .contains(projectRelativePaths[3]);
+      .contains("src/js/Foo.js");
   }
 
   @Test
   public void any_component_with_projectRelativePath_has_this_value_appended_to_scmBasePath_and_a_slash_as_scmPath_if_scmBasePath_is_not_empty() {
-    String[] projectRelativePaths = {
-      randomAlphabetic(4),
-      randomAlphabetic(5),
-      randomAlphabetic(6),
-      randomAlphabetic(7)
-    };
+    ScannerReport.Component project = createProject();
+    String scmBasePath = randomAlphabetic(10);
+
+    Component root = call(project, scmBasePath);
+    assertThat(root.getReportAttributes().getScmPath())
+      .contains(scmBasePath);
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getReportAttributes().getScmPath())
+      .contains(scmBasePath + "/src/js");
+    Component file = directory.getChildren().iterator().next();
+    assertThat(file.getReportAttributes().getScmPath())
+      .contains(scmBasePath + "/src/js/Foo.js");
+  }
+
+  private ScannerReport.Component createProject() {
+    ScannerReport.Component project = newBuilder()
+      .setType(PROJECT)
+      .setKey(projectInDb.getKey())
+      .setRef(1)
+      .addChildRef(2)
+      .build();
+    scannerComponentProvider.add(newBuilder()
+      .setRef(2)
+      .setType(FILE)
+      .setProjectRelativePath("src/js/Foo.js")
+      .setLines(1));
+    return project;
+  }
+
+  @Test
+  public void keys_of_directory_and_file_are_generated() {
+    ScannerReport.Component project = createProject();
+
+    Component root = call(project);
+    assertThat(root.getDbKey()).isEqualTo("generated_" + projectInDb.getKey());
+    assertThat(root.getKey()).isEqualTo("public_" + projectInDb.getKey());
+    assertThat(root.getChildren()).hasSize(1);
+
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getDbKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js");
+    assertThat(directory.getKey()).isEqualTo("public_" + projectInDb.getKey() + ":src/js");
+    assertThat(directory.getChildren()).hasSize(1);
+
+    Component file = directory.getChildren().iterator().next();
+    assertThat(file.getDbKey()).isEqualTo("generated_" + projectInDb.getKey() + ":src/js/Foo.js");
+    assertThat(file.getKey()).isEqualTo("public_" + projectInDb.getKey() + ":src/js/Foo.js");
+    assertThat(file.getChildren()).isEmpty();
+  }
+
+  @Test
+  public void modules_are_not_created() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
       .setRef(1)
       .addChildRef(2)
-      .setProjectRelativePath(projectRelativePaths[0])
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(MODULE)
       .setKey("M")
-      .setProjectRelativePath(projectRelativePaths[1])
       .addChildRef(3));
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
       .setType(DIRECTORY)
-      .setPath("src/js")
-      .setProjectRelativePath(projectRelativePaths[2])
+      .setProjectRelativePath("src/js")
       .addChildRef(4));
     scannerComponentProvider.add(newBuilder()
       .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
-      .setProjectRelativePath(projectRelativePaths[3])
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
-    String scmBasePath = randomAlphabetic(10);
 
-    Component root = call(project, scmBasePath);
+    Component root = call(project);
 
-    assertThat(root.getReportAttributes().getScmPath())
-      .contains(scmBasePath + "/" + projectRelativePaths[0]);
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getReportAttributes().getScmPath())
-      .contains(scmBasePath + "/" + projectRelativePaths[1]);
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getReportAttributes().getScmPath())
-      .contains(scmBasePath + "/" + projectRelativePaths[2]);
-    Component file = directory.getChildren().iterator().next();
-    assertThat(file.getReportAttributes().getScmPath())
-      .contains(scmBasePath + "/" + projectRelativePaths[3]);
+    List<Component> components = root.getChildren();
+    assertThat(components).extracting("type").containsOnly(Component.Type.DIRECTORY);
   }
 
   @Test
-  public void keys_of_module_directory_and_file_are_generated() {
+  public void folder_hierarchy_is_created() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
       .setRef(1)
       .addChildRef(2)
+      .addChildRef(3)
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
-      .setType(MODULE)
-      .setKey("M")
-      .addChildRef(3));
+      .setType(DIRECTORY)
+      .setProjectRelativePath("src/main/xoo")
+      .addChildRef(4));
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
       .setType(DIRECTORY)
-      .setPath("src/js")
-      .addChildRef(4));
+      .setProjectRelativePath("src/test/xoo/org/sonar")
+      .addChildRef(5));
     scannerComponentProvider.add(newBuilder()
       .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/main/xoo/Foo1.js")
+      .setLines(1));
+    scannerComponentProvider.add(newBuilder()
+      .setRef(5)
+      .setType(FILE)
+      .setProjectRelativePath("src/test/xoo/org/sonar/Foo2.js")
       .setLines(1));
 
     Component root = call(project);
-    assertThat(root.getDbKey()).isEqualTo("generated_" + projectInDb.getKey());
-    assertThat(root.getKey()).isEqualTo("public_" + projectInDb.getKey());
-    assertThat(root.getChildren()).hasSize(1);
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getDbKey()).isEqualTo("generated_M");
-    assertThat(module.getKey()).isEqualTo("public_M");
-    assertThat(module.getChildren()).hasSize(1);
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getName()).isEqualTo("public_K1:src");
 
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getDbKey()).isEqualTo("generated_M:src/js");
-    assertThat(directory.getKey()).isEqualTo("public_M:src/js");
-    assertThat(directory.getChildren()).hasSize(1);
+    // folders are collapsed and they only contain one directory
+    Component d1 = directory.getChildren().get(0);
+    assertThat(d1.getName()).isEqualTo("public_K1:src/main/xoo");
 
-    Component file = directory.getChildren().iterator().next();
-    assertThat(file.getDbKey()).isEqualTo("generated_M:src/js/Foo.js");
-    assertThat(file.getKey()).isEqualTo("public_M:src/js/Foo.js");
-    assertThat(file.getChildren()).isEmpty();
+    Component d2 = directory.getChildren().get(1);
+    assertThat(d2.getName()).isEqualTo("public_K1:src/test/xoo/org/sonar");
   }
 
   @Test
-  public void names_of_module_directory_and_file_are_public_keys_if_names_are_absent_from_report() {
+  public void directories_are_collapsed() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
@@ -375,34 +412,26 @@ public class ComponentTreeBuilderTest {
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
-      .setType(MODULE)
-      .setKey("M")
+      .setType(DIRECTORY)
+      .setPath("/")
       .addChildRef(3));
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
-      .setType(DIRECTORY)
-      .setPath("src/js")
-      .addChildRef(4));
-    scannerComponentProvider.add(newBuilder()
-      .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getName()).isEqualTo("public_M");
-
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getName()).isEqualTo("public_M:src/js");
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getName()).isEqualTo("public_K1:src/js");
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js");
+    assertThat(file.getName()).isEqualTo("public_K1:src/js/Foo.js");
   }
 
   @Test
-  public void names_of_module_directory_and_file_are_public_keys_if_names_are_empty_in_report() {
+  public void names_of_directory_and_file_are_public_keys_if_names_are_empty_in_report() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
@@ -411,33 +440,61 @@ public class ComponentTreeBuilderTest {
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
-      .setType(MODULE)
-      .setKey("M")
+      .setType(DIRECTORY)
+      .setProjectRelativePath("src/js")
       .setName("")
       .addChildRef(3));
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
-      .setType(DIRECTORY)
-      .setPath("src/js")
+      .setType(FILE)
+      .setProjectRelativePath("src/js/Foo.js")
       .setName("")
-      .addChildRef(4));
+      .setLines(1));
+
+    Component root = call(project);
+
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getName()).isEqualTo("public_K1:src/js");
+
+    Component file = directory.getChildren().iterator().next();
+    assertThat(file.getName()).isEqualTo("public_K1:src/js/Foo.js");
+  }
+
+  @Test
+  public void create_full_hierarchy_of_directories() {
+    ScannerReport.Component project = newBuilder()
+      .setType(PROJECT)
+      .setKey(projectInDb.getKey())
+      .setRef(1)
+      .addChildRef(2)
+      .addChildRef(3)
+      .build();
     scannerComponentProvider.add(newBuilder()
-      .setRef(4)
+      .setRef(2)
+      .setType(FILE)
+      .setProjectRelativePath("src/java/Bar.java")
+      .setName("")
+      .setLines(2));
+    scannerComponentProvider.add(newBuilder()
+      .setRef(3)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setName("")
       .setLines(1));
 
     Component root = call(project);
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getName()).isEqualTo("public_M");
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getName()).isEqualTo("public_K1:src");
 
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getName()).isEqualTo("public_M:src/js");
+    Component directoryJava = directory.getChildren().get(0);
+    assertThat(directoryJava.getName()).isEqualTo("public_K1:src/java");
 
-    Component file = directory.getChildren().iterator().next();
-    assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js");
+    Component directoryJs = directory.getChildren().get(1);
+    assertThat(directoryJs.getName()).isEqualTo("public_K1:src/js");
+
+    Component file = directoryJs.getChildren().iterator().next();
+    assertThat(file.getName()).isEqualTo("public_K1:src/js/Foo.js");
   }
 
   private void assertThatFileAttributesAreNotSet(Component root) {
@@ -450,7 +507,7 @@ public class ComponentTreeBuilderTest {
   }
 
   @Test
-  public void keys_of_module_directory_and_files_includes_name_of_closest_module() {
+  public void keys_of_directory_and_files_includes_always_root_project() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey("project 1")
@@ -459,51 +516,24 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder().setRef(11).setType(MODULE).setKey("module 1").addChildRef(12).addChildRef(22).addChildRef(32));
     scannerComponentProvider.add(newBuilder().setRef(12).setType(MODULE).setKey("module 2").addChildRef(13).addChildRef(23).addChildRef(33));
     scannerComponentProvider.add(newBuilder().setRef(13).setType(MODULE).setKey("module 3").addChildRef(24).addChildRef(34));
-    scannerComponentProvider.add(newBuilder().setRef(21).setType(DIRECTORY).setPath("directory in project").addChildRef(35));
-    scannerComponentProvider.add(newBuilder().setRef(22).setType(DIRECTORY).setPath("directory in module 1").addChildRef(36));
-    scannerComponentProvider.add(newBuilder().setRef(23).setType(DIRECTORY).setPath("directory in module 2").addChildRef(37));
-    scannerComponentProvider.add(newBuilder().setRef(24).setType(DIRECTORY).setPath("directory in module 3").addChildRef(38));
-    scannerComponentProvider.add(newBuilder().setRef(31).setType(FILE).setPath("file in project").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(32).setType(FILE).setPath("file in module 1").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(33).setType(FILE).setPath("file in module 2").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(34).setType(FILE).setPath("file in module 3").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(35).setType(FILE).setPath("file in directory in project").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(36).setType(FILE).setPath("file in directory in module 1").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(37).setType(FILE).setPath("file in directory in module 2").setLines(1));
-    scannerComponentProvider.add(newBuilder().setRef(38).setType(FILE).setPath("file in directory in module 3").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(21).setType(DIRECTORY).setProjectRelativePath("directory in project").addChildRef(35));
+    scannerComponentProvider.add(newBuilder().setRef(22).setType(DIRECTORY).setProjectRelativePath("directory in module 1").addChildRef(36));
+    scannerComponentProvider.add(newBuilder().setRef(23).setType(DIRECTORY).setProjectRelativePath("directory in module 2").addChildRef(37));
+    scannerComponentProvider.add(newBuilder().setRef(24).setType(DIRECTORY).setProjectRelativePath("directory in module 3").addChildRef(38));
+    scannerComponentProvider.add(newBuilder().setRef(31).setType(FILE).setProjectRelativePath("file in project").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(32).setType(FILE).setProjectRelativePath("file in module 1").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(33).setType(FILE).setProjectRelativePath("file in module 2").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(34).setType(FILE).setProjectRelativePath("file in module 3").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(35).setType(FILE).setProjectRelativePath("file in directory in project").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(36).setType(FILE).setProjectRelativePath("file in directory in module 1").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(37).setType(FILE).setProjectRelativePath("file in directory in module 2").setLines(1));
+    scannerComponentProvider.add(newBuilder().setRef(38).setType(FILE).setProjectRelativePath("file in directory in module 3").setLines(1));
 
     Component root = call(project);
-    Map<Integer, Component> componentsByRef = indexComponentByRef(root);
-    assertThat(componentsByRef.get(11).getDbKey()).isEqualTo("generated_module 1");
-    assertThat(componentsByRef.get(11).getKey()).isEqualTo("public_module 1");
-    assertThat(componentsByRef.get(12).getDbKey()).isEqualTo("generated_module 2");
-    assertThat(componentsByRef.get(12).getKey()).isEqualTo("public_module 2");
-    assertThat(componentsByRef.get(13).getDbKey()).isEqualTo("generated_module 3");
-    assertThat(componentsByRef.get(13).getKey()).isEqualTo("public_module 3");
-    assertThat(componentsByRef.get(21).getDbKey()).startsWith("generated_project 1:");
-    assertThat(componentsByRef.get(21).getKey()).startsWith("public_project 1:");
-    assertThat(componentsByRef.get(22).getDbKey()).startsWith("generated_module 1:");
-    assertThat(componentsByRef.get(22).getKey()).startsWith("public_module 1:");
-    assertThat(componentsByRef.get(23).getDbKey()).startsWith("generated_module 2:");
-    assertThat(componentsByRef.get(23).getKey()).startsWith("public_module 2:");
-    assertThat(componentsByRef.get(24).getDbKey()).startsWith("generated_module 3:");
-    assertThat(componentsByRef.get(24).getKey()).startsWith("public_module 3:");
-    assertThat(componentsByRef.get(31).getDbKey()).startsWith("generated_project 1:");
-    assertThat(componentsByRef.get(31).getKey()).startsWith("public_project 1:");
-    assertThat(componentsByRef.get(32).getDbKey()).startsWith("generated_module 1:");
-    assertThat(componentsByRef.get(32).getKey()).startsWith("public_module 1:");
-    assertThat(componentsByRef.get(33).getDbKey()).startsWith("generated_module 2:");
-    assertThat(componentsByRef.get(33).getKey()).startsWith("public_module 2:");
-    assertThat(componentsByRef.get(34).getDbKey()).startsWith("generated_module 3:");
-    assertThat(componentsByRef.get(34).getKey()).startsWith("public_module 3:");
-    assertThat(componentsByRef.get(35).getDbKey()).startsWith("generated_project 1:");
-    assertThat(componentsByRef.get(35).getKey()).startsWith("public_project 1:");
-    assertThat(componentsByRef.get(36).getDbKey()).startsWith("generated_module 1:");
-    assertThat(componentsByRef.get(36).getKey()).startsWith("public_module 1:");
-    assertThat(componentsByRef.get(37).getDbKey()).startsWith("generated_module 2:");
-    assertThat(componentsByRef.get(37).getKey()).startsWith("public_module 2:");
-    assertThat(componentsByRef.get(38).getDbKey()).startsWith("generated_module 3:");
-    assertThat(componentsByRef.get(38).getKey()).startsWith("public_module 3:");
+    Map<String, Component> componentsByKey = indexComponentByKey(root);
+
+    assertThat(componentsByKey.values()).extracting("key").startsWith("public_project 1");
+    assertThat(componentsByKey.values()).extracting("dbKey").startsWith("generated_project 1");
   }
 
   @Test
@@ -522,25 +552,22 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
       .setType(DIRECTORY)
-      .setPath("src/js")
+      .setProjectRelativePath("src/js")
       .addChildRef(4));
     scannerComponentProvider.add(newBuilder()
       .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
     assertThat(root.getUuid()).isEqualTo("generated_c1_uuid");
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getUuid()).isEqualTo("generated_c2_uuid");
-
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getUuid()).isEqualTo("generated_c2:src/js_uuid");
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getUuid()).isEqualTo("generated_c1:src/js_uuid");
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getUuid()).isEqualTo("generated_c2:src/js/Foo.js_uuid");
+    assertThat(file.getUuid()).isEqualTo("generated_c1:src/js/Foo.js_uuid");
   }
 
   @Test
@@ -557,20 +584,17 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(3)
       .setType(DIRECTORY)
-      .setPath("src/js")
+      .setProjectRelativePath("src/js")
       .addChildRef(4));
     scannerComponentProvider.add(newBuilder()
       .setRef(4)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getDescription()).isNull();
-
-    Component directory = module.getChildren().iterator().next();
+    Component directory = root.getChildren().iterator().next();
     assertThat(directory.getDescription()).isNull();
 
     Component file = directory.getChildren().iterator().next();
@@ -594,21 +618,18 @@ public class ComponentTreeBuilderTest {
       .setRef(3)
       .setType(DIRECTORY)
       .setDescription("")
-      .setPath("src/js")
+      .setProjectRelativePath("src/js")
       .addChildRef(4));
     scannerComponentProvider.add(newBuilder()
       .setRef(4)
       .setType(FILE)
       .setDescription("")
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
 
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getDescription()).isNull();
-
-    Component directory = module.getChildren().iterator().next();
+    Component directory = root.getChildren().iterator().next();
     assertThat(directory.getDescription()).isNull();
 
     Component file = directory.getChildren().iterator().next();
@@ -624,29 +645,20 @@ public class ComponentTreeBuilderTest {
       .build();
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
-      .setType(MODULE)
-      .setDescription("b")
-      .addChildRef(3));
-    scannerComponentProvider.add(newBuilder()
-      .setRef(3)
       .setType(DIRECTORY)
       .setDescription("c")
-      .setPath("src/js")
-      .addChildRef(4));
+      .setProjectRelativePath("src/js")
+      .addChildRef(3));
     scannerComponentProvider.add(newBuilder()
-      .setRef(4)
+      .setRef(3)
       .setType(FILE)
       .setDescription("d")
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
-
-    Component module = root.getChildren().iterator().next();
-    assertThat(module.getDescription()).isEqualTo("b");
-
-    Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getDescription()).isEqualTo("c");
+    Component directory = root.getChildren().iterator().next();
+    assertThat(directory.getDescription()).isNull();
 
     Component file = directory.getChildren().iterator().next();
     assertThat(file.getDescription()).isEqualTo("d");
@@ -662,11 +674,12 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1));
 
     Component root = call(project);
-    Component file = root.getChildren().iterator().next();
+    Component dir = root.getChildren().iterator().next();
+    Component file = dir.getChildren().iterator().next();
     assertThat(file.getFileAttributes().getLines()).isEqualTo(1);
     assertThat(file.getFileAttributes().getLanguageKey()).isNull();
     assertThat(file.getFileAttributes().isUnitTest()).isFalse();
@@ -682,12 +695,14 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1)
       .setLanguage(""));
 
     Component root = call(project);
-    Component file = root.getChildren().iterator().next();
+    Component dir2 = root.getChildren().iterator().next();
+
+    Component file = dir2.getChildren().iterator().next();
     assertThat(file.getFileAttributes().getLanguageKey()).isNull();
   }
 
@@ -701,13 +716,14 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(1)
       .setLanguage("js")
       .setIsTest(true));
 
     Component root = call(project);
-    Component file = root.getChildren().iterator().next();
+    Component dir = root.getChildren().iterator().next();
+    Component file = dir.getChildren().iterator().next();
     assertThat(file.getFileAttributes().getLines()).isEqualTo(1);
     assertThat(file.getFileAttributes().getLanguageKey()).isEqualTo("js");
     assertThat(file.getFileAttributes().isUnitTest()).isTrue();
@@ -723,7 +739,7 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js"));
+      .setProjectRelativePath("src/js/Foo.js"));
 
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("File 'src/js/Foo.js' has no line");
@@ -741,7 +757,7 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(0));
 
     expectedException.expect(IllegalArgumentException.class);
@@ -760,7 +776,7 @@ public class ComponentTreeBuilderTest {
     scannerComponentProvider.add(newBuilder()
       .setRef(2)
       .setType(FILE)
-      .setPath("src/js/Foo.js")
+      .setProjectRelativePath("src/js/Foo.js")
       .setLines(-10));
 
     expectedException.expect(IllegalArgumentException.class);
@@ -807,9 +823,10 @@ public class ComponentTreeBuilderTest {
   }
 
   private ComponentTreeBuilder newUnderTest(@Nullable SnapshotDto baseAnalysis, boolean mainBranch) {
-    Branch branch = Mockito.mock(Branch.class);
+    Branch branch = mock(Branch.class);
     when(branch.isMain()).thenReturn(mainBranch);
-    return new ComponentTreeBuilder(KEY_GENERATOR, PUBLIC_KEY_GENERATOR, UUID_SUPPLIER, scannerComponentProvider, projectInDb, branch, baseAnalysis);
+    return new ComponentTreeBuilder(KEY_GENERATOR, PUBLIC_KEY_GENERATOR, UUID_SUPPLIER, scannerComponentProvider, projectInDb, branch, baseAnalysis,
+      mock(IssueRelocationToRoot.class));
   }
 
   private static Map<Integer, Component> indexComponentByRef(Component root) {
@@ -823,4 +840,16 @@ public class ComponentTreeBuilderTest {
       }).visit(root);
     return componentsByRef;
   }
+
+  private static Map<String, Component> indexComponentByKey(Component root) {
+    Map<String, Component> componentsByKey = new HashMap<>();
+    new DepthTraversalTypeAwareCrawler(
+      new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, PRE_ORDER) {
+        @Override
+        public void visitAny(Component any) {
+          componentsByKey.put(any.getDbKey(), any);
+        }
+      }).visit(root);
+    return componentsByKey;
+  }
 }
index 3126c329147176bc64f28153dedc18462e0b0b80..2d76be70a4b15b4d518e7547ba4af18a283af43b 100644 (file)
@@ -91,31 +91,6 @@ public class CrawlerDepthLimitTest {
     assertIsHigherThanViewsType(CrawlerDepthLimit.PROJECT);
   }
 
-  @Test
-  public void MODULE_isSameAs_only_MODULE_type() {
-    assertIsSameAs(CrawlerDepthLimit.MODULE, Type.MODULE);
-  }
-
-  @Test
-  public void MODULE_isDeeper_than_no_views_types() {
-    assertIsDeeperThanViewsType(CrawlerDepthLimit.MODULE);
-  }
-
-  @Test
-  public void MODULE_isDeeper_than_only_PROJECT_report_types() {
-    assertIsDeeperThanReportType(CrawlerDepthLimit.MODULE, Type.PROJECT);
-  }
-
-  @Test
-  public void MODULE_isHigher_than_no_views_types() {
-    assertIsHigherThanViewsType(CrawlerDepthLimit.MODULE);
-  }
-
-  @Test
-  public void MODULE_isHigher_than_only_DIRECTORY_and_FILE() {
-    assertIsHigherThanReportType(CrawlerDepthLimit.MODULE, Type.DIRECTORY, Type.FILE);
-  }
-
   @Test
   public void DIRECTORY_isSameAs_only_DIRECTORY_type() {
     assertIsSameAs(CrawlerDepthLimit.DIRECTORY, Type.DIRECTORY);
@@ -127,8 +102,8 @@ public class CrawlerDepthLimitTest {
   }
 
   @Test
-  public void DIRECTORY_isDeeper_than_only_PROJECT_and_MODULE_report_types() {
-    assertIsDeeperThanReportType(CrawlerDepthLimit.DIRECTORY, Type.PROJECT, Type.MODULE);
+  public void DIRECTORY_isDeeper_than_only_PROJECT_report_type() {
+    assertIsDeeperThanReportType(CrawlerDepthLimit.DIRECTORY, Type.PROJECT);
   }
 
   @Test
@@ -165,7 +140,7 @@ public class CrawlerDepthLimitTest {
 
   @Test
   public void FILE_isDeeper_than_only_PROJECT_MODULE_and_DIRECTORY_report_types() {
-    assertIsDeeperThanReportType(CrawlerDepthLimit.FILE, Type.PROJECT, Type.MODULE, Type.DIRECTORY);
+    assertIsDeeperThanReportType(CrawlerDepthLimit.FILE, Type.PROJECT, Type.DIRECTORY);
   }
 
   @Test
@@ -254,7 +229,7 @@ public class CrawlerDepthLimitTest {
 
   @Test
   public void LEAVES_isDeeper_than_PROJECT_MODULE_and_DIRECTORY_report_types() {
-    assertIsDeeperThanReportType(CrawlerDepthLimit.LEAVES, Type.PROJECT, Type.MODULE, Type.DIRECTORY);
+    assertIsDeeperThanReportType(CrawlerDepthLimit.LEAVES, Type.PROJECT, Type.DIRECTORY);
   }
 
   @Test
index c8ce6d25ae6ff3f83e263a42a0cc37297b0847c0..9ad91d8af5dbfedca7a5cca8a10af7191e959a81 100644 (file)
@@ -34,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class DefaultBranchImplTest {
 
   private static final ScannerReport.Component PROJECT = ScannerReport.Component.newBuilder().setType(ComponentType.PROJECT).setKey("P").build();
-  private static final ScannerReport.Component MODULE = ScannerReport.Component.newBuilder().setType(ComponentType.MODULE).setKey("M").build();
-  private static final ScannerReport.Component FILE = ScannerReport.Component.newBuilder().setType(ComponentType.FILE).setPath("src/Foo.js").build();
+  private static final ScannerReport.Component FILE = ScannerReport.Component.newBuilder().setType(ComponentType.FILE).setProjectRelativePath("src/Foo.js").build();
 
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
@@ -60,8 +59,7 @@ public class DefaultBranchImplTest {
     assertThat(branch.supportsCrossProjectCpd()).isTrue();
 
     assertThat(branch.generateKey(PROJECT, null)).isEqualTo("P");
-    assertThat(branch.generateKey(MODULE, null)).isEqualTo("M");
-    assertThat(branch.generateKey(MODULE, FILE)).isEqualTo("M:src/Foo.js");
+    assertThat(branch.generateKey(PROJECT, FILE.getProjectRelativePath())).isEqualTo("P:src/Foo.js");
   }
 
   @Test
@@ -75,8 +73,7 @@ public class DefaultBranchImplTest {
     assertThat(branch.supportsCrossProjectCpd()).isFalse();
 
     assertThat(branch.generateKey(PROJECT, null)).isEqualTo("P:bar");
-    assertThat(branch.generateKey(MODULE, null)).isEqualTo("M:bar");
-    assertThat(branch.generateKey(MODULE, FILE)).isEqualTo("M:bar:src/Foo.js");
+    assertThat(branch.generateKey(PROJECT, FILE.getProjectRelativePath())).isEqualTo("P:bar:src/Foo.js");
   }
 
   private void assertThatNameIsCorrect(@Nullable String name) {
index 2869436110cf73be50f47d62409d3b686c2e66e0..967118c869bbadd63b40942fdf63027e5e6a29e1 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.task.projectanalysis.component;
 
-import com.google.common.base.Function;
+import java.util.function.Function;
 import javax.annotation.Nullable;
 import org.junit.rules.ExternalResource;
 
@@ -52,7 +52,7 @@ public class MutableDbIdsRepositoryRule extends ExternalResource implements Muta
       @Nullable
       @Override
       public String apply(Component input) {
-        return input.getType().isReportType() ? String.valueOf(input.getReportAttributes().getRef()) : input.getDbKey();
+        return input.getType().isReportType() ? input.getUuid() : input.getDbKey();
       }
     });
   }
index ab56fc8e2a7a87b2c005035a305bba6d37d7c175..89e4afc75b2248f7a2a4f89328c4bf8b91ee1100 100644 (file)
@@ -166,12 +166,12 @@ public class ReportComponent implements Component {
       return false;
     }
     ReportComponent that = (ReportComponent) o;
-    return reportAttributes.getRef() == that.reportAttributes.getRef();
+    return uuid.equals(that.uuid);
   }
 
   @Override
   public int hashCode() {
-    return this.reportAttributes.getRef();
+    return uuid.hashCode();
   }
 
   @Override
index 64423cbbd0b6243fc6e617e0060e2513f1a78ab7..96613409b6a6e26e3f46059ebe3b7e728dc49375 100644 (file)
@@ -28,7 +28,6 @@ import static com.google.common.collect.ImmutableList.of;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
@@ -36,30 +35,16 @@ import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order
 public class ReportPathAwareVisitorTest {
 
   private static final int ROOT_REF = 1;
-  private static final ReportComponent SOME_TREE_ROOT = ReportComponent.builder(PROJECT, ROOT_REF)
-    .addChildren(
-      ReportComponent.builder(MODULE, 11)
-        .addChildren(
-          ReportComponent.builder(DIRECTORY, 111)
-            .addChildren(
-              ReportComponent.builder(FILE, 1111).build(),
-              ReportComponent.builder(FILE, 1112).build())
-            .build(),
-          ReportComponent.builder(DIRECTORY, 112)
-            .addChildren(
-              ReportComponent.builder(FILE, 1121).build())
-            .build())
-        .build(),
-      ReportComponent.builder(MODULE, 12)
-        .addChildren(
-          ReportComponent.builder(MODULE, 121)
-            .addChildren(
-              ReportComponent.builder(DIRECTORY, 1211)
-                .addChildren(
-                  ReportComponent.builder(FILE, 12111).build())
-                .build())
-            .build())
+  private static final ReportComponent SOME_TREE_ROOT = ReportComponent.builder(PROJECT, ROOT_REF).addChildren(
+    ReportComponent.builder(DIRECTORY, 11).addChildren(
+      ReportComponent.builder(FILE, 111).build(),
+      ReportComponent.builder(FILE, 112).build())
+      .build(),
+    ReportComponent.builder(DIRECTORY, 12).addChildren(
+      ReportComponent.builder(DIRECTORY, 121).addChildren(
+        ReportComponent.builder(FILE, 1211).build())
         .build())
+      .build())
     .build();
 
   @Test
@@ -71,25 +56,17 @@ public class ReportPathAwareVisitorTest {
       newCallRecord("visitAny", 1, null, of(1)),
       newCallRecord("visitProject", 1, null, of(1)),
       newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
+      newCallRecord("visitDirectory", 11, 1, of(11, 1)),
       newCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitAny", 1111, 111, of(1111, 111, 11, 1)),
-      newCallRecord("visitFile", 1111, 111, of(1111, 111, 11, 1)),
-      newCallRecord("visitAny", 1112, 111, of(1112, 111, 11, 1)),
-      newCallRecord("visitFile", 1112, 111, of(1112, 111, 11, 1)),
+      newCallRecord("visitFile", 111, 11, of(111, 11, 1)),
       newCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitAny", 1121, 112, of(1121, 112, 11, 1)),
-      newCallRecord("visitFile", 1121, 112, of(1121, 112, 11, 1)),
+      newCallRecord("visitFile", 112, 11, of(112, 11, 1)),
       newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
+      newCallRecord("visitDirectory", 12, 1, of(12, 1)),
       newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1)),
+      newCallRecord("visitDirectory", 121, 12, of(121, 12, 1)),
       newCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitAny", 12111, 1211, of(12111, 1211, 121, 12, 1)),
-      newCallRecord("visitFile", 12111, 1211, of(12111, 1211, 121, 12, 1))).iterator();
+      newCallRecord("visitFile", 1211, 121, of(1211, 121, 12, 1))).iterator();
     verifyCallRecords(expected, underTest.callsRecords.iterator());
   }
 
@@ -102,34 +79,11 @@ public class ReportPathAwareVisitorTest {
       newCallRecord("visitAny", 1, null, of(1)),
       newCallRecord("visitProject", 1, null, of(1)),
       newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
-      newCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
-      newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1))).iterator();
-    verifyCallRecords(expected, underTest.callsRecords.iterator());
-  }
-
-  @Test
-  public void verify_preOrder_visit_call_when_visit_tree_with_depth_MODULE() {
-    CallRecorderPathAwareVisitor underTest = new CallRecorderPathAwareVisitor(CrawlerDepthLimit.MODULE, PRE_ORDER);
-    new PathAwareCrawler<>(underTest).visit(SOME_TREE_ROOT);
-
-    Iterator<PathAwareCallRecord> expected = of(
-      newCallRecord("visitAny", 1, null, of(1)),
-      newCallRecord("visitProject", 1, null, of(1)),
-      newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
+      newCallRecord("visitDirectory", 11, 1, of(11, 1)),
       newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
+      newCallRecord("visitDirectory", 12, 1, of(12, 1)),
       newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1))).iterator();
+      newCallRecord("visitDirectory", 121, 12, of(121, 12, 1))).iterator();
     verifyCallRecords(expected, underTest.callsRecords.iterator());
   }
 
@@ -150,26 +104,18 @@ public class ReportPathAwareVisitorTest {
     new PathAwareCrawler<>(underTest).visit(SOME_TREE_ROOT);
 
     Iterator<PathAwareCallRecord> expected = of(
-      newCallRecord("visitAny", 1111, 111, of(1111, 111, 11, 1)),
-      newCallRecord("visitFile", 1111, 111, of(1111, 111, 11, 1)),
-      newCallRecord("visitAny", 1112, 111, of(1112, 111, 11, 1)),
-      newCallRecord("visitFile", 1112, 111, of(1112, 111, 11, 1)),
       newCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitAny", 1121, 112, of(1121, 112, 11, 1)),
-      newCallRecord("visitFile", 1121, 112, of(1121, 112, 11, 1)),
+      newCallRecord("visitFile", 111, 11, of(111, 11, 1)),
       newCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
+      newCallRecord("visitFile", 112, 11, of(112, 11, 1)),
       newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
-      newCallRecord("visitAny", 12111, 1211, of(12111, 1211, 121, 12, 1)),
-      newCallRecord("visitFile", 12111, 1211, of(12111, 1211, 121, 12, 1)),
+      newCallRecord("visitDirectory", 11, 1, of(11, 1)),
       newCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
+      newCallRecord("visitFile", 1211, 121, of(1211, 121, 12, 1)),
       newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1)),
+      newCallRecord("visitDirectory", 121, 12, of(121, 12, 1)),
       newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
+      newCallRecord("visitDirectory", 12, 1, of(12, 1)),
       newCallRecord("visitAny", 1, null, of(1)),
       newCallRecord("visitProject", 1, null, of(1))).iterator();
     verifyCallRecords(expected, underTest.callsRecords.iterator());
@@ -180,36 +126,13 @@ public class ReportPathAwareVisitorTest {
     CallRecorderPathAwareVisitor underTest = new CallRecorderPathAwareVisitor(CrawlerDepthLimit.DIRECTORY, POST_ORDER);
     new PathAwareCrawler<>(underTest).visit(SOME_TREE_ROOT);
 
-    Iterator<PathAwareCallRecord> expected = of(
-      newCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      newCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
-      newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
-      newCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
-      newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
-      newCallRecord("visitAny", 1, null, of(1)),
-      newCallRecord("visitProject", 1, null, of(1))).iterator();
-    verifyCallRecords(expected, underTest.callsRecords.iterator());
-  }
-
-  @Test
-  public void verify_postOrder_visit_call_when_visit_tree_with_depth_MODULE() {
-    CallRecorderPathAwareVisitor underTest = new CallRecorderPathAwareVisitor(CrawlerDepthLimit.MODULE, POST_ORDER);
-    new PathAwareCrawler<>(underTest).visit(SOME_TREE_ROOT);
-
     Iterator<PathAwareCallRecord> expected = of(
       newCallRecord("visitAny", 11, 1, of(11, 1)),
-      newCallRecord("visitModule", 11, 1, of(11, 1)),
+      newCallRecord("visitDirectory", 11, 1, of(11, 1)),
       newCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      newCallRecord("visitModule", 121, 12, of(121, 12, 1)),
+      newCallRecord("visitDirectory", 121, 12, of(121, 12, 1)),
       newCallRecord("visitAny", 12, 1, of(12, 1)),
-      newCallRecord("visitModule", 12, 1, of(12, 1)),
+      newCallRecord("visitDirectory", 12, 1, of(12, 1)),
       newCallRecord("visitAny", 1, null, of(1)),
       newCallRecord("visitProject", 1, null, of(1))).iterator();
     verifyCallRecords(expected, underTest.callsRecords.iterator());
index 38eb4bbdf4db43effc076f8c3349356f5133c7c9..e695df3fc623d3bd3467e116d4e84966f4985c8c 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Test;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 
@@ -33,16 +32,12 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
   private static final Component FILE_5 = component(FILE, 5);
   private static final Component FILE_6 = component(FILE, 6);
   private static final Component DIRECTORY_4 = component(DIRECTORY, 4, FILE_5, FILE_6);
-  private static final Component MODULE_3 = component(MODULE, 3, DIRECTORY_4);
-  private static final Component MODULE_2 = component(MODULE, 2, MODULE_3);
-  private static final Component COMPONENT_TREE = component(PROJECT, 1, MODULE_2);
+  private static final Component COMPONENT_TREE = component(PROJECT, 1, DIRECTORY_4);
 
   private final CallRecorderTypeAwareVisitor projectVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.PROJECT, POST_ORDER);
-  private final CallRecorderTypeAwareVisitor moduleVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.MODULE, POST_ORDER);
   private final CallRecorderTypeAwareVisitor directoryVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.DIRECTORY, POST_ORDER);
   private final CallRecorderTypeAwareVisitor fileVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.FILE, POST_ORDER);
   private final DepthTraversalTypeAwareCrawler projectCrawler = new DepthTraversalTypeAwareCrawler(projectVisitor);
-  private final DepthTraversalTypeAwareCrawler moduleCrawler = new DepthTraversalTypeAwareCrawler(moduleVisitor);
   private final DepthTraversalTypeAwareCrawler directoryCrawler = new DepthTraversalTypeAwareCrawler(directoryVisitor);
   private final DepthTraversalTypeAwareCrawler fileCrawler = new DepthTraversalTypeAwareCrawler(fileVisitor);
 
@@ -61,16 +56,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitFile", component));
   }
 
-  @Test
-  public void visit_module_with_depth_FILE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    fileCrawler.visit(component);
-
-    assertThat(fileVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_directory_with_depth_FILE_calls_visit_directory() {
     Component component = component(DIRECTORY, 1);
@@ -109,16 +94,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitDirectory", component));
   }
 
-  @Test
-  public void visit_module_with_depth_DIRECTORY_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    directoryCrawler.visit(component);
-
-    assertThat(directoryVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_project_with_depth_DIRECTORY_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -129,42 +104,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitProject", component));
   }
 
-  @Test
-  public void visit_file_with_depth_MODULE_does_not_call_visit_file_nor_visitAny() {
-    Component component = component(FILE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).isEmpty();
-  }
-
-  @Test
-  public void visit_directory_with_depth_MODULE_does_not_call_visit_directory_nor_visitAny() {
-    Component component = component(DIRECTORY, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).isEmpty();
-  }
-
-  @Test
-  public void visit_module_with_depth_MODULE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
-  @Test
-  public void visit_project_with_depth_MODULE_calls_visit_project() {
-    Component component = component(MODULE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_file_with_depth_PROJECT_does_not_call_visit_file_nor_visitAny() {
     Component component = component(FILE, 1);
@@ -181,14 +120,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
     assertThat(projectVisitor.callsRecords).isEmpty();
   }
 
-  @Test
-  public void visit_module_with_depth_PROJECT_does_not_call_visit_module_nor_visitAny() {
-    Component component = component(MODULE, 1);
-    projectCrawler.visit(component);
-
-    assertThat(projectVisitor.callsRecords).isEmpty();
-  }
-
   @Test
   public void visit_project_with_depth_PROJECT_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -210,10 +141,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitFile", FILE_6),
       reportCallRecord("visitAny", DIRECTORY_4),
       reportCallRecord("visitDirectory", DIRECTORY_4),
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
       reportCallRecord("visitAny", COMPONENT_TREE),
       reportCallRecord("visitProject", COMPONENT_TREE));
   }
@@ -225,23 +152,6 @@ public class ReportPostOrderDepthTraversalTypeAwareCrawlerTest {
     assertThat(directoryVisitor.callsRecords).containsExactly(
       reportCallRecord("visitAny", DIRECTORY_4),
       reportCallRecord("visitDirectory", DIRECTORY_4),
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
-      reportCallRecord("visitAny", COMPONENT_TREE),
-      reportCallRecord("visitProject", COMPONENT_TREE));
-  }
-
-  @Test
-  public void verify_visit_call_when_visit_tree_with_depth_MODULE() {
-    moduleCrawler.visit(COMPONENT_TREE);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
       reportCallRecord("visitAny", COMPONENT_TREE),
       reportCallRecord("visitProject", COMPONENT_TREE));
   }
index 0b0e8eb3725c5cf5b5c519c0952ed56096e7e155..b476b996b6b9e212e0d9b7848ebcd21a461b44b4 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Test;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
 
@@ -33,17 +32,13 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
   private static final Component FILE_5 = component(FILE, 5);
   private static final Component FILE_6 = component(FILE, 6);
   private static final Component DIRECTORY_4 = component(DIRECTORY, 4, FILE_5, FILE_6);
-  private static final Component MODULE_3 = component(MODULE, 3, DIRECTORY_4);
-  private static final Component MODULE_2 = component(MODULE, 2, MODULE_3);
-  private static final Component COMPONENT_TREE = component(PROJECT, 1, MODULE_2);
+  private static final Component COMPONENT_TREE = component(PROJECT, 1, DIRECTORY_4);
 
   private final CallRecorderTypeAwareVisitor projectVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.PROJECT, PRE_ORDER);
-  private final CallRecorderTypeAwareVisitor moduleVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.MODULE, PRE_ORDER);
   private final CallRecorderTypeAwareVisitor directoryVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.DIRECTORY, PRE_ORDER);
   private final CallRecorderTypeAwareVisitor fileVisitor = new CallRecorderTypeAwareVisitor(CrawlerDepthLimit.FILE, PRE_ORDER);
 
   private final DepthTraversalTypeAwareCrawler projectCrawler = new DepthTraversalTypeAwareCrawler(projectVisitor);
-  private final DepthTraversalTypeAwareCrawler moduleCrawler = new DepthTraversalTypeAwareCrawler(moduleVisitor);
   private final DepthTraversalTypeAwareCrawler directoryCrawler = new DepthTraversalTypeAwareCrawler(directoryVisitor);
   private final DepthTraversalTypeAwareCrawler fileCrawler = new DepthTraversalTypeAwareCrawler(fileVisitor);
 
@@ -62,16 +57,6 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitFile", component));
   }
 
-  @Test
-  public void visit_module_with_depth_FILE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    fileCrawler.visit(component);
-
-    assertThat(fileVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_directory_with_depth_FILE_calls_visit_directory() {
     Component component = component(DIRECTORY, 1);
@@ -110,16 +95,6 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitDirectory", component));
   }
 
-  @Test
-  public void visit_module_with_depth_DIRECTORY_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    directoryCrawler.visit(component);
-
-    assertThat(directoryVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_project_with_depth_DIRECTORY_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -130,42 +105,6 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
       reportCallRecord("visitProject", component));
   }
 
-  @Test
-  public void visit_file_with_depth_MODULE_does_not_call_visit_file_nor_visit_any() {
-    Component component = component(FILE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).isEmpty();
-  }
-
-  @Test
-  public void visit_directory_with_depth_MODULE_does_not_call_visit_directory_not_visit_any() {
-    Component component = component(DIRECTORY, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).isEmpty();
-  }
-
-  @Test
-  public void visit_module_with_depth_MODULE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
-  @Test
-  public void visit_project_with_depth_MODULE_calls_visit_project() {
-    Component component = component(MODULE, 1);
-    moduleCrawler.visit(component);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", component),
-      reportCallRecord("visitModule", component));
-  }
-
   @Test
   public void visit_file_with_depth_PROJECT_does_not_call_visit_file_nor_visitAny() {
     Component component = component(FILE, 1);
@@ -182,14 +121,6 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
     assertThat(projectVisitor.callsRecords).isEmpty();
   }
 
-  @Test
-  public void visit_module_with_depth_PROJECT_does_not_call_visit_module_nor_visitAny() {
-    Component component = component(MODULE, 1);
-    projectCrawler.visit(component);
-
-    assertThat(projectVisitor.callsRecords).isEmpty();
-  }
-
   @Test
   public void visit_project_with_depth_PROJECT_calls_visit_project_nor_visitAny() {
     Component component = component(PROJECT, 1);
@@ -207,10 +138,6 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
     assertThat(fileVisitor.callsRecords).containsExactly(
       reportCallRecord("visitAny", COMPONENT_TREE),
       reportCallRecord("visitProject", COMPONENT_TREE),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3),
       reportCallRecord("visitAny", DIRECTORY_4),
       reportCallRecord("visitDirectory", DIRECTORY_4),
       reportCallRecord("visitAny", FILE_5),
@@ -226,27 +153,10 @@ public class ReportPreOrderDepthTraversalTypeAwareCrawlerTest {
     assertThat(directoryVisitor.callsRecords).containsExactly(
       reportCallRecord("visitAny", COMPONENT_TREE),
       reportCallRecord("visitProject", COMPONENT_TREE),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3),
       reportCallRecord("visitAny", DIRECTORY_4),
       reportCallRecord("visitDirectory", DIRECTORY_4));
   }
 
-  @Test
-  public void verify_visit_call_when_visit_tree_with_depth_MODULE() {
-    moduleCrawler.visit(COMPONENT_TREE);
-
-    assertThat(moduleVisitor.callsRecords).containsExactly(
-      reportCallRecord("visitAny", COMPONENT_TREE),
-      reportCallRecord("visitProject", COMPONENT_TREE),
-      reportCallRecord("visitAny", MODULE_2),
-      reportCallRecord("visitModule", MODULE_2),
-      reportCallRecord("visitAny", MODULE_3),
-      reportCallRecord("visitModule", MODULE_3));
-  }
-
   @Test
   public void verify_visit_call_when_visit_tree_with_depth_PROJECT() {
     projectCrawler.visit(COMPONENT_TREE);
index b36c378744a912416f29dfa75878e379e0cb9873..f91700148a2da332d6755f42fb28868c9934ca02 100644 (file)
@@ -32,7 +32,6 @@ import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.spy;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
@@ -44,9 +43,7 @@ public class ReportVisitorsCrawlerTest {
 
   private static final Component FILE_5 = component(FILE, 5);
   private static final Component DIRECTORY_4 = component(DIRECTORY, 4, FILE_5);
-  private static final Component MODULE_3 = component(MODULE, 3, DIRECTORY_4);
-  private static final Component MODULE_2 = component(MODULE, 2, MODULE_3);
-  private static final Component COMPONENT_TREE = component(PROJECT, 1, MODULE_2);
+  private static final Component COMPONENT_TREE = component(PROJECT, 1, DIRECTORY_4);
 
   private final TypeAwareVisitor spyPreOrderTypeAwareVisitor = spy(new TestTypeAwareVisitor(CrawlerDepthLimit.FILE, PRE_ORDER));
   private final TypeAwareVisitor spyPostOrderTypeAwareVisitor = spy(new TestTypeAwareVisitor(CrawlerDepthLimit.FILE, POST_ORDER));
@@ -68,16 +65,6 @@ public class ReportVisitorsCrawlerTest {
     inOrder.verify(spyPathAwareVisitor).visitAny(eq(DIRECTORY_4), any(PathAwareVisitor.Path.class));
     inOrder.verify(spyPathAwareVisitor).visitDirectory(eq(DIRECTORY_4), any(PathAwareVisitor.Path.class));
 
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyPathAwareVisitor).visitAny(eq(MODULE_3), any(PathAwareVisitor.Path.class));
-    inOrder.verify(spyPathAwareVisitor).visitModule(eq(MODULE_3), any(PathAwareVisitor.Path.class));
-
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyPathAwareVisitor).visitAny(eq(MODULE_2), any(PathAwareVisitor.Path.class));
-    inOrder.verify(spyPathAwareVisitor).visitModule(eq(MODULE_2), any(PathAwareVisitor.Path.class));
-
     inOrder.verify(spyPostOrderTypeAwareVisitor).visitAny(COMPONENT_TREE);
     inOrder.verify(spyPostOrderTypeAwareVisitor).visitProject(COMPONENT_TREE);
     inOrder.verify(spyPathAwareVisitor).visitAny(eq(COMPONENT_TREE), any(PathAwareVisitor.Path.class));
@@ -91,15 +78,11 @@ public class ReportVisitorsCrawlerTest {
     underTest.visit(COMPONENT_TREE);
 
     inOrder.verify(spyPreOrderTypeAwareVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verify(spyPreOrderTypeAwareVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyPreOrderTypeAwareVisitor).visitModule(MODULE_3);
     inOrder.verify(spyPreOrderTypeAwareVisitor).visitDirectory(DIRECTORY_4);
     inOrder.verify(spyPreOrderTypeAwareVisitor).visitFile(FILE_5);
 
     inOrder.verify(spyPostOrderTypeAwareVisitor).visitFile(FILE_5);
     inOrder.verify(spyPostOrderTypeAwareVisitor).visitDirectory(DIRECTORY_4);
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyPostOrderTypeAwareVisitor).visitModule(MODULE_2);
     inOrder.verify(spyPostOrderTypeAwareVisitor).visitProject(COMPONENT_TREE);
   }
 
index a6b442ff6b16c0146435d7be15833e7782213bc6..21ec562bbd2eb01669904db95cd88735e8df1a3e 100644 (file)
@@ -29,7 +29,6 @@ import static com.google.common.collect.ImmutableList.of;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
@@ -39,26 +38,17 @@ public class ReportVisitorsCrawlerWithPathAwareVisitorTest {
   private static final int ROOT_REF = 1;
   private static final ReportComponent SOME_TREE_ROOT = ReportComponent.builder(PROJECT, ROOT_REF)
     .addChildren(
-      ReportComponent.builder(MODULE, 11)
+      ReportComponent.builder(DIRECTORY, 11)
         .addChildren(
-          ReportComponent.builder(DIRECTORY, 111)
-            .addChildren(
-              ReportComponent.builder(FILE, 1111).build(),
-              ReportComponent.builder(FILE, 1112).build())
-            .build(),
-          ReportComponent.builder(DIRECTORY, 112)
-            .addChildren(
-              ReportComponent.builder(FILE, 1121).build())
-            .build())
+          ReportComponent.builder(FILE, 111).build(),
+          ReportComponent.builder(FILE, 112).build())
         .build(),
-      ReportComponent.builder(MODULE, 12)
+      ReportComponent.builder(DIRECTORY, 12)
         .addChildren(
-          ReportComponent.builder(MODULE, 121)
+          ReportComponent.builder(FILE, 121).build(),
+          ReportComponent.builder(DIRECTORY, 122)
             .addChildren(
-              ReportComponent.builder(DIRECTORY, 1211)
-                .addChildren(
-                  ReportComponent.builder(FILE, 12111).build())
-                .build())
+              ReportComponent.builder(FILE, 1221).build())
             .build())
         .build())
     .build();
@@ -73,25 +63,19 @@ public class ReportVisitorsCrawlerWithPathAwareVisitorTest {
       reportCallRecord("visitAny", 1, null, of(1)),
       reportCallRecord("visitProject", 1, null, of(1)),
       reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
+      reportCallRecord("visitDirectory", 11, 1, of(11, 1)),
       reportCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitAny", 1111, 111, of(1111, 111, 11, 1)),
-      reportCallRecord("visitFile", 1111, 111, of(1111, 111, 11, 1)),
-      reportCallRecord("visitAny", 1112, 111, of(1112, 111, 11, 1)),
-      reportCallRecord("visitFile", 1112, 111, of(1112, 111, 11, 1)),
+      reportCallRecord("visitFile", 111, 11, of(111, 11, 1)),
       reportCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      reportCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
-      reportCallRecord("visitAny", 1121, 112, of(1121, 112, 11, 1)),
-      reportCallRecord("visitFile", 1121, 112, of(1121, 112, 11, 1)),
+      reportCallRecord("visitFile", 112, 11, of(112, 11, 1)),
       reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
+      reportCallRecord("visitDirectory", 12, 1, of(12, 1)),
       reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitAny", 12111, 1211, of(12111, 1211, 121, 12, 1)),
-      reportCallRecord("visitFile", 12111, 1211, of(12111, 1211, 121, 12, 1))).iterator();
+      reportCallRecord("visitFile", 121, 12, of(121, 12, 1)),
+      reportCallRecord("visitAny", 122, 12, of(122, 12, 1)),
+      reportCallRecord("visitDirectory", 122, 12, of(122, 12, 1)),
+      reportCallRecord("visitAny", 1221, 122, of(1221, 122, 12, 1)),
+      reportCallRecord("visitFile", 1221, 122, of(1221, 122, 12, 1))).iterator();
     verifyCallRecords(expected, visitor.callsRecords.iterator());
   }
 
@@ -105,35 +89,11 @@ public class ReportVisitorsCrawlerWithPathAwareVisitorTest {
       reportCallRecord("visitAny", 1, null, of(1)),
       reportCallRecord("visitProject", 1, null, of(1)),
       reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
-      reportCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      reportCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
+      reportCallRecord("visitDirectory", 11, 1, of(11, 1)),
       reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
-      reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1))).iterator();
-    verifyCallRecords(expected, visitor.callsRecords.iterator());
-  }
-
-  @Test
-  public void verify_preOrder_visit_call_when_visit_tree_with_depth_MODULE() {
-    CallRecorderPathAwareVisitor visitor = new CallRecorderPathAwareVisitor(CrawlerDepthLimit.MODULE, PRE_ORDER);
-    VisitorsCrawler underTest = newVisitorsCrawler(visitor);
-    underTest.visit(SOME_TREE_ROOT);
-
-    Iterator<PathAwareCallRecord> expected = of(
-      reportCallRecord("visitAny", 1, null, of(1)),
-      reportCallRecord("visitProject", 1, null, of(1)),
-      reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
-      reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
-      reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1))).iterator();
+      reportCallRecord("visitDirectory", 12, 1, of(12, 1)),
+      reportCallRecord("visitAny", 122, 12, of(122, 12, 1)),
+      reportCallRecord("visitDirectory", 122, 12, of(122, 12, 1))).iterator();
     verifyCallRecords(expected, visitor.callsRecords.iterator());
   }
 
@@ -156,26 +116,20 @@ public class ReportVisitorsCrawlerWithPathAwareVisitorTest {
     underTest.visit(SOME_TREE_ROOT);
 
     Iterator<PathAwareCallRecord> expected = of(
-      reportCallRecord("visitAny", 1111, 111, of(1111, 111, 11, 1)),
-      reportCallRecord("visitFile", 1111, 111, of(1111, 111, 11, 1)),
-      reportCallRecord("visitAny", 1112, 111, of(1112, 111, 11, 1)),
-      reportCallRecord("visitFile", 1112, 111, of(1112, 111, 11, 1)),
       reportCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitAny", 1121, 112, of(1121, 112, 11, 1)),
-      reportCallRecord("visitFile", 1121, 112, of(1121, 112, 11, 1)),
+      reportCallRecord("visitFile", 111, 11, of(111, 11, 1)),
       reportCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      reportCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
+      reportCallRecord("visitFile", 112, 11, of(112, 11, 1)),
       reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
-      reportCallRecord("visitAny", 12111, 1211, of(12111, 1211, 121, 12, 1)),
-      reportCallRecord("visitFile", 12111, 1211, of(12111, 1211, 121, 12, 1)),
-      reportCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
+      reportCallRecord("visitDirectory", 11, 1, of(11, 1)),
       reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1)),
+      reportCallRecord("visitFile", 121, 12, of(121, 12, 1)),
+      reportCallRecord("visitAny", 1221, 122, of(1221, 122, 12, 1)),
+      reportCallRecord("visitFile", 1221, 122, of(1221, 122, 12, 1)),
+      reportCallRecord("visitAny", 122, 12, of(122, 12, 1)),
+      reportCallRecord("visitDirectory", 122, 12, of(122, 12, 1)),
       reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
+      reportCallRecord("visitDirectory", 12, 1, of(12, 1)),
       reportCallRecord("visitAny", 1, null, of(1)),
       reportCallRecord("visitProject", 1, null, of(1))).iterator();
     verifyCallRecords(expected, visitor.callsRecords.iterator());
@@ -188,36 +142,12 @@ public class ReportVisitorsCrawlerWithPathAwareVisitorTest {
     underTest.visit(SOME_TREE_ROOT);
 
     Iterator<PathAwareCallRecord> expected = of(
-      reportCallRecord("visitAny", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitDirectory", 111, 11, of(111, 11, 1)),
-      reportCallRecord("visitAny", 112, 11, of(112, 11, 1)),
-      reportCallRecord("visitDirectory", 112, 11, of(112, 11, 1)),
       reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
-      reportCallRecord("visitAny", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitDirectory", 1211, 121, of(1211, 121, 12, 1)),
-      reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
-      reportCallRecord("visitAny", 1, null, of(1)),
-      reportCallRecord("visitProject", 1, null, of(1))).iterator();
-    verifyCallRecords(expected, visitor.callsRecords.iterator());
-  }
-
-  @Test
-  public void verify_postOrder_visit_call_when_visit_tree_with_depth_MODULE() {
-    CallRecorderPathAwareVisitor visitor = new CallRecorderPathAwareVisitor(CrawlerDepthLimit.MODULE, POST_ORDER);
-    VisitorsCrawler underTest = newVisitorsCrawler(visitor);
-    underTest.visit(SOME_TREE_ROOT);
-
-    Iterator<PathAwareCallRecord> expected = of(
-      reportCallRecord("visitAny", 11, 1, of(11, 1)),
-      reportCallRecord("visitModule", 11, 1, of(11, 1)),
-      reportCallRecord("visitAny", 121, 12, of(121, 12, 1)),
-      reportCallRecord("visitModule", 121, 12, of(121, 12, 1)),
+      reportCallRecord("visitDirectory", 11, 1, of(11, 1)),
+      reportCallRecord("visitAny", 122, 12, of(122, 12, 1)),
+      reportCallRecord("visitDirectory", 122, 12, of(122, 12, 1)),
       reportCallRecord("visitAny", 12, 1, of(12, 1)),
-      reportCallRecord("visitModule", 12, 1, of(12, 1)),
+      reportCallRecord("visitDirectory", 12, 1, of(12, 1)),
       reportCallRecord("visitAny", 1, null, of(1)),
       reportCallRecord("visitProject", 1, null, of(1))).iterator();
     verifyCallRecords(expected, visitor.callsRecords.iterator());
index a7bd8a7f4d1f279aa330c24229cffb930263b721..1b23eace022af094e958e762c54b409d4bc69748 100644 (file)
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER;
 
@@ -37,19 +36,15 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
   private static final Component FILE_5 = component(FILE, 5);
   private static final Component FILE_6 = component(FILE, 6);
   private static final Component DIRECTORY_4 = component(DIRECTORY, 4, FILE_5, FILE_6);
-  private static final Component MODULE_3 = component(MODULE, 3, DIRECTORY_4);
-  private static final Component MODULE_2 = component(MODULE, 2, MODULE_3);
-  private static final Component COMPONENT_TREE = component(PROJECT, 1, MODULE_2);
+  private static final Component COMPONENT_TREE = component(PROJECT, 1, DIRECTORY_4);
 
   private final TypeAwareVisitor spyProjectVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.PROJECT, POST_ORDER) {
   });
-  private final TypeAwareVisitor spyModuleVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.MODULE, POST_ORDER) {
-  });
   private final TypeAwareVisitor spyDirectoryVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.DIRECTORY, POST_ORDER) {
   });
   private final TypeAwareVisitor spyFileVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {
   });
-  private final InOrder inOrder = inOrder(spyProjectVisitor, spyModuleVisitor, spyDirectoryVisitor, spyFileVisitor);
+  private final InOrder inOrder = inOrder(spyProjectVisitor, spyDirectoryVisitor, spyFileVisitor);
 
   @Test(expected = NullPointerException.class)
   public void visit_null_Component_throws_NPE() {
@@ -68,17 +63,6 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_module_with_depth_FILE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyFileVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyFileVisitor).visitAny(component);
-    inOrder.verify(spyFileVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_directory_with_depth_FILE_calls_visit_directory() {
     Component component = component(DIRECTORY, 1);
@@ -122,17 +106,6 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_module_with_depth_DIRECTORY_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyDirectoryVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyDirectoryVisitor).visitAny(component);
-    inOrder.verify(spyDirectoryVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_project_with_depth_DIRECTORY_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -144,49 +117,6 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_file_with_depth_MODULE_does_not_call_visit_file_nor_visitAny() {
-    Component component = component(FILE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor, never()).visitFile(component);
-    inOrder.verify(spyModuleVisitor, never()).visitAny(component);
-  }
-
-  @Test
-  public void visit_directory_with_depth_MODULE_does_not_call_visit_directory_nor_visitAny() {
-    Component component = component(DIRECTORY, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor, never()).visitDirectory(component);
-    inOrder.verify(spyModuleVisitor, never()).visitFile(component);
-    inOrder.verify(spyModuleVisitor, never()).visitAny(component);
-  }
-
-  @Test
-  public void visit_module_with_depth_MODULE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor).visitAny(component);
-    inOrder.verify(spyModuleVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
-  @Test
-  public void visit_project_with_depth_MODULE_calls_visit_project() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor).visitAny(component);
-    inOrder.verify(spyModuleVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_file_with_depth_PROJECT_does_not_call_visit_file_nor_visitAny() {
     Component component = component(FILE, 1);
@@ -208,18 +138,6 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
     inOrder.verify(spyProjectVisitor, never()).visitAny(component);
   }
 
-  @Test
-  public void visit_module_with_depth_PROJECT_does_not_call_visit_module_nor_visitAny() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyProjectVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyProjectVisitor, never()).visitModule(component);
-    inOrder.verify(spyProjectVisitor, never()).visitDirectory(component);
-    inOrder.verify(spyProjectVisitor, never()).visitFile(component);
-    inOrder.verify(spyProjectVisitor, never()).visitAny(component);
-  }
-
   @Test
   public void visit_project_with_depth_PROJECT_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -242,10 +160,6 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
     inOrder.verify(spyFileVisitor).visitFile(FILE_6);
     inOrder.verify(spyFileVisitor).visitAny(DIRECTORY_4);
     inOrder.verify(spyFileVisitor).visitDirectory(DIRECTORY_4);
-    inOrder.verify(spyFileVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyFileVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyFileVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyFileVisitor).visitModule(MODULE_2);
     inOrder.verify(spyFileVisitor).visitAny(COMPONENT_TREE);
     inOrder.verify(spyFileVisitor).visitProject(COMPONENT_TREE);
     inOrder.verifyNoMoreInteractions();
@@ -258,29 +172,11 @@ public class ReportVisitorsCrawlerWithPostOrderTypeAwareVisitorTest {
 
     inOrder.verify(spyDirectoryVisitor).visitAny(DIRECTORY_4);
     inOrder.verify(spyDirectoryVisitor).visitDirectory(DIRECTORY_4);
-    inOrder.verify(spyDirectoryVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyDirectoryVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyDirectoryVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyDirectoryVisitor).visitModule(MODULE_2);
     inOrder.verify(spyDirectoryVisitor).visitAny(COMPONENT_TREE);
     inOrder.verify(spyDirectoryVisitor).visitProject(COMPONENT_TREE);
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void verify_visit_call_when_visit_tree_with_depth_MODULE() {
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(COMPONENT_TREE);
-
-    inOrder.verify(spyModuleVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyModuleVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyModuleVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyModuleVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyModuleVisitor).visitAny(COMPONENT_TREE);
-    inOrder.verify(spyModuleVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void verify_visit_call_when_visit_tree_with_depth_PROJECT() {
     VisitorsCrawler underTest = newVisitorsCrawler(spyProjectVisitor);
index 3d603febe5293e494caee2d3e6dd9730804e2ef2..0889943726f4117337c8e6fe4d6c9cf447ea9f59 100644 (file)
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
 
@@ -37,19 +36,15 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
   private static final Component FILE_5 = component(FILE, 5);
   private static final Component FILE_6 = component(FILE, 6);
   private static final Component DIRECTORY_4 = component(DIRECTORY, 4, FILE_5, FILE_6);
-  private static final Component MODULE_3 = component(MODULE, 3, DIRECTORY_4);
-  private static final Component MODULE_2 = component(MODULE, 2, MODULE_3);
-  private static final Component COMPONENT_TREE = component(PROJECT, 1, MODULE_2);
+  private static final Component COMPONENT_TREE = component(PROJECT, 1, DIRECTORY_4);
 
   private final TypeAwareVisitor spyProjectVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.PROJECT, PRE_ORDER) {
   });
-  private final TypeAwareVisitor spyModuleVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.MODULE, PRE_ORDER) {
-  });
   private final TypeAwareVisitor spyDirectoryVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.DIRECTORY, PRE_ORDER) {
   });
   private final TypeAwareVisitor spyFileVisitor = spy(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, PRE_ORDER) {
   });
-  private final InOrder inOrder = inOrder(spyProjectVisitor, spyModuleVisitor, spyDirectoryVisitor, spyFileVisitor);
+  private final InOrder inOrder = inOrder(spyProjectVisitor, spyDirectoryVisitor, spyFileVisitor);
 
   @Test(expected = NullPointerException.class)
   public void visit_null_Component_throws_NPE() {
@@ -68,17 +63,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_module_with_depth_FILE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyFileVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyFileVisitor).visitAny(component);
-    inOrder.verify(spyFileVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_directory_with_depth_FILE_calls_visit_directory() {
     Component component = component(DIRECTORY, 1);
@@ -121,17 +105,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_module_with_depth_DIRECTORY_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyDirectoryVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyDirectoryVisitor).visitAny(component);
-    inOrder.verify(spyDirectoryVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_project_with_depth_DIRECTORY_calls_visit_project() {
     Component component = component(PROJECT, 1);
@@ -143,48 +116,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
     inOrder.verifyNoMoreInteractions();
   }
 
-  @Test
-  public void visit_file_with_depth_MODULE_does_not_call_visit_file_nor_visit_any() {
-    Component component = component(FILE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor, never()).visitFile(component);
-    inOrder.verify(spyModuleVisitor, never()).visitAny(component);
-  }
-
-  @Test
-  public void visit_directory_with_depth_MODULE_does_not_call_visit_directory_not_visit_any() {
-    Component component = component(DIRECTORY, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor, never()).visitFile(component);
-    inOrder.verify(spyModuleVisitor, never()).visitAny(component);
-  }
-
-  @Test
-  public void visit_module_with_depth_MODULE_calls_visit_module() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor).visitAny(component);
-    inOrder.verify(spyModuleVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
-  @Test
-  public void visit_project_with_depth_MODULE_calls_visit_project() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyModuleVisitor).visitAny(component);
-    inOrder.verify(spyModuleVisitor).visitModule(component);
-    inOrder.verifyNoMoreInteractions();
-  }
-
   @Test
   public void visit_file_with_depth_PROJECT_does_not_call_visit_file_nor_visitAny() {
     Component component = component(FILE, 1);
@@ -205,16 +136,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
     inOrder.verify(spyProjectVisitor, never()).visitAny(component);
   }
 
-  @Test
-  public void visit_module_with_depth_PROJECT_does_not_call_visit_module_nor_visitAny() {
-    Component component = component(MODULE, 1);
-    VisitorsCrawler underTest = newVisitorsCrawler(spyProjectVisitor);
-    underTest.visit(component);
-
-    inOrder.verify(spyProjectVisitor, never()).visitFile(component);
-    inOrder.verify(spyProjectVisitor, never()).visitAny(component);
-  }
-
   @Test
   public void visit_project_with_depth_PROJECT_calls_visit_project_nor_visitAny() {
     Component component = component(PROJECT, 1);
@@ -233,10 +154,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
 
     inOrder.verify(spyFileVisitor).visitAny(COMPONENT_TREE);
     inOrder.verify(spyFileVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verify(spyFileVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyFileVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyFileVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyFileVisitor).visitModule(MODULE_3);
     inOrder.verify(spyFileVisitor).visitAny(DIRECTORY_4);
     inOrder.verify(spyFileVisitor).visitDirectory(DIRECTORY_4);
     inOrder.verify(spyFileVisitor).visitAny(FILE_5);
@@ -252,27 +169,11 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
     underTest.visit(COMPONENT_TREE);
 
     inOrder.verify(spyDirectoryVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verify(spyDirectoryVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyDirectoryVisitor).visitModule(MODULE_3);
     inOrder.verify(spyDirectoryVisitor).visitDirectory(DIRECTORY_4);
     inOrder.verify(spyProjectVisitor, never()).visitFile(FILE_5);
     inOrder.verify(spyProjectVisitor, never()).visitFile(FILE_6);
   }
 
-  @Test
-  public void verify_visit_call_when_visit_tree_with_depth_MODULE() {
-    VisitorsCrawler underTest = newVisitorsCrawler(spyModuleVisitor);
-    underTest.visit(COMPONENT_TREE);
-
-    inOrder.verify(spyModuleVisitor).visitAny(COMPONENT_TREE);
-    inOrder.verify(spyModuleVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verify(spyModuleVisitor).visitAny(MODULE_2);
-    inOrder.verify(spyModuleVisitor).visitModule(MODULE_2);
-    inOrder.verify(spyModuleVisitor).visitAny(MODULE_3);
-    inOrder.verify(spyModuleVisitor).visitModule(MODULE_3);
-    inOrder.verify(spyProjectVisitor, never()).visitDirectory(DIRECTORY_4);
-  }
-
   @Test
   public void verify_visit_call_when_visit_tree_with_depth_PROJECT() {
     VisitorsCrawler underTest = newVisitorsCrawler(spyProjectVisitor);
@@ -280,8 +181,6 @@ public class ReportVisitorsCrawlerWithPreOrderTypeAwareVisitorTest {
 
     inOrder.verify(spyProjectVisitor).visitAny(COMPONENT_TREE);
     inOrder.verify(spyProjectVisitor).visitProject(COMPONENT_TREE);
-    inOrder.verify(spyProjectVisitor, never()).visitModule(MODULE_2);
-    inOrder.verify(spyProjectVisitor, never()).visitModule(MODULE_3);
   }
 
   private static Component component(final Component.Type type, final int ref, final Component... children) {
index 3d744f1a94015d46131c5c2ac62b836235496dc0..8b112185793f027028464136355921f6c0ec4534 100644 (file)
@@ -26,7 +26,6 @@ import org.junit.rules.ExpectedException;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.VIEW;
@@ -35,13 +34,10 @@ import static org.sonar.ce.task.projectanalysis.component.ReportComponent.DUMB_P
 public class TreeRootHolderImplTest {
 
   private static final ReportComponent SOME_REPORT_COMPONENT_TREE = ReportComponent.builder(PROJECT, 1)
-    .addChildren(
-      ReportComponent.builder(MODULE, 2)
-        .addChildren(ReportComponent.builder(DIRECTORY, 3)
-          .addChildren(
-            ReportComponent.builder(FILE, 4).build())
-          .build())
-        .build())
+    .addChildren(ReportComponent.builder(DIRECTORY, 2)
+      .addChildren(
+        ReportComponent.builder(FILE, 3).build())
+      .build())
     .build();
   private static final ViewsComponent SOME_VIEWS_COMPONENT_TREE = ViewsComponent.builder(VIEW, 1)
     .addChildren(
@@ -99,7 +95,7 @@ public class TreeRootHolderImplTest {
   public void getComponentByRef_returns_any_report_component_in_the_tree() {
     underTest.setRoots(SOME_REPORT_COMPONENT_TREE, DUMB_PROJECT);
 
-    for (int i = 1; i <= 4; i++) {
+    for (int i = 1; i <= 3; i++) {
       assertThat(underTest.getComponentByRef(i).getReportAttributes().getRef()).isEqualTo(i);
     }
   }
@@ -108,7 +104,7 @@ public class TreeRootHolderImplTest {
   public void getOptionalComponentByRef_returns_any_report_component_in_the_tree() {
     underTest.setRoots(SOME_REPORT_COMPONENT_TREE, DUMB_PROJECT);
 
-    for (int i = 1; i <= 4; i++) {
+    for (int i = 1; i <= 3; i++) {
       assertThat(underTest.getOptionalComponentByRef(i).get().getReportAttributes().getRef()).isEqualTo(i);
     }
   }
@@ -162,7 +158,7 @@ public class TreeRootHolderImplTest {
   @Test
   public void getSize_counts_number_of_components() {
     underTest.setRoots(SOME_REPORT_COMPONENT_TREE, DUMB_PROJECT);
-    assertThat(underTest.getSize()).isEqualTo(4);
+    assertThat(underTest.getSize()).isEqualTo(3);
   }
 
   private void expectNotInitialized_ISE() {
index ad21c78c51e9593581a6cd1b56a658118ff4dbe2..0b698b616021a2f93fa7659cbd95090d020d8100 100644 (file)
@@ -40,16 +40,12 @@ import static org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY;
 import static org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
 
 public class DuplicationMeasuresTest {
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_1_REF = 123;
-  private static final int SUB_MODULE_2_REF = 126;
   private static final int DIRECTORY_REF = 1234;
   private static final int FILE_1_REF = 12341;
   private static final int FILE_2_REF = 12342;
@@ -67,22 +63,13 @@ public class DuplicationMeasuresTest {
     .setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
+          builder(DIRECTORY, DIRECTORY_REF)
             .addChildren(
-              builder(MODULE, SUB_MODULE_1_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(
-                      builder(FILE, FILE_1_REF).setFileAttributes(FILE_1_ATTRS).build(),
-                      builder(FILE, FILE_2_REF).setFileAttributes(FILE_2_ATTRS).build())
-                    .build())
-                .build(),
-              builder(MODULE, SUB_MODULE_2_REF)
-                .addChildren(
-                  builder(FILE, FILE_3_REF).setFileAttributes(FILE_3_ATTRS).build(),
-                  builder(FILE, FILE_4_REF).setFileAttributes(FILE_4_ATTRS).build())
-                .build())
-            .build())
+              builder(FILE, FILE_1_REF).setFileAttributes(FILE_1_ATTRS).build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(FILE_2_ATTRS).build())
+            .build(),
+          builder(FILE, FILE_3_REF).setFileAttributes(FILE_3_ATTRS).build(),
+          builder(FILE, FILE_4_REF).setFileAttributes(FILE_4_ATTRS).build())
         .build());
   @Rule
   public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
@@ -148,9 +135,6 @@ public class DuplicationMeasuresTest {
     assertRawMeasureValue(FILE_3_REF, DUPLICATED_BLOCKS_KEY, 0);
     assertRawMeasureValue(FILE_4_REF, DUPLICATED_BLOCKS_KEY, 5);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_BLOCKS_KEY, 50);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_BLOCKS_KEY, 50);
-    assertRawMeasureValue(SUB_MODULE_2_REF, DUPLICATED_BLOCKS_KEY, 5);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_BLOCKS_KEY, 55);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_BLOCKS_KEY, 55);
   }
 
@@ -225,9 +209,6 @@ public class DuplicationMeasuresTest {
     assertRawMeasureValue(FILE_3_REF, DUPLICATED_FILES_KEY, 1);
     assertRawMeasureValue(FILE_4_REF, DUPLICATED_FILES_KEY, 1);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_FILES_KEY, 1);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_FILES_KEY, 1);
-    assertRawMeasureValue(SUB_MODULE_2_REF, DUPLICATED_FILES_KEY, 2);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_FILES_KEY, 3);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_FILES_KEY, 3);
   }
 
@@ -251,9 +232,6 @@ public class DuplicationMeasuresTest {
     assertRawMeasureValue(FILE_3_REF, DUPLICATED_LINES_KEY, 0);
     assertRawMeasureValue(FILE_4_REF, DUPLICATED_LINES_KEY, 7);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_LINES_KEY, 19);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_LINES_KEY, 19);
-    assertRawMeasureValue(SUB_MODULE_2_REF, DUPLICATED_LINES_KEY, 7);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_LINES_KEY, 26);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_LINES_KEY, 26);
   }
 
@@ -279,9 +257,6 @@ public class DuplicationMeasuresTest {
     assertNoRawMeasure(FILE_3_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertNoRawMeasure(FILE_4_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_LINES_DENSITY_KEY, 10d);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_LINES_DENSITY_KEY, 10d);
-    assertNoRawMeasure(SUB_MODULE_2_REF, DUPLICATED_LINES_DENSITY_KEY);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_LINES_DENSITY_KEY, 10d);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_LINES_DENSITY_KEY, 10d);
   }
 
@@ -297,9 +272,6 @@ public class DuplicationMeasuresTest {
     assertNoRawMeasure(FILE_3_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertNoRawMeasure(FILE_4_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_LINES_DENSITY_KEY, 0d);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_LINES_DENSITY_KEY, 0d);
-    assertNoRawMeasure(SUB_MODULE_2_REF, DUPLICATED_LINES_DENSITY_KEY);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_LINES_DENSITY_KEY, 0d);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_LINES_DENSITY_KEY, 0d);
   }
 
@@ -326,9 +298,6 @@ public class DuplicationMeasuresTest {
     assertNoRawMeasure(FILE_3_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertNoRawMeasure(FILE_4_REF, DUPLICATED_LINES_DENSITY_KEY);
     assertRawMeasureValue(DIRECTORY_REF, DUPLICATED_LINES_DENSITY_KEY, 100d);
-    assertRawMeasureValue(SUB_MODULE_1_REF, DUPLICATED_LINES_DENSITY_KEY, 100d);
-    assertNoRawMeasure(SUB_MODULE_2_REF, DUPLICATED_LINES_DENSITY_KEY);
-    assertRawMeasureValue(MODULE_REF, DUPLICATED_LINES_DENSITY_KEY, 100d);
     assertRawMeasureValue(ROOT_REF, DUPLICATED_LINES_DENSITY_KEY, 100d);
   }
 
@@ -354,8 +323,6 @@ public class DuplicationMeasuresTest {
     assertThat(measureRepository.getAddedRawMeasures(FILE_1_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(FILE_2_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF).get(metricKey)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_1_REF).get(metricKey)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(MODULE_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF).get(metricKey)).isEmpty();
   }
 
@@ -377,9 +344,6 @@ public class DuplicationMeasuresTest {
     assertRawMeasureValue(FILE_3_REF, metricKey, 0);
     assertRawMeasureValue(FILE_4_REF, metricKey, 0);
     assertRawMeasureValue(DIRECTORY_REF, metricKey, 0);
-    assertRawMeasureValue(SUB_MODULE_1_REF, metricKey, 0);
-    assertRawMeasureValue(SUB_MODULE_2_REF, metricKey, 0);
-    assertRawMeasureValue(MODULE_REF, metricKey, 0);
     assertRawMeasureValue(ROOT_REF, metricKey, 0);
   }
 
index f2c673d7442dc5359ac0d010a5f92a377de50cf3..20384237dce2e2f3da071974d0b60b0b73f8102d 100644 (file)
@@ -33,9 +33,8 @@ import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builde
 
 public class MutableMovedFilesRepositoryImplTest {
   private static final Component SOME_FILE = builder(Component.Type.FILE, 1).build();
-  private static final Component[] COMPONENTS_BUT_FILE = {
+  private static final Component[] COMPONENTS_EXCEPT_FILE = {
     builder(Component.Type.PROJECT, 1).build(),
-    builder(Component.Type.MODULE, 1).build(),
     builder(Component.Type.DIRECTORY, 1).build(),
     ViewsComponent.builder(Component.Type.VIEW, 1).build(),
     ViewsComponent.builder(Component.Type.SUBVIEW, 1).build(),
@@ -66,7 +65,7 @@ public class MutableMovedFilesRepositoryImplTest {
 
   @Test
   public void setOriginalFile_throws_IAE_when_type_is_no_FILE() {
-    for (Component component : COMPONENTS_BUT_FILE) {
+    for (Component component : COMPONENTS_EXCEPT_FILE) {
       try {
         underTest.setOriginalFile(component, SOME_ORIGINAL_FILE);
         fail("should have raised a NPE");
@@ -115,7 +114,7 @@ public class MutableMovedFilesRepositoryImplTest {
   @Test
   public void getOriginalFile_returns_absent_for_any_component_type_when_empty() {
     assertThat(underTest.getOriginalFile(SOME_FILE)).isAbsent();
-    for (Component component : COMPONENTS_BUT_FILE) {
+    for (Component component : COMPONENTS_EXCEPT_FILE) {
       assertThat(underTest.getOriginalFile(component)).isAbsent();
     }
   }
@@ -124,7 +123,7 @@ public class MutableMovedFilesRepositoryImplTest {
   public void getOriginalFile_returns_absent_for_any_type_of_Component_but_file_when_non_empty() {
     underTest.setOriginalFile(SOME_FILE, SOME_ORIGINAL_FILE);
 
-    for (Component component : COMPONENTS_BUT_FILE) {
+    for (Component component : COMPONENTS_EXCEPT_FILE) {
       assertThat(underTest.getOriginalFile(component)).isAbsent();
     }
     assertThat(underTest.getOriginalFile(SOME_FILE)).contains(SOME_ORIGINAL_FILE);
index ea7d033d8e61b04809169f3a8c710c8eb40d00f5..1e3936ededaaa545cb080fe2a08ec3f45502eaba 100644 (file)
@@ -38,7 +38,6 @@ import static org.sonar.api.measures.CoreMetrics.COMPLEXITY_IN_FUNCTIONS_KEY;
 import static org.sonar.api.measures.CoreMetrics.FUNCTIONS_KEY;
 import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -76,20 +75,14 @@ public class AverageFormulaExecutionTest {
   public void add_measures() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 111)
           .addChildren(
-            builder(DIRECTORY, 111)
-              .addChildren(
-                builder(Component.Type.FILE, 1111).build(),
-                builder(Component.Type.FILE, 1112).build())
-              .build())
+            builder(Component.Type.FILE, 1111).build(),
+            builder(Component.Type.FILE, 1112).build())
           .build(),
-        builder(MODULE, 12)
+        builder(DIRECTORY, 121)
           .addChildren(
-            builder(DIRECTORY, 121)
-              .addChildren(
-                builder(Component.Type.FILE, 1211).build())
-              .build())
+            builder(Component.Type.FILE, 1211).build())
           .build())
       .build();
 
@@ -107,11 +100,9 @@ public class AverageFormulaExecutionTest {
     new PathAwareCrawler<>(underTest).visit(project);
 
     assertThat(toEntries(measureRepository.getAddedRawMeasures(1))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(3d, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(1111))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2.5d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(1112))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(1d, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(12))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(1211))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
   }
@@ -120,12 +111,9 @@ public class AverageFormulaExecutionTest {
   public void not_add_measures_when_no_data_on_file() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 111)
           .addChildren(
-            builder(DIRECTORY, 111)
-              .addChildren(
-                builder(Component.Type.FILE, 1111).build())
-              .build())
+            builder(Component.Type.FILE, 1111).build())
           .build())
       .build();
 
@@ -134,7 +122,6 @@ public class AverageFormulaExecutionTest {
     new PathAwareCrawler<>(underTest).visit(project);
 
     assertThat(measureRepository.getAddedRawMeasures(1)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(11)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(111)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
   }
index 5c36dba43365ebf67f695d99dfa12840ba51d436..ee45417ead21f397928a5334b9ed446b4285d241 100644 (file)
@@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
 import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -63,7 +62,7 @@ public class DistributionFormulaExecutionTest {
   public void add_measures() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 11)
           .addChildren(
             builder(DIRECTORY, 111)
               .addChildren(
@@ -71,7 +70,7 @@ public class DistributionFormulaExecutionTest {
                 builder(Component.Type.FILE, 1112).build())
               .build())
           .build(),
-        builder(MODULE, 12)
+        builder(DIRECTORY, 12)
           .addChildren(
             builder(DIRECTORY, 121)
               .addChildren(
@@ -102,7 +101,7 @@ public class DistributionFormulaExecutionTest {
   public void not_add_measures_when_no_data_on_file() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 11)
           .addChildren(
             builder(DIRECTORY, 111)
               .addChildren(
index ace7a07d6f71eee4e06b0243991088bd0827dac5..8237e2d3fdbc3d4ff356343522e97a9ce344671e 100644 (file)
@@ -41,7 +41,6 @@ import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_COVERAGE_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_LINES_TO_COVER_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -51,30 +50,22 @@ import static org.sonar.test.ExceptionCauseMatcher.hasType;
 
 public class ReportFormulaExecutorComponentVisitorTest {
   private static final int ROOT_REF = 1;
-  private static final int MODULE_1_REF = 11;
   private static final int DIRECTORY_1_REF = 111;
   private static final int FILE_1_REF = 1111;
   private static final int FILE_2_REF = 1112;
-  private static final int MODULE_2_REF = 12;
   private static final int DIRECTORY_2_REF = 121;
   private static final int FILE_3_REF = 1211;
 
   private static final ReportComponent BALANCED_COMPONENT_TREE = ReportComponent.builder(PROJECT, ROOT_REF)
     .addChildren(
-      ReportComponent.builder(MODULE, MODULE_1_REF)
+      ReportComponent.builder(DIRECTORY, DIRECTORY_1_REF)
         .addChildren(
-          ReportComponent.builder(DIRECTORY, DIRECTORY_1_REF)
-            .addChildren(
-              builder(Component.Type.FILE, FILE_1_REF).build(),
-              builder(Component.Type.FILE, FILE_2_REF).build())
-            .build())
+          builder(Component.Type.FILE, FILE_1_REF).build(),
+          builder(Component.Type.FILE, FILE_2_REF).build())
         .build(),
-      ReportComponent.builder(MODULE, MODULE_2_REF)
+      ReportComponent.builder(DIRECTORY, DIRECTORY_2_REF)
         .addChildren(
-          ReportComponent.builder(DIRECTORY, DIRECTORY_2_REF)
-            .addChildren(
-              builder(Component.Type.FILE, FILE_3_REF).build())
-            .build())
+          builder(Component.Type.FILE, FILE_3_REF).build())
         .build())
     .build();
 
@@ -103,11 +94,9 @@ public class ReportFormulaExecutorComponentVisitorTest {
       .visit(BALANCED_COMPONENT_TREE);
 
     assertAddedRawMeasure(ROOT_REF, 20);
-    assertAddedRawMeasure(MODULE_1_REF, 18);
     assertAddedRawMeasure(111, 18);
     assertAddedRawMeasure(FILE_1_REF, 10);
     assertAddedRawMeasure(FILE_2_REF, 8);
-    assertAddedRawMeasure(MODULE_2_REF, 2);
     assertAddedRawMeasure(DIRECTORY_2_REF, 2);
     assertAddedRawMeasure(FILE_3_REF, 2);
   }
@@ -126,9 +115,6 @@ public class ReportFormulaExecutorComponentVisitorTest {
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(
       entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(30)),
       entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(120)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_1_REF))).containsOnly(
-      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(28)),
-      entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(118)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(
       entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(28)),
       entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(118)));
@@ -138,14 +124,11 @@ public class ReportFormulaExecutorComponentVisitorTest {
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(
       entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(18)),
       entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(108)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_2_REF))).containsOnly(
-      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(MODULE_2_REF)),
-      entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(102)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).containsOnly(
-      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(MODULE_2_REF)),
+      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(12)),
       entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(102)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_3_REF))).containsOnly(
-      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(MODULE_2_REF)),
+      entryOf(NEW_LINES_TO_COVER_KEY, newMeasureBuilder().create(12)),
       entryOf(NEW_COVERAGE_KEY, newMeasureBuilder().create(102)));
   }
 
@@ -161,11 +144,9 @@ public class ReportFormulaExecutorComponentVisitorTest {
       .visit(BALANCED_COMPONENT_TREE);
 
     assertAddedRawMeasureVariation(ROOT_REF, 20);
-    assertAddedRawMeasureVariation(MODULE_1_REF, 18);
     assertAddedRawMeasureVariation(DIRECTORY_1_REF, 18);
     assertAddedRawMeasureVariation(FILE_1_REF, 10);
     assertAddedRawMeasureVariation(FILE_2_REF, 8);
-    assertAddedRawMeasureVariation(MODULE_2_REF, 2);
     assertAddedRawMeasureVariation(DIRECTORY_2_REF, 2);
     assertAddedRawMeasureVariation(FILE_3_REF, 2);
   }
@@ -174,12 +155,9 @@ public class ReportFormulaExecutorComponentVisitorTest {
   public void measures_are_0_when_there_is_no_input_measure() {
     ReportComponent project = ReportComponent.builder(PROJECT, ROOT_REF)
       .addChildren(
-        ReportComponent.builder(MODULE, MODULE_1_REF)
+        ReportComponent.builder(DIRECTORY, DIRECTORY_1_REF)
           .addChildren(
-            ReportComponent.builder(DIRECTORY, DIRECTORY_1_REF)
-              .addChildren(
-                builder(Component.Type.FILE, FILE_1_REF).build())
-              .build())
+            builder(Component.Type.FILE, FILE_1_REF).build())
           .build())
       .build();
     treeRootHolder.setRoot(project);
@@ -188,7 +166,6 @@ public class ReportFormulaExecutorComponentVisitorTest {
       .visit(project);
 
     assertAddedRawMeasure(ROOT_REF, 0);
-    assertAddedRawMeasure(MODULE_1_REF, 0);
     assertAddedRawMeasure(DIRECTORY_1_REF, 0);
     assertAddedRawMeasure(FILE_1_REF, 0);
   }
@@ -197,17 +174,13 @@ public class ReportFormulaExecutorComponentVisitorTest {
   public void add_measure_even_when_leaf_is_not_FILE() {
     ReportComponent project = ReportComponent.builder(PROJECT, ROOT_REF)
       .addChildren(
-        ReportComponent.builder(MODULE, MODULE_1_REF)
-          .addChildren(
-            ReportComponent.builder(DIRECTORY, 111).build())
-          .build())
+        ReportComponent.builder(DIRECTORY, 111).build())
       .build();
     treeRootHolder.setRoot(project);
 
     new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula()))
       .visit(project);
 
-    assertAddedRawMeasure(MODULE_1_REF, 0);
     assertAddedRawMeasure(DIRECTORY_1_REF, 0);
   }
 
@@ -269,25 +242,6 @@ public class ReportFormulaExecutorComponentVisitorTest {
       .visit(root);
   }
 
-  @Test
-  public void fail_on_project_containing_module_without_children_already_having_computed_measure() {
-    ReportComponent root = builder(PROJECT, ROOT_REF)
-      .addChildren(
-        ReportComponent.builder(MODULE, MODULE_1_REF).build(),
-        builder(Component.Type.FILE, FILE_1_REF).build())
-      .build();
-    treeRootHolder.setRoot(root);
-    measureRepository.addRawMeasure(FILE_1_REF, LINES_KEY, newMeasureBuilder().create(10));
-    // Ncloc is already computed on module
-    measureRepository.addRawMeasure(MODULE_1_REF, NCLOC_KEY, newMeasureBuilder().create(3));
-
-    expectedException.expectCause(hasType(UnsupportedOperationException.class)
-      .andMessage(String.format("A measure can only be set once for Component (ref=%s), Metric (key=%s)", MODULE_1_REF, NCLOC_KEY)));
-
-    new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula()))
-      .visit(root);
-  }
-
   private FormulaExecutorComponentVisitor formulaExecutorComponentVisitor(Formula formula) {
     return FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
       .buildFor(ImmutableList.of(formula));
index f67762ba4b9bd0e70af0b114ba141f15a294061e..dade125e4194e361be852f1a3262be86ef27c703 100644 (file)
@@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
 import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.formula.SumFormula.createIntSumFormula;
@@ -64,20 +63,14 @@ public class SumFormulaExecutionTest {
   public void add_measures() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 111)
           .addChildren(
-            builder(DIRECTORY, 111)
-              .addChildren(
-                builder(Component.Type.FILE, 1111).build(),
-                builder(Component.Type.FILE, 1112).build())
-              .build())
+            builder(Component.Type.FILE, 1111).build(),
+            builder(Component.Type.FILE, 1112).build())
           .build(),
-        builder(MODULE, 12)
+        builder(DIRECTORY, 121)
           .addChildren(
-            builder(DIRECTORY, 121)
-              .addChildren(
-                builder(Component.Type.FILE, 1211).build())
-              .build())
+            builder(Component.Type.FILE, 1211).build())
           .build())
       .build();
 
@@ -90,11 +83,9 @@ public class SumFormulaExecutionTest {
     new PathAwareCrawler<>(underTest).visit(project);
 
     assertThat(toEntries(measureRepository.getAddedRawMeasures(1))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(20)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(18)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(18)));
     assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(1112)).isEmpty();
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(12))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(2)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(2)));
     assertThat(measureRepository.getAddedRawMeasures(1211)).isEmpty();
   }
@@ -103,12 +94,9 @@ public class SumFormulaExecutionTest {
   public void not_add_measures_when_no_data_on_file() {
     ReportComponent project = builder(PROJECT, 1)
       .addChildren(
-        builder(MODULE, 11)
+        builder(DIRECTORY, 111)
           .addChildren(
-            builder(DIRECTORY, 111)
-              .addChildren(
-                builder(Component.Type.FILE, 1111).build())
-              .build())
+            builder(Component.Type.FILE, 1111).build())
           .build())
       .build();
 
@@ -117,7 +105,6 @@ public class SumFormulaExecutionTest {
     new PathAwareCrawler<>(underTest).visit(project);
 
     assertThat(measureRepository.getAddedRawMeasures(1)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(11)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(111)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
   }
index 1c02995a8f16c0dbbd4ccdb3737651d00cda3c36..c9b578677708ef340cd6bcc74e323e6efc7d8eb3 100644 (file)
@@ -39,7 +39,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 
 public class CloseIssuesOnRemovedComponentsVisitorTest {
@@ -92,15 +91,6 @@ public class CloseIssuesOnRemovedComponentsVisitorTest {
     assertThat(issues.hasNext()).isFalse();
   }
 
-  @Test
-  public void do_nothing_on_module() {
-    underTest.visit(ReportComponent.builder(MODULE, 1).build());
-
-    verifyZeroInteractions(issueLifecycle);
-    CloseableIterator<DefaultIssue> issues = issueCache.traverse();
-    assertThat(issues.hasNext()).isFalse();
-  }
-
   @Test
   public void do_nothing_on_directory() {
     underTest.visit(ReportComponent.builder(DIRECTORY, 1).build());
index 34c2a1bea68da6c24dd087d47121f9b024ff0ad7..deda0b2abaaaf6a4ad0867d2dca913bbe83b9651 100644 (file)
@@ -117,6 +117,7 @@ public class IntegrateIssuesVisitorTest {
   private ShortBranchIssueMerger issueStatusCopier = mock(ShortBranchIssueMerger.class);
   private MergeBranchComponentUuids mergeBranchComponentUuids = mock(MergeBranchComponentUuids.class);
   private SourceLinesHashRepository sourceLinesHash = mock(SourceLinesHashRepository.class);
+  private IssueRelocationToRoot issueRelocationToRoot = mock(IssueRelocationToRoot.class);
 
   private ArgumentCaptor<DefaultIssue> defaultIssueCaptor;
 
@@ -138,8 +139,8 @@ public class IntegrateIssuesVisitorTest {
     when(movedFilesRepository.getOriginalFile(any(Component.class))).thenReturn(Optional.absent());
 
     DbClient dbClient = dbTester.getDbClient();
-    TrackerRawInputFactory rawInputFactory = new TrackerRawInputFactory(treeRootHolder, reportReader, sourceLinesHash, new CommonRuleEngineImpl(), issueFilter, ruleRepositoryRule,
-      activeRulesHolder);
+    TrackerRawInputFactory rawInputFactory = new TrackerRawInputFactory(treeRootHolder, reportReader, sourceLinesHash, new CommonRuleEngineImpl(),
+      issueFilter, ruleRepositoryRule, activeRulesHolder, issueRelocationToRoot);
     TrackerBaseInputFactory baseInputFactory = new TrackerBaseInputFactory(issuesLoader, dbClient, movedFilesRepository);
     TrackerMergeBranchInputFactory mergeInputFactory = new TrackerMergeBranchInputFactory(issuesLoader, mergeBranchComponentsUuids, dbClient);
     ClosedIssuesInputFactory closedIssuesInputFactory = new ClosedIssuesInputFactory(issuesLoader, dbClient, movedFilesRepository);
index 2feb1df60b36193a23206a2ef552b9ea15afdb7c..98993c0dcf6854f6553ff963b72d09d422fefbf9 100644 (file)
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 
 public class LoadComponentUuidsHavingOpenIssuesVisitorTest {
@@ -53,7 +52,6 @@ public class LoadComponentUuidsHavingOpenIssuesVisitorTest {
   public void do_nothing_on_not_project_level() {
     when(baseIssuesLoader.loadUuidsOfComponentsWithOpenIssues()).thenReturn(newHashSet("FILE1", "FILE2"));
 
-    underTest.visit(ReportComponent.builder(MODULE, 1).build());
     underTest.visit(ReportComponent.builder(DIRECTORY, 1).build());
     underTest.visit(ReportComponent.builder(FILE, 1).build());
 
index c6a612c5901cd0446cd2fe5157dbcc8ae735b0a7..b3b8e6164ace2a0c391014b8799c9f4abbbf1c6d 100644 (file)
@@ -79,8 +79,9 @@ public class TrackerRawInputFactoryTest {
   private SourceLinesHashRepository sourceLinesHash = mock(SourceLinesHashRepository.class);
   private CommonRuleEngine commonRuleEngine = mock(CommonRuleEngine.class);
   private IssueFilter issueFilter = mock(IssueFilter.class);
+  private IssueRelocationToRoot issueRelocationToRoot = mock(IssueRelocationToRoot.class);
   private TrackerRawInputFactory underTest = new TrackerRawInputFactory(treeRootHolder, reportReader, sourceLinesHash,
-    commonRuleEngine, issueFilter, ruleRepository, activeRulesHolder);
+    commonRuleEngine, issueFilter, ruleRepository, activeRulesHolder, issueRelocationToRoot);
 
   @Test
   public void load_source_hash_sequences() {
index 2afb2880dea361bb0085aff1d592c792f244e12f..f688352163294da9ba16967f512285d07e6f9b63 100644 (file)
@@ -34,7 +34,7 @@ import static org.sonar.server.measure.Rating.B;
 public class BestValueOptimizationTest {
 
   private static final ReportComponent FILE_COMPONENT = ReportComponent.builder(Component.Type.FILE, 1).build();
-  private static final ReportComponent SOME_NON_FILE_COMPONENT = ReportComponent.builder(Component.Type.MODULE, 2).build();
+  private static final ReportComponent SOME_NON_FILE_COMPONENT = ReportComponent.builder(Component.Type.DIRECTORY, 2).build();
   private static final String SOME_DATA = "some_data";
   private static final MetricImpl METRIC_BOOLEAN_FALSE = createMetric(Metric.MetricType.BOOL, 6d);
   private static final MetricImpl METRIC_BOOLEAN_TRUE = createMetric(Metric.MetricType.BOOL, 1d);
index e4762b64a380d939b031b0d0ff1f533f27d992d8..202d748581c3b2af1bdd95b9227317c0004d5f40 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.ce.task.projectanalysis.measure;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 import com.tngtech.java.junit.dataprovider.DataProvider;
 import com.tngtech.java.junit.dataprovider.DataProviderRunner;
@@ -28,8 +26,6 @@ import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -50,7 +46,6 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.rule.RuleDto;
 
-import static com.google.common.collect.FluentIterable.from;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -66,8 +61,14 @@ public class MapBasedRawMeasureRepositoryTest {
   public ExpectedException expectedException = ExpectedException.none();
 
   private static final String FILE_COMPONENT_KEY = "file cpt key";
-  private static final ReportComponent FILE_COMPONENT = ReportComponent.builder(Component.Type.FILE, 1).setKey(FILE_COMPONENT_KEY).build();
-  private static final ReportComponent OTHER_COMPONENT = ReportComponent.builder(Component.Type.FILE, 2).setKey("some other key").build();
+  private static final ReportComponent FILE_COMPONENT = ReportComponent.builder(Component.Type.FILE, 1)
+    .setKey(FILE_COMPONENT_KEY)
+    .setUuid("1")
+    .build();
+  private static final ReportComponent OTHER_COMPONENT = ReportComponent.builder(Component.Type.FILE, 2)
+    .setKey("some other key")
+    .setUuid("2")
+    .build();
 
   private static final String METRIC_KEY_1 = "metric 1";
   private static final String METRIC_KEY_2 = "metric 2";
@@ -82,13 +83,7 @@ public class MapBasedRawMeasureRepositoryTest {
   private ReportMetricValidator reportMetricValidator = mock(ReportMetricValidator.class);
 
   private MetricRepository metricRepository = mock(MetricRepository.class);
-  private MapBasedRawMeasureRepository<Integer> underTest = new MapBasedRawMeasureRepository<>(new Function<Component, Integer>() {
-    @Override
-    public Integer apply(Component component) {
-      return component.getReportAttributes().getRef();
-    }
-  });
-
+  private MapBasedRawMeasureRepository<Integer> underTest = new MapBasedRawMeasureRepository<>(component -> component.getReportAttributes().getRef());
   private DbClient mockedDbClient = mock(DbClient.class);
   private BatchReportReader mockBatchReportReader = mock(BatchReportReader.class);
   private MeasureRepositoryImpl underTestWithMock = new MeasureRepositoryImpl(mockedDbClient, mockBatchReportReader, metricRepository, reportMetricValidator);
@@ -159,13 +154,9 @@ public class MapBasedRawMeasureRepositoryTest {
 
   @DataProvider
   public static Object[][] measures() {
-    return from(MEASURES).transform(new Function<Measure, Object[]>() {
-      @Nullable
-      @Override
-      public Object[] apply(Measure input) {
-        return new Measure[] {input};
-      }
-    }).toArray(Object[].class);
+    return MEASURES.stream()
+      .map(c -> new Measure[] {c})
+      .toArray(i -> new Object[i][]);
   }
 
   @Test
@@ -206,12 +197,9 @@ public class MapBasedRawMeasureRepositoryTest {
   }
 
   private Measure getSomeMeasureByValueType(final Metric.MetricType metricType) {
-    return from(MEASURES).filter(new Predicate<Measure>() {
-      @Override
-      public boolean apply(@Nonnull Measure input) {
-        return input.getValueType() == metricType.getValueType();
-      }
-    }).first().get();
+    return MEASURES.stream()
+      .filter(measure -> measure.getValueType() == metricType.getValueType())
+      .findFirst().get();
   }
 
   @Test
index 4af541b70bef7a19ac57a851d12c8c2afa72507f..154d8c5116db485ab171fc8fd520d79ca6dafe3f 100644 (file)
@@ -41,7 +41,6 @@ import static org.sonar.api.measures.CoreMetrics.NCLOC;
 import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -55,23 +54,19 @@ public class ReportMeasureComputersVisitorTest {
 
   private static final org.sonar.api.measures.Metric<Integer> NEW_METRIC = new org.sonar.api.measures.Metric.Builder(NEW_METRIC_KEY, NEW_METRIC_NAME,
     org.sonar.api.measures.Metric.ValueType.INT)
-      .create();
+    .create();
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
   private static final int DIRECTORY_REF = 123;
   private static final int FILE_1_REF = 1231;
   private static final int FILE_2_REF = 1232;
 
   private static final Component ROOT = builder(PROJECT, ROOT_REF).setKey("project")
     .addChildren(
-      builder(MODULE, MODULE_REF).setKey("module")
+      builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
         .addChildren(
-          builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
-            .addChildren(
-              builder(FILE, FILE_1_REF).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setKey("file2").build())
-            .build())
+          builder(FILE, FILE_1_REF).setKey("file1").build(),
+          builder(FILE, FILE_2_REF).setKey("file2").build())
         .build())
     .build();
 
@@ -99,8 +94,6 @@ public class ReportMeasureComputersVisitorTest {
     addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, 5);
     addRawMeasure(DIRECTORY_REF, NCLOC_KEY, 50);
     addRawMeasure(DIRECTORY_REF, COMMENT_LINES_KEY, 7);
-    addRawMeasure(MODULE_REF, NCLOC_KEY, 50);
-    addRawMeasure(MODULE_REF, COMMENT_LINES_KEY, 7);
     addRawMeasure(ROOT_REF, NCLOC_KEY, 50);
     addRawMeasure(ROOT_REF, COMMENT_LINES_KEY, 7);
 
@@ -134,7 +127,6 @@ public class ReportMeasureComputersVisitorTest {
     assertAddedRawMeasure(12, FILE_1_REF, NEW_METRIC_KEY);
     assertAddedRawMeasure(45, FILE_2_REF, NEW_METRIC_KEY);
     assertAddedRawMeasure(57, DIRECTORY_REF, NEW_METRIC_KEY);
-    assertAddedRawMeasure(57, MODULE_REF, NEW_METRIC_KEY);
     assertAddedRawMeasure(57, ROOT_REF, NEW_METRIC_KEY);
   }
 
@@ -146,8 +138,6 @@ public class ReportMeasureComputersVisitorTest {
     addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, 5);
     addRawMeasure(DIRECTORY_REF, NCLOC_KEY, 50);
     addRawMeasure(DIRECTORY_REF, COMMENT_LINES_KEY, 7);
-    addRawMeasure(MODULE_REF, NCLOC_KEY, 50);
-    addRawMeasure(MODULE_REF, COMMENT_LINES_KEY, 7);
     addRawMeasure(ROOT_REF, NCLOC_KEY, 50);
     addRawMeasure(ROOT_REF, COMMENT_LINES_KEY, 7);
 
@@ -159,7 +149,6 @@ public class ReportMeasureComputersVisitorTest {
     assertNoAddedRawMeasure(FILE_1_REF);
     assertNoAddedRawMeasure(FILE_2_REF);
     assertNoAddedRawMeasure(DIRECTORY_REF);
-    assertNoAddedRawMeasure(MODULE_REF);
     assertNoAddedRawMeasure(ROOT_REF);
   }
 
index 25f3da2a39c26b0d4359d88b9ee67ae1409f019b..6af0fe5cb74379eaefd607b87d691cdf3332bfa4 100644 (file)
@@ -52,7 +52,6 @@ import static org.sonar.api.measures.CoreMetrics.TECHNICAL_DEBT;
 import static org.sonar.api.measures.CoreMetrics.TECHNICAL_DEBT_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -73,20 +72,16 @@ public class MaintainabilityMeasuresVisitorTest {
   static final long DEV_COST_LANGUAGE_2 = 42;
 
   static final int PROJECT_REF = 1;
-  static final int MODULE_REF = 12;
   static final int DIRECTORY_REF = 123;
   static final int FILE_1_REF = 1231;
   static final int FILE_2_REF = 1232;
 
   static final Component ROOT_PROJECT = builder(Component.Type.PROJECT, PROJECT_REF).setKey("project")
     .addChildren(
-      builder(MODULE, MODULE_REF).setKey("module")
+      builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
         .addChildren(
-          builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
-            .addChildren(
-              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
-            .build())
+          builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
+          builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
         .build())
     .build();
 
@@ -139,38 +134,24 @@ public class MaintainabilityMeasuresVisitorTest {
 
   @Test
   public void compute_development_cost() {
-    ReportComponent root = builder(PROJECT, 1)
-      .addChildren(
-        builder(MODULE, 11)
-          .addChildren(
-            builder(DIRECTORY, 111)
-              .addChildren(
-                createFileComponent(LANGUAGE_KEY_1, 1111),
-                createFileComponent(LANGUAGE_KEY_2, 1112),
-                // Unit test should not be ignored
-                builder(FILE, 1113).setFileAttributes(new FileAttributes(true, LANGUAGE_KEY_1, 1)).build())
-              .build(),
-            builder(DIRECTORY, 112)
-              .addChildren(
-                createFileComponent(LANGUAGE_KEY_2, 1121))
-              .build())
-          .build(),
-        builder(MODULE, 12)
-          .addChildren(
-            builder(DIRECTORY, 121)
-              .addChildren(
-                createFileComponent(LANGUAGE_KEY_1, 1211))
-              .build(),
-            builder(DIRECTORY, 122).build())
-          .build(),
-        builder(MODULE, 13).build())
+    ReportComponent root = builder(PROJECT, 1).addChildren(
+      builder(DIRECTORY, 111).addChildren(
+        createFileComponent(LANGUAGE_KEY_1, 1111),
+        createFileComponent(LANGUAGE_KEY_2, 1112),
+        // Unit test should not be ignored
+        builder(FILE, 1113).setFileAttributes(new FileAttributes(true, LANGUAGE_KEY_1, 1)).build())
+        .build(),
+      builder(DIRECTORY, 112).addChildren(
+        createFileComponent(LANGUAGE_KEY_2, 1121))
+        .build(),
+      builder(DIRECTORY, 121).addChildren(
+        createFileComponent(LANGUAGE_KEY_1, 1211))
+        .build(),
+      builder(DIRECTORY, 122).build())
       .build();
 
     treeRootHolder.setRoot(root);
 
-    int ncloc1111 = 10;
-    addRawMeasure(NCLOC_KEY, 1111, ncloc1111);
-
     int ncloc1112 = 12;
     addRawMeasure(NCLOC_KEY, 1112, ncloc1112);
 
@@ -186,7 +167,6 @@ public class MaintainabilityMeasuresVisitorTest {
     underTest.visit(root);
 
     // verify measures on files
-    verifyAddedRawMeasure(1111, DEVELOPMENT_COST_KEY, Long.toString(ncloc1111 * DEV_COST_LANGUAGE_1));
     verifyAddedRawMeasure(1112, DEVELOPMENT_COST_KEY, Long.toString(ncloc1112 * DEV_COST_LANGUAGE_2));
     verifyAddedRawMeasure(1113, DEVELOPMENT_COST_KEY, Long.toString(ncloc1113 * DEV_COST_LANGUAGE_1));
     verifyAddedRawMeasure(1121, DEVELOPMENT_COST_KEY, Long.toString(nclocValue1121 * DEV_COST_LANGUAGE_2));
@@ -197,23 +177,13 @@ public class MaintainabilityMeasuresVisitorTest {
 
     // directory has children => dev cost is aggregated
     verifyAddedRawMeasure(111, DEVELOPMENT_COST_KEY, Long.toString(
-      ncloc1111 * DEV_COST_LANGUAGE_1 +
-        ncloc1112 * DEV_COST_LANGUAGE_2 +
+      ncloc1112 * DEV_COST_LANGUAGE_2 +
         ncloc1113 * DEV_COST_LANGUAGE_1));
     verifyAddedRawMeasure(112, DEVELOPMENT_COST_KEY, Long.toString(nclocValue1121 * DEV_COST_LANGUAGE_2));
     verifyAddedRawMeasure(121, DEVELOPMENT_COST_KEY, Long.toString(ncloc1211 * DEV_COST_LANGUAGE_1));
 
-    // just for fun, we didn't define any debt on module => they must all have rating A
-    verifyAddedRawMeasure(11, DEVELOPMENT_COST_KEY, Long.toString(
-      ncloc1111 * DEV_COST_LANGUAGE_1 +
-        ncloc1112 * DEV_COST_LANGUAGE_2 +
-        ncloc1113 * DEV_COST_LANGUAGE_1 +
-        nclocValue1121 * DEV_COST_LANGUAGE_2));
-    verifyAddedRawMeasure(12, DEVELOPMENT_COST_KEY, Long.toString(ncloc1211 * DEV_COST_LANGUAGE_1));
-    verifyAddedRawMeasure(13, DEVELOPMENT_COST_KEY, "0");
     verifyAddedRawMeasure(1, DEVELOPMENT_COST_KEY, Long.toString(
-      ncloc1111 * DEV_COST_LANGUAGE_1 +
-        ncloc1112 * DEV_COST_LANGUAGE_2 +
+      ncloc1112 * DEV_COST_LANGUAGE_2 +
         ncloc1113 * DEV_COST_LANGUAGE_1 +
         nclocValue1121 * DEV_COST_LANGUAGE_2 +
         ncloc1211 * DEV_COST_LANGUAGE_1));
@@ -236,9 +206,6 @@ public class MaintainabilityMeasuresVisitorTest {
     long directoryMaintainabilityCost = 100L;
     addRawMeasure(TECHNICAL_DEBT_KEY, DIRECTORY_REF, directoryMaintainabilityCost);
 
-    long moduleMaintainabilityCost = 100L;
-    addRawMeasure(TECHNICAL_DEBT_KEY, MODULE_REF, moduleMaintainabilityCost);
-
     long projectMaintainabilityCost = 1000L;
     addRawMeasure(TECHNICAL_DEBT_KEY, PROJECT_REF, projectMaintainabilityCost);
 
@@ -247,7 +214,6 @@ public class MaintainabilityMeasuresVisitorTest {
     verifyAddedRawMeasure(FILE_1_REF, SQALE_DEBT_RATIO_KEY, file1MaintainabilityCost * 1d / (file1Ncloc * DEV_COST_LANGUAGE_1) * 100);
     verifyAddedRawMeasure(FILE_2_REF, SQALE_DEBT_RATIO_KEY, file2MaintainabilityCost * 1d / (file2Ncloc * DEV_COST_LANGUAGE_1) * 100);
     verifyAddedRawMeasure(DIRECTORY_REF, SQALE_DEBT_RATIO_KEY, directoryMaintainabilityCost * 1d / ((file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1) * 100);
-    verifyAddedRawMeasure(MODULE_REF, SQALE_DEBT_RATIO_KEY, moduleMaintainabilityCost * 1d / ((file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1) * 100);
     verifyAddedRawMeasure(PROJECT_REF, SQALE_DEBT_RATIO_KEY, projectMaintainabilityCost * 1d / ((file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1) * 100);
   }
 
@@ -262,7 +228,6 @@ public class MaintainabilityMeasuresVisitorTest {
     addRawMeasure(TECHNICAL_DEBT_KEY, FILE_2_REF, 1L);
 
     addRawMeasure(TECHNICAL_DEBT_KEY, DIRECTORY_REF, 100L);
-    addRawMeasure(TECHNICAL_DEBT_KEY, MODULE_REF, 100L);
     addRawMeasure(TECHNICAL_DEBT_KEY, PROJECT_REF, 1000L);
 
     underTest.visit(ROOT_PROJECT);
@@ -270,7 +235,6 @@ public class MaintainabilityMeasuresVisitorTest {
     verifyAddedRawMeasure(FILE_1_REF, SQALE_RATING_KEY, C);
     verifyAddedRawMeasure(FILE_2_REF, SQALE_RATING_KEY, A);
     verifyAddedRawMeasure(DIRECTORY_REF, SQALE_RATING_KEY, C);
-    verifyAddedRawMeasure(MODULE_REF, SQALE_RATING_KEY, C);
     verifyAddedRawMeasure(PROJECT_REF, SQALE_RATING_KEY, E);
   }
 
@@ -291,9 +255,6 @@ public class MaintainabilityMeasuresVisitorTest {
     long dirEffort = 120L;
     addRawMeasure(TECHNICAL_DEBT_KEY, DIRECTORY_REF, dirEffort);
 
-    long moduleEffort = 120L;
-    addRawMeasure(TECHNICAL_DEBT_KEY, MODULE_REF, moduleEffort);
-
     long projectEffort = 150L;
     addRawMeasure(TECHNICAL_DEBT_KEY, PROJECT_REF, projectEffort);
 
@@ -305,8 +266,6 @@ public class MaintainabilityMeasuresVisitorTest {
       (long) (file2Effort - RATING_GRID[0] * file2Ncloc * DEV_COST_LANGUAGE_1));
     verifyAddedRawMeasure(DIRECTORY_REF, EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
       (long) (dirEffort - RATING_GRID[0] * (file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1));
-    verifyAddedRawMeasure(MODULE_REF, EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
-      (long) (moduleEffort - RATING_GRID[0] * (file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1));
     verifyAddedRawMeasure(PROJECT_REF, EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
       (long) (projectEffort - RATING_GRID[0] * (file1Ncloc + file2Ncloc) * DEV_COST_LANGUAGE_1));
   }
index 61ca6452f9298f3cede7c2e890d87d717c5dd048..1931072d0aacc26461a803ac98be9e30cbe2a018 100644 (file)
@@ -58,7 +58,6 @@ import static org.sonar.api.measures.CoreMetrics.NEW_TECHNICAL_DEBT;
 import static org.sonar.api.measures.CoreMetrics.NEW_TECHNICAL_DEBT_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
 import static org.sonar.ce.task.projectanalysis.measure.MeasureAssert.assertThat;
@@ -280,18 +279,14 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, 11)
-            .addChildren(
-              builder(DIRECTORY, 111)
-                .addChildren(file)
-                .build())
+          builder(DIRECTORY, 111)
+            .addChildren(file)
             .build())
         .build());
 
     Measure newDebtMeasure = createNewDebtMeasure(50);
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
     measureRepository.addRawMeasure(111, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(150));
-    measureRepository.addRawMeasure(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
     measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(250));
     // 4 lines file, only first one is not ncloc
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
@@ -301,7 +296,6 @@ public class NewMaintainabilityMeasuresVisitorTest {
 
     assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 83.33);
     assertNewDebtRatioValues(111, 83.33);
-    assertNewDebtRatioValues(11, 83.33);
     assertNewDebtRatioValues(ROOT_REF, 83.33);
   }
 
@@ -312,18 +306,14 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, 11)
-            .addChildren(
-              builder(DIRECTORY, 111)
-                .addChildren(file)
-                .build())
+          builder(DIRECTORY, 111)
+            .addChildren(file)
             .build())
         .build());
 
     Measure newDebtMeasure = createNewDebtMeasure(50);
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
     measureRepository.addRawMeasure(111, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(150));
-    measureRepository.addRawMeasure(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
     measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(250));
     // 4 lines file, only first one is not ncloc
     measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
@@ -335,7 +325,6 @@ public class NewMaintainabilityMeasuresVisitorTest {
 
     assertNewMaintainability(LANGUAGE_1_FILE_REF, D);
     assertNewMaintainability(111, D);
-    assertNewMaintainability(11, D);
     assertNewMaintainability(ROOT_REF, D);
   }
 
@@ -347,11 +336,8 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, 11)
-            .addChildren(
-              builder(DIRECTORY, 111)
-                .addChildren(file1, file2)
-                .build())
+          builder(DIRECTORY, 111)
+            .addChildren(file1, file2)
             .build())
         .build());
 
@@ -379,12 +365,9 @@ public class NewMaintainabilityMeasuresVisitorTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, 11)
+          builder(DIRECTORY, 111)
             .addChildren(
-              builder(DIRECTORY, 111)
-                .addChildren(
-                  builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
-                .build())
+              builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
             .build())
         .build());
 
@@ -392,7 +375,6 @@ public class NewMaintainabilityMeasuresVisitorTest {
 
     assertNewMaintainability(LANGUAGE_1_FILE_REF, A);
     assertNewMaintainability(111, A);
-    assertNewMaintainability(11, A);
     assertNewMaintainability(ROOT_REF, A);
   }
 
index c390400d599fcb10a084a11fa9ee9d0a81b6e5c1..f76530bf9214a7a9ab390c0d3011eda9001094de 100644 (file)
@@ -57,7 +57,6 @@ import static org.sonar.api.rules.RuleType.CODE_SMELL;
 import static org.sonar.api.rules.RuleType.VULNERABILITY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.server.measure.Rating.A;
@@ -76,14 +75,14 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
   static final String LANGUAGE_KEY_1 = "lKey1";
 
   static final int PROJECT_REF = 1;
-  static final int MODULE_REF = 12;
+  static final int DIR_REF = 12;
   static final int DIRECTORY_REF = 123;
   static final int FILE_1_REF = 1231;
   static final int FILE_2_REF = 1232;
 
   static final Component ROOT_PROJECT = builder(Component.Type.PROJECT, PROJECT_REF).setKey("project")
     .addChildren(
-      builder(MODULE, MODULE_REF).setKey("module")
+      builder(DIRECTORY, DIR_REF).setKey("dir")
         .addChildren(
           builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
             .addChildren(
@@ -150,7 +149,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
       newVulnerabilityIssue(3L, MINOR).setCreationDate(AFTER_LEAK_PERIOD_DATE),
       // Should not be taken into account
       newVulnerabilityIssue(10L, BLOCKER).setCreationDate(AFTER_LEAK_PERIOD_DATE).setResolution(RESOLUTION_FIXED));
-    fillComponentIssuesVisitorRule.setIssues(MODULE_REF,
+    fillComponentIssuesVisitorRule.setIssues(DIR_REF,
       newVulnerabilityIssue(7L, BLOCKER).setCreationDate(AFTER_LEAK_PERIOD_DATE));
 
     underTest.visit(ROOT_PROJECT);
@@ -158,7 +157,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_SECURITY_RATING_KEY, C);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_SECURITY_RATING_KEY, D);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_SECURITY_RATING_KEY, D);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_SECURITY_RATING_KEY, E);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_SECURITY_RATING_KEY, E);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_SECURITY_RATING_KEY, E);
   }
 
@@ -172,7 +171,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_SECURITY_RATING_KEY, A);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_SECURITY_RATING_KEY, A);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_SECURITY_RATING_KEY, A);
   }
 
@@ -187,7 +186,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_SECURITY_RATING_KEY, A);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_SECURITY_RATING_KEY, A);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_SECURITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_SECURITY_RATING_KEY, A);
   }
 
@@ -204,7 +203,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
       newBugIssue(3L, MINOR).setCreationDate(AFTER_LEAK_PERIOD_DATE),
       // Should not be taken into account
       newBugIssue(10L, BLOCKER).setCreationDate(AFTER_LEAK_PERIOD_DATE).setResolution(RESOLUTION_FIXED));
-    fillComponentIssuesVisitorRule.setIssues(MODULE_REF,
+    fillComponentIssuesVisitorRule.setIssues(DIR_REF,
       newBugIssue(7L, BLOCKER).setCreationDate(AFTER_LEAK_PERIOD_DATE));
 
     underTest.visit(ROOT_PROJECT);
@@ -212,7 +211,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_RELIABILITY_RATING_KEY, C);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_RELIABILITY_RATING_KEY, D);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_RELIABILITY_RATING_KEY, D);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_RELIABILITY_RATING_KEY, E);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_RELIABILITY_RATING_KEY, E);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_RELIABILITY_RATING_KEY, E);
   }
 
@@ -226,7 +225,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_RELIABILITY_RATING_KEY, A);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_RELIABILITY_RATING_KEY, A);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_RELIABILITY_RATING_KEY, A);
   }
 
@@ -241,7 +240,7 @@ public class NewReliabilityAndSecurityRatingMeasuresVisitorTest {
     verifyAddedRawMeasureOnLeakPeriod(FILE_1_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(FILE_2_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(DIRECTORY_REF, NEW_RELIABILITY_RATING_KEY, A);
-    verifyAddedRawMeasureOnLeakPeriod(MODULE_REF, NEW_RELIABILITY_RATING_KEY, A);
+    verifyAddedRawMeasureOnLeakPeriod(DIR_REF, NEW_RELIABILITY_RATING_KEY, A);
     verifyAddedRawMeasureOnLeakPeriod(PROJECT_REF, NEW_RELIABILITY_RATING_KEY, A);
   }
 
index 43cde5495abd19ba67dd459b700e227ed7543ca4..5bace1873f6bcd5bad8aff7d01dbc8c22bc6d710 100644 (file)
@@ -55,7 +55,6 @@ import static org.sonar.api.rules.RuleType.CODE_SMELL;
 import static org.sonar.api.rules.RuleType.VULNERABILITY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -72,20 +71,16 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorTest {
   static final String LANGUAGE_KEY_1 = "lKey1";
 
   static final int PROJECT_REF = 1;
-  static final int MODULE_REF = 12;
   static final int DIRECTORY_REF = 123;
   static final int FILE_1_REF = 1231;
   static final int FILE_2_REF = 1232;
 
   static final Component ROOT_PROJECT = builder(Component.Type.PROJECT, PROJECT_REF).setKey("project")
     .addChildren(
-      builder(MODULE, MODULE_REF).setKey("module")
+      builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
         .addChildren(
-          builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
-            .addChildren(
-              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
-              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
-            .build())
+          builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file1").build(),
+          builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_KEY_1, 1)).setKey("file2").build())
         .build())
     .build();
 
@@ -131,14 +126,13 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorTest {
     fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newBugIssue(2L, CRITICAL), newBugIssue(3L, MINOR),
       // Should not be taken into account
       newBugIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED));
-    fillComponentIssuesVisitorRule.setIssues(MODULE_REF, newBugIssue(7L, BLOCKER));
+    fillComponentIssuesVisitorRule.setIssues(PROJECT_REF, newBugIssue(7L, BLOCKER));
 
     underTest.visit(ROOT_PROJECT);
 
     verifyAddedRawMeasure(FILE_1_REF, RELIABILITY_RATING_KEY, C);
     verifyAddedRawMeasure(FILE_2_REF, RELIABILITY_RATING_KEY, D);
     verifyAddedRawMeasure(DIRECTORY_REF, RELIABILITY_RATING_KEY, D);
-    verifyAddedRawMeasure(MODULE_REF, RELIABILITY_RATING_KEY, E);
     verifyAddedRawMeasure(PROJECT_REF, RELIABILITY_RATING_KEY, E);
   }
 
@@ -151,14 +145,13 @@ public class ReliabilityAndSecurityRatingMeasuresVisitorTest {
     fillComponentIssuesVisitorRule.setIssues(FILE_2_REF, newVulnerabilityIssue(2L, CRITICAL), newVulnerabilityIssue(3L, MINOR),
       // Should not be taken into account
       newVulnerabilityIssue(10L, BLOCKER).setResolution(RESOLUTION_FIXED));
-    fillComponentIssuesVisitorRule.setIssues(MODULE_REF, newVulnerabilityIssue(7L, BLOCKER));
+    fillComponentIssuesVisitorRule.setIssues(PROJECT_REF, newVulnerabilityIssue(7L, BLOCKER));
 
     underTest.visit(ROOT_PROJECT);
 
     verifyAddedRawMeasure(FILE_1_REF, SECURITY_RATING_KEY, C);
     verifyAddedRawMeasure(FILE_2_REF, SECURITY_RATING_KEY, D);
     verifyAddedRawMeasure(DIRECTORY_REF, SECURITY_RATING_KEY, D);
-    verifyAddedRawMeasure(MODULE_REF, SECURITY_RATING_KEY, E);
     verifyAddedRawMeasure(PROJECT_REF, SECURITY_RATING_KEY, E);
   }
 
index 51b39f6c20898ed7592c898265854ce312859cb1..c10b50d225d3ead7d57aac80808d54d8def282d4 100644 (file)
@@ -40,7 +40,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.measures.CoreMetrics.LAST_COMMIT_DATE_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -51,7 +50,7 @@ import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilde
 public class LastCommitVisitorTest {
 
   private static final int PROJECT_REF = 1;
-  private static final int MODULE_REF = 2;
+  private static final int DIR_REF = 2;
   private static final int FILE_1_REF = 1_111;
   private static final int FILE_2_REF = 1_112;
   private static final int FILE_3_REF = 1_121;
@@ -104,7 +103,7 @@ public class LastCommitVisitorTest {
     // project with 1 module, 2 directories and 3 files
     ReportComponent project = ReportComponent.builder(PROJECT, PROJECT_REF)
       .addChildren(
-        ReportComponent.builder(MODULE, MODULE_REF)
+        ReportComponent.builder(DIRECTORY, DIR_REF)
           .addChildren(
             ReportComponent.builder(DIRECTORY, DIR_1_REF)
               .addChildren(
@@ -125,8 +124,7 @@ public class LastCommitVisitorTest {
     assertDate(DIR_1_REF, FILE_2_DATE);
     assertDate(DIR_2_REF, FILE_3_DATE);
 
-    // module = most recent commit date of directories
-    assertDate(MODULE_REF, FILE_3_DATE);
+    assertDate(DIR_REF, FILE_3_DATE);
 
     // project
     assertDate(PROJECT_REF, FILE_3_DATE);
index 2f81951f3768aeba9510facc33d6a9b4b5328b57..a519bd661b801eea8efb9a529fef45653e78bf31 100644 (file)
@@ -101,7 +101,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
         DbFileSources.Line.newBuilder().setSource("line1").setLine(1).build(),
         DbFileSources.Line.newBuilder().setSource("line2").setLine(2).build()))
       .build();
-    when(fileSourceDataComputer.compute(fileComponent(), fileSourceDataWarnings)).thenReturn(new FileSourceDataComputer.Data(fileSourceData, lineHashes, sourceHash, null));
+    when(fileSourceDataComputer.compute(fileComponent().build(), fileSourceDataWarnings))
+      .thenReturn(new FileSourceDataComputer.Data(fileSourceData, lineHashes, sourceHash, null));
 
     underTest.execute(new TestComputationStepContext());
 
@@ -160,8 +161,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     verify(fileSourceDataWarnings).commitWarnings();
   }
 
-  private Component fileComponent() {
-    return ReportComponent.builder(Component.Type.FILE, FILE1_REF).build();
+  private ReportComponent.Builder fileComponent() {
+    return ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("PROJECT_KEY" + ":src/Foo.java");
   }
 
   @Test
@@ -439,20 +440,17 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
 
   private void setComputedData(DbFileSources.Data data, List<String> lineHashes, String sourceHash, Changeset latestChangeWithRevision) {
     FileSourceDataComputer.Data computedData = new FileSourceDataComputer.Data(data, lineHashes, sourceHash, latestChangeWithRevision);
-    when(fileSourceDataComputer.compute(fileComponent(), fileSourceDataWarnings)).thenReturn(computedData);
+    when(fileSourceDataComputer.compute(fileComponent().build(), fileSourceDataWarnings)).thenReturn(computedData);
   }
 
   private void setComputedData(DbFileSources.Data data) {
     FileSourceDataComputer.Data computedData = new FileSourceDataComputer.Data(data, Collections.emptyList(), "", null);
-    when(fileSourceDataComputer.compute(fileComponent(), fileSourceDataWarnings)).thenReturn(computedData);
+    when(fileSourceDataComputer.compute(fileComponent().build(), fileSourceDataWarnings)).thenReturn(computedData);
   }
 
   private void initBasicReport(int numberOfLines) {
     ReportComponent root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren(
-        ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("MODULE_KEY:src/Foo.java")
-          .setFileAttributes(new FileAttributes(false, null, numberOfLines)).build())
-        .build())
+      fileComponent().setFileAttributes(new FileAttributes(false, null, numberOfLines)).build())
       .build();
     treeRootHolder.setRoots(root, root);
   }
index c32d000a20b9cee9bbef12c07797896ee3fa48a6..56d326d10ab66b61162a09523afa8a6229ade390 100644 (file)
@@ -69,7 +69,7 @@ public class SourceLineReadersFactoryTest {
 
   private void initBasicReport(int numberOfLines) {
     treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren(
+      ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren(
         ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("MODULE_KEY:src/Foo.java")
           .setFileAttributes(new FileAttributes(false, null, numberOfLines)).build())
         .build())
index 428534df7b9011b03fbef06919473d5a0ebf16f3..46afb3798517fbbd2a578491e4dd8a8f7d71ed85 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.ce.task.projectanalysis.batch.BatchReportReaderRule;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl;
 import org.sonar.ce.task.projectanalysis.component.MutableTreeRootHolderRule;
+import org.sonar.ce.task.projectanalysis.issue.IssueRelocationToRoot;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
@@ -47,10 +48,6 @@ import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
 import org.sonar.scanner.protocol.output.ScannerReport.Component.FileStatus;
 import org.sonar.server.project.Project;
 
-import static com.google.common.base.Predicates.in;
-import static com.google.common.base.Predicates.not;
-import static com.google.common.collect.FluentIterable.from;
-import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
@@ -65,8 +62,6 @@ import static org.sonar.scanner.protocol.output.ScannerReport.Component.Componen
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.MODULE;
 import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.PROJECT;
-import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.UNRECOGNIZED;
-import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.UNSET;
 
 @RunWith(DataProviderRunner.class)
 public class BuildComponentTreeStepTest {
@@ -84,13 +79,14 @@ public class BuildComponentTreeStepTest {
 
   private static final String REPORT_PROJECT_KEY = "REPORT_PROJECT_KEY";
   private static final String REPORT_MODULE_KEY = "MODULE_KEY";
-  private static final String REPORT_DIR_KEY_1 = "src/main/java/dir1";
-  private static final String REPORT_FILE_KEY_1 = "src/main/java/dir1/File1.java";
-  private static final String REPORT_DIR_KEY_2 = "src/main/java/dir2";
-  private static final String REPORT_FILE_KEY_2 = "src/main/java/dir2/File2.java";
+  private static final String REPORT_DIR_PATH_1 = "src/main/java/dir1";
+  private static final String REPORT_FILE_PATH_1 = "src/main/java/dir1/File1.java";
+  private static final String REPORT_DIR_PATH_2 = "src/main/java/dir2";
+  private static final String REPORT_FILE_PATH_2 = "src/main/java/dir2/File2.java";
+  private static final String REPORT_FILE_PATH_3 = "src/main/java/dir2/File3.java";
   private static final String REPORT_LEAFLESS_MODULE_KEY = "LEAFLESS_MODULE_KEY";
-  private static final String REPORT_LEAFLESS_DIR_KEY = "src/main/java/leafless";
-  private static final String REPORT_UNCHANGED_FILE_KEY = "src/main/java/leafless/File3.java";
+  private static final String REPORT_LEAFLESS_DIR_PATH = "src/main/java/leafless";
+  private static final String REPORT_UNCHANGED_FILE_PATH = "src/main/java/leafless/File3.java";
 
   private static final long ANALYSIS_DATE = 123456789L;
 
@@ -107,8 +103,10 @@ public class BuildComponentTreeStepTest {
   @Rule
   public MutableAnalysisMetadataHolderRule analysisMetadataHolder = new MutableAnalysisMetadataHolderRule();
 
+  private IssueRelocationToRoot issueRelocationToRoot = mock(IssueRelocationToRoot.class);
+
   private DbClient dbClient = dbTester.getDbClient();
-  private BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
+  private BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
 
   @Test(expected = NullPointerException.class)
   public void fails_if_root_component_does_not_exist_in_reportReader() {
@@ -117,43 +115,16 @@ public class BuildComponentTreeStepTest {
     underTest.execute(new TestComputationStepContext());
   }
 
-  @DataProvider
-  public static Object[][] allComponentTypes() {
-    Object[][] res = new Object[ComponentType.values().length - 2][1];
-    int i = 0;
-    for (ComponentType componentType : from(asList(ComponentType.values())).filter(not(in(asList(UNSET, UNRECOGNIZED))))) {
-      res[i][0] = componentType;
-      i++;
-    }
-    return res;
-  }
-
-  @Test
-  @UseDataProvider("allComponentTypes")
-  public void verify_ref_and_type(ComponentType componentType) {
-    setAnalysisMetadataHolder();
-    int componentRef = 1;
-    reportReader.putComponent(component(componentRef, componentType));
-
-    underTest.execute(new TestComputationStepContext());
-
-    Component root = treeRootHolder.getRoot();
-    assertThat(root).isNotNull();
-    assertThat(root.getType()).isEqualTo(Component.Type.valueOf(componentType.name()));
-    assertThat(root.getReportAttributes().getRef()).isEqualTo(ROOT_REF);
-    assertThat(root.getChildren()).isEmpty();
-  }
-
   @Test
   public void verify_tree_is_correctly_built() {
     setAnalysisMetadataHolder();
-    reportReader.putComponent(component(ROOT_REF, PROJECT, MODULE_REF));
-    reportReader.putComponent(component(MODULE_REF, MODULE, DIR_REF_1, DIR_REF_2));
-    reportReader.putComponent(component(DIR_REF_1, DIRECTORY, FILE_1_REF, FILE_2_REF));
-    reportReader.putComponent(component(FILE_1_REF, FILE));
-    reportReader.putComponent(component(FILE_2_REF, FILE));
-    reportReader.putComponent(component(DIR_REF_2, DIRECTORY, FILE_3_REF));
-    reportReader.putComponent(component(FILE_3_REF, FILE));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1, DIR_REF_2));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF, FILE_2_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
+    reportReader.putComponent(componentWithPath(FILE_2_REF, FILE, REPORT_FILE_PATH_2));
+    reportReader.putComponent(componentWithPath(DIR_REF_2, DIRECTORY, REPORT_DIR_PATH_2, FILE_3_REF));
+    reportReader.putComponent(componentWithPath(FILE_3_REF, FILE, REPORT_FILE_PATH_3));
 
     TestComputationStepContext context = new TestComputationStepContext();
     underTest.execute(context);
@@ -161,15 +132,18 @@ public class BuildComponentTreeStepTest {
     Component root = treeRootHolder.getRoot();
     assertThat(root).isNotNull();
     verifyComponent(root, Component.Type.PROJECT, ROOT_REF, 1);
-    Component module = root.getChildren().iterator().next();
-    verifyComponent(module, Component.Type.MODULE, MODULE_REF, 2);
-    Component dir1 = module.getChildren().get(0);
-    verifyComponent(dir1, Component.Type.DIRECTORY, DIR_REF_1, 2);
+
+    Component dir = root.getChildren().iterator().next();
+    verifyComponent(dir, Component.Type.DIRECTORY, null, 2);
+
+    Component dir1 = dir.getChildren().get(0);
+    verifyComponent(dir1, Component.Type.DIRECTORY, null, 1);
     verifyComponent(dir1.getChildren().get(0), Component.Type.FILE, FILE_1_REF, 0);
-    verifyComponent(dir1.getChildren().get(1), Component.Type.FILE, FILE_2_REF, 0);
-    Component dir2 = module.getChildren().get(1);
-    verifyComponent(dir2, Component.Type.DIRECTORY, DIR_REF_2, 1);
-    verifyComponent(dir2.getChildren().iterator().next(), Component.Type.FILE, FILE_3_REF, 0);
+
+    Component dir2 = dir.getChildren().get(1);
+    verifyComponent(dir2, Component.Type.DIRECTORY, null, 2);
+    verifyComponent(dir2.getChildren().get(0), Component.Type.FILE, FILE_2_REF, 0);
+    verifyComponent(dir2.getChildren().get(1), Component.Type.FILE, FILE_3_REF, 0);
 
     context.getStatistics().assertValue("components", 7);
   }
@@ -177,17 +151,16 @@ public class BuildComponentTreeStepTest {
   @Test
   public void compute_keys_and_uuids() {
     setAnalysisMetadataHolder();
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY);
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY);
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1);
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1);
   }
 
   @Test
@@ -196,21 +169,21 @@ public class BuildComponentTreeStepTest {
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
     ComponentDto module = insertComponent(newModuleDto("BCDE", project).setDbKey(REPORT_MODULE_KEY));
-    ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_KEY_1);
-    insertComponent(directory.setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
-    insertComponent(newFileDto(module, directory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1));
+    ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_PATH_1);
+    insertComponent(directory.setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_PATH_1));
+    insertComponent(newFileDto(module, directory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_PATH_1));
 
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY, "ABCD");
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY, "BCDE");
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, "CDEF");
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, "DEFG");
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, "ABCD");
+    // TODO migrate modules
+    //    verifyComponentByRef(DIR_REF_1, REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "CDEF");
+    //   verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, "DEFG");
   }
 
   @Test
@@ -224,18 +197,18 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(newPrivateProjectDto(newOrganizationDto()).setDbKey(REPORT_PROJECT_KEY)))
       .setBranch(branch);
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
-    verifyComponent(MODULE_REF, "generated", REPORT_MODULE_KEY, null);
-    verifyComponent(DIR_REF_1, "generated", REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, null);
-    verifyComponent(FILE_1_REF, "generated", REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, null);
+    verifyComponentByRef(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
+
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "generated");
+    verifyComponentByRef(FILE_1_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, null);
   }
 
   @Test
@@ -251,18 +224,18 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(newPrivateProjectDto(newOrganizationDto()).setDbKey(REPORT_PROJECT_KEY)))
       .setBranch(branch);
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, LEAFLESS_MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
-
-    reportReader.putComponent(componentWithKey(LEAFLESS_MODULE_REF, MODULE, REPORT_LEAFLESS_MODULE_KEY, LEAFLESS_DIR_REF));
-    reportReader.putComponent(componentWithPath(LEAFLESS_DIR_REF, DIRECTORY, REPORT_LEAFLESS_DIR_KEY, UNCHANGED_FILE_REF));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, LEAFLESS_MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
+
+    reportReader.putComponent(component(LEAFLESS_MODULE_REF, MODULE, REPORT_LEAFLESS_MODULE_KEY, LEAFLESS_DIR_REF));
+    reportReader.putComponent(componentWithPath(LEAFLESS_DIR_REF, DIRECTORY, REPORT_LEAFLESS_DIR_PATH, UNCHANGED_FILE_REF));
     ScannerReport.Component unchangedFile = ScannerReport.Component.newBuilder()
       .setType(FILE)
       .setRef(UNCHANGED_FILE_REF)
-      .setPath(REPORT_UNCHANGED_FILE_KEY)
+      .setProjectRelativePath(REPORT_UNCHANGED_FILE_PATH)
       .setStatus(FileStatus.SAME)
       .setLines(1)
       .build();
@@ -270,14 +243,13 @@ public class BuildComponentTreeStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
-    verifyComponent(MODULE_REF, "generated", REPORT_MODULE_KEY, null);
-    verifyComponent(DIR_REF_1, "generated", REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, null);
-    verifyComponent(FILE_1_REF, "generated", REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, null);
+    verifyComponentByRef(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "generated");
+    verifyComponentByRef(FILE_1_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, null);
 
-    verifyComponentMissing(LEAFLESS_MODULE_REF);
-    verifyComponentMissing(LEAFLESS_DIR_REF);
-    verifyComponentMissing(UNCHANGED_FILE_REF);
+    verifyComponentMissingByRef(LEAFLESS_MODULE_REF);
+    verifyComponentMissingByRef(LEAFLESS_DIR_REF);
+    verifyComponentMissingByRef(UNCHANGED_FILE_REF);
   }
 
   @Test
@@ -292,18 +264,18 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(newPrivateProjectDto(newOrganizationDto()).setDbKey(REPORT_PROJECT_KEY)))
       .setBranch(branch);
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, LEAFLESS_MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
-
-    reportReader.putComponent(componentWithKey(LEAFLESS_MODULE_REF, MODULE, REPORT_LEAFLESS_MODULE_KEY, LEAFLESS_DIR_REF));
-    reportReader.putComponent(componentWithPath(LEAFLESS_DIR_REF, DIRECTORY, REPORT_LEAFLESS_DIR_KEY, UNCHANGED_FILE_REF));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, LEAFLESS_MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
+
+    reportReader.putComponent(component(LEAFLESS_MODULE_REF, MODULE, REPORT_LEAFLESS_MODULE_KEY, LEAFLESS_DIR_REF));
+    reportReader.putComponent(componentWithPath(LEAFLESS_DIR_REF, DIRECTORY, REPORT_LEAFLESS_DIR_PATH, UNCHANGED_FILE_REF));
     ScannerReport.Component unchangedFile = ScannerReport.Component.newBuilder()
       .setType(FILE)
       .setRef(UNCHANGED_FILE_REF)
-      .setPath(REPORT_UNCHANGED_FILE_KEY)
+      .setProjectRelativePath(REPORT_UNCHANGED_FILE_PATH)
       .setStatus(FileStatus.SAME)
       .setLines(1)
       .build();
@@ -311,14 +283,14 @@ public class BuildComponentTreeStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
-    verifyComponent(MODULE_REF, "generated", REPORT_MODULE_KEY, null);
-    verifyComponent(DIR_REF_1, "generated", REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, null);
-    verifyComponent(FILE_1_REF, "generated", REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, null);
+    verifyComponentByRef(ROOT_REF, "generated", REPORT_PROJECT_KEY, null);
+    verifyComponentMissingByRef(MODULE_REF);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "generated");
+    verifyComponentByRef(FILE_1_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, null);
 
-    verifyComponent(LEAFLESS_MODULE_REF, "generated", REPORT_LEAFLESS_MODULE_KEY, null);
-    verifyComponent(LEAFLESS_DIR_REF, "generated", REPORT_LEAFLESS_MODULE_KEY + ":" + REPORT_LEAFLESS_DIR_KEY, null);
-    verifyComponent(UNCHANGED_FILE_REF, "generated", REPORT_LEAFLESS_MODULE_KEY + ":" + REPORT_UNCHANGED_FILE_KEY, null);
+    verifyComponentMissingByRef(LEAFLESS_MODULE_REF);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_LEAFLESS_DIR_PATH, "generated");
+    verifyComponentByRef(UNCHANGED_FILE_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_UNCHANGED_FILE_PATH, null);
   }
 
   @DataProvider
@@ -339,12 +311,12 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(projectDto))
       .setBranch(branch);
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, branchDto.getKey()));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, branchDto.getKey()));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, branchDto.getDbKey(), branchDto.getKey(), branchDto.uuid());
+    verifyComponentByRef(ROOT_REF, branchDto.getDbKey(), branchDto.getKey(), branchDto.uuid());
   }
 
   @Test
@@ -354,18 +326,18 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(newPrivateProjectDto(newOrganizationDto()).setDbKey(REPORT_PROJECT_KEY)))
       .setBranch(branch);
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY, REPORT_PROJECT_KEY, null);
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY, REPORT_MODULE_KEY, null);
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, null);
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, null);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, REPORT_PROJECT_KEY, null);
+    verifyComponentMissingByRef(MODULE_REF);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, null);
   }
 
   @Test
@@ -374,56 +346,58 @@ public class BuildComponentTreeStepTest {
       .setAnalysisDate(ANALYSIS_DATE)
       .setProject(Project.from(newPrivateProjectDto(newOrganizationDto()).setDbKey(REPORT_PROJECT_KEY)))
       .setBranch(new DefaultBranchImpl("origin/feature"));
-    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, issueRelocationToRoot);
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY + ":origin/feature", null);
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY + ":origin/feature", null);
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":origin/feature:" + REPORT_DIR_KEY_1, null);
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":origin/feature:" + REPORT_FILE_KEY_1, null);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY + ":origin/feature", null);
+    verifyComponentMissingByRef(MODULE_REF);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":origin/feature:" + REPORT_DIR_PATH_1);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":origin/feature:" + REPORT_FILE_PATH_1, null);
   }
 
   @Test
   public void compute_keys_and_uuids_on_project_having_module_and_directory() {
     setAnalysisMetadataHolder();
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, DIR_REF_2));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_2, DIRECTORY, REPORT_DIR_KEY_2, FILE_2_REF));
-    reportReader.putComponent(componentWithPath(FILE_2_REF, FILE, REPORT_FILE_KEY_2));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF, DIR_REF_2));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_2, DIRECTORY, REPORT_DIR_PATH_2, FILE_2_REF));
+    reportReader.putComponent(componentWithPath(FILE_2_REF, FILE, REPORT_FILE_PATH_2));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY);
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY);
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1);
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1);
-    verifyComponent(DIR_REF_2, REPORT_PROJECT_KEY + ":" + REPORT_DIR_KEY_2);
-    verifyComponent(FILE_2_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_KEY_2);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY);
+    verifyComponentMissingByRef(MODULE_REF);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1);
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_2);
+    verifyComponentByRef(FILE_2_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_2);
   }
 
   @Test
   public void compute_keys_and_uuids_on_multi_modules() {
     setAnalysisMetadataHolder();
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, 100));
-    reportReader.putComponent(componentWithKey(100, MODULE, "SUB_MODULE_KEY", DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, 100));
+    reportReader.putComponent(component(100, MODULE, "SUB_MODULE_KEY", DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY);
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY);
-    verifyComponent(100, "SUB_MODULE_KEY");
-    verifyComponent(DIR_REF_1, "SUB_MODULE_KEY" + ":" + REPORT_DIR_KEY_1);
-    verifyComponent(FILE_1_REF, "SUB_MODULE_KEY" + ":" + REPORT_FILE_KEY_1);
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY);
+    verifyComponentMissingByRef(MODULE_REF);
+    verifyComponentMissingByKey(REPORT_MODULE_KEY);
+    verifyComponentMissingByRef(100);
+    verifyComponentMissingByKey("SUB_MODULE_KEY");
+    verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1);
+    verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1);
   }
 
   @Test
@@ -432,28 +406,29 @@ public class BuildComponentTreeStepTest {
     OrganizationDto organizationDto = dbTester.organizations().insert();
     ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
     ComponentDto removedModule = insertComponent(newModuleDto("BCDE", project).setDbKey(REPORT_MODULE_KEY).setEnabled(false));
-    ComponentDto removedDirectory = insertComponent(newDirectory(removedModule, "CDEF", REPORT_DIR_KEY_1).setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1).setEnabled(false));
-    insertComponent(newFileDto(removedModule, removedDirectory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
+    ComponentDto removedDirectory = insertComponent(newDirectory(removedModule, "CDEF", REPORT_DIR_PATH_1).setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_PATH_1).setEnabled(false));
+    insertComponent(newFileDto(removedModule, removedDirectory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_PATH_1).setEnabled(false));
 
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
-    reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
-    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_KEY_1, FILE_1_REF));
-    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_KEY_1));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
+    reportReader.putComponent(component(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
+    reportReader.putComponent(componentWithPath(DIR_REF_1, DIRECTORY, REPORT_DIR_PATH_1, FILE_1_REF));
+    reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
 
     underTest.execute(new TestComputationStepContext());
 
-    verifyComponent(ROOT_REF, REPORT_PROJECT_KEY, "ABCD");
+    verifyComponentByRef(ROOT_REF, REPORT_PROJECT_KEY, "ABCD");
 
     // No new UUID is generated on removed components
-    verifyComponent(MODULE_REF, REPORT_MODULE_KEY, "BCDE");
-    verifyComponent(DIR_REF_1, REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1, "CDEF");
-    verifyComponent(FILE_1_REF, REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1, "DEFG");
+    verifyComponentMissingByRef(MODULE_REF);
+    // TODO migrate modules
+    //verifyComponentByRef(DIR_REF_1, REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "CDEF");
+    //verifyComponentByRef(FILE_1_REF, REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, "DEFG");
   }
 
   @Test
   public void set_no_base_project_snapshot_when_no_snapshot() {
     setAnalysisMetadataHolder();
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
     underTest.execute(new TestComputationStepContext());
 
     assertThat(analysisMetadataHolder.isFirstAnalysis()).isTrue();
@@ -466,7 +441,7 @@ public class BuildComponentTreeStepTest {
     ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(false));
 
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
     underTest.execute(new TestComputationStepContext());
 
     assertThat(analysisMetadataHolder.isFirstAnalysis()).isTrue();
@@ -479,27 +454,48 @@ public class BuildComponentTreeStepTest {
     ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
     insertSnapshot(newAnalysis(project).setLast(true));
 
-    reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
+    reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
     underTest.execute(new TestComputationStepContext());
 
     assertThat(analysisMetadataHolder.isFirstAnalysis()).isFalse();
   }
 
-  private void verifyComponent(Component component, Component.Type type, int componentRef, int size) {
+  private void verifyComponent(Component component, Component.Type type, @Nullable Integer componentRef, int size) {
     assertThat(component.getType()).isEqualTo(type);
     assertThat(component.getReportAttributes().getRef()).isEqualTo(componentRef);
     assertThat(component.getChildren()).hasSize(size);
   }
 
-  private void verifyComponent(int ref, String key) {
-    verifyComponent(ref, key, key, null);
+  private void verifyComponentByRef(int ref, String key) {
+    verifyComponentByRef(ref, key, key, null);
+  }
+
+  private void verifyComponentByRef(int ref, String key, @Nullable String uuid) {
+    verifyComponentByRef(ref, key, key, uuid);
   }
 
-  private void verifyComponent(int ref, String key, @Nullable String uuid) {
-    verifyComponent(ref, key, key, uuid);
+  private void verifyComponentByKey(String publicKey) {
+    verifyComponentByKey(publicKey, publicKey, null);
   }
 
-  private void verifyComponent(int ref, String key, String publicKey, @Nullable String uuid) {
+  private void verifyComponentByKey(String publicKey, String key) {
+    verifyComponentByKey(publicKey, key, null);
+  }
+
+  private void verifyComponentByKey(String publicKey, String key, @Nullable String uuid) {
+    Map<String, Component> componentsByKey = indexAllComponentsInTreeByKey(treeRootHolder.getRoot());
+    Component component = componentsByKey.get(publicKey);
+    assertThat(component.getDbKey()).isEqualTo(key);
+    assertThat(component.getReportAttributes().getRef()).isNull();
+    assertThat(component.getKey()).isEqualTo(publicKey);
+    if (uuid != null) {
+      assertThat(component.getUuid()).isEqualTo(uuid);
+    } else {
+      assertThat(component.getUuid()).isNotNull();
+    }
+  }
+
+  private void verifyComponentByRef(int ref, String key, String publicKey, @Nullable String uuid) {
     Map<Integer, Component> componentsByRef = indexAllComponentsInTreeByRef(treeRootHolder.getRoot());
     Component component = componentsByRef.get(ref);
     assertThat(component.getDbKey()).isEqualTo(key);
@@ -511,34 +507,33 @@ public class BuildComponentTreeStepTest {
     }
   }
 
-  private void verifyComponentMissing(int ref) {
+  private void verifyComponentMissingByRef(int ref) {
     Map<Integer, Component> componentsByRef = indexAllComponentsInTreeByRef(treeRootHolder.getRoot());
     assertThat(componentsByRef.get(ref)).isNull();
   }
 
-  private static ScannerReport.Component component(int componentRef, ComponentType componentType, int... children) {
-    return component(componentRef, componentType, null, null, children);
+  private void verifyComponentMissingByKey(String key) {
+    Map<String, Component> componentsByKey = indexAllComponentsInTreeByKey(treeRootHolder.getRoot());
+    assertThat(componentsByKey.get(key)).isNull();
   }
 
-  private static ScannerReport.Component componentWithKey(int componentRef, ComponentType componentType, String key, int... children) {
+  private static ScannerReport.Component component(int componentRef, ComponentType componentType, String key, int... children) {
     return component(componentRef, componentType, key, null, children);
   }
 
   private static ScannerReport.Component componentWithPath(int componentRef, ComponentType componentType, String path, int... children) {
-    return component(componentRef, componentType, null, path, children);
+    return component(componentRef, componentType, REPORT_PROJECT_KEY + ":" + path, path, children);
   }
 
-  private static ScannerReport.Component component(int componentRef, ComponentType componentType, @Nullable String key, @Nullable String path, int... children) {
+  private static ScannerReport.Component component(int componentRef, ComponentType componentType, String key, @Nullable String path, int... children) {
     ScannerReport.Component.Builder builder = ScannerReport.Component.newBuilder()
       .setType(componentType)
       .setRef(componentRef)
       .setStatus(FileStatus.UNAVAILABLE)
-      .setLines(1);
-    if (key != null) {
-      builder.setKey(key);
-    }
+      .setLines(1)
+      .setKey(key);
     if (path != null) {
-      builder.setPath(path);
+      builder.setProjectRelativePath(path);
     }
     for (int child : children) {
       builder.addChildRef(child);
@@ -552,6 +547,19 @@ public class BuildComponentTreeStepTest {
     return componentsByRef;
   }
 
+  private static Map<String, Component> indexAllComponentsInTreeByKey(Component root) {
+    Map<String, Component> componentsByKey = new HashMap<>();
+    feedComponentByKey(root, componentsByKey);
+    return componentsByKey;
+  }
+
+  private static void feedComponentByKey(Component component, Map<String, Component> map) {
+    map.put(component.getKey(), component);
+    for (Component child : component.getChildren()) {
+      feedComponentByKey(child, map);
+    }
+  }
+
   private static void feedComponentByRef(Component component, Map<Integer, Component> map) {
     map.put(component.getReportAttributes().getRef(), component);
     for (Component child : component.getChildren()) {
index 56dbdcc6fa84c2b75ff02d709762deaa335eaee9..7aa0f353bc24611dc2b3d61c62f5285ccd462c9e 100644 (file)
@@ -44,7 +44,6 @@ import static org.sonar.api.measures.CoreMetrics.QUALITY_PROFILES;
 import static org.sonar.api.measures.CoreMetrics.QUALITY_PROFILES_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 
 public class ComputeQProfileMeasureStepTest {
@@ -56,8 +55,6 @@ public class ComputeQProfileMeasureStepTest {
 
   private static final String PROJECT_KEY = "PROJECT KEY";
   private static final int PROJECT_REF = 1;
-  private static final int MODULE_REF = 11;
-  private static final int SUB_MODULE_REF = 111;
   private static final int FOLDER_1_REF = 1111;
   private static final int FOLDER_2_REF = 1112;
   private static final int FILE_1_1_REF = 11111;
@@ -66,21 +63,15 @@ public class ComputeQProfileMeasureStepTest {
   private static final int FILE_2_2_REF = 11122;
 
   private static final Component MULTI_MODULE_PROJECT = ReportComponent.builder(PROJECT, PROJECT_REF).setKey(PROJECT_KEY)
-    .addChildren(
-      ReportComponent.builder(MODULE, MODULE_REF)
+    .addChildren(ReportComponent.builder(DIRECTORY, FOLDER_1_REF)
         .addChildren(
-          ReportComponent.builder(MODULE, SUB_MODULE_REF)
-            .addChildren(ReportComponent.builder(DIRECTORY, FOLDER_1_REF)
-              .addChildren(
-                ReportComponent.builder(FILE, FILE_1_1_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build(),
-                ReportComponent.builder(FILE, FILE_1_2_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build())
-              .build(),
-              ReportComponent.builder(DIRECTORY, FOLDER_2_REF)
-                .addChildren(
-                  ReportComponent.builder(FILE, FILE_2_1_REF).setFileAttributes(new FileAttributes(false, null, 1)).build(),
-                  ReportComponent.builder(FILE, FILE_2_2_REF).setFileAttributes(new FileAttributes(false, "php", 1)).build())
-                .build())
-            .build())
+          ReportComponent.builder(FILE, FILE_1_1_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build(),
+          ReportComponent.builder(FILE, FILE_1_2_REF).setFileAttributes(new FileAttributes(false, "java", 1)).build())
+        .build(),
+      ReportComponent.builder(DIRECTORY, FOLDER_2_REF)
+        .addChildren(
+          ReportComponent.builder(FILE, FILE_2_1_REF).setFileAttributes(new FileAttributes(false, null, 1)).build(),
+          ReportComponent.builder(FILE, FILE_2_2_REF).setFileAttributes(new FileAttributes(false, "php", 1)).build())
         .build())
     .build();
 
index ca7f5c2c49793d31794169186c14f1110618e025..43d78064a22567053c7bb4c85873b08c43a54060 100644 (file)
@@ -42,7 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -56,17 +55,11 @@ import static org.sonar.ce.task.projectanalysis.step.CustomMeasuresCopyStep.dtoT
 public class CustomMeasuresCopyStepTest {
 
   private static final int PROJECT_REF = 1;
-  private static final int MODULE_REF = 11;
-  private static final int MODULE2_REF = 12;
-  private static final int SUB_MODULE_REF = 111;
   private static final int DIR_REF = 1111;
   private static final int FILE1_REF = 11111;
   private static final int FILE2_REF = 11112;
 
   private static final String PROJECT_UUID = "PROJECT";
-  private static final String MODULE_UUID = "MODULE";
-  private static final String MODULE2_UUID = "MODULE2";
-  private static final String SUB_MODULE_UUID = "SUB_MODULE";
   private static final String DIR_UUID = "DIR";
   private static final String FILE1_UUID = "FILE1";
   private static final String FILE2_UUID = "FILE2";
@@ -106,26 +99,17 @@ public class CustomMeasuresCopyStepTest {
   public void copy_custom_measures_on_report() {
     insertCustomMeasure(FILE1_UUID, FLOAT_METRIC, 3.14);
     insertCustomMeasure(DIR_UUID, FLOAT_METRIC, 123d);
-    insertCustomMeasure(SUB_MODULE_UUID, STRING_METRIC, "sub-module");
-    insertCustomMeasure(MODULE_UUID, STRING_METRIC, "module");
     insertCustomMeasure(PROJECT_UUID, STRING_METRIC, "project");
     // Module2 has no custom measure
 
     treeRootHolder.setRoot(
       builder(PROJECT, PROJECT_REF).setUuid(PROJECT_UUID)
         .addChildren(
-          ReportComponent.builder(MODULE, MODULE_REF).setUuid(MODULE_UUID)
+          ReportComponent.builder(DIRECTORY, DIR_REF).setUuid(DIR_UUID)
             .addChildren(
-              ReportComponent.builder(MODULE, SUB_MODULE_REF).setUuid(SUB_MODULE_UUID)
-                .addChildren(
-                  ReportComponent.builder(DIRECTORY, DIR_REF).setUuid(DIR_UUID)
-                    .addChildren(
-                      ReportComponent.builder(FILE, FILE1_REF).setUuid(FILE1_UUID).build(),
-                      ReportComponent.builder(FILE, FILE2_REF).setUuid(FILE2_UUID).build())
-                    .build())
-                .build())
-            .build(),
-          ReportComponent.builder(MODULE, MODULE2_REF).setUuid(MODULE2_UUID).build())
+              ReportComponent.builder(FILE, FILE1_REF).setUuid(FILE1_UUID).build(),
+              ReportComponent.builder(FILE, FILE2_REF).setUuid(FILE2_UUID).build())
+            .build())
         .build());
 
     underTest.execute(new TestComputationStepContext());
@@ -133,10 +117,7 @@ public class CustomMeasuresCopyStepTest {
     assertNoRawMeasureValue(FILE1_REF);
     assertNoRawMeasureValue(FILE2_REF);
     assertNoRawMeasureValue(DIR_REF);
-    assertRawMeasureValue(SUB_MODULE_REF, STRING_METRIC.getKey(), "sub-module");
-    assertRawMeasureValue(MODULE_REF, STRING_METRIC.getKey(), "module");
     assertRawMeasureValue(PROJECT_REF, STRING_METRIC.getKey(), "project");
-    assertNoRawMeasureValue(MODULE2_REF);
 
   }
 
index 2121204d5c0a621a8217b029173cf91f4b92e705..a7e92cc0664f5de8cb895fc076e7a28585ec9a8b 100644 (file)
@@ -45,7 +45,6 @@ import static org.sonar.api.measures.CoreMetrics.NCLOC;
 import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -55,7 +54,6 @@ public class ExecuteVisitorsStepTest {
   private static final String TEST_METRIC_KEY = "test";
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
   private static final int DIRECTORY_REF = 123;
   private static final int FILE_1_REF = 1231;
   private static final int FILE_2_REF = 1232;
@@ -76,13 +74,10 @@ public class ExecuteVisitorsStepTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF).setKey("project")
         .addChildren(
-          builder(MODULE, MODULE_REF).setKey("module")
+          builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
             .addChildren(
-              builder(DIRECTORY, DIRECTORY_REF).setKey("directory")
-                .addChildren(
-                  builder(FILE, FILE_1_REF).setKey("file1").build(),
-                  builder(FILE, FILE_2_REF).setKey("file2").build())
-                .build())
+              builder(FILE, FILE_1_REF).setKey("file1").build(),
+              builder(FILE, FILE_2_REF).setKey("file2").build())
             .build())
         .build());
   }
@@ -94,7 +89,6 @@ public class ExecuteVisitorsStepTest {
     measureRepository.addRawMeasure(FILE_1_REF, NCLOC_KEY, newMeasureBuilder().create(1));
     measureRepository.addRawMeasure(FILE_2_REF, NCLOC_KEY, newMeasureBuilder().create(2));
     measureRepository.addRawMeasure(DIRECTORY_REF, NCLOC_KEY, newMeasureBuilder().create(3));
-    measureRepository.addRawMeasure(MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(3));
     measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(3));
 
     underStep.execute(new TestComputationStepContext());
@@ -102,7 +96,6 @@ public class ExecuteVisitorsStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(2);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(3);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(4);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(4);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(4);
   }
 
@@ -118,7 +111,6 @@ public class ExecuteVisitorsStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(1);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(1);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(2);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(2);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_METRIC_KEY).get().getIntValue()).isEqualTo(2);
   }
 
@@ -191,11 +183,6 @@ public class ExecuteVisitorsStepTest {
       computeAndSaveMeasures(project, path);
     }
 
-    @Override
-    public void visitModule(Component module, Path<Counter> path) {
-      computeAndSaveMeasures(module, path);
-    }
-
     @Override
     public void visitDirectory(Component directory, Path<Counter> path) {
       computeAndSaveMeasures(directory, path);
index 49304fa9d2f60c934e00b6c32575fb2b276b8df8..ca324627a3340bc392fbeb393180f9acbe172a29 100644 (file)
@@ -49,7 +49,6 @@ import static org.sonar.api.measures.CoreMetrics.NEW_LINES;
 import static org.sonar.api.measures.CoreMetrics.NEW_LINES_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 
@@ -58,9 +57,6 @@ public class NewSizeMeasuresStepTest {
   private static final Offset<Double> DEFAULT_OFFSET = Offset.offset(0.1d);
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_1_REF = 123;
-  private static final int SUB_MODULE_2_REF = 126;
   private static final int DIRECTORY_REF = 1234;
   private static final int DIRECTORY_2_REF = 1235;
   private static final int FILE_1_REF = 12341;
@@ -79,19 +75,11 @@ public class NewSizeMeasuresStepTest {
     .setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
-            .addChildren(
-              builder(MODULE, SUB_MODULE_1_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(FILE_1, FILE_2)
-                    .build(),
-                  builder(DIRECTORY, DIRECTORY_2_REF).build())
-                .build(),
-              builder(MODULE, SUB_MODULE_2_REF)
-                .addChildren(FILE_3, FILE_4)
-                .build())
-            .build())
+          builder(DIRECTORY, DIRECTORY_REF)
+            .addChildren(FILE_1, FILE_2)
+            .build(),
+          builder(DIRECTORY, DIRECTORY_2_REF).build(),
+          FILE_3, FILE_4)
         .build());
 
   @Rule
@@ -121,9 +109,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_4_REF, NEW_LINES_KEY, 11);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, NEW_LINES_KEY, 22);
     assertNoRawMeasure(DIRECTORY_2_REF, NEW_LINES_KEY);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, NEW_LINES_KEY, 22);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, NEW_LINES_KEY, 11);
-    assertRawMeasureValueOnPeriod(MODULE_REF, NEW_LINES_KEY, 33);
     assertRawMeasureValueOnPeriod(ROOT_REF, NEW_LINES_KEY, 33);
   }
 
@@ -139,9 +124,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_4_REF, NEW_LINES_KEY, 2);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, NEW_LINES_KEY, 4);
     assertNoRawMeasure(DIRECTORY_2_REF, NEW_LINES_KEY);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, NEW_LINES_KEY, 4);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, NEW_LINES_KEY, 2);
-    assertRawMeasureValueOnPeriod(MODULE_REF, NEW_LINES_KEY, 6);
     assertRawMeasureValueOnPeriod(ROOT_REF, NEW_LINES_KEY, 6);
   }
 
@@ -222,9 +204,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_4_REF, NEW_DUPLICATED_LINES_KEY, 11d);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, NEW_DUPLICATED_LINES_KEY, 2d);
     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_KEY, 20d);
-    assertRawMeasureValueOnPeriod(MODULE_REF, NEW_DUPLICATED_LINES_KEY, 22d);
     assertRawMeasureValueOnPeriod(ROOT_REF, NEW_DUPLICATED_LINES_KEY, 22d);
   }
 
@@ -244,9 +223,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_4_REF, NEW_DUPLICATED_LINES_KEY, 2d);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, NEW_DUPLICATED_LINES_KEY, 2d);
     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_KEY, 4d);
-    assertRawMeasureValueOnPeriod(MODULE_REF, NEW_DUPLICATED_LINES_KEY, 6d);
     assertRawMeasureValueOnPeriod(ROOT_REF, NEW_DUPLICATED_LINES_KEY, 6d);
   }
 
@@ -315,9 +291,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_3_REF, NEW_BLOCKS_DUPLICATED_KEY, 0);
     assertRawMeasureValueOnPeriod(FILE_4_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
-    assertRawMeasureValueOnPeriod(MODULE_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
     assertRawMeasureValueOnPeriod(ROOT_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
   }
 
@@ -345,9 +318,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValue(FILE_4_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d);
     assertRawMeasureValue(DIRECTORY_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d);
     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY);
-    assertRawMeasureValue(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d);
-    assertRawMeasureValue(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d);
-    assertRawMeasureValue(MODULE_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d);
     assertRawMeasureValue(ROOT_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d);
   }
 
@@ -403,9 +373,6 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod(FILE_3_REF, metricKey, 0);
     assertRawMeasureValueOnPeriod(FILE_4_REF, metricKey, 0);
     assertRawMeasureValueOnPeriod(DIRECTORY_REF, metricKey, 0);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_1_REF, metricKey, 0);
-    assertRawMeasureValueOnPeriod(SUB_MODULE_2_REF, metricKey, 0);
-    assertRawMeasureValueOnPeriod(MODULE_REF, metricKey, 0);
     assertRawMeasureValueOnPeriod(ROOT_REF, metricKey, 0);
   }
 
@@ -419,9 +386,6 @@ public class NewSizeMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(FILE_4_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF).get(metricKey)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_1_REF).get(metricKey)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_2_REF).get(metricKey)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(MODULE_REF).get(metricKey)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF).get(metricKey)).isEmpty();
   }
 }
index 828dbec1b4e05531f9237e8d540f4a9520578dfe..cbddab6f46e309d52d8a41e5023a50c40b5ff24d 100644 (file)
@@ -47,7 +47,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.db.event.EventDto.CATEGORY_ALERT;
@@ -61,7 +60,7 @@ public class PersistEventsStepTest extends BaseStepTest {
     .setUuid("ABCD")
     .setProjectVersion("version_1")
     .addChildren(
-      builder(MODULE, 2)
+      builder(DIRECTORY, 2)
         .setUuid("BCDE")
         .addChildren(
           builder(DIRECTORY, 3)
@@ -110,7 +109,7 @@ public class PersistEventsStepTest extends BaseStepTest {
       .setUuid("ABCD")
       .setProjectVersion("1.0")
       .addChildren(
-        builder(MODULE, 2)
+        builder(DIRECTORY, 2)
           .setUuid("BCDE")
           .addChildren(
             builder(DIRECTORY, 3)
@@ -200,7 +199,7 @@ public class PersistEventsStepTest extends BaseStepTest {
       .setUuid(projectDto.uuid())
       .setProjectVersion("1.5-SNAPSHOT")
       .addChildren(
-        builder(MODULE, 2)
+        builder(DIRECTORY, 2)
           .setUuid("BCDE")
           .addChildren(
             builder(DIRECTORY, 3)
index 1e70125a1e1803084fc2fb370f210ea80c2e27b0..3c78bf10c54894ad41e48bc2e6c500e790bbfde2 100644 (file)
@@ -46,7 +46,6 @@ import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -98,7 +97,6 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
 
     // the computed measures
     measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
-    measureRepository.addRawMeasure(REF_2, STRING_METRIC.getKey(), newMeasureBuilder().create("module-value"));
     measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("dir-value"));
     measureRepository.addRawMeasure(REF_4, STRING_METRIC.getKey(), newMeasureBuilder().create("file-value"));
 
@@ -106,12 +104,11 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
     step().execute(context);
 
     // all measures are persisted, from project to file
-    assertThat(db.countRowsOfTable("live_measures")).isEqualTo(4);
+    assertThat(db.countRowsOfTable("live_measures")).isEqualTo(3);
     assertThat(selectMeasure("project-uuid", STRING_METRIC).get().getDataAsString()).isEqualTo("project-value");
-    assertThat(selectMeasure("module-uuid", STRING_METRIC).get().getDataAsString()).isEqualTo("module-value");
     assertThat(selectMeasure("dir-uuid", STRING_METRIC).get().getDataAsString()).isEqualTo("dir-value");
     assertThat(selectMeasure("file-uuid", STRING_METRIC).get().getDataAsString()).isEqualTo("file-value");
-    verifyStatistics(context, 4);
+    verifyStatistics(context, 3);
   }
 
   @Test
@@ -229,19 +226,16 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
   private void assertThatMeasureDoesNotExist(LiveMeasureDto template) {
     assertThat(dbClient.liveMeasureDao().selectMeasure(db.getSession(),
       template.getComponentUuid(), metricRepository.getById(template.getMetricId()).getKey()))
-        .isEmpty();
+      .isEmpty();
   }
 
   private void prepareProject() {
     // tree of components as defined by scanner report
     Component project = ReportComponent.builder(PROJECT, REF_1).setUuid("project-uuid")
       .addChildren(
-        ReportComponent.builder(MODULE, REF_2).setUuid("module-uuid")
+        ReportComponent.builder(DIRECTORY, REF_3).setUuid("dir-uuid")
           .addChildren(
-            ReportComponent.builder(DIRECTORY, REF_3).setUuid("dir-uuid")
-              .addChildren(
-                ReportComponent.builder(FILE, REF_4).setUuid("file-uuid")
-                  .build())
+            ReportComponent.builder(FILE, REF_4).setUuid("file-uuid")
               .build())
           .build())
       .build();
@@ -250,7 +244,6 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
 
     // components as persisted in db
     ComponentDto projectDto = insertComponent("project-key", "project-uuid");
-    ComponentDto moduleDto = insertComponent("module-key", "module-uuid");
     ComponentDto dirDto = insertComponent("dir-key", "dir-uuid");
     ComponentDto fileDto = insertComponent("file-key", "file-uuid");
   }
index c7e24ce1e80ddeb4871d0b43a3060367bb496c28..06d708ed31a2a7eb25457c330e73bbcc16668a2a 100644 (file)
@@ -44,7 +44,6 @@ import org.sonar.db.metric.MetricDto;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.SUBVIEW;
@@ -91,19 +90,17 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
     // the computed measures
     measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
-    measureRepository.addRawMeasure(REF_2, STRING_METRIC.getKey(), newMeasureBuilder().create("module-value"));
     measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("dir-value"));
     measureRepository.addRawMeasure(REF_4, STRING_METRIC.getKey(), newMeasureBuilder().create("file-value"));
 
     TestComputationStepContext context = execute(true);
 
-    // project, module and dir measures are persisted, but not file measures
-    assertThat(db.countRowsOfTable("project_measures")).isEqualTo(3);
+    // project and dir measures are persisted, but not file measures
+    assertThat(db.countRowsOfTable("project_measures")).isEqualTo(2);
     assertThat(selectMeasure("project-uuid", STRING_METRIC).get().getData()).isEqualTo("project-value");
-    assertThat(selectMeasure("module-uuid", STRING_METRIC).get().getData()).isEqualTo("module-value");
     assertThat(selectMeasure("dir-uuid", STRING_METRIC).get().getData()).isEqualTo("dir-value");
     assertThatMeasuresAreNotPersisted("file-uuid");
-    assertNbOfInserts(context, 3);
+    assertNbOfInserts(context, 2);
   }
 
   @Test
@@ -112,19 +109,17 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
     // the computed measures
     measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
-    measureRepository.addRawMeasure(REF_2, STRING_METRIC.getKey(), newMeasureBuilder().create("module-value"));
     measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("dir-value"));
     measureRepository.addRawMeasure(REF_4, STRING_METRIC.getKey(), newMeasureBuilder().create("file-value"));
 
     TestComputationStepContext context = execute(false);
 
-    // project, module and dir measures are persisted, but not file measures
-    assertThat(db.countRowsOfTable("project_measures")).isEqualTo(2);
+    // project and dir measures are persisted, but not file measures
+    assertThat(db.countRowsOfTable("project_measures")).isEqualTo(1);
     assertThat(selectMeasure("project-uuid", STRING_METRIC).get().getData()).isEqualTo("project-value");
-    assertThat(selectMeasure("module-uuid", STRING_METRIC).get().getData()).isEqualTo("module-value");
     assertThatMeasuresAreNotPersisted("dir-uuid");
     assertThatMeasuresAreNotPersisted("file-uuid");
-    assertNbOfInserts(context, 2);
+    assertNbOfInserts(context, 1);
   }
 
   @Test
@@ -133,7 +128,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
     measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().createNoValue());
     measureRepository.addRawMeasure(REF_1, INT_METRIC.getKey(), newMeasureBuilder().createNoValue());
 
-    TestComputationStepContext context =  execute(false);
+    TestComputationStepContext context = execute(false);
 
     assertThatMeasureIsNotPersisted("project-uuid", STRING_METRIC);
     assertThatMeasureIsNotPersisted("project-uuid", INT_METRIC);
@@ -162,7 +157,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
     measureRepository.addRawMeasure(REF_2, STRING_METRIC.getKey(), newMeasureBuilder().create("subview-value"));
     measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
 
-    TestComputationStepContext context =  execute(true);
+    TestComputationStepContext context = execute(true);
 
     assertThat(db.countRowsOfTable("project_measures")).isEqualTo(2);
     assertThat(selectMeasure("view-uuid", STRING_METRIC).get().getData()).isEqualTo("view-value");
@@ -174,12 +169,9 @@ public class PersistMeasuresStepTest extends BaseStepTest {
     // tree of components as defined by scanner report
     Component project = ReportComponent.builder(PROJECT, REF_1).setUuid("project-uuid")
       .addChildren(
-        ReportComponent.builder(MODULE, REF_2).setUuid("module-uuid")
+        ReportComponent.builder(DIRECTORY, REF_3).setUuid("dir-uuid")
           .addChildren(
-            ReportComponent.builder(DIRECTORY, REF_3).setUuid("dir-uuid")
-              .addChildren(
-                ReportComponent.builder(FILE, REF_4).setUuid("file-uuid")
-                  .build())
+            ReportComponent.builder(FILE, REF_4).setUuid("file-uuid")
               .build())
           .build())
       .build();
@@ -187,7 +179,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
     // components as persisted in db
     ComponentDto projectDto = insertComponent("project-key", "project-uuid");
-    ComponentDto moduleDto = insertComponent("module-key", "module-uuid");
     ComponentDto dirDto = insertComponent("dir-key", "dir-uuid");
     ComponentDto fileDto = insertComponent("file-key", "file-uuid");
     db.components().insertSnapshot(projectDto, s -> s.setUuid(ANALYSIS_UUID));
index 8522028cc6be0b35ab62dfac94768449e69bc383..3f2073bfe6bda7135be77c88869c64f53f09fff8 100644 (file)
@@ -90,9 +90,7 @@ public class PersistProjectLinksStepTest extends BaseStepTest {
   @Test
   public void add_links_on_project() {
     mockBranch(true);
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").build())
-      .build());
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
 
     // project
     reportReader.putComponent(ScannerReport.Component.newBuilder()
@@ -140,9 +138,7 @@ public class PersistProjectLinksStepTest extends BaseStepTest {
   @Test
   public void do_not_add_links_on_module() {
     mockBranch(true);
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").build())
-      .build());
+    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
     reportReader.putComponent(ScannerReport.Component.newBuilder()
       .setRef(1)
       .setType(ComponentType.PROJECT)
index 267118556f62f4577787f6c1083859de04fcdd3b..f8baeaefc7912f4006d7021601b50cabb624c632 100644 (file)
@@ -87,11 +87,10 @@ public class PersistTestsStepTest extends BaseStepTest {
     underTest = new PersistTestsStep(dbClient, system2, reportReader, treeRootHolder);
 
     root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE_UUID").setKey("MODULE_KEY").addChildren(
-        ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
-        ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
-        ReportComponent.builder(Component.Type.FILE, 5).setUuid(MAIN_FILE_UUID_1).setKey("MAIN_FILE1_KEY").build(),
-        ReportComponent.builder(Component.Type.FILE, 6).setUuid(MAIN_FILE_UUID_2).setKey("MAIN_FILE2_KEY").build()).build())
+      ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
+      ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(),
+      ReportComponent.builder(Component.Type.FILE, 5).setUuid(MAIN_FILE_UUID_1).setKey("MAIN_FILE1_KEY").build(),
+      ReportComponent.builder(Component.Type.FILE, 6).setUuid(MAIN_FILE_UUID_2).setKey("MAIN_FILE2_KEY").build())
       .build();
     treeRootHolder.setRoot(root);
   }
index 0b0787fec0225fed6c16c58788fe2106b08c8f8d..62871445c5f555acb8968d907e35ed06dc6cdb66 100644 (file)
@@ -62,7 +62,7 @@ public class QualityGateEventsStepTest {
     .setUuid("uuid 1")
     .setKey("key 1")
     .setProjectVersion("V1.9")
-    .addChildren(ReportComponent.builder(Component.Type.MODULE, 2).build())
+    .addChildren(ReportComponent.builder(Component.Type.DIRECTORY, 2).build())
     .build();
   private static final String INVALID_ALERT_STATUS = "trololo";
   private static final String ALERT_TEXT = "alert text";
index ee87d157d3580d04e8d76d0f491a1eafc83c82f4..8312099cb2ba0229964926acad3e425633086a49 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.step;
 
-import java.util.Optional;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.assertj.core.api.AbstractAssert;
 import org.junit.Before;
@@ -117,7 +117,7 @@ public class QualityGateMeasuresStepTest {
 
   @Test
   public void no_measure_if_tree_has_no_project() {
-    ReportComponent notAProjectComponent = ReportComponent.builder(Component.Type.MODULE, 1).build();
+    ReportComponent notAProjectComponent = ReportComponent.builder(Component.Type.DIRECTORY, 1).build();
 
     treeRootHolder.setRoot(notAProjectComponent);
 
index db66cfdd79c8ae9c75e8a8348c3b6c15c3569729..2fc460476109b62a1c3384ceeead5825d296b930 100644 (file)
@@ -46,7 +46,6 @@ import static org.sonar.api.measures.CoreMetrics.PUBLIC_UNDOCUMENTED_API;
 import static org.sonar.api.measures.CoreMetrics.PUBLIC_UNDOCUMENTED_API_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -54,8 +53,6 @@ import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilde
 public class ReportCommentMeasuresStepTest {
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_REF = 123;
   private static final int DIRECTORY_REF = 1234;
   private static final int FILE_1_REF = 12341;
   private static final int FILE_2_REF = 12342;
@@ -83,16 +80,10 @@ public class ReportCommentMeasuresStepTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
+          builder(DIRECTORY, DIRECTORY_REF)
             .addChildren(
-              builder(MODULE, SUB_MODULE_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(
-                      builder(FILE, FILE_1_REF).build(),
-                      builder(FILE, FILE_2_REF).build())
-                    .build())
-                .build())
+              builder(FILE, FILE_1_REF).build(),
+              builder(FILE, FILE_2_REF).build())
             .build())
         .build());
   }
@@ -107,8 +98,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, COMMENTED_OUT_CODE_LINES_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, COMMENTED_OUT_CODE_LINES_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, COMMENTED_OUT_CODE_LINES_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, COMMENTED_OUT_CODE_LINES_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, COMMENTED_OUT_CODE_LINES_KEY).get().getIntValue()).isEqualTo(500);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, COMMENTED_OUT_CODE_LINES_KEY).get().getIntValue()).isEqualTo(500);
   }
 
@@ -122,8 +111,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, COMMENT_LINES_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, COMMENT_LINES_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, COMMENT_LINES_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, COMMENT_LINES_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, COMMENT_LINES_KEY).get().getIntValue()).isEqualTo(500);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, COMMENT_LINES_KEY).get().getIntValue()).isEqualTo(500);
   }
 
@@ -135,8 +122,6 @@ public class ReportCommentMeasuresStepTest {
     measureRepository.addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, newMeasureBuilder().create(50));
 
     measureRepository.addRawMeasure(DIRECTORY_REF, NCLOC_KEY, newMeasureBuilder().create(300));
-    measureRepository.addRawMeasure(SUB_MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(300));
-    measureRepository.addRawMeasure(MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(300));
     measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(300));
 
     underTest.execute(new TestComputationStepContext());
@@ -144,8 +129,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(60d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(20d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(40d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(40d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(40d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(40d);
   }
 
@@ -157,8 +140,6 @@ public class ReportCommentMeasuresStepTest {
     measureRepository.addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, newMeasureBuilder().create(0));
 
     measureRepository.addRawMeasure(DIRECTORY_REF, NCLOC_KEY, newMeasureBuilder().create(300));
-    measureRepository.addRawMeasure(SUB_MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(300));
-    measureRepository.addRawMeasure(MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(300));
     measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(300));
 
     underTest.execute(new TestComputationStepContext());
@@ -166,8 +147,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, COMMENT_LINES_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
   }
 
@@ -179,8 +158,6 @@ public class ReportCommentMeasuresStepTest {
     measureRepository.addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, newMeasureBuilder().create(0));
 
     measureRepository.addRawMeasure(DIRECTORY_REF, NCLOC_KEY, newMeasureBuilder().create(0));
-    measureRepository.addRawMeasure(SUB_MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(0));
-    measureRepository.addRawMeasure(MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(0));
     measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(0));
 
     underTest.execute(new TestComputationStepContext());
@@ -203,8 +180,6 @@ public class ReportCommentMeasuresStepTest {
     measureRepository.addRawMeasure(FILE_1_REF, NCLOC_KEY, newMeasureBuilder().create(100));
     measureRepository.addRawMeasure(FILE_2_REF, NCLOC_KEY, newMeasureBuilder().create(100));
     measureRepository.addRawMeasure(DIRECTORY_REF, NCLOC_KEY, newMeasureBuilder().create(200));
-    measureRepository.addRawMeasure(SUB_MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(200));
-    measureRepository.addRawMeasure(MODULE_REF, NCLOC_KEY, newMeasureBuilder().create(200));
     measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(200));
 
     underTest.execute(new TestComputationStepContext());
@@ -222,8 +197,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, PUBLIC_API_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, PUBLIC_API_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, PUBLIC_API_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, PUBLIC_API_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, PUBLIC_API_KEY).get().getIntValue()).isEqualTo(500);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, PUBLIC_API_KEY).get().getIntValue()).isEqualTo(500);
   }
 
@@ -237,8 +210,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, PUBLIC_UNDOCUMENTED_API_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, PUBLIC_UNDOCUMENTED_API_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, PUBLIC_UNDOCUMENTED_API_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, PUBLIC_UNDOCUMENTED_API_KEY).get().getIntValue()).isEqualTo(500);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, PUBLIC_UNDOCUMENTED_API_KEY).get().getIntValue()).isEqualTo(500);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, PUBLIC_UNDOCUMENTED_API_KEY).get().getIntValue()).isEqualTo(500);
 
   }
@@ -256,8 +227,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(50d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(75d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(70d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(70d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(70d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(70d);
   }
 
@@ -307,8 +276,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, PUBLIC_DOCUMENTED_API_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
   }
 
@@ -319,8 +286,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasures(FILE_1_REF)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(FILE_2_REF)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_REF)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(MODULE_REF)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF)).isEmpty();
   }
 
@@ -328,8 +293,6 @@ public class ReportCommentMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasures(FILE_1_REF).get(metric)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(FILE_2_REF).get(metric)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF).get(metric)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_REF).get(metric)).isEmpty();
-    assertThat(measureRepository.getAddedRawMeasures(MODULE_REF).get(metric)).isEmpty();
     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF).get(metric)).isEmpty();
   }
 }
index fed17c19c1365d27b226c3c9ce6551df09c76a92..cb53f5eb735f9eba1476905845cd45628366665f 100644 (file)
@@ -57,7 +57,6 @@ import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTIO
 import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -67,8 +66,6 @@ import static org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry.toEntri
 public class ReportComplexityMeasuresStepTest {
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 11;
-  private static final int SUB_MODULE_REF = 111;
   private static final int DIRECTORY_REF = 1111;
   private static final int FILE_1_REF = 11111;
   private static final int FILE_2_REF = 11121;
@@ -79,16 +76,10 @@ public class ReportComplexityMeasuresStepTest {
   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule()
     .setRoot(builder(PROJECT, ROOT_REF)
       .addChildren(
-        builder(MODULE, MODULE_REF)
+        builder(DIRECTORY, DIRECTORY_REF)
           .addChildren(
-            builder(MODULE, SUB_MODULE_REF)
-              .addChildren(
-                builder(DIRECTORY, DIRECTORY_REF)
-                  .addChildren(
-                    builder(FILE, FILE_1_REF).build(),
-                    builder(FILE, FILE_2_REF).build())
-                  .build())
-              .build())
+            builder(FILE, FILE_1_REF).build(),
+            builder(FILE, FILE_2_REF).build())
           .build())
       .build());
   @Rule
@@ -143,8 +134,6 @@ public class ReportComplexityMeasuresStepTest {
 
     int expectedNonFileValue = 50;
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
   }
 
@@ -174,8 +163,6 @@ public class ReportComplexityMeasuresStepTest {
 
     String expectedNonFileValue = "0.5=3;3.5=7;6.5=10";
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue)));
   }
 
@@ -208,8 +195,6 @@ public class ReportComplexityMeasuresStepTest {
 
     double expectedNonFileValue = 2d;
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(metricKey, newMeasureBuilder().create(expectedNonFileValue, 1)));
   }
 
index 432287e821a7e80c210547b99af9e24580994bc4..6ddde6255350cd7fde710802544611667082ede5 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.ce.task.step.TestComputationStepContext;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -43,8 +42,6 @@ import static org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry.toEntri
 
 public class ReportCoverageMeasuresStepTest {
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_REF = 123;
   private static final int DIRECTORY_REF = 1234;
   private static final int FILE_1_REF = 12341;
   private static final int UNIT_TEST_FILE_REF = 12342;
@@ -72,17 +69,11 @@ public class ReportCoverageMeasuresStepTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
+          builder(DIRECTORY, DIRECTORY_REF)
             .addChildren(
-              builder(MODULE, SUB_MODULE_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(
-                      builder(FILE, FILE_1_REF).build(),
-                      builder(FILE, UNIT_TEST_FILE_REF).setFileAttributes(new FileAttributes(true, "some language", 1)).build(),
-                      builder(FILE, FILE_2_REF).build())
-                    .build())
-                .build())
+              builder(FILE, FILE_1_REF).build(),
+              builder(FILE, UNIT_TEST_FILE_REF).setFileAttributes(new FileAttributes(true, "some language", 1)).build(),
+              builder(FILE, FILE_2_REF).build())
             .build())
         .build());
   }
@@ -117,8 +108,6 @@ public class ReportCoverageMeasuresStepTest {
     };
 
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(nonFileRepoEntries);
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(nonFileRepoEntries);
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(nonFileRepoEntries);
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries);
   }
 
@@ -165,8 +154,6 @@ public class ReportCoverageMeasuresStepTest {
     };
 
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(nonFileRepoEntries);
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(nonFileRepoEntries);
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(nonFileRepoEntries);
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries);
   }
 
index 508a1483e8905a8f8b437de0ef465a54afe66923..6bfcc3f31ae05dd3e0971c5464b2807f9ac08132 100644 (file)
@@ -36,7 +36,6 @@ import static org.sonar.api.measures.CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION;
 import static org.sonar.api.measures.CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -47,8 +46,6 @@ public class ReportLanguageDistributionMeasuresStepTest {
   private static final String JAVA_LANGUAGE = "java";
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_REF = 123;
   private static final int DIRECTORY_REF = 1234;
   private static final int FILE_1_REF = 12341;
   private static final int FILE_2_REF = 12342;
@@ -73,18 +70,12 @@ public class ReportLanguageDistributionMeasuresStepTest {
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
+          builder(DIRECTORY, DIRECTORY_REF)
             .addChildren(
-              builder(MODULE, SUB_MODULE_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(
-                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
-                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
-                      builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, JAVA_LANGUAGE, 1)).build(),
-                      builder(FILE, FILE_4_REF).setFileAttributes(new FileAttributes(false, null, 1)).build())
-                    .build())
-                .build())
+              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, XOO_LANGUAGE, 1)).build(),
+              builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, JAVA_LANGUAGE, 1)).build(),
+              builder(FILE, FILE_4_REF).setFileAttributes(new FileAttributes(false, null, 1)).build())
             .build())
         .build());
   }
@@ -104,8 +95,6 @@ public class ReportLanguageDistributionMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_4_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY).get().getStringValue()).isEqualTo("<null>=2");
 
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY).get().getStringValue()).isEqualTo("<null>=2;java=6;xoo=18");
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY).get().getStringValue()).isEqualTo("<null>=2;java=6;xoo=18");
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY).get().getStringValue()).isEqualTo("<null>=2;java=6;xoo=18");
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY).get().getStringValue()).isEqualTo("<null>=2;java=6;xoo=18");
   }
 
@@ -119,8 +108,6 @@ public class ReportLanguageDistributionMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_4_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY)).isNotPresent();
 
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, NCLOC_LANGUAGE_DISTRIBUTION_KEY)).isNotPresent();
   }
 
index f37b37b336ada3a3dff463f083e13f0fbbd849c5..3fe2036216c85687d4cb227ef6e7de7aac47c5a2 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.ce.task.projectanalysis.measure.Measure;
 import org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry;
 import org.sonar.ce.task.projectanalysis.measure.MeasureRepositoryRule;
 import org.sonar.ce.task.projectanalysis.metric.MetricRepositoryRule;
-import org.sonar.ce.task.projectanalysis.scm.Changeset;
 import org.sonar.ce.task.projectanalysis.source.NewLinesRepository;
 import org.sonar.ce.task.step.TestComputationStepContext;
 
@@ -51,10 +50,8 @@ import static org.sonar.api.measures.CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_LINES_TO_COVER_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_UNCOVERED_LINES_KEY;
-import static org.sonar.api.utils.DateUtils.parseDate;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -64,8 +61,6 @@ import static org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry.toEntri
 public class ReportNewCoverageMeasuresStepTest {
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 11;
-  private static final int SUB_MODULE_REF = 111;
   private static final int DIRECTORY_1_REF = 1111;
   private static final int FILE_1_REF = 11111;
   private static final int DIRECTORY_2_REF = 1112;
@@ -77,17 +72,11 @@ public class ReportNewCoverageMeasuresStepTest {
 
   private static final ReportComponent MULTIPLE_FILES_TREE = builder(PROJECT, ROOT_REF)
     .addChildren(
-      builder(MODULE, MODULE_REF)
-        .addChildren(
-          builder(MODULE, SUB_MODULE_REF)
-            .addChildren(
-              builder(DIRECTORY, DIRECTORY_1_REF)
-                .addChildren(FILE_1)
-                .build(),
-              builder(DIRECTORY, DIRECTORY_2_REF)
-                .addChildren(FILE_2, FILE_3)
-                .build())
-            .build())
+      builder(DIRECTORY, DIRECTORY_1_REF)
+        .addChildren(FILE_1)
+        .build(),
+      builder(DIRECTORY, DIRECTORY_2_REF)
+        .addChildren(FILE_2, FILE_3)
         .build())
     .build();
 
@@ -122,15 +111,6 @@ public class ReportNewCoverageMeasuresStepTest {
     assertThat(measureRepository.isEmpty()).isTrue();
   }
 
-  @Test
-  public void no_measure_for_MODULE_component() {
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.MODULE, MODULE_REF).build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    assertThat(measureRepository.isEmpty()).isTrue();
-  }
-
   @Test
   public void no_measure_for_DIRECTORY_component() {
     treeRootHolder.setRoot(ReportComponent.builder(Component.Type.DIRECTORY, DIRECTORY_1_REF).build());
@@ -174,12 +154,12 @@ public class ReportNewCoverageMeasuresStepTest {
 
   @Test
   public void zero_measures_for_FILE_component_without_CoverageData() {
-    treeRootHolder.setRoot(FILE_COMPONENT);
+    treeRootHolder.setRoot(FILE_1);
     setNewLines(FILE_1);
 
     underTest.execute(new TestComputationStepContext());
 
-    verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_COMPONENT);
+    verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_1);
   }
 
   @Test
@@ -278,15 +258,12 @@ public class ReportNewCoverageMeasuresStepTest {
       entryOf(metricKeys.newConditionsToCover, createMeasure(44d)),
       entryOf(metricKeys.newUncoveredConditions, createMeasure(23d)));
     // submodule
-    MeasureRepoEntry[] repoEntriesFromSubModuleUp = {entryOf(metricKeys.newLinesToCover, createMeasure(15d)),
+    MeasureRepoEntry[] repoEntriesFromProject = {entryOf(metricKeys.newLinesToCover, createMeasure(15d)),
       entryOf(metricKeys.newUncoveredLines, createMeasure(9d)),
       entryOf(metricKeys.newConditionsToCover, createMeasure(51d)),
       entryOf(metricKeys.newUncoveredConditions, createMeasure(27d))};
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(repoEntriesFromSubModuleUp);
-    // module
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(repoEntriesFromSubModuleUp);
     // project
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(repoEntriesFromSubModuleUp);
+    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(repoEntriesFromProject);
   }
 
   @Test
@@ -342,8 +319,6 @@ public class ReportNewCoverageMeasuresStepTest {
       entryOf(branchCoverageKey, createMeasure(96.4d))
     };
 
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).containsOnly(modulesAndProjectEntries);
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(modulesAndProjectEntries);
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
   }
 
@@ -356,9 +331,11 @@ public class ReportNewCoverageMeasuresStepTest {
   }
 
   private void defineNewLinesAndMeasures(Component c, MetricKeys metricKeys, MeasureValues line4, MeasureValues line6) {
-    setNewLines(c, 1, 2, 4,5,6,7);
-    measureRepository.addRawMeasure(c.getReportAttributes().getRef(), metricKeys.coverageLineHitsData, newMeasureBuilder().create("2=0;3=2;4=" + line4.lineHits + ";5=1;6=" + line6.lineHits + ";7=0"));
-    measureRepository.addRawMeasure(c.getReportAttributes().getRef(), metricKeys.conditionsByLine, newMeasureBuilder().create("4=" + line4.coveredConditions + ";6=" + line6.coveredConditions));
+    setNewLines(c, 1, 2, 4, 5, 6, 7);
+    measureRepository.addRawMeasure(c.getReportAttributes().getRef(), metricKeys.coverageLineHitsData,
+      newMeasureBuilder().create("2=0;3=2;4=" + line4.lineHits + ";5=1;6=" + line6.lineHits + ";7=0"));
+    measureRepository
+      .addRawMeasure(c.getReportAttributes().getRef(), metricKeys.conditionsByLine, newMeasureBuilder().create("4=" + line4.coveredConditions + ";6=" + line6.coveredConditions));
     measureRepository.addRawMeasure(c.getReportAttributes().getRef(), metricKeys.coveredConditionsByLine,
       newMeasureBuilder().create("4=" + line4.uncoveredConditions + ";6=" + line6.uncoveredConditions));
   }
index eec1daa44fe7c6c04f04e50cd1bad48140b23aa8..8c5bcaa137f9d26f25a54a5040f09f02b73196a2 100644 (file)
@@ -105,14 +105,12 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     dbClient.componentDao().insert(dbTester.getSession(), fileDto);
     dbTester.getSession().commit();
 
-    Component file = ReportComponent.builder(Component.Type.FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
-    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
-    Component module = ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").addChildren(directory).build();
-    Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).setProjectVersion("1.0").addChildren(module).build();
+    Component file = ReportComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
+    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
+    Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).setProjectVersion("1.0").addChildren(directory).build();
     treeRootHolder.setRoot(project);
 
     dbIdsRepository.setComponentId(project, projectDto.getId());
-    dbIdsRepository.setComponentId(module, moduleDto.getId());
     dbIdsRepository.setComponentId(directory, directoryDto.getId());
     dbIdsRepository.setComponentId(file, fileDto.getId());
 
@@ -129,7 +127,6 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
     assertThat(projectSnapshot.getCreatedAt()).isEqualTo(analysisDate);
     assertThat(projectSnapshot.getBuildDate()).isEqualTo(now);
 
-    assertThat(dbIdsRepository.getComponentId(module)).isEqualTo(moduleDto.getId());
     assertThat(dbIdsRepository.getComponentId(directory)).isEqualTo(directoryDto.getId());
     assertThat(dbIdsRepository.getComponentId(file)).isEqualTo(fileDto.getId());
   }
@@ -177,14 +174,12 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest {
 
     dbTester.getSession().commit();
 
-    Component file = ReportComponent.builder(Component.Type.FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
-    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
-    Component module = ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").addChildren(directory).build();
-    Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(module).build();
+    Component file = ReportComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
+    Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
+    Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(directory).build();
     treeRootHolder.setRoot(project);
 
     dbIdsRepository.setComponentId(project, projectDto.getId());
-    dbIdsRepository.setComponentId(module, moduleDto.getId());
     dbIdsRepository.setComponentId(directory, directoryDto.getId());
     dbIdsRepository.setComponentId(file, fileDto.getId());
 
index ec69bc2d1c601dd6b94bafc97f347f55218d69d6..e7268370af9954c50f65f2d1ecb082f8c5e57616 100644 (file)
@@ -70,7 +70,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
 
   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
   private static final String PROJECT_KEY = "PROJECT_KEY";
-  private static final String MODULE_KEY = "MODULE_KEY";
   private static final String ORGANIZATION_UUID = "org1";
   private static final String QUALITY_GATE_UUID = "gg1";
 
@@ -109,62 +108,40 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persist_components() {
     ComponentDto projectDto = prepareProject();
-    Component file = builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+    Component file = builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
       .setPath("src/main/java/dir/Foo.java")
       .setFileAttributes(new FileAttributes(false, "java", 1))
       .build();
-    Component directory = builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
+    Component directory = builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
       .setPath("src/main/java/dir")
       .addChildren(file)
       .build();
-    Component module = builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-      .setPath("module")
-      .setName("Module")
-      .setDescription("Module description")
-      .addChildren(directory)
-      .build();
     Component treeRoot = asTreeRoot(projectDto)
-      .addChildren(module)
+      .addChildren(directory)
       .build();
     treeRootHolder.setRoot(treeRoot);
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
-
-    ComponentDto moduleDto = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-    assertThat(moduleDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
-    assertThat(moduleDto.name()).isEqualTo("Module");
-    assertThat(moduleDto.description()).isEqualTo("Module description");
-    assertThat(moduleDto.path()).isEqualTo("module");
-    assertThat(moduleDto.uuid()).isEqualTo("BCDE");
-    assertThat(moduleDto.getUuidPath()).isEqualTo(projectDto.getUuidPath() + projectDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(moduleDto.moduleUuid()).isEqualTo(projectDto.uuid());
-    assertThat(moduleDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath() + moduleDto.uuid() + ".");
-    assertThat(moduleDto.getMainBranchProjectUuid()).isNull();
-    assertThat(moduleDto.projectUuid()).isEqualTo(projectDto.uuid());
-    assertThat(moduleDto.qualifier()).isEqualTo("BRC");
-    assertThat(moduleDto.scope()).isEqualTo("PRJ");
-    assertThat(moduleDto.getRootUuid()).isEqualTo(projectDto.uuid());
-    assertThat(moduleDto.getCreatedAt()).isEqualTo(now);
-
-    ComponentDto directoryDto = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get();
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
+
+    ComponentDto directoryDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
     assertThat(directoryDto.name()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.description()).isNull();
     assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.uuid()).isEqualTo("CDEF");
-    assertThat(directoryDto.getUuidPath()).isEqualTo(moduleDto.getUuidPath() + moduleDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(directoryDto.moduleUuid()).isEqualTo(moduleDto.uuid());
-    assertThat(directoryDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
+    assertThat(directoryDto.getUuidPath()).isEqualTo(UUID_PATH_SEPARATOR + projectDto.uuid() + UUID_PATH_SEPARATOR);
+    assertThat(directoryDto.moduleUuid()).isEqualTo(projectDto.uuid());
+    assertThat(directoryDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(directoryDto.getMainBranchProjectUuid()).isNull();
     assertThat(directoryDto.projectUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
-    assertThat(directoryDto.getRootUuid()).isEqualTo(moduleDto.uuid());
+    assertThat(directoryDto.getRootUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
 
-    ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
     assertThat(fileDto.name()).isEqualTo("Foo.java");
     assertThat(fileDto.description()).isNull();
@@ -172,16 +149,15 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.language()).isEqualTo("java");
     assertThat(fileDto.uuid()).isEqualTo("DEFG");
     assertThat(fileDto.getUuidPath()).isEqualTo(directoryDto.getUuidPath() + directoryDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(fileDto.moduleUuid()).isEqualTo(moduleDto.uuid());
-    assertThat(fileDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
+    assertThat(fileDto.moduleUuid()).isEqualTo(projectDto.uuid());
+    assertThat(fileDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath());
     assertThat(fileDto.getMainBranchProjectUuid()).isNull();
     assertThat(fileDto.projectUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
-    assertThat(fileDto.getRootUuid()).isEqualTo(moduleDto.uuid());
+    assertThat(fileDto.getRootUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.getCreatedAt()).isEqualTo(now);
 
-    assertThat(dbIdsRepository.getComponentId(module)).isEqualTo(moduleDto.getId());
     assertThat(dbIdsRepository.getComponentId(directory)).isEqualTo(directoryDto.getId());
     assertThat(dbIdsRepository.getComponentId(file)).isEqualTo(fileDto.getId());
   }
@@ -189,62 +165,40 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persist_components_of_existing_branch() {
     ComponentDto project = prepareBranch("feature/foo");
-    Component file = builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+    Component file = builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
       .setPath("src/main/java/dir/Foo.java")
       .setFileAttributes(new FileAttributes(false, "java", 1))
       .build();
-    Component directory = builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
+    Component directory = builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
       .setPath("src/main/java/dir")
       .addChildren(file)
       .build();
-    Component module = builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-      .setPath("module")
-      .setName("Module")
-      .setDescription("Module description")
-      .addChildren(directory)
-      .build();
     Component treeRoot = asTreeRoot(project)
-      .addChildren(module)
+      .addChildren(directory)
       .build();
     treeRootHolder.setRoot(treeRoot);
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
-
-    ComponentDto moduleDto = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-    assertThat(moduleDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
-    assertThat(moduleDto.name()).isEqualTo("Module");
-    assertThat(moduleDto.description()).isEqualTo("Module description");
-    assertThat(moduleDto.path()).isEqualTo("module");
-    assertThat(moduleDto.uuid()).isEqualTo("BCDE");
-    assertThat(moduleDto.getUuidPath()).isEqualTo(project.getUuidPath() + project.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(moduleDto.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(moduleDto.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleDto.uuid() + ".");
-    assertThat(moduleDto.getMainBranchProjectUuid()).isEqualTo(project.uuid());
-    assertThat(moduleDto.projectUuid()).isEqualTo(project.uuid());
-    assertThat(moduleDto.qualifier()).isEqualTo("BRC");
-    assertThat(moduleDto.scope()).isEqualTo("PRJ");
-    assertThat(moduleDto.getRootUuid()).isEqualTo(project.uuid());
-    assertThat(moduleDto.getCreatedAt()).isEqualTo(now);
-
-    ComponentDto directoryDto = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get();
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
+
+    ComponentDto directoryDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
     assertThat(directoryDto.name()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.description()).isNull();
     assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
     assertThat(directoryDto.uuid()).isEqualTo("CDEF");
-    assertThat(directoryDto.getUuidPath()).isEqualTo(moduleDto.getUuidPath() + moduleDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(directoryDto.moduleUuid()).isEqualTo(moduleDto.uuid());
-    assertThat(directoryDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
+    assertThat(directoryDto.getUuidPath()).isEqualTo(UUID_PATH_SEPARATOR + project.uuid() + UUID_PATH_SEPARATOR);
+    assertThat(directoryDto.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(directoryDto.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(directoryDto.getMainBranchProjectUuid()).isEqualTo(project.uuid());
     assertThat(directoryDto.projectUuid()).isEqualTo(project.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
-    assertThat(directoryDto.getRootUuid()).isEqualTo(moduleDto.uuid());
+    assertThat(directoryDto.getRootUuid()).isEqualTo(project.uuid());
     assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
 
-    ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileDto.getOrganizationUuid()).isEqualTo(ORGANIZATION_UUID);
     assertThat(fileDto.name()).isEqualTo("Foo.java");
     assertThat(fileDto.description()).isNull();
@@ -252,16 +206,15 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.language()).isEqualTo("java");
     assertThat(fileDto.uuid()).isEqualTo("DEFG");
     assertThat(fileDto.getUuidPath()).isEqualTo(directoryDto.getUuidPath() + directoryDto.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(fileDto.moduleUuid()).isEqualTo(moduleDto.uuid());
-    assertThat(fileDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
+    assertThat(fileDto.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(fileDto.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(fileDto.getMainBranchProjectUuid()).isEqualTo(project.uuid());
     assertThat(fileDto.projectUuid()).isEqualTo(project.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
-    assertThat(fileDto.getRootUuid()).isEqualTo(moduleDto.uuid());
+    assertThat(fileDto.getRootUuid()).isEqualTo(project.uuid());
     assertThat(fileDto.getCreatedAt()).isEqualTo(now);
 
-    assertThat(dbIdsRepository.getComponentId(module)).isEqualTo(moduleDto.getId());
     assertThat(dbIdsRepository.getComponentId(directory)).isEqualTo(directoryDto.getId());
     assertThat(dbIdsRepository.getComponentId(file)).isEqualTo(fileDto.getId());
   }
@@ -319,30 +272,24 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   public void persist_only_new_components() {
     // Project and module already exists
     ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
-    dbClient.componentDao().insert(db.getSession(), module);
     db.getSession().commit();
 
     treeRootHolder.setRoot(
       builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
         .setName("Project")
         .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
+          builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
+            .setPath("src/main/java/dir")
             .addChildren(
-              builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
-                .setPath("src/main/java/dir")
-                .addChildren(
-                  builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
-                    .setPath("src/main/java/dir/Foo.java")
-                    .build())
+              builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
+                .setPath("src/main/java/dir/Foo.java")
                 .build())
             .build())
         .build());
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
 
     ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get();
     assertThat(projectReloaded.getId()).isEqualTo(project.getId());
@@ -350,127 +297,29 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(projectReloaded.getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
     assertThat(projectReloaded.getMainBranchProjectUuid()).isNull();
 
-    ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-    assertThat(moduleReloaded.getId()).isEqualTo(module.getId());
-    assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid());
-    assertThat(moduleReloaded.getUuidPath()).isEqualTo(module.getUuidPath());
-    assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid());
-    assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
-    assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid());
-    assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid());
-    assertThat(moduleReloaded.getMainBranchProjectUuid()).isNull();
-
-    ComponentDto directory = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get();
+    ComponentDto directory = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
-    assertThat(directory.moduleUuid()).isEqualTo(module.uuid());
-    assertThat(directory.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
+    assertThat(directory.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(directory.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(directory.projectUuid()).isEqualTo(project.uuid());
-    assertThat(directory.getRootUuid()).isEqualTo(module.uuid());
+    assertThat(directory.getRootUuid()).isEqualTo(project.uuid());
     assertThat(directory.getMainBranchProjectUuid()).isNull();
 
-    ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
-    assertThat(file.moduleUuid()).isEqualTo(module.uuid());
-    assertThat(file.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
+    assertThat(file.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(file.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(file.projectUuid()).isEqualTo(project.uuid());
-    assertThat(file.getRootUuid()).isEqualTo(module.uuid());
+    assertThat(file.getRootUuid()).isEqualTo(project.uuid());
     assertThat(file.getMainBranchProjectUuid()).isNull();
   }
 
-  @Test
-  public void compute_root_uuid() {
-    ComponentDto project = prepareProject();
-    treeRootHolder.setRoot(
-      asTreeRoot(project)
-        .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
-            .addChildren(
-              builder(Component.Type.MODULE, 3).setUuid("CDEF").setKey("SUB_MODULE_1_KEY")
-                .setName("Sub Module 1")
-                .addChildren(
-                  builder(Component.Type.MODULE, 4).setUuid("DEFG").setKey("SUB_MODULE_2_KEY")
-                    .setName("Sub Module 2")
-                    .addChildren(
-                      builder(DIRECTORY, 5).setUuid("EFGH").setKey("SUB_MODULE_2_KEY:src/main/java/dir")
-                        .setPath("src/main/java/dir")
-                        .build())
-                    .build())
-                .build())
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(5);
-
-    Optional<ComponentDto> module = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY);
-    assertThat(module).isPresent();
-    assertThat(module.get().getRootUuid()).isEqualTo(project.uuid());
-
-    Optional<ComponentDto> subModule1 = dbClient.componentDao().selectByKey(db.getSession(), "SUB_MODULE_1_KEY");
-    assertThat(subModule1).isPresent();
-    assertThat(subModule1.get().getRootUuid()).isEqualTo(project.uuid());
-
-    Optional<ComponentDto> subModule2 = dbClient.componentDao().selectByKey(db.getSession(), "SUB_MODULE_2_KEY");
-    assertThat(subModule2).isPresent();
-    assertThat(subModule2.get().getRootUuid()).isEqualTo(project.uuid());
-
-    Optional<ComponentDto> directory = dbClient.componentDao().selectByKey(db.getSession(), "SUB_MODULE_2_KEY:src/main/java/dir");
-    assertThat(directory).isPresent();
-    assertThat(directory.get().getRootUuid()).isEqualTo(subModule2.get().uuid());
-  }
-
-  @Test
-  public void persist_multi_modules() {
-    ComponentDto project = prepareProject();
-    treeRootHolder.setRoot(
-      asTreeRoot(project)
-        .setName("Project")
-        .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_A")
-            .setName("Module A")
-            .addChildren(
-              builder(Component.Type.MODULE, 3).setUuid("DEFG").setKey("SUB_MODULE_A")
-                .setName("Sub Module A")
-                .build())
-            .build(),
-          builder(Component.Type.MODULE, 4).setUuid("CDEF").setKey("MODULE_B")
-            .setName("Module B")
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
-
-    ComponentDto moduleA = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_A").get();
-    assertThat(moduleA.getUuidPath()).isEqualTo(project.getUuidPath() + project.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(moduleA.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(moduleA.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleA.uuid() + ".");
-    assertThat(moduleA.getRootUuid()).isEqualTo(project.uuid());
-
-    ComponentDto subModuleA = dbClient.componentDao().selectByKey(db.getSession(), "SUB_MODULE_A").get();
-    assertThat(subModuleA.getUuidPath()).isEqualTo(moduleA.getUuidPath() + moduleA.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(subModuleA.moduleUuid()).isEqualTo(moduleA.uuid());
-    assertThat(subModuleA.moduleUuidPath()).isEqualTo(moduleA.moduleUuidPath() + subModuleA.uuid() + ".");
-    assertThat(subModuleA.getRootUuid()).isEqualTo(project.uuid());
-
-    ComponentDto moduleB = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_B").get();
-    assertThat(moduleB.getUuidPath()).isEqualTo(project.getUuidPath() + project.uuid() + UUID_PATH_SEPARATOR);
-    assertThat(moduleB.moduleUuid()).isEqualTo(project.uuid());
-    assertThat(moduleB.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleB.uuid() + ".");
-    assertThat(moduleB.getRootUuid()).isEqualTo(project.uuid());
-  }
-
   @Test
   public void nothing_to_persist() {
     ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
-    dbClient.componentDao().insert(db.getSession(), module);
-    ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_KEY:src/main/java/dir");
-    ComponentDto file = ComponentTesting.newFileDto(module, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
-      .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
+    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setDbKey("PROJECT_KEY:src/main/java/dir");
+    ComponentDto file = ComponentTesting.newFileDto(project, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
+      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java");
     dbClient.componentDao().insert(db.getSession(), directory, file);
     db.getSession().commit();
 
@@ -478,26 +327,21 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
       builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
         .setName("Project")
         .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
+          builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
+            .setPath("src/main/java/dir")
             .addChildren(
-              builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
-                .setPath("src/main/java/dir")
-                .addChildren(
-                  builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
-                    .setPath("src/main/java/dir/Foo.java")
-                    .build())
+              builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
+                .setPath("src/main/java/dir/Foo.java")
                 .build())
             .build())
         .build());
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get().getId()).isEqualTo(project.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get().getId()).isEqualTo(module.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get().getId()).isEqualTo(directory.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(file.getId());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get().getId()).isEqualTo(directory.getId());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(file.getId());
 
     ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get();
     assertThat(projectReloaded.getId()).isEqualTo(project.getId());
@@ -507,16 +351,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid());
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
 
-    ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-    assertThat(moduleReloaded.getId()).isEqualTo(module.getId());
-    assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid());
-    assertThat(moduleReloaded.getUuidPath()).isEqualTo(module.getUuidPath());
-    assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid());
-    assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
-    assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid());
-    assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid());
-
-    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get();
+    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
     assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid());
@@ -526,7 +361,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryReloaded.name()).isEqualTo(directory.name());
     assertThat(directoryReloaded.path()).isEqualTo(directory.path());
 
-    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
     assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid());
@@ -537,85 +372,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.path()).isEqualTo(file.path());
   }
 
-  @Test
-  public void update_module_name_and_description() {
-    ComponentDto project = prepareProject(p -> p.setName("Project").setDescription("Project description"));
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
-    dbClient.componentDao().insert(db.getSession(), module);
-    db.getSession().commit();
-
-    treeRootHolder.setRoot(
-      builder(PROJECT, 1)
-        .setUuid(project.uuid())
-        .setKey(project.getDbKey())
-        .setName("New Project")
-        .setDescription("New project description")
-        .addChildren(
-          builder(Component.Type.MODULE, 2)
-            .setUuid("BCDE")
-            .setKey(MODULE_KEY)
-            .setName("New Module")
-            .setDescription("New module description")
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    // functional transaction not finished, "A-fields" are not updated yet
-    assertNameAndDescription(project.getDbKey(), "Project", "Project description");
-    assertNameAndDescription(MODULE_KEY, "Module", null);
-
-    // commit functional transaction -> copies B-fields to A-fields
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
-    assertNameAndDescription(project.getDbKey(), "New Project", "New project description");
-    assertNameAndDescription(MODULE_KEY, "New Module", "New module description");
-  }
-
-  private void assertNameAndDescription(String key, String expectedName, String expectedDescription) {
-    ComponentDto dto = dbClient.componentDao().selectByKey(db.getSession(), key).get();
-    assertThat(dto.name()).isEqualTo(expectedName);
-    assertThat(dto.description()).isEqualTo(expectedDescription);
-  }
-
-  @Test
-  public void update_module_path() {
-    ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module").setPath("path");
-    dbClient.componentDao().insert(db.getSession(), module);
-    db.getSession().commit();
-
-    treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
-        .setName("Project")
-        .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
-            .setPath("New path")
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get().path()).isEqualTo("path");
-
-    // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get().path()).isEqualTo("New path");
-  }
-
   @Test
   public void update_module_uuid_when_moving_a_module() {
     ComponentDto project = prepareProject();
-    ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project)
-      .setDbKey("MODULE_A")
-      .setName("Module A");
-    ComponentDto moduleB = ComponentTesting.newModuleDto("BCDE", project)
-      .setDbKey("MODULE_B")
-      .setName("Module B");
-    dbClient.componentDao().insert(db.getSession(), moduleA, moduleB);
-    ComponentDto directory = ComponentTesting.newDirectory(moduleB, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_B:src/main/java/dir");
-    ComponentDto file = ComponentTesting.newFileDto(moduleB, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
-      .setDbKey("MODULE_B:src/main/java/dir/Foo.java");
+    ComponentDto directory = ComponentTesting.newDirectory(project, "src/main/java/dir").setUuid("CDEF").setDbKey("PROJECT_KEY:src/main/java/dir");
+    ComponentDto file = ComponentTesting.newFileDto(project, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
+      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java");
     dbClient.componentDao().insert(db.getSession(), directory, file);
     db.getSession().commit();
 
@@ -623,19 +385,11 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
       builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
         .setName("Project")
         .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("EDCB").setKey("MODULE_A")
-            .setName("Module A")
+          builder(DIRECTORY, 4).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
+            .setPath("src/main/java/dir")
             .addChildren(
-              builder(Component.Type.MODULE, 3).setUuid("BCDE").setKey("MODULE_B")
-                .setName("Module B")
-                .addChildren(
-                  builder(DIRECTORY, 4).setUuid("CDEF").setKey("MODULE_B:src/main/java/dir")
-                    .setPath("src/main/java/dir")
-                    .addChildren(
-                      builder(FILE, 5).setUuid("DEFG").setKey("MODULE_B:src/main/java/dir/Foo.java")
-                        .setPath("src/main/java/dir/Foo.java")
-                        .build())
-                    .build())
+              builder(FILE, 5).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
+                .setPath("src/main/java/dir/Foo.java")
                 .build())
             .build())
         .build());
@@ -646,44 +400,31 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
     db.commit();
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(5);
-
-    ComponentDto moduleAreloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_A").get();
-
-    ComponentDto moduleBReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_B").get();
-    assertThat(moduleBReloaded).isNotNull();
-    assertThat(moduleBReloaded.uuid()).isEqualTo(moduleB.uuid());
-    assertThat(moduleBReloaded.getUuidPath()).isEqualTo(moduleBReloaded.getUuidPath());
-    assertThat(moduleBReloaded.moduleUuid()).isEqualTo(moduleAreloaded.uuid());
-    assertThat(moduleBReloaded.moduleUuidPath()).isEqualTo(moduleAreloaded.moduleUuidPath() + moduleBReloaded.uuid() + ".");
-    assertThat(moduleBReloaded.projectUuid()).isEqualTo(project.uuid());
-    assertThat(moduleBReloaded.getRootUuid()).isEqualTo(project.uuid());
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
 
-    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_B:src/main/java/dir").get();
+    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded).isNotNull();
     assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directoryReloaded.getUuidPath());
-    assertThat(directoryReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid());
-    assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath());
+    assertThat(directoryReloaded.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(directoryReloaded.projectUuid()).isEqualTo(project.uuid());
-    assertThat(directoryReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid());
+    assertThat(directoryReloaded.getRootUuid()).isEqualTo(project.uuid());
 
-    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_B:src/main/java/dir/Foo.java").get();
+    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileReloaded).isNotNull();
     assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
-    assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid());
-    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath());
+    assertThat(fileReloaded.moduleUuid()).isEqualTo(project.uuid());
+    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
     assertThat(fileReloaded.projectUuid()).isEqualTo(project.uuid());
-    assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid());
+    assertThat(fileReloaded.getRootUuid()).isEqualTo(project.uuid());
   }
 
   @Test
   public void do_not_update_created_at_on_existing_component() {
     Date oldDate = DateUtils.parseDate("2015-01-01");
     ComponentDto project = prepareProject(p -> p.setCreatedAt(oldDate));
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module").setPath("path").setCreatedAt(oldDate);
-    dbClient.componentDao().insert(db.getSession(), module);
     db.getSession().commit();
 
     treeRootHolder.setRoot(
@@ -699,19 +440,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   @Test
   public void persist_components_that_were_previously_removed() {
     ComponentDto project = prepareProject();
-    ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project)
-      .setDbKey(MODULE_KEY)
-      .setName("Module")
-      .setEnabled(false);
-    dbClient.componentDao().insert(db.getSession(), removedModule);
-    ComponentDto removedDirectory = ComponentTesting.newDirectory(removedModule, "src/main/java/dir")
+    ComponentDto removedDirectory = ComponentTesting.newDirectory(project, "src/main/java/dir")
       .setUuid("CDEF")
-      .setDbKey("MODULE_KEY:src/main/java/dir")
+      .setDbKey("PROJECT_KEY:src/main/java/dir")
       .setEnabled(false);
-    ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, removedDirectory, "DEFG")
+    ComponentDto removedFile = ComponentTesting.newFileDto(project, removedDirectory, "DEFG")
       .setPath("src/main/java/dir/Foo.java")
       .setName("Foo.java")
-      .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java")
+      .setDbKey("PROJECT_KEY:src/main/java/dir/Foo.java")
       .setEnabled(false);
     dbClient.componentDao().insert(db.getSession(), removedDirectory, removedFile);
     db.getSession().commit();
@@ -720,27 +456,22 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
       builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
         .setName("Project")
         .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
+          builder(DIRECTORY, 3).setUuid("CDEF").setKey("PROJECT_KEY:src/main/java/dir")
+            .setPath("src/main/java/dir")
             .addChildren(
-              builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
-                .setPath("src/main/java/dir")
-                .addChildren(
-                  builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
-                    .setPath("src/main/java/dir/Foo.java")
-                    .build())
+              builder(FILE, 4).setUuid("DEFG").setKey("PROJECT_KEY:src/main/java/dir/Foo.java")
+                .setPath("src/main/java/dir/Foo.java")
                 .build())
             .build())
         .build());
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(4);
+    assertThat(db.countRowsOfTable("projects")).isEqualTo(3);
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), project.getDbKey()).get().getId()).isEqualTo(project.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get().getId()).isEqualTo(removedModule.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get().getId()).isEqualTo(removedDirectory.getId());
-    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(removedFile.getId());
-    assertExistButDisabled(removedModule.getDbKey(), removedDirectory.getDbKey(), removedFile.getDbKey());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get().getId()).isEqualTo(removedDirectory.getId());
+    assertThat(dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(removedFile.getId());
+    assertExistButDisabled(removedDirectory.getDbKey(), removedFile.getDbKey());
 
     // commit the functional transaction
     dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
@@ -755,17 +486,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
     assertThat(projectReloaded.isEnabled()).isTrue();
 
-    ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-    assertThat(moduleReloaded.getId()).isEqualTo(removedModule.getId());
-    assertThat(moduleReloaded.uuid()).isEqualTo(removedModule.uuid());
-    assertThat(moduleReloaded.getUuidPath()).isEqualTo(removedModule.getUuidPath());
-    assertThat(moduleReloaded.moduleUuid()).isEqualTo(removedModule.moduleUuid());
-    assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(removedModule.moduleUuidPath());
-    assertThat(moduleReloaded.projectUuid()).isEqualTo(removedModule.projectUuid());
-    assertThat(moduleReloaded.getRootUuid()).isEqualTo(removedModule.getRootUuid());
-    assertThat(moduleReloaded.isEnabled()).isTrue();
-
-    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir").get();
+    ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.getId()).isEqualTo(removedDirectory.getId());
     assertThat(directoryReloaded.uuid()).isEqualTo(removedDirectory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
@@ -777,7 +498,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryReloaded.path()).isEqualTo(removedDirectory.path());
     assertThat(directoryReloaded.isEnabled()).isTrue();
 
-    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(fileReloaded.getId()).isEqualTo(fileReloaded.getId());
     assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
@@ -797,59 +518,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     }
   }
 
-  @Test
-  public void update_module_uuid_when_reactivating_removed_component() {
-    ComponentDto project = prepareProject();
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
-    ComponentDto removedModule = ComponentTesting.newModuleDto("EDCD", project).setDbKey("REMOVED_MODULE_KEY").setName("Removed Module").setEnabled(false);
-    dbClient.componentDao().insert(db.getSession(), module, removedModule);
-    ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_KEY:src/main/java/dir");
-    // The file was attached to another module
-    ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
-      .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java").setEnabled(false);
-    dbClient.componentDao().insert(db.getSession(), directory, removedFile);
-    db.getSession().commit();
-
-    treeRootHolder.setRoot(
-      builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey())
-        .setName("Project")
-        .addChildren(
-          builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY)
-            .setName("Module")
-            .addChildren(
-              builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
-                .setPath("src/main/java/dir")
-                .addChildren(
-                  builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
-                    .setPath("src/main/java/dir/Foo.java")
-                    .build())
-                .build())
-            .build())
-        .build());
-
-    underTest.execute(new TestComputationStepContext());
-
-    // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
-    db.commit();
-
-    // Projects contains 4 components from the report + one removed module
-    assertThat(db.countRowsOfTable("projects")).isEqualTo(5);
-
-    ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(db.getSession(), MODULE_KEY).get();
-
-    ComponentDto fileReloaded = dbClient.componentDao().selectByKey(db.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
-    assertThat(fileReloaded.getId()).isEqualTo(removedFile.getId());
-    assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
-    assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
-    assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleReloaded.uuid());
-    assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleReloaded.moduleUuidPath());
-    assertThat(fileReloaded.projectUuid()).isEqualTo(moduleReloaded.projectUuid());
-    assertThat(fileReloaded.name()).isEqualTo(removedFile.name());
-    assertThat(fileReloaded.path()).isEqualTo(removedFile.path());
-    assertThat(fileReloaded.isEnabled()).isTrue();
-  }
-
   @Test
   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
     ComponentDto project = prepareProject(p -> p.setPrivate(true));
@@ -874,15 +542,11 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     return builder(PROJECT, 1).setUuid(projectUuid).setKey(projectKey)
       .setName("Project")
       .addChildren(
-        builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE")
-          .setName("Module")
+        builder(Component.Type.DIRECTORY, 3).setUuid("DEFG").setKey("DIR")
+          .setPath("Directory")
           .addChildren(
-            builder(Component.Type.DIRECTORY, 3).setUuid("DEFG").setKey("DIR")
-              .setPath("Directory")
-              .addChildren(
-                builder(FILE, 4).setUuid("CDEF").setKey("FILE")
-                  .setPath("file")
-                  .build())
+            builder(FILE, 4).setUuid("CDEF").setKey("FILE")
+              .setPath("file")
               .build())
           .build())
       .build();
@@ -949,12 +613,12 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     }
 
     @Override
-    public String generateKey(ScannerReport.Component module, @Nullable ScannerReport.Component fileOrDir) {
-      String moduleKey = module.getKey();
-      if (fileOrDir == null || isEmpty(fileOrDir.getPath())) {
-        return moduleKey;
+    public String generateKey(ScannerReport.Component project, @Nullable String fileOrDirPath) {
+      String projectKey = project.getKey();
+      if (isEmpty(fileOrDirPath)) {
+        return projectKey;
       }
-      return ComponentKeys.createEffectiveKey(moduleKey, trimToNull(fileOrDir.getPath()));
+      return ComponentKeys.createEffectiveKey(projectKey, trimToNull(fileOrDirPath));
     }
   }
 }
index 2853712e87708f9fee170460fbf80ca2474cac67..7a629d17d3058c3bcb41267d5d513cf709535c62 100644 (file)
@@ -45,7 +45,6 @@ import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
 import static org.sonar.api.measures.CoreMetrics.STATEMENTS_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -56,8 +55,6 @@ public class ReportSizeMeasuresStepTest {
 
   private static final String LANGUAGE_DOES_NOT_MATTER_HERE = null;
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_REF = 123;
   private static final int DIRECTORY_1_REF = 1234;
   private static final int DIRECTORY_2_REF = 1235;
   private static final int DIRECTORY_3_REF = 1236;
@@ -72,25 +69,19 @@ public class ReportSizeMeasuresStepTest {
   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule().setRoot(
     builder(PROJECT, ROOT_REF)
       .addChildren(
-        builder(MODULE, MODULE_REF)
+        builder(DIRECTORY, DIRECTORY_1_REF)
           .addChildren(
-            builder(MODULE, SUB_MODULE_REF)
-              .addChildren(
-                builder(DIRECTORY, DIRECTORY_1_REF)
-                  .addChildren(
-                    builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 1)).build(),
-                    builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 2)).build())
-                  .build(),
-                builder(DIRECTORY, DIRECTORY_2_REF)
-                  .addChildren(
-                    builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 7)).build(),
-                    builder(FILE, UNIT_TEST_1_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 4)).build())
-                  .build(),
-                builder(DIRECTORY, DIRECTORY_3_REF)
-                  .addChildren(
-                    builder(FILE, UNIT_TEST_2_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 10)).build())
-                  .build())
-              .build())
+            builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 1)).build(),
+            builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 2)).build())
+          .build(),
+        builder(DIRECTORY, DIRECTORY_2_REF)
+          .addChildren(
+            builder(FILE, FILE_3_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_DOES_NOT_MATTER_HERE, 7)).build(),
+            builder(FILE, UNIT_TEST_1_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 4)).build())
+          .build(),
+        builder(DIRECTORY, DIRECTORY_3_REF)
+          .addChildren(
+            builder(FILE, UNIT_TEST_2_REF).setFileAttributes(new FileAttributes(true, LANGUAGE_DOES_NOT_MATTER_HERE, 10)).build())
           .build())
       .build());
   @Rule
@@ -121,8 +112,6 @@ public class ReportSizeMeasuresStepTest {
     verifyMeasuresOnOtherComponent(DIRECTORY_1_REF, 3, 2, 1);
     verifyMeasuresOnOtherComponent(DIRECTORY_2_REF, 7, 1, 1);
     verifyMeasuresOnOtherComponent(DIRECTORY_3_REF, NO_METRIC, NO_METRIC, NO_METRIC);
-    verifyMeasuresOnOtherComponent(SUB_MODULE_REF, 10, 3, 2);
-    verifyMeasuresOnOtherComponent(MODULE_REF, 10, 3, 2);
     verifyMeasuresOnOtherComponent(ROOT_REF, 10, 3, 2);
   }
 
@@ -151,8 +140,6 @@ public class ReportSizeMeasuresStepTest {
     verifyMeasuresOnOtherComponent(DIRECTORY_1_REF, 3, 2, 1, entryOf(metricKey, newMeasureBuilder().create(16)));
     verifyMeasuresOnOtherComponent(DIRECTORY_2_REF, 7, 1, 1, entryOf(metricKey, newMeasureBuilder().create(3)));
     verifyMeasuresOnOtherComponent(DIRECTORY_3_REF, NO_METRIC, NO_METRIC, NO_METRIC);
-    verifyMeasuresOnOtherComponent(SUB_MODULE_REF, 10, 3, 2, entryOf(metricKey, newMeasureBuilder().create(19)));
-    verifyMeasuresOnOtherComponent(MODULE_REF, 10, 3, 2, entryOf(metricKey, newMeasureBuilder().create(19)));
     verifyMeasuresOnOtherComponent(ROOT_REF, 10, 3, 2, entryOf(metricKey, newMeasureBuilder().create(19)));
   }
 
@@ -181,8 +168,6 @@ public class ReportSizeMeasuresStepTest {
       entryOf(metric2Key, newMeasureBuilder().create(100))
     };
     verifyMeasuresOnOtherComponent(DIRECTORY_3_REF, NO_METRIC, NO_METRIC, NO_METRIC);
-    verifyMeasuresOnOtherComponent(SUB_MODULE_REF, 10, 3, 2, subModuleAndAboveEntries);
-    verifyMeasuresOnOtherComponent(MODULE_REF, 10, 3, 2, subModuleAndAboveEntries);
     verifyMeasuresOnOtherComponent(ROOT_REF, 10, 3, 2, subModuleAndAboveEntries);
   }
 
@@ -218,7 +203,7 @@ public class ReportSizeMeasuresStepTest {
     return from(concat(
       asList(otherMeasures),
       from(asList(measureRepoEntries)).filter(notNull())))
-        .toArray(MeasureRepoEntry.class);
+      .toArray(MeasureRepoEntry.class);
   }
 
   private void verifyNoMeasure(int componentRef) {
index 093b27f14e38fb996534a9561810c5ddedc3e754..5b5892b30244f92dd93582be8b791332c55a7d00 100644 (file)
@@ -44,7 +44,6 @@ import static org.sonar.api.measures.CoreMetrics.TEST_SUCCESS_DENSITY;
 import static org.sonar.api.measures.CoreMetrics.TEST_SUCCESS_DENSITY_KEY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTORY;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
-import static org.sonar.ce.task.projectanalysis.component.Component.Type.MODULE;
 import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder;
@@ -56,8 +55,6 @@ public class ReportUnitTestMeasuresStepTest {
   private static final Offset<Double> DEFAULT_OFFSET = Offset.offset(0.01d);
 
   private static final int ROOT_REF = 1;
-  private static final int MODULE_REF = 12;
-  private static final int SUB_MODULE_REF = 123;
   private static final int DIRECTORY_REF = 1234;
   private static final int FILE_1_REF = 12341;
   private static final int FILE_2_REF = 12342;
@@ -67,16 +64,10 @@ public class ReportUnitTestMeasuresStepTest {
     .setRoot(
       builder(PROJECT, ROOT_REF)
         .addChildren(
-          builder(MODULE, MODULE_REF)
+          builder(DIRECTORY, DIRECTORY_REF)
             .addChildren(
-              builder(MODULE, SUB_MODULE_REF)
-                .addChildren(
-                  builder(DIRECTORY, DIRECTORY_REF)
-                    .addChildren(
-                      builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build(),
-                      builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(true, null, 1)).build())
-                    .build())
-                .build())
+              builder(FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build(),
+              builder(FILE, FILE_2_REF).setFileAttributes(new FileAttributes(true, null, 1)).build())
             .build())
         .build());
   @Rule
@@ -133,8 +124,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(40d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(70d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(60d, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(60d, 1)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(60d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(60d, 1)));
   }
 
@@ -154,8 +143,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(60d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(95d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(83.3d, DEFAULT_OFFSET);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(83.3d, DEFAULT_OFFSET);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(83.3d, DEFAULT_OFFSET);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(83.3d, DEFAULT_OFFSET);
   }
 
@@ -175,8 +162,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(80d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(75d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(76.7d, DEFAULT_OFFSET);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(76.7d, DEFAULT_OFFSET);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(76.7d, DEFAULT_OFFSET);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(76.7d, DEFAULT_OFFSET);
   }
 
@@ -196,8 +181,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(100d);
   }
 
@@ -217,8 +200,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY).get().getDoubleValue()).isEqualTo(0d);
   }
 
@@ -235,8 +216,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
   }
 
@@ -253,8 +232,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(DIRECTORY_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(SUB_MODULE_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
-    assertThat(measureRepository.getAddedRawMeasure(MODULE_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(ROOT_REF, TEST_SUCCESS_DENSITY_KEY)).isNotPresent();
   }
 
@@ -262,10 +239,7 @@ public class ReportUnitTestMeasuresStepTest {
   public void aggregate_measures_when_tests_measures_are_defined_on_directory() {
     treeRootHolder.setRoot(builder(PROJECT, ROOT_REF)
       .addChildren(
-        builder(MODULE, MODULE_REF)
-          .addChildren(
-            builder(DIRECTORY, DIRECTORY_REF).build())
-          .build())
+        builder(DIRECTORY, DIRECTORY_REF).build())
       .build());
     measureRepository.addRawMeasure(DIRECTORY_REF, TESTS_KEY, newMeasureBuilder().create(10));
     measureRepository.addRawMeasure(DIRECTORY_REF, TEST_ERRORS_KEY, newMeasureBuilder().create(2));
@@ -275,13 +249,6 @@ public class ReportUnitTestMeasuresStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(
-      entryOf(TESTS_KEY, newMeasureBuilder().create(10)),
-      entryOf(TEST_ERRORS_KEY, newMeasureBuilder().create(2)),
-      entryOf(TEST_FAILURES_KEY, newMeasureBuilder().create(1)),
-      entryOf(SKIPPED_TESTS_KEY, newMeasureBuilder().create(5)),
-      entryOf(TEST_EXECUTION_TIME_KEY, newMeasureBuilder().create(100L)),
-      entryOf(TEST_SUCCESS_DENSITY_KEY, newMeasureBuilder().create(70d, 1)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(
       entryOf(TESTS_KEY, newMeasureBuilder().create(10)),
       entryOf(TEST_ERRORS_KEY, newMeasureBuilder().create(2)),
@@ -315,8 +282,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, metricKey)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, metricKey)).isNotPresent();
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
   }
 
@@ -329,8 +294,6 @@ public class ReportUnitTestMeasuresStepTest {
     assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, metricKey)).isNotPresent();
     assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, metricKey)).isNotPresent();
     assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
-    assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(entryOf(metricKey, newMeasureBuilder().create(expectedValue)));
   }
 }
index 282b055fd4b9af004bc6097715118997e7592045..6e472812af7183817933b97089271df47ab28419 100644 (file)
@@ -39,7 +39,6 @@ import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotTesting;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
 
@@ -47,7 +46,6 @@ public class ValidateProjectStepTest {
 
   static long DEFAULT_ANALYSIS_TIME = 1433131200000L; // 2015-06-01
   static final String PROJECT_KEY = "PROJECT_KEY";
-  static final String MODULE_KEY = "MODULE_KEY";
   static final Branch DEFAULT_BRANCH = new DefaultBranchImpl();
 
   @Rule
@@ -71,71 +69,6 @@ public class ValidateProjectStepTest {
 
   ValidateProjectStep underTest = new ValidateProjectStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder);
 
-  @Test
-  public void fail_if_module_key_is_already_used_as_project_key() {
-    reportReader.putComponent(ScannerReport.Component.newBuilder()
-      .setRef(1)
-      .setType(ComponentType.PROJECT)
-      .setKey(PROJECT_KEY)
-      .addChildRef(2)
-      .build());
-    reportReader.putComponent(ScannerReport.Component.newBuilder()
-      .setRef(2)
-      .setType(ComponentType.MODULE)
-      .setKey(MODULE_KEY)
-      .build());
-
-    ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(MODULE_KEY);
-    dbClient.componentDao().insert(dbTester.getSession(), project);
-    dbTester.getSession().commit();
-
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY).build())
-      .build());
-
-    thrown.expect(MessageException.class);
-    thrown.expectMessage("Validation of project failed:\n" +
-      "  o The project \"" + MODULE_KEY + "\" is already defined in SonarQube but not as a module of project \"" + PROJECT_KEY + "\". " +
-      "If you really want to stop directly analysing project \"" + MODULE_KEY + "\", please first delete it from SonarQube and then relaunch the analysis of project \""
-      + PROJECT_KEY + "\".");
-
-    underTest.execute(new TestComputationStepContext());
-  }
-
-  @Test
-  public void fail_if_module_key_already_exists_in_another_project() {
-    String anotherProjectKey = "ANOTHER_PROJECT_KEY";
-    reportReader.putComponent(ScannerReport.Component.newBuilder()
-      .setRef(1)
-      .setType(ComponentType.PROJECT)
-      .setKey(PROJECT_KEY)
-      .addChildRef(2)
-      .build());
-    reportReader.putComponent(ScannerReport.Component.newBuilder()
-      .setRef(2)
-      .setType(ComponentType.MODULE)
-      .setKey(MODULE_KEY)
-      .build());
-
-    OrganizationDto organizationDto = dbTester.organizations().insert();
-    ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY);
-    ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(anotherProjectKey);
-    dbClient.componentDao().insert(dbTester.getSession(), project, anotherProject);
-    ComponentDto module = ComponentTesting.newModuleDto("BCDE", anotherProject).setDbKey(MODULE_KEY);
-    dbClient.componentDao().insert(dbTester.getSession(), module);
-    dbTester.getSession().commit();
-
-    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(
-      ReportComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY).build())
-      .build());
-
-    thrown.expect(MessageException.class);
-    thrown.expectMessage("Validation of project failed:\n" +
-      "  o Module \"" + MODULE_KEY + "\" is already part of project \"" + anotherProjectKey + "\"");
-
-    underTest.execute(new TestComputationStepContext());
-  }
-
   @Test
   public void not_fail_if_analysis_date_is_after_last_analysis() {
     reportReader.putComponent(ScannerReport.Component.newBuilder()
index 94cf773edb243cb2bdfe45961e5b3fe4569ff30e..0b2285aaaae1e9c19369320aca4e0b22dd4ded8f 100644 (file)
@@ -46,13 +46,13 @@ public final class ComponentKeys {
     // only static stuff
   }
 
-  public static String createEffectiveKey(String moduleKey, InputPath inputPath) {
-    return createEffectiveKey(moduleKey, inputPath.relativePath());
+  public static String createEffectiveKey(String projectKey, InputPath inputPath) {
+    return createEffectiveKey(projectKey, inputPath.relativePath());
   }
 
-  public static String createEffectiveKey(String moduleKey, @Nullable String path) {
+  public static String createEffectiveKey(String projectKey, @Nullable String path) {
     StringBuilder sb = new StringBuilder(MAX_COMPONENT_KEY_LENGTH);
-    sb.append(moduleKey);
+    sb.append(projectKey);
     if (path != null) {
       sb.append(':').append(path);
     }