summaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-03-21 18:52:14 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2016-03-24 09:57:28 +0100
commit0fd2f2204c44b6b5ec82741233940b8471df06d8 (patch)
treead129d4af5e0cdbaf003c8849a858cfce138ab4e /sonar-scanner-engine
parentcc9c506efd50786649658baa0d243654c59c512e (diff)
downloadsonarqube-0fd2f2204c44b6b5ec82741233940b8471df06d8.tar.gz
sonarqube-0fd2f2204c44b6b5ec82741233940b8471df06d8.zip
SONAR-7368 Deprecate quality_profiles measure and add data in scanner report
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/report/MetadataPublisher.java13
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/rule/QProfileSensor.java72
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/rule/UsedQProfiles.java112
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/cpd/CpdMediumTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java3
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java22
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java135
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/rule/UsedQProfilesTest.java72
9 files changed, 35 insertions, 398 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MetadataPublisher.java
index 67dc6c0be04..489d71fd7d5 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MetadataPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/MetadataPublisher.java
@@ -26,6 +26,8 @@ import org.sonar.api.resources.Project;
import org.sonar.batch.cpd.index.SonarCpdBlockIndex;
import org.sonar.batch.index.BatchComponent;
import org.sonar.batch.index.BatchComponentCache;
+import org.sonar.batch.rule.ModuleQProfiles;
+import org.sonar.batch.rule.QProfile;
import org.sonar.batch.scan.ImmutableProjectReactor;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
@@ -35,11 +37,13 @@ public class MetadataPublisher implements ReportPublisherStep {
private final BatchComponentCache componentCache;
private final ImmutableProjectReactor reactor;
private final Settings settings;
+ private final ModuleQProfiles qProfiles;
- public MetadataPublisher(BatchComponentCache componentCache, ImmutableProjectReactor reactor, Settings settings) {
+ public MetadataPublisher(BatchComponentCache componentCache, ImmutableProjectReactor reactor, Settings settings, ModuleQProfiles qProfiles) {
this.componentCache = componentCache;
this.reactor = reactor;
this.settings = settings;
+ this.qProfiles = qProfiles;
}
@Override
@@ -56,6 +60,13 @@ public class MetadataPublisher implements ReportPublisherStep {
if (branch != null) {
builder.setBranch(branch);
}
+ for (QProfile qp : qProfiles.findAll()) {
+ builder.getMutableQprofilesPerLanguage().put(qp.getLanguage(), org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile.newBuilder()
+ .setKey(qp.getKey())
+ .setLanguage(qp.getLanguage())
+ .setName(qp.getName())
+ .setRulesUpdatedAt(qp.getRulesUpdatedAt().getTime()).build());
+ }
writer.writeMetadata(builder.build());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/QProfileSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/QProfileSensor.java
deleted file mode 100644
index bdffd6f1f5d..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/QProfileSensor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import org.sonar.api.batch.AnalysisMode;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-
-/**
- * Stores which Quality profiles have been used on the current module.
- *
- * TODO This information should not be stored as a measure but should be send as metadata in the {@link org.sonar.scanner.protocol.output.ScannerReport}
- */
-public class QProfileSensor implements Sensor {
-
- private final ModuleQProfiles moduleQProfiles;
- private final FileSystem fs;
- private final AnalysisMode analysisMode;
-
- public QProfileSensor(ModuleQProfiles moduleQProfiles, FileSystem fs, AnalysisMode analysisMode) {
- this.moduleQProfiles = moduleQProfiles;
- this.fs = fs;
- this.analysisMode = analysisMode;
- }
-
- @Override
- public boolean shouldExecuteOnProject(Project project) {
- // Should be only executed on leaf modules
- return project.getModules().isEmpty()
- // Useless in issues mode
- && !analysisMode.isIssues();
- }
-
- @Override
- public void analyse(Project project, SensorContext context) {
- UsedQProfiles used = new UsedQProfiles();
- for (String language : fs.languages()) {
- QProfile profile = moduleQProfiles.findByLanguage(language);
- if (profile != null) {
- used.add(profile);
- }
- }
- Measure<?> detailsMeasure = new Measure<>(CoreMetrics.QUALITY_PROFILES, used.toJson());
- context.saveMeasure(detailsMeasure);
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/UsedQProfiles.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/UsedQProfiles.java
deleted file mode 100644
index 72186a5e959..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/UsedQProfiles.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import com.google.common.collect.Sets;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.util.UtcDateUtils;
-
-import javax.annotation.concurrent.Immutable;
-
-import java.io.StringWriter;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-
-@Immutable
-public class UsedQProfiles {
-
- private final SortedSet<QProfile> profiles = Sets.newTreeSet(new Comparator<QProfile>() {
- @Override
- public int compare(QProfile o1, QProfile o2) {
- int c = o1.getLanguage().compareTo(o2.getLanguage());
- if (c == 0) {
- c = o1.getName().compareTo(o2.getName());
- }
- return c;
- }
- });
-
- public static UsedQProfiles fromJson(String json) {
- UsedQProfiles result = new UsedQProfiles();
- JsonArray jsonRoot = new JsonParser().parse(json).getAsJsonArray();
- for (JsonElement jsonElt : jsonRoot) {
- JsonObject jsonProfile = jsonElt.getAsJsonObject();
- QProfile profile = new QProfile();
- profile.setKey(jsonProfile.get("key").getAsString());
- profile.setName(jsonProfile.get("name").getAsString());
- profile.setLanguage(jsonProfile.get("language").getAsString());
- profile.setRulesUpdatedAt(UtcDateUtils.parseDateTime(jsonProfile.get("rulesUpdatedAt").getAsString()));
- result.add(profile);
- }
- return result;
- }
-
- public String toJson() {
- StringWriter json = new StringWriter();
- JsonWriter writer = JsonWriter.of(json);
- writer.beginArray();
- for (QProfile profile : profiles) {
- writer
- .beginObject()
- .prop("key", profile.getKey())
- .prop("language", profile.getLanguage())
- .prop("name", profile.getName())
- .prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt()))
- .endObject();
- }
- writer.endArray();
- writer.close();
- return json.toString();
- }
-
- public UsedQProfiles add(UsedQProfiles other) {
- addAll(other.profiles);
- return this;
- }
-
- public UsedQProfiles add(QProfile profile) {
- profiles.add(profile);
- return this;
- }
-
- public UsedQProfiles addAll(Collection<QProfile> profiles) {
- this.profiles.addAll(profiles);
- return this;
- }
-
- public SortedSet<QProfile> profiles() {
- return profiles;
- }
-
- public Map<String, QProfile> profilesByKey() {
- Map<String, QProfile> map = new HashMap<>();
- for (QProfile profile : profiles) {
- map.put(profile.getKey(), profile);
- }
- return map;
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index 56da7fd624d..daba4b1c6c9 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -56,7 +56,6 @@ import org.sonar.batch.phases.PublishPhaseExecutor;
import org.sonar.batch.phases.SensorsExecutor;
import org.sonar.batch.postjob.DefaultPostJobContext;
import org.sonar.batch.postjob.PostJobOptimizer;
-import org.sonar.batch.rule.QProfileSensor;
import org.sonar.batch.rule.QProfileVerifier;
import org.sonar.batch.rule.RuleFinderCompatibility;
import org.sonar.batch.rule.RulesProfileProvider;
@@ -151,7 +150,6 @@ public class ModuleScanContainer extends ComponentContainer {
// rules
new RulesProfileProvider(),
- QProfileSensor.class,
CheckFactory.class,
// issues
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/cpd/CpdMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/cpd/CpdMediumTest.java
index 7a349224239..19e2600ed25 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/cpd/CpdMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/cpd/CpdMediumTest.java
@@ -324,7 +324,7 @@ public class CpdMediumTest {
Map<String, List<Measure>> allMeasures = result.allMeasures();
- assertThat(allMeasures.get("com.foo.project")).extracting("metricKey").containsOnly(CoreMetrics.QUALITY_PROFILES_KEY);
+ assertThat(allMeasures.get("com.foo.project")).extracting("metricKey").isEmpty();
assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value").containsOnly(
tuple(CoreMetrics.LINES_KEY, blockCount * 2 + 1));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
index b72458e3141..0affd4dad8e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
@@ -90,8 +90,7 @@ public class MeasuresMediumTest {
Map<String, List<Measure>> allMeasures = result.allMeasures();
- assertThat(allMeasures.get("com.foo.project")).extracting("metricKey", "stringValue.value").containsOnly(
- tuple(CoreMetrics.QUALITY_PROFILES_KEY, "[{\"key\":\"Sonar Way\",\"language\":\"xoo\",\"name\":\"Sonar Way\",\"rulesUpdatedAt\":\"2009-02-13T23:31:31+0000\"}]"));
+ assertThat(allMeasures.get("com.foo.project")).extracting("metricKey", "stringValue.value").isEmpty();
assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value").containsOnly(
tuple(CoreMetrics.LINES_KEY, 2));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
index 7069845e9cf..dd2fe0b7b6d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
@@ -30,12 +30,18 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.batch.index.BatchComponentCache;
+import org.sonar.batch.rule.ModuleQProfiles;
+import org.sonar.batch.rule.QProfile;
import org.sonar.batch.scan.ImmutableProjectReactor;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportReader;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.entry;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class MetadataPublisherTest {
@@ -46,6 +52,7 @@ public class MetadataPublisherTest {
private Project project;
private MetadataPublisher underTest;
private Settings settings;
+ private ModuleQProfiles qProfiles;
@Before
public void prepare() {
@@ -56,12 +63,19 @@ public class MetadataPublisherTest {
componentCache.add(project, null);
componentCache.add(sampleFile, project);
settings = new Settings();
- underTest = new MetadataPublisher(componentCache, new ImmutableProjectReactor(projectDef), settings);
+ qProfiles = mock(ModuleQProfiles.class);
+ underTest = new MetadataPublisher(componentCache, new ImmutableProjectReactor(projectDef), settings, qProfiles);
}
@Test
public void write_metadata() throws Exception {
settings.setProperty(CoreProperties.CPD_CROSS_PROJECT, "true");
+ Date date = new Date();
+ when(qProfiles.findAll()).thenReturn(asList(new QProfile()
+ .setKey("q1")
+ .setName("Q1")
+ .setLanguage("java")
+ .setRulesUpdatedAt(date)));
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
@@ -73,6 +87,12 @@ public class MetadataPublisherTest {
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getCrossProjectDuplicationActivated()).isTrue();
+ assertThat(metadata.getQprofilesPerLanguage()).containsOnly(entry("java", org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile.newBuilder()
+ .setKey("q1")
+ .setName("Q1")
+ .setLanguage("java")
+ .setRulesUpdatedAt(date.getTime())
+ .build()));
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java
deleted file mode 100644
index 4801f246c55..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.AnalysisMode;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.resources.Project;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.core.util.UtcDateUtils;
-
-import java.util.Collections;
-import java.util.Date;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class QProfileSensorTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- static final Date DATE = UtcDateUtils.parseDateTime("2014-01-15T12:00:00+0000");
- static final QProfile JAVA_PROFILE = new QProfile().setKey("java-two").setName("Java Two").setLanguage("java")
- .setRulesUpdatedAt(DATE);
- static final QProfile PHP_PROFILE = new QProfile().setKey("php-one").setName("Php One").setLanguage("php")
- .setRulesUpdatedAt(DATE);
-
- ModuleQProfiles moduleQProfiles = mock(ModuleQProfiles.class);
- Project project = mock(Project.class);
- SensorContext sensorContext = mock(SensorContext.class);
- DefaultFileSystem fs;
-
- @Before
- public void prepare() throws Exception {
- fs = new DefaultFileSystem(temp.newFolder().toPath());
- }
-
- @Test
- public void to_string() {
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, mock(AnalysisMode.class));
- assertThat(sensor.toString()).isEqualTo("QProfileSensor");
- }
-
- @Test
- public void no_execution_in_issues_mode() {
- AnalysisMode analysisMode = mock(AnalysisMode.class);
- when(analysisMode.isIssues()).thenReturn(true);
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, analysisMode);
- assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
-
- }
-
- @Test
- public void no_qprofiles() {
- when(moduleQProfiles.findAll()).thenReturn(Collections.<QProfile>emptyList());
-
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, mock(AnalysisMode.class));
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
- sensor.analyse(project, sensorContext);
-
- // measures are not saved
- verify(sensorContext).saveMeasure(argThat(new IsMeasure(CoreMetrics.QUALITY_PROFILES, "[]")));
- }
-
- @Test
- public void mark_profiles_as_used() {
- when(moduleQProfiles.findByLanguage("java")).thenReturn(JAVA_PROFILE);
- when(moduleQProfiles.findByLanguage("php")).thenReturn(PHP_PROFILE);
- when(moduleQProfiles.findByLanguage("abap")).thenReturn(null);
- fs.addLanguages("java", "php", "abap");
-
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, mock(AnalysisMode.class));
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
- sensor.analyse(project, sensorContext);
- }
-
- @Test
- public void store_measures_on_single_lang_module() {
- when(moduleQProfiles.findByLanguage("java")).thenReturn(JAVA_PROFILE);
- when(moduleQProfiles.findByLanguage("php")).thenReturn(PHP_PROFILE);
- when(moduleQProfiles.findByLanguage("abap")).thenReturn(null);
- fs.addLanguages("java");
-
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, mock(AnalysisMode.class));
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
- sensor.analyse(project, sensorContext);
-
- verify(sensorContext).saveMeasure(
- argThat(new IsMeasure(CoreMetrics.QUALITY_PROFILES,
- "[{\"key\":\"java-two\",\"language\":\"java\",\"name\":\"Java Two\",\"rulesUpdatedAt\":\"2014-01-15T12:00:00+0000\"}]")));
- }
-
- @Test
- public void store_measures_on_multi_lang_module() {
- when(moduleQProfiles.findByLanguage("java")).thenReturn(JAVA_PROFILE);
- when(moduleQProfiles.findByLanguage("php")).thenReturn(PHP_PROFILE);
- when(moduleQProfiles.findByLanguage("abap")).thenReturn(null);
- fs.addLanguages("java", "php");
-
- QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, mock(AnalysisMode.class));
- assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
- sensor.analyse(project, sensorContext);
-
- verify(sensorContext).saveMeasure(
- argThat(new IsMeasure(CoreMetrics.QUALITY_PROFILES,
- "[{\"key\":\"java-two\",\"language\":\"java\",\"name\":\"Java Two\",\"rulesUpdatedAt\":\"2014-01-15T12:00:00+0000\"}," +
- "{\"key\":\"php-one\",\"language\":\"php\",\"name\":\"Php One\",\"rulesUpdatedAt\":\"2014-01-15T12:00:00+0000\"}]")));
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/UsedQProfilesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/UsedQProfilesTest.java
deleted file mode 100644
index dd46501e68e..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/rule/UsedQProfilesTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import org.junit.Test;
-import org.sonar.core.util.UtcDateUtils;
-
-import java.util.Arrays;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class UsedQProfilesTest {
-
- static final String JAVA_JSON = "{\"key\":\"p1\",\"language\":\"java\",\"name\":\"Sonar Way\",\"rulesUpdatedAt\":\"2014-01-15T00:00:00+0000\"}";
- static final String PHP_JSON = "{\"key\":\"p2\",\"language\":\"php\",\"name\":\"Sonar Way\",\"rulesUpdatedAt\":\"2014-02-20T00:00:00+0000\"}";
-
- @Test
- public void from_and_to_json() {
- QProfile java = new QProfile().setKey("p1").setName("Sonar Way").setLanguage("java")
- .setRulesUpdatedAt(UtcDateUtils.parseDateTime("2014-01-15T00:00:00+0000"));
- QProfile php = new QProfile().setKey("p2").setName("Sonar Way").setLanguage("php")
- .setRulesUpdatedAt(UtcDateUtils.parseDateTime("2014-02-20T00:00:00+0000"));
-
- UsedQProfiles used = new UsedQProfiles().add(java).add(php);
- String json = "[" + JAVA_JSON + "," + PHP_JSON + "]";
- assertThat(used.toJson()).isEqualTo(json);
-
- used = UsedQProfiles.fromJson(json);
- assertThat(used.profiles()).hasSize(2);
- assertThat(used.profiles().first().getKey()).isEqualTo("p1");
- assertThat(used.profiles().last().getKey()).isEqualTo("p2");
- }
-
- @Test
- public void do_not_duplicate_profiles() {
- QProfile java = new QProfile().setKey("p1").setName("Sonar Way").setLanguage("java");
- QProfile php = new QProfile().setKey("p2").setName("Sonar Way").setLanguage("php");
-
- UsedQProfiles used = new UsedQProfiles().addAll(Arrays.asList(java, java, php));
- assertThat(used.profiles()).hasSize(2);
- }
-
- @Test
- public void group_profiles_by_key() {
- QProfile java = new QProfile().setKey("p1").setName("Sonar Way").setLanguage("java");
- QProfile php = new QProfile().setKey("p2").setName("Sonar Way").setLanguage("php");
-
- UsedQProfiles used = new UsedQProfiles().addAll(Arrays.asList(java, java, php));
- Map<String, QProfile> map = used.profilesByKey();
- assertThat(map).hasSize(2);
- assertThat(map.get("p1")).isSameAs(java);
- assertThat(map.get("p2")).isSameAs(php);
- }
-}