aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-03-20 13:30:21 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-03-20 13:30:21 +0600
commitea2f43be47be01cb790348d90b7cc12db5d27f48 (patch)
treed548181596fba60ca3fab48c67bdae18a178d1c6 /sonar-server
parent27447442880586ef8636448b07857eee75d270c1 (diff)
parent02b1910cacbc3c5e563d55779ea13bb0c6dca528 (diff)
downloadsonarqube-ea2f43be47be01cb790348d90b7cc12db5d27f48.tar.gz
sonarqube-ea2f43be47be01cb790348d90b7cc12db5d27f48.zip
Merge branch 'master' into grunt
Conflicts: sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/templates/_quality_gate_detail_conditions_template.hbs.erb sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-header-view.js
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtCharacteristicsXMLImporter.java82
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java58
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelSynchronizer.java19
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java9
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGate.java67
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java15
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/DoPrivileged.java45
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb100
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb2
-rw-r--r--sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee3
-rw-r--r--sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-header-view.coffee3
-rw-r--r--sonar-server/src/main/webapp/js/templates/quality-gates.js16
-rw-r--r--sonar-server/src/main/webapp/less/style.less7
-rw-r--r--sonar-server/src/main/webapp/templates/quality-gates/quality-gate-detail-conditions.hbs43
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java33
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java119
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelSynchronizerTest.java12
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java12
-rw-r--r--sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGateTest.java85
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java11
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RuleRepositoriesTest.java25
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/DoPrivilegedTest.java40
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest/fail_on_bad_xml.xml1
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/debt/DebtRulesXMLImporterTest/fail_on_bad_xml.xml1
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/fail_if_require_greater_SQ_version/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar (renamed from sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar)bin12689 -> 12689 bytes
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/ignore_rule_debt_definitions_if_rule_is_linked_on_root_characteristic.xml2
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml6
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules-result.xml8
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found-result.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found.xml2
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled-result.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden-result.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml4
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml2
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml8
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml8
48 files changed, 748 insertions, 162 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtCharacteristicsXMLImporter.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtCharacteristicsXMLImporter.java
index d10c8056add..1c47ffbc6a0 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtCharacteristicsXMLImporter.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtCharacteristicsXMLImporter.java
@@ -20,38 +20,40 @@
package org.sonar.server.debt;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import org.apache.commons.lang.StringUtils;
import org.codehaus.stax2.XMLInputFactory2;
import org.codehaus.staxmate.SMInputFactory;
import org.codehaus.staxmate.in.SMHierarchicCursor;
import org.codehaus.staxmate.in.SMInputCursor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.ServerExtension;
import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import java.io.Reader;
import java.io.StringReader;
+import java.util.Collection;
+import java.util.List;
-public class DebtCharacteristicsXMLImporter implements ServerExtension {
+import static com.google.common.collect.Lists.newArrayList;
- private static final Logger LOG = LoggerFactory.getLogger(DebtCharacteristicsXMLImporter.class);
+public class DebtCharacteristicsXMLImporter implements ServerExtension {
public static final String CHARACTERISTIC = "chc";
public static final String CHARACTERISTIC_KEY = "key";
public static final String CHARACTERISTIC_NAME = "name";
- public DefaultTechnicalDebtModel importXML(String xml, ValidationMessages messages) {
- return importXML(new StringReader(xml), messages);
+ public DebtModel importXML(String xml) {
+ return importXML(new StringReader(xml));
}
- public DefaultTechnicalDebtModel importXML(Reader xml, ValidationMessages messages) {
- DefaultTechnicalDebtModel model = new DefaultTechnicalDebtModel();
+ public DebtModel importXML(Reader xml) {
+ DebtModel model = new DebtModel();
try {
SMInputFactory inputFactory = initStax();
SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);
@@ -61,14 +63,13 @@ public class DebtCharacteristicsXMLImporter implements ServerExtension {
SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);
while (chcCursor.getNext() != null) {
- processCharacteristic(model, null, chcCursor, messages);
+ processCharacteristic(model, null, chcCursor);
}
cursor.getStreamReader().closeCompletely();
} catch (XMLStreamException e) {
- LOG.error("XML is not valid", e);
- messages.addErrorText("XML is not valid: " + e.getMessage());
+ throw new IllegalStateException("XML is not valid", e);
}
return model;
}
@@ -82,8 +83,8 @@ public class DebtCharacteristicsXMLImporter implements ServerExtension {
return new SMInputFactory(xmlFactory);
}
- private DefaultCharacteristic processCharacteristic(DefaultTechnicalDebtModel model, DefaultCharacteristic parent, SMInputCursor chcCursor,
- ValidationMessages messages) throws XMLStreamException {
+ @CheckForNull
+ private DefaultCharacteristic processCharacteristic(DebtModel model, @Nullable DefaultCharacteristic parent, SMInputCursor chcCursor) throws XMLStreamException {
DefaultCharacteristic characteristic = new DefaultCharacteristic();
SMInputCursor cursor = chcCursor.childElementCursor();
while (cursor.getNext() != null) {
@@ -98,7 +99,7 @@ public class DebtCharacteristicsXMLImporter implements ServerExtension {
// <chc> can contain characteristics or requirements
} else if (StringUtils.equals(node, CHARACTERISTIC)) {
- processCharacteristic(model, characteristic, cursor, messages);
+ processCharacteristic(model, characteristic, cursor);
}
}
@@ -110,4 +111,53 @@ public class DebtCharacteristicsXMLImporter implements ServerExtension {
return null;
}
+ static class DebtModel {
+
+ private Collection<DefaultCharacteristic> rootCharacteristics;
+
+ public DebtModel() {
+ rootCharacteristics = newArrayList();
+ }
+
+ public DebtModel addRootCharacteristic(DefaultCharacteristic characteristic) {
+ rootCharacteristics.add(characteristic);
+ return this;
+ }
+
+ public List<DefaultCharacteristic> rootCharacteristics() {
+ return newArrayList(Iterables.filter(rootCharacteristics, new Predicate<DefaultCharacteristic>() {
+ @Override
+ public boolean apply(DefaultCharacteristic input) {
+ return input.isRoot();
+ }
+ }));
+ }
+
+ @CheckForNull
+ public DefaultCharacteristic characteristicByKey(final String key) {
+ return Iterables.find(characteristics(), new Predicate<DefaultCharacteristic>() {
+ @Override
+ public boolean apply(DefaultCharacteristic input) {
+ return input.key().equals(key);
+ }
+ }, null);
+ }
+
+ public List<DefaultCharacteristic> characteristics() {
+ List<DefaultCharacteristic> flatCharacteristics = newArrayList();
+ for (DefaultCharacteristic rootCharacteristic : rootCharacteristics) {
+ flatCharacteristics.add(rootCharacteristic);
+ for (DefaultCharacteristic characteristic : rootCharacteristic.children()) {
+ flatCharacteristics.add(characteristic);
+ }
+ }
+ return flatCharacteristics;
+ }
+
+ public boolean isEmpty() {
+ return rootCharacteristics.isEmpty();
+ }
+
+ }
+
}
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
index 367f3bd1052..a17b23fdb17 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
@@ -20,14 +20,18 @@
package org.sonar.server.debt;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.server.debt.DebtCharacteristic;
import org.sonar.api.server.debt.DebtModel;
import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
+import org.sonar.api.utils.System2;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.rule.RuleDao;
+import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
import org.sonar.core.technicaldebt.db.CharacteristicDto;
import org.sonar.server.exceptions.BadRequestException;
@@ -39,6 +43,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
@@ -51,10 +56,19 @@ public class DebtModelService implements DebtModel {
private final MyBatis mybatis;
private final CharacteristicDao dao;
+ private final RuleDao ruleDao;
+ private final System2 system2;
- public DebtModelService(MyBatis mybatis, CharacteristicDao dao) {
+ public DebtModelService(MyBatis mybatis, CharacteristicDao dao, RuleDao ruleDao) {
+ this(mybatis, dao, ruleDao, System2.INSTANCE);
+ }
+
+ @VisibleForTesting
+ DebtModelService(MyBatis mybatis, CharacteristicDao dao, RuleDao ruleDao, System2 system2) {
this.mybatis = mybatis;
this.dao = dao;
+ this.ruleDao = ruleDao;
+ this.system2 = system2;
}
public List<DebtCharacteristic> rootCharacteristics() {
@@ -156,6 +170,48 @@ public class DebtModelService implements DebtModel {
}
}
+ /**
+ * Disable characteristic and sub characteristic or only sub characteristic.
+ * Will also update every rules linked to sub characteristics by setting characteristic id to -1 and remove function, factor and offset.
+ */
+ public void delete(int characteristicOrSubCharactteristicId) {
+ checkPermission();
+
+ SqlSession session = mybatis.openBatchSession();
+ try {
+ Date now = new Date(system2.now());
+
+ CharacteristicDto characteristicOrSubCharacteristicDto = findCharacteristic(characteristicOrSubCharactteristicId, session);
+ List<RuleDto> ruleDtos = ruleDao.selectByCharacteristicOrSubCharacteristicId(characteristicOrSubCharacteristicDto.getId(), session);
+ for (RuleDto ruleDto : ruleDtos) {
+ ruleDto.setCharacteristicId(RuleDto.DISABLED_CHARACTERISTIC_ID);
+ ruleDto.setRemediationFunction(null);
+ ruleDto.setRemediationFactor(null);
+ ruleDto.setRemediationOffset(null);
+ ruleDto.setUpdatedAt(now);
+ ruleDao.update(ruleDto, session);
+
+ // TODO update rules from E/S
+ }
+
+ if (characteristicOrSubCharacteristicDto.getParentId() == null) {
+ List<CharacteristicDto> dtos = dao.selectCharacteristicsByParentId(characteristicOrSubCharacteristicDto.getId(), session);
+ for (CharacteristicDto subCharacteristicDto : dtos) {
+ subCharacteristicDto.setEnabled(false);
+ subCharacteristicDto.setUpdatedAt(now);
+ dao.update(subCharacteristicDto, session);
+ }
+ }
+ characteristicOrSubCharacteristicDto.setEnabled(false);
+ characteristicOrSubCharacteristicDto.setUpdatedAt(now);
+ dao.update(characteristicOrSubCharacteristicDto, session);
+
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
private CharacteristicDto findCharacteristic(Integer id, SqlSession session) {
CharacteristicDto dto = dao.selectById(id, session);
if (dto == null) {
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelSynchronizer.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelSynchronizer.java
index 9ef036dc864..5fa4ff5bd68 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelSynchronizer.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelSynchronizer.java
@@ -26,9 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.ServerExtension;
import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
import org.sonar.core.technicaldebt.TechnicalDebtModelRepository;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
import org.sonar.core.technicaldebt.db.CharacteristicDto;
@@ -54,12 +52,12 @@ public class DebtModelSynchronizer implements ServerExtension {
this.importer = importer;
}
- public List<CharacteristicDto> synchronize(ValidationMessages messages) {
+ public List<CharacteristicDto> synchronize() {
SqlSession session = mybatis.openSession();
List<CharacteristicDto> model = newArrayList();
try {
- model = synchronize(messages, session);
+ model = synchronize(session);
session.commit();
} finally {
MyBatis.closeQuietly(session);
@@ -67,14 +65,13 @@ public class DebtModelSynchronizer implements ServerExtension {
return model;
}
- public List<CharacteristicDto> synchronize(ValidationMessages messages, SqlSession session) {
- DefaultTechnicalDebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL, messages);
+ public List<CharacteristicDto> synchronize(SqlSession session) {
+ DebtCharacteristicsXMLImporter.DebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL);
List<CharacteristicDto> model = loadOrCreateModelFromDb(defaultModel, session);
- messages.log(LOG);
return model;
}
- private List<CharacteristicDto> loadOrCreateModelFromDb(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
+ private List<CharacteristicDto> loadOrCreateModelFromDb(DebtCharacteristicsXMLImporter.DebtModel defaultModel, SqlSession session) {
List<CharacteristicDto> characteristicDtos = loadModel();
if (characteristicDtos.isEmpty()) {
return createTechnicalDebtModel(defaultModel, session);
@@ -86,7 +83,7 @@ public class DebtModelSynchronizer implements ServerExtension {
return dao.selectEnabledCharacteristics();
}
- private List<CharacteristicDto> createTechnicalDebtModel(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
+ private List<CharacteristicDto> createTechnicalDebtModel(DebtCharacteristicsXMLImporter.DebtModel defaultModel, SqlSession session) {
List<CharacteristicDto> characteristics = newArrayList();
for (DefaultCharacteristic rootCharacteristic : defaultModel.rootCharacteristics()) {
CharacteristicDto rootCharacteristicDto = CharacteristicDto.toDto(rootCharacteristic, null);
@@ -101,11 +98,11 @@ public class DebtModelSynchronizer implements ServerExtension {
return characteristics;
}
- public DefaultTechnicalDebtModel loadModelFromXml(String pluginKey, ValidationMessages messages) {
+ public DebtCharacteristicsXMLImporter.DebtModel loadModelFromXml(String pluginKey) {
Reader xmlFileReader = null;
try {
xmlFileReader = languageModelFinder.createReaderForXMLFile(pluginKey);
- return importer.importXML(xmlFileReader, messages);
+ return importer.importXML(xmlFileReader);
} finally {
IOUtils.closeQuietly(xmlFileReader);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
index 3beb4daa1e4..5f76c882bb9 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
@@ -81,14 +81,13 @@ public class DebtRulesXMLImporter implements ServerExtension {
cursor.advance();
SMInputCursor rootCursor = cursor.childElementCursor(CHARACTERISTIC);
while (rootCursor.getNext() != null) {
- processCharacteristic(ruleDebts, null, null, rootCursor);
+ process(ruleDebts, null, null, rootCursor);
}
cursor.getStreamReader().closeCompletely();
} catch (XMLStreamException e) {
- LOG.error("XML is not valid", e);
+ throw new IllegalStateException("XML is not valid", e);
}
-
return ruleDebts;
}
@@ -101,7 +100,7 @@ public class DebtRulesXMLImporter implements ServerExtension {
return new SMInputFactory(xmlFactory);
}
- private void processCharacteristic(List<RuleDebt> ruleDebts, @Nullable String rootKey, @Nullable String parentKey, SMInputCursor chcCursor) throws XMLStreamException {
+ private void process(List<RuleDebt> ruleDebts, @Nullable String rootKey, @Nullable String parentKey, SMInputCursor chcCursor) throws XMLStreamException {
String currentCharacteristicKey = null;
SMInputCursor cursor = chcCursor.childElementCursor();
while (cursor.getNext() != null) {
@@ -109,7 +108,7 @@ public class DebtRulesXMLImporter implements ServerExtension {
if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
currentCharacteristicKey = cursor.collectDescendantText().trim();
} else if (StringUtils.equals(node, CHARACTERISTIC)) {
- processCharacteristic(ruleDebts, parentKey, currentCharacteristicKey, cursor);
+ process(ruleDebts, parentKey, currentCharacteristicKey, cursor);
} else if (StringUtils.equals(node, REPOSITORY_KEY)) {
RuleDebt ruleDebt = processRule(cursor);
if (ruleDebt != null) {
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
index 87e242e4ae2..95754a60b42 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
@@ -103,6 +103,7 @@ import org.sonar.server.platform.ws.RestartHandler;
import org.sonar.server.plugins.*;
import org.sonar.server.qualitygate.QgateProjectFinder;
import org.sonar.server.qualitygate.QualityGates;
+import org.sonar.server.qualitygate.RegisterBuiltinQualityGate;
import org.sonar.server.qualitygate.ws.QgateAppHandler;
import org.sonar.server.qualitygate.ws.QualityGatesWs;
import org.sonar.server.qualityprofile.*;
@@ -397,6 +398,7 @@ class ServerComponents {
ComponentContainer startupContainer = pico.createChild();
startupContainer.addSingleton(GwtPublisher.class);
startupContainer.addSingleton(RegisterMetrics.class);
+ startupContainer.addSingleton(RegisterBuiltinQualityGate.class);
startupContainer.addSingleton(DeprecatedRulesDefinition.class);
startupContainer.addSingleton(RuleDefinitionsLoader.class);
startupContainer.addSingleton(RuleRegistration.class);
@@ -413,14 +415,18 @@ class ServerComponents {
startupContainer.addSingleton(RegisterServletFilters.class);
startupContainer.addSingleton(CleanPreviewAnalysisCache.class);
startupContainer.addSingleton(CopyRequirementsFromCharacteristicsToRules.class);
+
+ DoPrivileged.start();
startupContainer.startComponents();
startupContainer.getComponentByType(ServerLifecycleNotifier.class).notifyStart();
+ DoPrivileged.stop();
// Do not put the following statements in a finally block.
// It would hide the possible exception raised during startup
// See SONAR-3107
startupContainer.stopComponents();
+
pico.getComponentByType(DatabaseSessionFactory.class).clear();
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
index e681b0a47ef..1a903de8ae5 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
@@ -128,7 +128,7 @@ public class ServerPluginJarsInstaller {
File destFile = new File(destDir, jar.getName());
if (destFile.exists()) {
// plugin with same filename already installed
- FileUtils.deleteQuietly(jar);
+ FileUtils.deleteQuietly(destFile);
}
try {
if (deleteSource) {
diff --git a/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGate.java b/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGate.java
new file mode 100644
index 00000000000..8d3be51d139
--- /dev/null
+++ b/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGate.java
@@ -0,0 +1,67 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.qualitygate;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.core.qualitygate.db.QualityGateConditionDto;
+import org.sonar.core.qualitygate.db.QualityGateDto;
+import org.sonar.core.template.LoadedTemplateDao;
+import org.sonar.core.template.LoadedTemplateDto;
+
+
+public final class RegisterBuiltinQualityGate {
+
+ private static final String BUILTIN_QUALITY_GATE = "SonarQube way";
+
+ private final QualityGates qualityGates;
+ private final LoadedTemplateDao loadedTemplateDao;
+
+ public RegisterBuiltinQualityGate(QualityGates qualityGates, LoadedTemplateDao loadedTemplateDao) {
+ this.qualityGates = qualityGates;
+ this.loadedTemplateDao = loadedTemplateDao;
+ }
+
+ public void start() {
+ if (shouldRegisterBuiltinQualityGate()) {
+ createBuiltinQualityGate();
+ registerBuiltinQualityGate();
+ }
+ }
+
+ private boolean shouldRegisterBuiltinQualityGate() {
+ return loadedTemplateDao.countByTypeAndKey(LoadedTemplateDto.QUALITY_GATE_TYPE, BUILTIN_QUALITY_GATE) == 0;
+ }
+
+ private void createBuiltinQualityGate() {
+ QualityGateDto builtin = qualityGates.create(BUILTIN_QUALITY_GATE);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.BLOCKER_VIOLATIONS_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "0", null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.CRITICAL_VIOLATIONS_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "0", null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.TEST_ERRORS_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "0", null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.TEST_FAILURES_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "0", null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.NEW_COVERAGE_KEY, QualityGateConditionDto.OPERATOR_LESS_THAN, null, "80", 3);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.OPEN_ISSUES_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, "0", null, null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.REOPENED_ISSUES_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, "0", null, null);
+ qualityGates.createCondition(builtin.getId(), CoreMetrics.SKIPPED_TESTS_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, "0", null, null);
+ }
+
+ private void registerBuiltinQualityGate() {
+ loadedTemplateDao.insert(new LoadedTemplateDto(BUILTIN_QUALITY_GATE, LoadedTemplateDto.QUALITY_GATE_TYPE));
+ }
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java b/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
index 294dea34686..47f39e88dbd 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java
@@ -71,6 +71,9 @@ public class QgateAppHandler implements RequestHandler {
"quality_gates.projects_for_default",
"quality_gates.projects_for_default.edit",
"quality_gates.rename",
+ "quality_gates.delete.confirm.message",
+ "quality_gates.delete.confirm.default",
+ "quality_gates.delete_condition.confirm.message",
"rename",
"save",
"set_as_default",
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java
index 6b82426ebaa..ee747ed4ba9 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java
@@ -195,7 +195,7 @@ public class RuleRegistration implements Startable {
.setDefaultRemediationFunction(remediationFunction.type().name())
.setDefaultRemediationFactor(remediationFunction.factor())
.setDefaultRemediationOffset(remediationFunction.offset())
- .setEffortToFixL10nKey(ruleDef.effortToFixL10nKey());
+ .setEffortToFixDescription(ruleDef.effortToFixDescription());
}
ruleDao.insert(ruleDto, sqlSession);
@@ -274,7 +274,7 @@ public class RuleRegistration implements Startable {
Integer characteristicId = characteristic != null ? characteristic.getId() : null;
String remediationFactor = hasCharacteristic ? debtRemediationFunction.factor() : null;
String remediationOffset = hasCharacteristic ? debtRemediationFunction.offset() : null;
- String effortToFixL10nKey = hasCharacteristic ? def.effortToFixL10nKey() : null;
+ String effortToFixDescription = hasCharacteristic ? def.effortToFixDescription() : null;
if (!ObjectUtils.equals(dto.getDefaultCharacteristicId(), characteristicId)) {
dto.setDefaultCharacteristicId(characteristicId);
@@ -293,8 +293,8 @@ public class RuleRegistration implements Startable {
dto.setDefaultRemediationOffset(remediationOffset);
changed = true;
}
- if (!StringUtils.equals(dto.getEffortToFixL10nKey(), effortToFixL10nKey)) {
- dto.setEffortToFixL10nKey(effortToFixL10nKey);
+ if (!StringUtils.equals(dto.getEffortToFixDescription(), effortToFixDescription)) {
+ dto.setEffortToFixDescription(effortToFixDescription);
changed = true;
}
return changed;
@@ -420,7 +420,7 @@ public class RuleRegistration implements Startable {
ruleDto.setDefaultRemediationFunction(parent.getDefaultRemediationFunction());
ruleDto.setDefaultRemediationFactor(parent.getDefaultRemediationFactor());
ruleDto.setDefaultRemediationOffset(parent.getDefaultRemediationOffset());
- ruleDto.setEffortToFixL10nKey(parent.getEffortToFixL10nKey());
+ ruleDto.setEffortToFixDescription(parent.getEffortToFixDescription());
ruleDto.setUpdatedAt(buffer.now());
ruleDao.update(ruleDto, sqlSession);
toBeRemoved = false;
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java
index 91153922bab..6eb28b6b0d2 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.SetMultimap;
+import org.apache.commons.lang.builder.CompareToBuilder;
import org.sonar.api.ServerComponent;
import org.sonar.api.server.rule.RulesDefinition;
@@ -110,7 +111,19 @@ public class RuleRepositories implements ServerComponent {
@Override
public int compareTo(Repository o) {
- return name.toLowerCase().compareTo(o.name.toLowerCase());
+ return new CompareToBuilder()
+ .append(name.toLowerCase(), o.name.toLowerCase())
+ .append(key, o.key)
+ .toComparison();
+ }
+
+ @Override
+ public String toString() {
+ return "Repository{" +
+ "key='" + key + '\'' +
+ ", name='" + name + '\'' +
+ ", language='" + language + '\'' +
+ '}';
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java b/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
index 54232217ae2..51fcac7192f 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
@@ -34,7 +34,7 @@ import org.sonar.api.rules.Rule;
import org.sonar.api.utils.Duration;
import org.sonar.api.utils.System2;
import org.sonar.core.persistence.Database;
-import org.sonar.core.technicaldebt.db.CharacteristicDto;
+import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.RequirementDao;
import org.sonar.core.technicaldebt.db.RequirementDto;
import org.sonar.server.db.migrations.MassUpdater;
@@ -174,7 +174,7 @@ public class CopyRequirementsFromCharacteristicsToRules {
if (enabledRequirement == null && !Rule.STATUS_REMOVED.equals(ruleRow.getStatus())) {
// If no requirements are enable, it means that the requirement has been disabled for this rule
- updateStatement.setInt(1, CharacteristicDto.DISABLED_CHARACTERISTIC_ID);
+ updateStatement.setInt(1, RuleDto.DISABLED_CHARACTERISTIC_ID);
updateStatement.setNull(2, Types.VARCHAR);
updateStatement.setNull(3, Types.VARCHAR);
updateStatement.setNull(4, Types.VARCHAR);
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java
index f0baaf7fdf5..59a4ecdf035 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java
@@ -23,7 +23,6 @@ package org.sonar.server.startup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.utils.TimeProfiler;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.server.debt.DebtModelSynchronizer;
public class RegisterDebtModel {
@@ -38,7 +37,7 @@ public class RegisterDebtModel {
public void start() {
TimeProfiler profiler = new TimeProfiler(LOGGER).start("Register technical debt model");
- manager.synchronize(ValidationMessages.create());
+ manager.synchronize();
profiler.stop();
}
diff --git a/sonar-server/src/main/java/org/sonar/server/user/DoPrivileged.java b/sonar-server/src/main/java/org/sonar/server/user/DoPrivileged.java
new file mode 100644
index 00000000000..0cf872702ad
--- /dev/null
+++ b/sonar-server/src/main/java/org/sonar/server/user/DoPrivileged.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.user;
+
+import java.util.Locale;
+
+public final class DoPrivileged {
+
+ private static final String SYSTEM_LOGIN = "<system>";
+ private static final String SYSTEM_NAME = "Internal System Account";
+
+ public static void start() {
+ UserSession.set(new UserSession() {
+ @Override
+ public boolean hasGlobalPermission(String globalPermission) {
+ return true;
+ }
+ @Override
+ public boolean hasProjectPermission(String permission, String projectKey) {
+ return true;
+ }
+ }.setLocale(Locale.getDefault()).setLogin(SYSTEM_LOGIN).setName(SYSTEM_NAME));
+ }
+
+ public static void stop() {
+ UserSession.remove();
+ }
+}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
index 9381e4bbb22..586698c4ea2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
@@ -81,11 +81,105 @@
</div>
<% end %>
- <% unless category_help(@category).blank? -%>
+ <% if @category.key() == 'exclusions' -%>
+ <div class="help marginbottom10" style="margin-left: -1px">
+ <h2>Wildcards</h2>
+ <p>Following rules are applied:</p>
+ <table class="data">
+ <thead><tr><th colspan="2"></th></tr></thead>
+ <tr>
+ <td>*</td>
+ <td>Match zero or more characters</td>
+ </tr>
+ <tr>
+ <td>**</td>
+ <td>Match zero or more directories</td>
+ </tr>
+ <tr>
+ <td>?</td>
+ <td>Match a single character</td>
+ </tr>
+ </table>
+ <br>
+ <table class="data">
+ <thead><tr><th>Example</th><th>Matches</th><th>Does not match</th></tr></thead>
+ <tbody>
+ <tr>
+ <td>**/foo/*.js</td>
+ <td>
+ <ul>
+ <li>src/foo/bar.js</li>
+ <li>lib/ui/foo/bar.js</li>
+ </ul>
+ </td>
+ <td>
+ <ul>
+ <li>src/bar.js</li>
+ <li>src/foo2/bar.js</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>src/foo/*bar*.js</td>
+ <td>
+ <ul>
+ <li>src/foo/bar.js</li>
+ <li>src/foo/bar1.js</li>
+ <li>src/foo/bar123.js</li>
+ <li>src/foo/123bar123.js</li>
+ </ul>
+ </td>
+ <td>
+ <ul>
+ <li>src/foo/ui/bar.js</li>
+ <li>src/bar.js</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>src/foo/**</td>
+ <td>
+ <ul>
+ <li>src/foo/bar.js</li>
+ <li>src/foo/ui/bar.js</li>
+ </ul>
+ </td>
+ <td>
+ <ul>
+ <li>src/bar/foo/bar.js</li>
+ <li>src/bar.js</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>**/foo?.js</td>
+ <td>
+ <ul>
+ <li>src/foo1.js</li>
+ <li>src/bar/foo1.js</li>
+ </ul>
+ </td>
+ <td>
+ <ul>
+ <li>src/foo.js</li>
+ <li>src/foo12.js</li>
+ <li>src/12foo3.js</li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <% else
+ help = category_help(@category)
+ unless help.blank?
+ -%>
<div class="help marginbottom10" style="margin-left: -1px">
- <%= category_help(@category) -%>
+ <%= help -%>
</div>
- <% end -%>
+ <% end
+ end
+ -%>
<% end %>
</form>
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb
index 059f3a88b37..5af0233dd8c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb
@@ -33,7 +33,7 @@ class AddDebtColumnsToRules < ActiveRecord::Migration
add_column 'rules', :default_remediation_factor, :string, :null => true, :limit => 20
add_column 'rules', :remediation_offset, :string, :null => true, :limit => 20
add_column 'rules', :default_remediation_offset, :string, :null => true, :limit => 20
- add_column 'rules', :effort_to_fix_l10n_key, :string, :null => true, :limit => 100
+ add_column 'rules', :effort_to_fix_description, :string, :null => true, :limit => 4000
end
end
diff --git a/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee b/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
index 1bebd6f6cb3..4182198ff25 100644
--- a/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
+++ b/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
@@ -90,9 +90,10 @@ define [
deleteCondition: ->
- if confirm t('are_you_sure')
+ if confirm t('quality_gates.delete_condition.confirm.message')
@showSpinner()
@model.delete().done =>
+ @options.collectionView.collection.remove @model
@options.collectionView.updateConditions()
@close()
diff --git a/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-header-view.coffee b/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-header-view.coffee
index 8111616458a..acf593f149f 100644
--- a/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-header-view.coffee
+++ b/sonar-server/src/main/webapp/coffee/quality-gate/views/quality-gate-detail-header-view.coffee
@@ -40,7 +40,8 @@ define [
deleteQualityGate: ->
- if confirm t('are_you_sure')
+ message = if @model.get 'default' then 'quality_gates.delete.confirm.default' else 'quality_gates.delete.confirm.message'
+ if confirm t(message).replace('{0}', @model.get 'name')
@showSpinner()
jQuery.ajax
type: 'POST'
diff --git a/sonar-server/src/main/webapp/js/templates/quality-gates.js b/sonar-server/src/main/webapp/js/templates/quality-gates.js
index 3a3bf93216c..00e75e93448 100644
--- a/sonar-server/src/main/webapp/js/templates/quality-gates.js
+++ b/sonar-server/src/main/webapp/js/templates/quality-gates.js
@@ -250,14 +250,14 @@ function program1(depth0,data) {
function program2(depth0,data) {
var buffer = "", stack1, helper;
- buffer += "\n <optgroup label=\"";
+ buffer += "\n <optgroup label=\"";
if (helper = helpers.domain) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.domain); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
- + "\">\n ";
+ + "\">\n ";
stack1 = helpers.each.call(depth0, (depth0 && depth0.metrics), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n </optgroup>\n ";
+ buffer += "\n </optgroup>\n ";
return buffer;
}
function program3(depth0,data) {
@@ -281,15 +281,15 @@ function program3(depth0,data) {
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "quality_gates.introduction", options) : helperMissing.call(depth0, "t", "quality_gates.introduction", options)))
+ "\n <a class=\"link-action quality-gate-introduction-show-more\">"
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "more", options) : helperMissing.call(depth0, "t", "more", options)))
- + "</a>\n </p>\n <div class=\"quality-gate-introduction-more\">\n "
+ + "</a>\n </p>\n <div class=\"quality-gate-introduction-more inline-help\">\n "
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "quality_gates.health_icons", options) : helperMissing.call(depth0, "t", "quality_gates.health_icons", options)))
- + "\n <table class=\"data\">\n <thead>\n <tr>\n <th colspan=\"3\"></th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"even\">\n <td><i class=\"icon-alert-ok\"></i></td>\n <td>"
+ + "\n <ul>\n <li>\n <i class=\"icon-alert-ok\"></i>\n "
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "alerts.notes.ok", options) : helperMissing.call(depth0, "t", "alerts.notes.ok", options)))
- + "</td>\n </tr>\n <tr class=\"odd\">\n <td><i class=\"icon-alert-warn\"></i></td>\n <td>"
+ + "\n </li>\n <li>\n <i class=\"icon-alert-warn\"></i>\n "
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "alerts.notes.warn", options) : helperMissing.call(depth0, "t", "alerts.notes.warn", options)))
- + "</td>\n </tr>\n <tr class=\"even\">\n <td><i class=\"icon-alert-error\"></i></td>\n <td>"
+ + "\n </li>\n <li>\n <i class=\"icon-alert-error\"></i>\n "
+ escapeExpression((helper = helpers.t || (depth0 && depth0.t),options={hash:{},data:data},helper ? helper.call(depth0, "alerts.notes.error", options) : helperMissing.call(depth0, "t", "alerts.notes.error", options)))
- + "</td>\n </tr>\n </tbody>\n </table>\n </div>\n</div>\n\n";
+ + "\n </li>\n </ul>\n </div>\n</div>\n\n";
stack1 = helpers['if'].call(depth0, (depth0 && depth0.canEdit), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n\n<table class=\"data zebra width100 marginbottom10 spaced quality-gate-conditions\">\n <thead><tr></tr></thead>\n <tbody></tbody>\n</table>";
diff --git a/sonar-server/src/main/webapp/less/style.less b/sonar-server/src/main/webapp/less/style.less
index 925cf6777e6..6c1aec34cd8 100644
--- a/sonar-server/src/main/webapp/less/style.less
+++ b/sonar-server/src/main/webapp/less/style.less
@@ -1611,6 +1611,13 @@ option.sev_BLOCKER, span.sev_BLOCKER {
padding: 5px 0;
}
+.inline-help {
+ padding: 5px;
+ margin: 5px;
+ background-color: #FFF6BF;
+ border: 1px solid #FFD324;
+}
+
/* ------------------- FORMS ------------------- */
.admintable {
border: solid 1px #FFD324;
diff --git a/sonar-server/src/main/webapp/templates/quality-gates/quality-gate-detail-conditions.hbs b/sonar-server/src/main/webapp/templates/quality-gates/quality-gate-detail-conditions.hbs
index ef2980720ce..343994fd780 100644
--- a/sonar-server/src/main/webapp/templates/quality-gates/quality-gate-detail-conditions.hbs
+++ b/sonar-server/src/main/webapp/templates/quality-gates/quality-gate-detail-conditions.hbs
@@ -4,29 +4,22 @@
<p>{{t 'quality_gates.introduction'}}
<a class="link-action quality-gate-introduction-show-more">{{t 'more'}}</a>
</p>
- <div class="quality-gate-introduction-more">
+ <div class="quality-gate-introduction-more inline-help">
{{t 'quality_gates.health_icons'}}
- <table class="data">
- <thead>
- <tr>
- <th colspan="3"></th>
- </tr>
- </thead>
- <tbody>
- <tr class="even">
- <td><i class="icon-alert-ok"></i></td>
- <td>{{t 'alerts.notes.ok'}}</td>
- </tr>
- <tr class="odd">
- <td><i class="icon-alert-warn"></i></td>
- <td>{{t 'alerts.notes.warn'}}</td>
- </tr>
- <tr class="even">
- <td><i class="icon-alert-error"></i></td>
- <td>{{t 'alerts.notes.error'}}</td>
- </tr>
- </tbody>
- </table>
+ <ul>
+ <li>
+ <i class="icon-alert-ok"></i>
+ {{t 'alerts.notes.ok'}}
+ </li>
+ <li>
+ <i class="icon-alert-warn"></i>
+ {{t 'alerts.notes.warn'}}
+ </li>
+ <li>
+ <i class="icon-alert-error"></i>
+ {{t 'alerts.notes.error'}}
+ </li>
+ </ul>
</div>
</div>
@@ -36,9 +29,9 @@
<select id="quality-gate-new-condition-metric">
<option></option>
{{#each metricGroups}}
- <optgroup label="{{domain}}">
- {{#each metrics}}<option value="{{key}}">{{name}}</option>{{/each}}
- </optgroup>
+ <optgroup label="{{domain}}">
+ {{#each metrics}}<option value="{{key}}">{{name}}</option>{{/each}}
+ </optgroup>
{{/each}}
</select>
</div>
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java
index 4a6b947c03d..1180215e3a2 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java
@@ -24,12 +24,11 @@ import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import org.junit.Test;
import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
import java.io.IOException;
import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
public class DebtCharacteristicsXMLImporterTest {
@@ -37,8 +36,7 @@ public class DebtCharacteristicsXMLImporterTest {
public void import_characteristics() {
String xml = getFileContent("import_characteristics.xml");
- ValidationMessages messages = ValidationMessages.create();
- DefaultTechnicalDebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml, messages);
+ DebtCharacteristicsXMLImporter.DebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml);
assertThat(debtModel.rootCharacteristics()).hasSize(2);
assertThat(debtModel.rootCharacteristics().get(0).key()).isEqualTo("PORTABILITY");
@@ -63,26 +61,31 @@ public class DebtCharacteristicsXMLImporterTest {
public void import_badly_formatted_xml() {
String xml = getFileContent("import_badly_formatted_xml.xml");
- ValidationMessages messages = ValidationMessages.create();
- DefaultTechnicalDebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml, messages);
-
- checkXmlCorrectlyImported(debtModel, messages);
- }
-
- private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, ValidationMessages messages) {
- assertThat(messages.getErrors()).isEmpty();
+ DebtCharacteristicsXMLImporter.DebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml);
// characteristics
- assertThat(sqale.rootCharacteristics()).hasSize(2);
- DefaultCharacteristic efficiency = sqale.characteristicByKey("EFFICIENCY");
+ assertThat(debtModel.rootCharacteristics()).hasSize(2);
+ DefaultCharacteristic efficiency = debtModel.characteristicByKey("EFFICIENCY");
assertThat(efficiency.name()).isEqualTo("Efficiency");
// sub-characteristics
assertThat(efficiency.children()).hasSize(1);
- DefaultCharacteristic memoryEfficiency = sqale.characteristicByKey("MEMORY_EFFICIENCY");
+ DefaultCharacteristic memoryEfficiency = debtModel.characteristicByKey("MEMORY_EFFICIENCY");
assertThat(memoryEfficiency.name()).isEqualTo("Memory use");
}
+ @Test
+ public void fail_on_bad_xml() {
+ String xml = getFileContent("fail_on_bad_xml.xml");
+
+ try {
+ new DebtCharacteristicsXMLImporter().importXML(xml);
+ fail();
+ } catch (Exception e){
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ }
+ }
+
private String getFileContent(String file) {
try {
return Resources.toString(Resources.getResource(DebtCharacteristicsXMLImporterTest.class, "DebtCharacteristicsXMLImporterTest/" + file), Charsets.UTF_8);
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java
index 61a58305daf..708a9a4165a 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java
@@ -29,8 +29,13 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.sonar.api.server.debt.DebtCharacteristic;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.System2;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.BatchSession;
import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.rule.RuleDao;
+import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
import org.sonar.core.technicaldebt.db.CharacteristicDto;
import org.sonar.server.exceptions.BadRequestException;
@@ -38,6 +43,8 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.user.MockUserSession;
+import java.util.Date;
+
import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
@@ -51,22 +58,32 @@ public class DebtModelServiceTest {
CharacteristicDao dao;
@Mock
+ RuleDao ruleDao;
+
+ @Mock
MyBatis mybatis;
@Mock
SqlSession session;
- CharacteristicDto rootCharacteristicDto = new CharacteristicDto()
+ @Mock
+ System2 system2;
+
+ Date now = DateUtils.parseDate("2014-03-19");
+
+ CharacteristicDto characteristicDto = new CharacteristicDto()
.setId(1)
.setKey("MEMORY_EFFICIENCY")
.setName("Memory use")
- .setOrder(2);
+ .setOrder(2)
+ .setEnabled(true);
- CharacteristicDto characteristicDto = new CharacteristicDto()
+ CharacteristicDto subCharacteristicDto = new CharacteristicDto()
.setId(2)
.setKey("EFFICIENCY")
.setName("Efficiency")
- .setParentId(1);
+ .setParentId(1)
+ .setEnabled(true);
int currentId;
@@ -74,6 +91,8 @@ public class DebtModelServiceTest {
@Before
public void setUp() throws Exception {
+ when(system2.now()).thenReturn(now.getTime());
+
MockUserSession.set().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
currentId = 10;
@@ -88,24 +107,24 @@ public class DebtModelServiceTest {
}).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class));
when(mybatis.openSession()).thenReturn(session);
- service = new DebtModelService(mybatis, dao);
+ service = new DebtModelService(mybatis, dao, ruleDao,system2);
}
@Test
public void find_root_characteristics() {
- when(dao.selectEnabledRootCharacteristics()).thenReturn(newArrayList(rootCharacteristicDto));
+ when(dao.selectEnabledRootCharacteristics()).thenReturn(newArrayList(characteristicDto));
assertThat(service.rootCharacteristics()).hasSize(1);
}
@Test
public void find_characteristics() {
- when(dao.selectEnabledCharacteristics()).thenReturn(newArrayList(rootCharacteristicDto));
+ when(dao.selectEnabledCharacteristics()).thenReturn(newArrayList(characteristicDto));
assertThat(service.characteristics()).hasSize(1);
}
@Test
public void find_characteristic_by_id() {
- when(dao.selectById(1)).thenReturn(rootCharacteristicDto);
+ when(dao.selectById(1)).thenReturn(characteristicDto);
DebtCharacteristic characteristic = service.characteristicById(1);
assertThat(characteristic.id()).isEqualTo(1);
@@ -119,7 +138,7 @@ public class DebtModelServiceTest {
@Test
public void create_sub_characteristic() {
- when(dao.selectById(1, session)).thenReturn(rootCharacteristicDto);
+ when(dao.selectById(1, session)).thenReturn(characteristicDto);
DebtCharacteristic result = service.create("Compilation name", 1);
@@ -131,7 +150,7 @@ public class DebtModelServiceTest {
@Test
public void fail_to_create_sub_characteristic_when_parent_id_is_not_a_root_characteristic() {
- when(dao.selectById(1, session)).thenReturn(characteristicDto);
+ when(dao.selectById(1, session)).thenReturn(subCharacteristicDto);
try {
service.create("Compilation", 1);
@@ -156,7 +175,7 @@ public class DebtModelServiceTest {
@Test
public void fail_to_create_sub_characteristic_when_name_already_used() {
when(dao.selectByName("Compilation", session)).thenReturn(new CharacteristicDto());
- when(dao.selectById(1, session)).thenReturn(rootCharacteristicDto);
+ when(dao.selectById(1, session)).thenReturn(characteristicDto);
try {
service.create("Compilation", 1);
@@ -205,7 +224,7 @@ public class DebtModelServiceTest {
@Test
public void rename_characteristic() {
- when(dao.selectById(10, session)).thenReturn(characteristicDto);
+ when(dao.selectById(10, session)).thenReturn(subCharacteristicDto);
DebtCharacteristic result = service.rename(10, "New Efficiency");
@@ -215,7 +234,7 @@ public class DebtModelServiceTest {
@Test
public void not_rename_characteristic_when_renaming_with_same_name() {
- when(dao.selectById(10, session)).thenReturn(characteristicDto);
+ when(dao.selectById(10, session)).thenReturn(subCharacteristicDto);
service.rename(10, "Efficiency");
@@ -286,4 +305,78 @@ public class DebtModelServiceTest {
verify(dao, never()).update(any(CharacteristicDto.class), eq(session));
}
+ @Test
+ public void delete_sub_characteristic() {
+ BatchSession batchSession = mock(BatchSession.class);
+ when(mybatis.openBatchSession()).thenReturn(batchSession);
+
+ when(ruleDao.selectByCharacteristicOrSubCharacteristicId(2, batchSession)).thenReturn(newArrayList(
+ new RuleDto()
+ .setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("5min")
+ .setDefaultCharacteristicId(10).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationFactor("4h").setDefaultRemediationOffset("15min")
+ ));
+ when(dao.selectById(2, batchSession)).thenReturn(subCharacteristicDto);
+
+ service.delete(2);
+
+ ArgumentCaptor<RuleDto> ruleArgument = ArgumentCaptor.forClass(RuleDto.class);
+ verify(ruleDao).update(ruleArgument.capture(), eq(batchSession));
+ RuleDto ruleDto = ruleArgument.getValue();
+
+ // Overridden debt data are disabled
+ assertThat(ruleDto.getCharacteristicId()).isEqualTo(-1);
+ assertThat(ruleDto.getRemediationFunction()).isNull();
+ assertThat(ruleDto.getRemediationFactor()).isNull();
+ assertThat(ruleDto.getRemediationOffset()).isNull();
+ assertThat(ruleDto.getUpdatedAt()).isEqualTo(now);
+
+ // Default debt data should not be touched
+ assertThat(ruleDto.getDefaultCharacteristicId()).isEqualTo(10);
+ assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
+ assertThat(ruleDto.getDefaultRemediationFactor()).isEqualTo("4h");
+ assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("15min");
+
+ ArgumentCaptor<CharacteristicDto> characteristicArgument = ArgumentCaptor.forClass(CharacteristicDto.class);
+ verify(dao).update(characteristicArgument.capture(), eq(batchSession));
+ CharacteristicDto characteristicDto = characteristicArgument.getValue();
+
+ // Sub characteristic is disable
+ assertThat(characteristicDto.getId()).isEqualTo(2);
+ assertThat(characteristicDto.isEnabled()).isFalse();
+ assertThat(characteristicDto.getUpdatedAt()).isEqualTo(now);
+ }
+
+ @Test
+ public void delete_characteristic() {
+ BatchSession batchSession = mock(BatchSession.class);
+ when(mybatis.openBatchSession()).thenReturn(batchSession);
+
+ when(ruleDao.selectByCharacteristicOrSubCharacteristicId(1, batchSession)).thenReturn(newArrayList(
+ new RuleDto().setCharacteristicId(2).setRemediationFunction("LINEAR_OFFSET").setRemediationFactor("2h").setRemediationOffset("5min")
+ ));
+ when(dao.selectCharacteristicsByParentId(1, batchSession)).thenReturn(newArrayList(
+ subCharacteristicDto
+ ));
+ when(dao.selectById(1, batchSession)).thenReturn(characteristicDto);
+
+ service.delete(1);
+
+ verify(ruleDao).update(any(RuleDto.class), eq(batchSession));
+
+ ArgumentCaptor<CharacteristicDto> characteristicArgument = ArgumentCaptor.forClass(CharacteristicDto.class);
+ verify(dao, times(2)).update(characteristicArgument.capture(), eq(batchSession));
+ CharacteristicDto subCharacteristicDto = characteristicArgument.getAllValues().get(0);
+ CharacteristicDto characteristicDto = characteristicArgument.getAllValues().get(1);
+
+ // Sub characteristic is disable
+ assertThat(subCharacteristicDto.getId()).isEqualTo(2);
+ assertThat(subCharacteristicDto.isEnabled()).isFalse();
+ assertThat(subCharacteristicDto.getUpdatedAt()).isEqualTo(now);
+
+ // Characteristic is disable
+ assertThat(characteristicDto.getId()).isEqualTo(1);
+ assertThat(characteristicDto.isEnabled()).isFalse();
+ assertThat(characteristicDto.getUpdatedAt()).isEqualTo(now);
+ }
+
}
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelSynchronizerTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelSynchronizerTest.java
index 9b7accc80b2..0ab0f351732 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelSynchronizerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelSynchronizerTest.java
@@ -31,9 +31,7 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
import org.sonar.core.technicaldebt.TechnicalDebtModelRepository;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
import org.sonar.core.technicaldebt.db.CharacteristicDto;
@@ -67,7 +65,7 @@ public class DebtModelSynchronizerTest {
Integer currentId = 1;
- private DefaultTechnicalDebtModel defaultModel;
+ private DebtCharacteristicsXMLImporter.DebtModel defaultModel;
private DebtModelSynchronizer manager;
@@ -75,10 +73,10 @@ public class DebtModelSynchronizerTest {
public void initAndMerge() throws Exception {
when(myBatis.openSession()).thenReturn(session);
- defaultModel = new DefaultTechnicalDebtModel();
+ defaultModel = new DebtCharacteristicsXMLImporter.DebtModel();
Reader defaultModelReader = mock(Reader.class);
when(technicalDebtModelRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader);
- when(xmlImporter.importXML(eq(defaultModelReader), any(ValidationMessages.class))).thenReturn(defaultModel);
+ when(xmlImporter.importXML(eq(defaultModelReader))).thenReturn(defaultModel);
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
@@ -102,7 +100,7 @@ public class DebtModelSynchronizerTest {
when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
when(dao.selectEnabledCharacteristics()).thenReturn(Lists.<CharacteristicDto>newArrayList());
- manager.synchronize(ValidationMessages.create());
+ manager.synchronize();
verify(dao).selectEnabledCharacteristics();
ArgumentCaptor<CharacteristicDto> characteristicCaptor = ArgumentCaptor.forClass(CharacteristicDto.class);
@@ -123,7 +121,7 @@ public class DebtModelSynchronizerTest {
when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList(new CharacteristicDto()));
- manager.synchronize(ValidationMessages.create());
+ manager.synchronize();
verify(dao, never()).insert(any(CharacteristicDto.class), eq(session));
}
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java
index 08ed971be0d..9fdaefb428f 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java
@@ -190,6 +190,18 @@ public class DebtRulesXMLImporterTest {
}
}
+ @Test
+ public void fail_on_bad_xml() {
+ String xml = getFileContent("fail_on_bad_xml.xml");
+
+ try {
+ new DebtCharacteristicsXMLImporter().importXML(xml);
+ fail();
+ } catch (Exception e){
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ }
+ }
+
private String getFileContent(String file) {
try {
return Resources.toString(Resources.getResource(DebtRulesXMLImporterTest.class, "DebtRulesXMLImporterTest/" + file), Charsets.UTF_8);
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java
index 6ceb0107900..1e58b7dbdb3 100644
--- a/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java
@@ -113,7 +113,7 @@ public class ServerPluginJarsInstallerTest {
}
@Test
- public void should_fail_on_plugin_depending_on_more_recent_sonar() {
+ public void fail_if_require_greater_SQ_version() {
when(server.getVersion()).thenReturn("2.0");
exception.expect(IllegalStateException.class);
diff --git a/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGateTest.java b/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGateTest.java
new file mode 100644
index 00000000000..3f94bfd4e6d
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterBuiltinQualityGateTest.java
@@ -0,0 +1,85 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.qualitygate;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.core.qualitygate.db.QualityGateDto;
+import org.sonar.core.template.LoadedTemplateDao;
+import org.sonar.core.template.LoadedTemplateDto;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RegisterBuiltinQualityGateTest {
+
+ @Mock
+ private QualityGates qualityGates;
+
+ @Mock
+ private LoadedTemplateDao templateDao;
+
+ private RegisterBuiltinQualityGate task;
+
+ @Before
+ public void setUp() {
+ task = new RegisterBuiltinQualityGate(qualityGates, templateDao);
+ }
+
+ @Test
+ public void should_register_builtin() {
+ String templateType = "QUALITY_GATE";
+ String templateName = "SonarQube way";
+ when(templateDao.countByTypeAndKey(templateType, templateName)).thenReturn(0);
+ when(qualityGates.create(templateName)).thenReturn(new QualityGateDto().setId(42L));
+
+ task.start();
+
+ verify(templateDao).countByTypeAndKey(templateType, templateName);
+ verify(qualityGates).create(templateName);
+ verify(qualityGates, times(8)).createCondition(anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt());
+ ArgumentCaptor<LoadedTemplateDto> templateArg = ArgumentCaptor.forClass(LoadedTemplateDto.class);
+ verify(templateDao).insert(templateArg.capture());
+ LoadedTemplateDto template = templateArg.getValue();
+ assertThat(template.getType()).isEqualTo(templateType);
+ assertThat(template.getKey()).isEqualTo(templateName);
+ }
+
+ @Test
+ public void should_not_register_builtin() {
+ String templateType = "QUALITY_GATE";
+ String templateName = "SonarQube way";
+ when(templateDao.countByTypeAndKey(templateType, templateName)).thenReturn(1);
+
+ task.start();
+
+ verify(templateDao).countByTypeAndKey(templateType, templateName);
+ verifyZeroInteractions(qualityGates);
+ verifyNoMoreInteractions(templateDao);
+ }
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java b/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
index 40b55c17c79..dd5c8645817 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QgateAppHandlerTest.java
@@ -35,15 +35,14 @@ import org.sonar.api.server.ws.WsTester;
import org.sonar.core.timemachine.Periods;
import org.sonar.server.qualitygate.QualityGates;
-import java.util.Collection;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class QgateAppHandlerTest {
@@ -89,7 +88,7 @@ public class QgateAppHandlerTest {
Collection<Map> periods = (Collection<Map>) responseJson.get("periods");
assertThat(periods).hasSize(3);
Map messages = (Map) responseJson.get("messages");
- assertThat(messages).isNotNull().isNotEmpty().hasSize(47);
+ assertThat(messages).isNotNull().isNotEmpty().hasSize(50);
for (Entry message: (Set<Entry>) messages.entrySet()) {
assertThat(message.getKey()).isEqualTo(message.getValue());
}
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java
index 40afa74f928..c0a4a97bdad 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java
@@ -50,7 +50,7 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
private static final String[] EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT = {"created_at", "updated_at", "note_data", "note_user_login", "note_created_at", "note_updated_at",
"characteristic_id", "default_characteristic_id",
"remediation_function", "default_remediation_function", "remediation_factor", "default_remediation_factor", "remediation_offset", "default_remediation_offset",
- "effort_to_fix_l10n_key"};
+ "effort_to_fix_description"};
RuleRegistration task;
ProfilesManager profilesManager = mock(ProfilesManager.class);
@@ -287,7 +287,7 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
.setSeverity(Severity.BLOCKER)
.setDebtCharacteristic("MEMORY_EFFICIENCY")
.setDebtRemediationFunction(DebtRemediationFunction.createLinearWithOffset("5d", "10h"))
- .setEffortToFixL10nKey("squid.S115.effortToFix")
+ .setEffortToFixDescription("squid.S115.effortToFix")
.setInternalKey("config1")
.setTags("tag1", "tag3", "tag5");
rule1.createParam("param1").setDescription("parameter one").setDefaultValue("default value one");
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleRepositoriesTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleRepositoriesTest.java
index 03d3d093c38..5ec62083e5c 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RuleRepositoriesTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleRepositoriesTest.java
@@ -25,6 +25,7 @@ import org.sonar.api.server.rule.RulesDefinition;
import static org.fest.assertions.Assertions.assertThat;
public class RuleRepositoriesTest {
+
@Test
public void should_register_repositories() {
RulesDefinition.Context context = new RulesDefinition.Context();
@@ -60,6 +61,30 @@ public class RuleRepositoriesTest {
assertThat(findbugs).isEqualTo(findbugs).isNotEqualTo(squid).isNotEqualTo("findbugs").isNotEqualTo(null);
}
+ @Test
+ public void register_repositories_having_same_name() {
+ RulesDefinition.Context context = new RulesDefinition.Context();
+ new RulesDefinition() {
+ @Override
+ public void define(Context context) {
+ context.createRepository("squid", "java").setName("SonarQube").done();
+ }
+ }.define(context);
+
+ // Repository with same name
+ new RulesDefinition() {
+ @Override
+ public void define(Context context) {
+ context.createRepository("javascript", "js").setName("SonarQube").done();
+ }
+ }.define(context);
+
+ RuleRepositories repositories = new RuleRepositories();
+ repositories.register(context);
+
+ assertThat(repositories.repositories()).hasSize(2);
+ }
+
static class FindbugsDefinitions implements RulesDefinition {
@Override
public void define(Context context) {
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java
index 5014226a950..b6d24cbcc94 100644
--- a/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java
@@ -21,10 +21,8 @@
package org.sonar.server.startup;
import org.junit.Test;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.server.debt.DebtModelSynchronizer;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
public class RegisterDebtModelTest {
@@ -36,6 +34,6 @@ public class RegisterDebtModelTest {
sqaleDefinition.start();
- verify(synchronizer, times(1)).synchronize(any(ValidationMessages.class));
+ verify(synchronizer, times(1)).synchronize();
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/user/DoPrivilegedTest.java b/sonar-server/src/test/java/org/sonar/server/user/DoPrivilegedTest.java
new file mode 100644
index 00000000000..410fcb612cb
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/user/DoPrivilegedTest.java
@@ -0,0 +1,40 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.server.user;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DoPrivilegedTest {
+
+ @Test
+ public void should_allow_everything_in_privileged_mode_only() {
+ DoPrivileged.start();
+ UserSession userSession = UserSession.get();
+ assertThat(userSession.isLoggedIn()).isTrue();
+ assertThat(userSession.hasGlobalPermission("any permission")).isTrue();
+ assertThat(userSession.hasProjectPermission("any permission", "any project")).isTrue();
+
+ DoPrivileged.stop();
+ userSession = UserSession.get();
+ assertThat(userSession.isLoggedIn()).isFalse();
+ }
+}
diff --git a/sonar-server/src/test/resources/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest/fail_on_bad_xml.xml b/sonar-server/src/test/resources/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest/fail_on_bad_xml.xml
new file mode 100644
index 00000000000..3b15eae11d6
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest/fail_on_bad_xml.xml
@@ -0,0 +1 @@
+Not a valid xml
diff --git a/sonar-server/src/test/resources/org/sonar/server/debt/DebtRulesXMLImporterTest/fail_on_bad_xml.xml b/sonar-server/src/test/resources/org/sonar/server/debt/DebtRulesXMLImporterTest/fail_on_bad_xml.xml
new file mode 100644
index 00000000000..3b15eae11d6
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/debt/DebtRulesXMLImporterTest/fail_on_bad_xml.xml
@@ -0,0 +1 @@
+Not a valid xml
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/fail_if_require_greater_SQ_version/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar
index 8044dff8988..8044dff8988 100644
--- a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar
+++ b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/fail_if_require_greater_SQ_version/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar
Binary files differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/ignore_rule_debt_definitions_if_rule_is_linked_on_root_characteristic.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/ignore_rule_debt_definitions_if_rule_is_linked_on_root_characteristic.xml
index 3a010942f21..2c69463ae43 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/ignore_rule_debt_definitions_if_rule_is_linked_on_root_characteristic.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/ignore_rule_debt_definitions_if_rule_is_linked_on_root_characteristic.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="LINEAR"
remediation_factor="[null]" default_remediation_factor="14min"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="squid.S1115.effortTotFix"/>
+ effort_to_fix_description="squid.S1115.effortTotFix"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml
index 489e2108e85..21cc3f9dab4 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"
@@ -14,7 +14,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix"/>
+ effort_to_fix_description="squid.S115.effortToFix"/>
<rules_parameters id="1" rule_id="2" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
<rules_parameters id="2" rule_id="2" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
@@ -33,6 +33,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules-result.xml
index a5faaa73c51..c4b64d12430 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"
+ effort_to_fix_description="[null]"
updated_at="2014-03-16"/>
<rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
@@ -15,7 +15,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"
+ effort_to_fix_description="[null]"
updated_at="2014-03-16"/>
<!-- New rules -->
@@ -25,7 +25,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix"
+ effort_to_fix_description="squid.S115.effortToFix"
updated_at="2014-03-17 19:10:03.0"/>
<rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
@@ -34,7 +34,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"
+ effort_to_fix_description="[null]"
updated_at="2014-03-17 19:10:03.0"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules.xml
index 8b0604e2036..27a03f91411 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_already_disabled_rules.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"
+ effort_to_fix_description="[null]"
updated_at="2014-03-16"/>
<rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
@@ -17,7 +17,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"
+ effort_to_fix_description="[null]"
updated_at="2014-03-16"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found-result.xml
index a773983725f..89e5191d7fd 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
@@ -14,6 +14,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found.xml
index 6de51e77092..14495983726 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_characteristic_not_found.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="LINEAR"
remediation_factor="[null]" default_remediation_factor="14min"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled-result.xml
index df6e0278b99..fcb2b867045 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
@@ -14,6 +14,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled.xml
index 69426df342f..fd2c3d8e489 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_characteristic_when_default_characteristic_not_found_and_overriding_characteristic_disabled.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"
@@ -16,6 +16,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden-result.xml
index aa889da419b..9fcf2872bb9 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden-result.xml
@@ -6,7 +6,7 @@
remediation_function="LINEAR_OFFSET" default_remediation_function="[null]"
remediation_factor="5d" default_remediation_factor="[null]"
remediation_offset="10h" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
@@ -14,6 +14,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden.xml
index cac7ab78521..66458e67ee3 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/set_no_default_characteristic_when_default_characteristic_not_found_but_characteristic_has_been_overridden.xml
@@ -10,7 +10,7 @@
remediation_function="LINEAR_OFFSET" default_remediation_function="[null]"
remediation_factor="5d" default_remediation_factor="[null]"
remediation_offset="10h" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"
@@ -18,6 +18,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml
index f630e3adbd9..4c832441dd4 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix"/>
+ effort_to_fix_description="squid.S115.effortToFix"/>
<rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
<rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
@@ -27,6 +27,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml
index 6ab04c32b61..5a04a1672f5 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="LINEAR"
remediation_factor="[null]" default_remediation_factor="14min"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]"/>
+ effort_to_fix_description="[null]"/>
<rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml
index 7821240a5c7..0fc47887777 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml
@@ -6,7 +6,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix" />
+ effort_to_fix_description="squid.S115.effortToFix" />
<!-- Instance of old rule 1 :/ -->
<rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
@@ -15,7 +15,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix" />
+ effort_to_fix_description="squid.S115.effortToFix" />
<rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
@@ -23,7 +23,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]" />
+ effort_to_fix_description="[null]" />
<!-- Template of old rule 3 :/ -->
<rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
@@ -32,6 +32,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]" />
+ effort_to_fix_description="[null]" />
</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml
index 51e70c311d4..2813575401e 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml
@@ -8,7 +8,7 @@
remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
remediation_factor="[null]" default_remediation_factor="5d"
remediation_offset="[null]" default_remediation_offset="10h"
- effort_to_fix_l10n_key="squid.S115.effortToFix" />
+ effort_to_fix_description="squid.S115.effortToFix" />
<!-- Instance of rule 1 -->
<rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
@@ -17,7 +17,7 @@
remediation_function="[null]" default_remediation_function="LINEAR"
remediation_factor="[null]" default_remediation_factor="1h"
remediation_offset="[null]" default_remediation_offset="15min"
- effort_to_fix_l10n_key="squid.S115.effortToFix2" />
+ effort_to_fix_description="squid.S115.effortToFix2" />
<rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
status="DEPRECATED" priority="1" cardinality="MULTIPLE" parent_id="[null]"
@@ -25,7 +25,7 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]" />
+ effort_to_fix_description="[null]" />
<!-- Instance of rule 3 -->
<rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
@@ -34,6 +34,6 @@
remediation_function="[null]" default_remediation_function="[null]"
remediation_factor="[null]" default_remediation_factor="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
- effort_to_fix_l10n_key="[null]" />
+ effort_to_fix_description="[null]" />
</dataset>