From 1ffa320fb3e44cdaf635678a04c473ca4f348514 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 10 Mar 2014 17:04:45 +0100 Subject: [PATCH] revert renaming of DebtModelPluginRepository to TechnicalDebtModelRepository as sonar-core module is used by Views Plugin --- .../CharacteristicsDebtModelSynchronizer.java | 6 +++--- ...java => TechnicalDebtModelRepository.java} | 8 ++++---- .../TechnicalDebtModelSynchronizer.java | 8 ++++---- ...racteristicsDebtModelSynchronizerTest.java | 10 +++++----- ... => TechnicalDebtModelRepositoryTest.java} | 10 +++++----- .../TechnicalDebtModelSynchronizerTest.java | 20 +++++++++---------- .../org/sonar/server/platform/Platform.java | 2 +- .../rule/DeprecatedRuleDefinitions.java | 10 +++++----- .../rule/DeprecatedRuleDefinitionsTest.java | 4 ++-- 9 files changed, 39 insertions(+), 39 deletions(-) rename sonar-core/src/main/java/org/sonar/core/technicaldebt/{DebtModelPluginRepository.java => TechnicalDebtModelRepository.java} (92%) rename sonar-core/src/test/java/org/sonar/core/technicaldebt/{DebtModelPluginRepositoryTest.java => TechnicalDebtModelRepositoryTest.java} (92%) diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java index 9ed88aa6004..7a8730bc191 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java @@ -42,10 +42,10 @@ public class CharacteristicsDebtModelSynchronizer implements ServerExtension { private final MyBatis mybatis; private final CharacteristicDao dao; - private final DebtModelPluginRepository languageModelFinder; + private final TechnicalDebtModelRepository languageModelFinder; private final CharacteristicsDebtModelXMLImporter importer; - public CharacteristicsDebtModelSynchronizer(MyBatis mybatis, CharacteristicDao dao, DebtModelPluginRepository modelRepository, CharacteristicsDebtModelXMLImporter importer) { + public CharacteristicsDebtModelSynchronizer(MyBatis mybatis, CharacteristicDao dao, TechnicalDebtModelRepository modelRepository, CharacteristicsDebtModelXMLImporter importer) { this.mybatis = mybatis; this.dao = dao; this.languageModelFinder = modelRepository; @@ -66,7 +66,7 @@ public class CharacteristicsDebtModelSynchronizer implements ServerExtension { } public List synchronize(ValidationMessages messages, SqlSession session) { - DefaultTechnicalDebtModel defaultModel = loadModelFromXml(DebtModelPluginRepository.DEFAULT_MODEL, messages); + DefaultTechnicalDebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL, messages); List model = loadOrCreateModelFromDb(defaultModel, session); messages.log(LOG); return model; diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelPluginRepository.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepository.java similarity index 92% rename from sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelPluginRepository.java rename to sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepository.java index d6bf39e74f3..d103004a595 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelPluginRepository.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepository.java @@ -43,7 +43,7 @@ import static com.google.common.collect.Lists.newArrayList; * they must be named "-model.xml". *

*/ -public class DebtModelPluginRepository implements ServerExtension, Startable { +public class TechnicalDebtModelRepository implements ServerExtension, Startable { public static final String DEFAULT_MODEL = "technical-debt"; @@ -55,19 +55,19 @@ public class DebtModelPluginRepository implements ServerExtension, Startable { private PluginRepository pluginRepository; private Map contributingPluginKeyToClassLoader; - public DebtModelPluginRepository(PluginRepository pluginRepository) { + public TechnicalDebtModelRepository(PluginRepository pluginRepository) { this.pluginRepository = pluginRepository; this.xmlFilePrefix = XML_FILE_PREFIX; } @VisibleForTesting - DebtModelPluginRepository(PluginRepository pluginRepository, String xmlFilePrefix) { + TechnicalDebtModelRepository(PluginRepository pluginRepository, String xmlFilePrefix) { this.pluginRepository = pluginRepository; this.xmlFilePrefix = xmlFilePrefix; } @VisibleForTesting - DebtModelPluginRepository(Map contributingPluginKeyToClassLoader, String xmlFilePrefix) { + TechnicalDebtModelRepository(Map contributingPluginKeyToClassLoader, String xmlFilePrefix) { this.contributingPluginKeyToClassLoader = contributingPluginKeyToClassLoader; this.xmlFilePrefix = xmlFilePrefix; } diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizer.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizer.java index fef9f7b23cd..349a08bc9cb 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizer.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizer.java @@ -49,11 +49,11 @@ public class TechnicalDebtModelSynchronizer implements ServerExtension { private final MyBatis mybatis; private final CharacteristicDao dao; - private final DebtModelPluginRepository languageModelFinder; + private final TechnicalDebtModelRepository languageModelFinder; private final TechnicalDebtXMLImporter importer; public TechnicalDebtModelSynchronizer(MyBatis mybatis, CharacteristicDao dao, - DebtModelPluginRepository modelRepository, TechnicalDebtXMLImporter importer) { + TechnicalDebtModelRepository modelRepository, TechnicalDebtXMLImporter importer) { this.mybatis = mybatis; this.dao = dao; this.languageModelFinder = modelRepository; @@ -74,7 +74,7 @@ public class TechnicalDebtModelSynchronizer implements ServerExtension { } public List synchronize(ValidationMessages messages, TechnicalDebtRuleCache rulesCache, SqlSession session) { - DefaultTechnicalDebtModel defaultModel = loadModelFromXml(DebtModelPluginRepository.DEFAULT_MODEL, messages, rulesCache); + DefaultTechnicalDebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL, messages, rulesCache); List model = loadOrCreateModelFromDb(defaultModel, session); disableRequirementsOnRemovedRules(model, rulesCache, session); mergePlugins(model, defaultModel, messages, rulesCache, session); @@ -169,7 +169,7 @@ public class TechnicalDebtModelSynchronizer implements ServerExtension { private Collection getContributingPluginListWithoutSqale() { Collection pluginList = newArrayList(languageModelFinder.getContributingPluginList()); - pluginList.remove(DebtModelPluginRepository.DEFAULT_MODEL); + pluginList.remove(TechnicalDebtModelRepository.DEFAULT_MODEL); return pluginList; } diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java index 814e12fa54f..db3184b7afe 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java @@ -55,7 +55,7 @@ public class CharacteristicsDebtModelSynchronizerTest { SqlSession session; @Mock - DebtModelPluginRepository debtModelPluginRepository; + TechnicalDebtModelRepository technicalDebtModelRepository; @Mock CharacteristicDao dao; @@ -75,7 +75,7 @@ public class CharacteristicsDebtModelSynchronizerTest { defaultModel = new DefaultTechnicalDebtModel(); Reader defaultModelReader = mock(Reader.class); - when(debtModelPluginRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader); + when(technicalDebtModelRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader); when(xmlImporter.importXML(eq(defaultModelReader), any(ValidationMessages.class))).thenReturn(defaultModel); doAnswer(new Answer() { @@ -88,7 +88,7 @@ public class CharacteristicsDebtModelSynchronizerTest { }).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class)); - manager = new CharacteristicsDebtModelSynchronizer(myBatis, dao, debtModelPluginRepository, xmlImporter); + manager = new CharacteristicsDebtModelSynchronizer(myBatis, dao, technicalDebtModelRepository, xmlImporter); } @Test @@ -97,7 +97,7 @@ public class CharacteristicsDebtModelSynchronizerTest { new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic); defaultModel.addRootCharacteristic(rootCharacteristic); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList()); manager.synchronize(ValidationMessages.create()); @@ -118,7 +118,7 @@ public class CharacteristicsDebtModelSynchronizerTest { new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic); defaultModel.addRootCharacteristic(rootCharacteristic); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList(new CharacteristicDto())); manager.synchronize(ValidationMessages.create()); diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelPluginRepositoryTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepositoryTest.java similarity index 92% rename from sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelPluginRepositoryTest.java rename to sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepositoryTest.java index 822c4682419..0b69fa82b0f 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelPluginRepositoryTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelRepositoryTest.java @@ -46,11 +46,11 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class DebtModelPluginRepositoryTest { +public class TechnicalDebtModelRepositoryTest { private static final String TEST_XML_PREFIX_PATH = "org/sonar/core/technicaldebt/TechnicalDebtModelRepositoryTest/"; - private DebtModelPluginRepository modelFinder; + private TechnicalDebtModelRepository modelFinder; @Test public void test_component_initialization() throws Exception { @@ -66,7 +66,7 @@ public class DebtModelPluginRepositoryTest { when(repository.getMetadata()).thenReturn(Lists.newArrayList(csharpPluginMetadata, phpPluginMetadata)); FakePlugin fakePlugin = new FakePlugin(); when(repository.getPlugin(anyString())).thenReturn(fakePlugin); - modelFinder = new DebtModelPluginRepository(repository, TEST_XML_PREFIX_PATH); + modelFinder = new TechnicalDebtModelRepository(repository, TEST_XML_PREFIX_PATH); // when modelFinder.start(); @@ -110,7 +110,7 @@ public class DebtModelPluginRepositoryTest { @Test public void contain_default_model() throws Exception { - modelFinder = new DebtModelPluginRepository(mock(PluginRepository.class)); + modelFinder = new TechnicalDebtModelRepository(mock(PluginRepository.class)); modelFinder.start(); assertThat(modelFinder.getContributingPluginKeyToClassLoader().keySet()).containsOnly("technical-debt"); } @@ -119,7 +119,7 @@ public class DebtModelPluginRepositoryTest { Map contributingPluginKeyToClassLoader = Maps.newHashMap(); contributingPluginKeyToClassLoader.put("csharp", newClassLoader()); contributingPluginKeyToClassLoader.put("java", newClassLoader()); - modelFinder = new DebtModelPluginRepository(contributingPluginKeyToClassLoader, TEST_XML_PREFIX_PATH); + modelFinder = new TechnicalDebtModelRepository(contributingPluginKeyToClassLoader, TEST_XML_PREFIX_PATH); } private ClassLoader newClassLoader() throws MalformedURLException { diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java index b49190b6f2f..5419bb96978 100644 --- a/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelSynchronizerTest.java @@ -61,7 +61,7 @@ public class TechnicalDebtModelSynchronizerTest { SqlSession session; @Mock - DebtModelPluginRepository debtModelPluginRepository; + TechnicalDebtModelRepository technicalDebtModelRepository; @Mock TechnicalDebtRuleCache ruleCache; @@ -84,7 +84,7 @@ public class TechnicalDebtModelSynchronizerTest { defaultModel = new DefaultTechnicalDebtModel(); Reader defaultModelReader = mock(Reader.class); - when(debtModelPluginRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader); + when(technicalDebtModelRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader); when(xmlImporter.importXML(eq(defaultModelReader), any(ValidationMessages.class), eq(ruleCache))).thenReturn(defaultModel); doAnswer(new Answer() { @@ -97,7 +97,7 @@ public class TechnicalDebtModelSynchronizerTest { }).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class)); - manager = new TechnicalDebtModelSynchronizer(myBatis, dao, debtModelPluginRepository, xmlImporter); + manager = new TechnicalDebtModelSynchronizer(myBatis, dao, technicalDebtModelRepository, xmlImporter); } @Test @@ -106,7 +106,7 @@ public class TechnicalDebtModelSynchronizerTest { new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic); defaultModel.addRootCharacteristic(rootCharacteristic); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.emptyList()); when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList()); manager.synchronize(ValidationMessages.create(), ruleCache); @@ -150,8 +150,8 @@ public class TechnicalDebtModelSynchronizerTest { Reader javaModelReader = mock(Reader.class); when(xmlImporter.importXML(eq(javaModelReader), any(ValidationMessages.class), eq(ruleCache))).thenReturn(javaModel); - when(debtModelPluginRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(newArrayList("java")); + when(technicalDebtModelRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(newArrayList("java")); manager.synchronize(ValidationMessages.create(), ruleCache); @@ -206,9 +206,9 @@ public class TechnicalDebtModelSynchronizerTest { .setRootCharacteristic(javaRootCharacteristic); Reader javaModelReader = mock(Reader.class); - when(debtModelPluginRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); + when(technicalDebtModelRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); when(xmlImporter.importXML(eq(javaModelReader), any(ValidationMessages.class), eq(ruleCache))).thenReturn(javaModel); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(newArrayList("java")); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(newArrayList("java")); manager.synchronize(ValidationMessages.create(), ruleCache); @@ -264,9 +264,9 @@ public class TechnicalDebtModelSynchronizerTest { javaModel.addRootCharacteristic(javaRootCharacteristic); Reader javaModelReader = mock(Reader.class); - when(debtModelPluginRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); + when(technicalDebtModelRepository.createReaderForXMLFile("java")).thenReturn(javaModelReader); when(xmlImporter.importXML(eq(javaModelReader), any(ValidationMessages.class), eq(ruleCache))).thenReturn(javaModel); - when(debtModelPluginRepository.getContributingPluginList()).thenReturn(newArrayList("java")); + when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(newArrayList("java")); manager.synchronize(ValidationMessages.create(), ruleCache); fail(); diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index fbd8d8aad29..a061f05ad78 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -385,7 +385,7 @@ public final class Platform { servicesContainer.addSingleton(DebtService.class); servicesContainer.addSingleton(TechnicalDebtModelSynchronizer.class); servicesContainer.addSingleton(CharacteristicsDebtModelSynchronizer.class); - servicesContainer.addSingleton(DebtModelPluginRepository.class); + servicesContainer.addSingleton(TechnicalDebtModelRepository.class); servicesContainer.addSingleton(TechnicalDebtXMLImporter.class); servicesContainer.addSingleton(RulesDebtModelXMLImporter.class); servicesContainer.addSingleton(CharacteristicsDebtModelXMLImporter.class); diff --git a/sonar-server/src/main/java/org/sonar/server/rule/DeprecatedRuleDefinitions.java b/sonar-server/src/main/java/org/sonar/server/rule/DeprecatedRuleDefinitions.java index 19e65fbe32d..4d49920f014 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/DeprecatedRuleDefinitions.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/DeprecatedRuleDefinitions.java @@ -31,8 +31,8 @@ import org.sonar.api.server.rule.RuleDefinitions; import org.sonar.api.server.rule.RuleParamType; import org.sonar.check.Cardinality; import org.sonar.core.i18n.RuleI18nManager; -import org.sonar.core.technicaldebt.DebtModelPluginRepository; import org.sonar.core.technicaldebt.RulesDebtModelXMLImporter; +import org.sonar.core.technicaldebt.TechnicalDebtModelRepository; import javax.annotation.CheckForNull; @@ -52,17 +52,17 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions { private final RuleI18nManager i18n; private final RuleRepository[] repositories; - private final DebtModelPluginRepository languageModelFinder; + private final TechnicalDebtModelRepository languageModelFinder; private final RulesDebtModelXMLImporter importer; - public DeprecatedRuleDefinitions(RuleI18nManager i18n, RuleRepository[] repositories, DebtModelPluginRepository languageModelFinder, RulesDebtModelXMLImporter importer) { + public DeprecatedRuleDefinitions(RuleI18nManager i18n, RuleRepository[] repositories, TechnicalDebtModelRepository languageModelFinder, RulesDebtModelXMLImporter importer) { this.i18n = i18n; this.repositories = repositories; this.languageModelFinder = languageModelFinder; this.importer = importer; } - public DeprecatedRuleDefinitions(RuleI18nManager i18n, DebtModelPluginRepository languageModelFinder, RulesDebtModelXMLImporter importer) { + public DeprecatedRuleDefinitions(RuleI18nManager i18n, TechnicalDebtModelRepository languageModelFinder, RulesDebtModelXMLImporter importer) { this(i18n, new RuleRepository[0], languageModelFinder, importer); } @@ -158,7 +158,7 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions { private Collection getContributingPluginListWithoutSqale() { Collection pluginList = newArrayList(languageModelFinder.getContributingPluginList()); - pluginList.remove(DebtModelPluginRepository.DEFAULT_MODEL); + pluginList.remove(TechnicalDebtModelRepository.DEFAULT_MODEL); return pluginList; } diff --git a/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRuleDefinitionsTest.java b/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRuleDefinitionsTest.java index b5002bb6cc1..b7db1081698 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRuleDefinitionsTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRuleDefinitionsTest.java @@ -32,8 +32,8 @@ import org.sonar.api.rules.RulePriority; import org.sonar.api.rules.RuleRepository; import org.sonar.api.server.rule.RuleDefinitions; import org.sonar.core.i18n.RuleI18nManager; -import org.sonar.core.technicaldebt.DebtModelPluginRepository; import org.sonar.core.technicaldebt.RulesDebtModelXMLImporter; +import org.sonar.core.technicaldebt.TechnicalDebtModelRepository; import java.io.Reader; import java.util.Arrays; @@ -52,7 +52,7 @@ public class DeprecatedRuleDefinitionsTest { RuleI18nManager i18n; @Mock - DebtModelPluginRepository debtModelRepository; + TechnicalDebtModelRepository debtModelRepository; @Mock RulesDebtModelXMLImporter importer; -- 2.39.5