diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-10-01 10:43:26 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-10-01 10:43:38 +0200 |
commit | 3a9dfb1fd7e4c854da5eab3d041e70b27e9c709c (patch) | |
tree | af412fa79fe01db559d2f02bd7e386ba512ad954 | |
parent | 6381abfb0276af35d36f711f8398bda53d3789de (diff) | |
download | sonarqube-3a9dfb1fd7e4c854da5eab3d041e70b27e9c709c.tar.gz sonarqube-3a9dfb1fd7e4c854da5eab3d041e70b27e9c709c.zip |
SONAR-4714 Load technical debt model only once per project instead of once per module
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculator.java | 5 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecorator.java | 14 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculatorTest.java | 5 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecoratorTest.java | 2 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java | 39 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/Characteristicable.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/Characteristicable.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtCharacteristic.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCharacteristic.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModel.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModel.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtRequirement.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirement.java) | 12 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnit.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnit.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnitConverter.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverter.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/AbstractFunction.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/AbstractFunction.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/ConstantFunction.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunction.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Function.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Function.java) | 8 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Functions.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Functions.java) | 8 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearFunction.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunction.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunction.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunction.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunction.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunction.java) | 6 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/package-info.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/package-info.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/technicaldebt/package-info.java | 23 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModelTest.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtRequirementTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirementTest.java) | 10 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/WorkUnitConverterTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverterTest.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/ConstantFunctionTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunctionTest.java) | 26 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/FunctionsTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/FunctionsTest.java) | 2 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearFunctionTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunctionTest.java) | 20 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java) | 28 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java) | 30 |
28 files changed, 147 insertions, 139 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculator.java index 36b758d529b..6c188e93584 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculator.java @@ -31,7 +31,10 @@ import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilters; import org.sonar.api.measures.Metric; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.functions.Functions; +import org.sonar.core.technicaldebt.TechnicalDebtCharacteristic; +import org.sonar.core.technicaldebt.TechnicalDebtModel; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.functions.Functions; import java.util.Collection; import java.util.List; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecorator.java index 84b62a796c7..86374222608 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecorator.java @@ -30,7 +30,9 @@ import org.sonar.api.measures.PersistenceMode; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; -import org.sonar.plugins.core.technicaldebt.functions.*; +import org.sonar.core.technicaldebt.TechnicalDebtCharacteristic; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Arrays; import java.util.List; @@ -101,16 +103,8 @@ public final class TechnicalDebtDecorator implements Decorator { ImmutableList.Builder<Object> extensions = ImmutableList.builder(); extensions.addAll(definitions()); extensions.add( - // base components - TechnicalDebtModel.class, WorkUnitConverter.class, TechnicalDebtCalculator.class, - - // functions - ConstantFunction.class, LinearFunction.class, LinearWithOffsetFunction.class, LinearWithThresholdFunction.class, Functions.class, - - // decorator - TechnicalDebtDecorator.class + TechnicalDebtDecorator.class, TechnicalDebtCalculator.class ); - return extensions.build(); } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculatorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculatorTest.java index cbccca4fccb..7eea344975d 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculatorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCalculatorTest.java @@ -29,7 +29,10 @@ import org.sonar.api.measures.MeasuresFilter; import org.sonar.api.qualitymodel.Characteristic; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.functions.Functions; +import org.sonar.core.technicaldebt.TechnicalDebtCharacteristic; +import org.sonar.core.technicaldebt.TechnicalDebtModel; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.functions.Functions; import java.util.Collection; import java.util.Collections; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecoratorTest.java index 14cb4d56353..65bfafefa10 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtDecoratorTest.java @@ -146,7 +146,7 @@ public class TechnicalDebtDecoratorTest { @Test public void check_extensions() { - assertThat(TechnicalDebtDecorator.extensions()).hasSize(1 /* properties */ + 9 /* extensions */); + assertThat(TechnicalDebtDecorator.extensions()).hasSize(1 /* properties */ + 2 /* extensions */); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java index 7992aab42ea..ec79143de77 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java @@ -33,30 +33,9 @@ import org.sonar.batch.DefaultFileLinesContextFactory; import org.sonar.batch.DefaultResourceCreationLock; import org.sonar.batch.ProjectConfigurator; import org.sonar.batch.ProjectTree; -import org.sonar.batch.bootstrap.BootstrapSettings; -import org.sonar.batch.bootstrap.ExtensionInstaller; -import org.sonar.batch.bootstrap.ExtensionMatcher; -import org.sonar.batch.bootstrap.ExtensionUtils; -import org.sonar.batch.bootstrap.MetricProvider; -import org.sonar.batch.index.Caches; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.batch.index.ComponentDataPersister; -import org.sonar.batch.index.DefaultIndex; -import org.sonar.batch.index.DefaultPersistenceManager; -import org.sonar.batch.index.DefaultResourcePersister; -import org.sonar.batch.index.DependencyPersister; -import org.sonar.batch.index.EventPersister; -import org.sonar.batch.index.LinkPersister; -import org.sonar.batch.index.MeasurePersister; -import org.sonar.batch.index.MemoryOptimizer; -import org.sonar.batch.index.ResourceCache; -import org.sonar.batch.index.SnapshotCache; -import org.sonar.batch.index.SourcePersister; -import org.sonar.batch.issue.DefaultProjectIssues; -import org.sonar.batch.issue.DeprecatedViolations; -import org.sonar.batch.issue.IssueCache; -import org.sonar.batch.issue.IssuePersister; -import org.sonar.batch.issue.ScanIssueStorage; +import org.sonar.batch.bootstrap.*; +import org.sonar.batch.index.*; +import org.sonar.batch.issue.*; import org.sonar.batch.phases.GraphPersister; import org.sonar.batch.profiling.PhasesSumUpTimeProfiler; import org.sonar.batch.scan.maven.FakeMavenPluginExecutor; @@ -69,6 +48,9 @@ import org.sonar.core.issue.IssueUpdater; import org.sonar.core.issue.workflow.FunctionExecutor; import org.sonar.core.issue.workflow.IssueWorkflow; import org.sonar.core.notification.DefaultNotificationManager; +import org.sonar.core.technicaldebt.TechnicalDebtModel; +import org.sonar.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.functions.*; import org.sonar.core.test.TestPlanBuilder; import org.sonar.core.test.TestPlanPerspectiveLoader; import org.sonar.core.test.TestableBuilder; @@ -158,6 +140,15 @@ public class ProjectScanContainer extends ComponentContainer { HighlightableBuilder.class, SymbolizableBuilder.class, + // technical debt + TechnicalDebtModel.class, + WorkUnitConverter.class, + ConstantFunction.class, + LinearFunction.class, + LinearWithOffsetFunction.class, + LinearWithThresholdFunction.class, + Functions.class, + ProjectSettingsReady.class); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/Characteristicable.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/Characteristicable.java index 5beeb7263f1..67d8e92af25 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/Characteristicable.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/Characteristicable.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.sonar.api.qualitymodel.Characteristic; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCharacteristic.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtCharacteristic.java index 104aceeb6e8..81a668f4d7d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtCharacteristic.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtCharacteristic.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import com.google.common.collect.Lists; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModel.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModel.java index 570fc3f085f..fbcee9db691 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModel.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtModel.java @@ -17,13 +17,13 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.BatchExtension; +import org.sonar.api.BatchComponent; import org.sonar.api.qualitymodel.Model; import org.sonar.api.qualitymodel.ModelFinder; import org.sonar.api.rules.Rule; @@ -34,7 +34,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; -public class TechnicalDebtModel implements BatchExtension { +public class TechnicalDebtModel implements BatchComponent { private static final Logger LOGGER = LoggerFactory.getLogger(TechnicalDebtModel.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirement.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtRequirement.java index 3dad2072ea9..93799c5878d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirement.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtRequirement.java @@ -17,12 +17,12 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.sonar.api.rules.Rule; -import org.sonar.plugins.core.technicaldebt.functions.LinearFunction; -import org.sonar.plugins.core.technicaldebt.functions.LinearWithOffsetFunction; -import org.sonar.plugins.core.technicaldebt.functions.LinearWithThresholdFunction; +import org.sonar.core.technicaldebt.functions.LinearFunction; +import org.sonar.core.technicaldebt.functions.LinearWithOffsetFunction; +import org.sonar.core.technicaldebt.functions.LinearWithThresholdFunction; public class TechnicalDebtRequirement implements Characteristicable { @@ -53,13 +53,13 @@ public class TechnicalDebtRequirement implements Characteristicable { private void initFactor() { factor = WorkUnit.create(characteristic.getPropertyValue(PROPERTY_REMEDIATION_FACTOR, null), - characteristic.getPropertyTextValue(PROPERTY_REMEDIATION_FACTOR, null)); + characteristic.getPropertyTextValue(PROPERTY_REMEDIATION_FACTOR, null)); } private void initOffset() { if (LinearWithOffsetFunction.FUNCTION_LINEAR_WITH_OFFSET.equals(function) || LinearWithThresholdFunction.FUNCTION_LINEAR_WITH_THRESHOLD.equals(function)) { offset = WorkUnit.create(characteristic.getPropertyValue(PROPERTY_OFFSET, null), - characteristic.getPropertyTextValue(PROPERTY_OFFSET, null)); + characteristic.getPropertyTextValue(PROPERTY_OFFSET, null)); } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnit.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnit.java index f5d20dbb3e9..1972cc70772 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnit.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnit.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnitConverter.java index ab768e8cad4..b83dc4cbfd7 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverter.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/WorkUnitConverter.java @@ -17,13 +17,13 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.apache.commons.lang.StringUtils; -import org.sonar.api.BatchExtension; +import org.sonar.api.BatchComponent; import org.sonar.api.config.Settings; -public final class WorkUnitConverter implements BatchExtension { +public final class WorkUnitConverter implements BatchComponent { public static final int DEFAULT_HOURS_IN_DAY = 8; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/AbstractFunction.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/AbstractFunction.java index 98b596e1be4..dd2ea2d8dfe 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/AbstractFunction.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/AbstractFunction.java @@ -17,11 +17,11 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunction.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/ConstantFunction.java index 7739230c205..4c54129258d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunction.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/ConstantFunction.java @@ -17,11 +17,11 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Function.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Function.java index 4fcb51290ba..cb54e529e4e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Function.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Function.java @@ -17,15 +17,15 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; -import org.sonar.api.BatchExtension; +import org.sonar.api.BatchComponent; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; import java.util.Collection; -public interface Function extends BatchExtension { +public interface Function extends BatchComponent { String getKey(); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Functions.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Functions.java index 37576e40f28..99263df6ef1 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/Functions.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/Functions.java @@ -17,17 +17,17 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import com.google.common.collect.Maps; -import org.sonar.api.BatchExtension; +import org.sonar.api.BatchComponent; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; import java.util.Collection; import java.util.Map; -public class Functions implements BatchExtension { +public class Functions implements BatchComponent { private final Map<String, Function> functionsByKey = Maps.newHashMap(); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunction.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearFunction.java index a883470c67b..727168c8dd9 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunction.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearFunction.java @@ -17,11 +17,11 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunction.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunction.java index 27a6e7a282f..02b3f22d1e0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunction.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunction.java @@ -17,11 +17,11 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunction.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunction.java index f7eb514afb7..cac84ce45c7 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunction.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunction.java @@ -17,11 +17,11 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/package-info.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/package-info.java index 9b252a2f1a2..dfc07e1508a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/technicaldebt/functions/package-info.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/functions/package-info.java @@ -18,6 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @ParametersAreNonnullByDefault -package org.sonar.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/package-info.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/package-info.java new file mode 100644 index 00000000000..268f4dbbc54 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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. + */ +@ParametersAreNonnullByDefault +package org.sonar.core.technicaldebt; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModelTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelTest.java index c6222bbdd6d..8384153bb8a 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtModelTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtModelTest.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.junit.Test; import org.sonar.api.qualitymodel.Characteristic; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirementTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtRequirementTest.java index 1eeabeaf274..1cf6f740e25 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/TechnicalDebtRequirementTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/TechnicalDebtRequirementTest.java @@ -17,14 +17,14 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.junit.Test; import org.sonar.api.qualitymodel.Characteristic; -import org.sonar.plugins.core.technicaldebt.functions.ConstantFunction; -import org.sonar.plugins.core.technicaldebt.functions.LinearFunction; -import org.sonar.plugins.core.technicaldebt.functions.LinearWithOffsetFunction; -import org.sonar.plugins.core.technicaldebt.functions.LinearWithThresholdFunction; +import org.sonar.core.technicaldebt.functions.ConstantFunction; +import org.sonar.core.technicaldebt.functions.LinearFunction; +import org.sonar.core.technicaldebt.functions.LinearWithOffsetFunction; +import org.sonar.core.technicaldebt.functions.LinearWithThresholdFunction; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/WorkUnitConverterTest.java index f3303db78e2..9f5473dfa91 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/WorkUnitConverterTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/WorkUnitConverterTest.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt; +package org.sonar.core.technicaldebt; import org.junit.Test; import org.sonar.api.config.Settings; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunctionTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/ConstantFunctionTest.java index 6cb6068af67..2a46394aa21 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/ConstantFunctionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/ConstantFunctionTest.java @@ -17,26 +17,24 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import com.google.common.collect.Lists; +import org.hamcrest.core.Is; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.sonar.api.config.Settings; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnit; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnit; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; import java.util.Collections; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class ConstantFunctionTest { private TechnicalDebtRequirement requirement; @@ -45,13 +43,13 @@ public class ConstantFunctionTest { @Before public void before() { function = new ConstantFunction(new WorkUnitConverter(new Settings())); - requirement = mock(TechnicalDebtRequirement.class); - when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(3.14)); + requirement = Mockito.mock(TechnicalDebtRequirement.class); + Mockito.when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(3.14)); } @Test public void zeroIfNoViolations() { - assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), is(0.0)); + Assert.assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), Is.is(0.0)); } @Test @@ -60,9 +58,9 @@ public class ConstantFunctionTest { Rule rule = Rule.create("checkstyle", "foo", "Foo"); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(3.14)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(3.14)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(3.14)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(3.14)); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/FunctionsTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/FunctionsTest.java index b3f33466bdd..ada1862aa87 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/FunctionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/FunctionsTest.java @@ -17,7 +17,7 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import org.junit.Test; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunctionTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearFunctionTest.java index 3feb12d37a1..6f3e2cb9106 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearFunctionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearFunctionTest.java @@ -17,23 +17,23 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import com.google.common.collect.Lists; +import org.hamcrest.core.Is; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.Settings; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnit; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnit; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; import java.util.Collections; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -50,7 +50,7 @@ public class LinearFunctionTest { @Test public void zeroIfNoViolations() { - assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), is(0.0)); + Assert.assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), Is.is(0.0)); } @Test @@ -59,10 +59,10 @@ public class LinearFunctionTest { Rule rule = Rule.create("checkstyle", "foo", "Foo"); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(3.14)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(3.14)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(3.14 * 2)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(3.14 * 2)); } @Test @@ -73,6 +73,6 @@ public class LinearFunctionTest { violations.add(new Violation(rule).setCost(20.5)); violations.add(new Violation(rule).setCost(3.8)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(3.14 * (20.5 + 3.8 + 1))); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(3.14 * (20.5 + 3.8 + 1))); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java index 4aff78fe658..0bcaeca8043 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithOffsetFunctionTest.java @@ -17,26 +17,24 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import com.google.common.collect.Lists; +import org.hamcrest.core.Is; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.sonar.api.config.Settings; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnit; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnit; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; import java.util.Collections; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class LinearWithOffsetFunctionTest { private TechnicalDebtRequirement requirement; @@ -44,14 +42,14 @@ public class LinearWithOffsetFunctionTest { @Before public void before() { - requirement = mock(TechnicalDebtRequirement.class); - when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(3.14)); - when(requirement.getOffset()).thenReturn(WorkUnit.createInDays(2.12)); + requirement = Mockito.mock(TechnicalDebtRequirement.class); + Mockito.when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(3.14)); + Mockito.when(requirement.getOffset()).thenReturn(WorkUnit.createInDays(2.12)); } @Test public void zeroIfNoViolations() { - assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), is(0.0)); + Assert.assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), Is.is(0.0)); } @Test @@ -60,9 +58,9 @@ public class LinearWithOffsetFunctionTest { Rule rule = Rule.create("checkstyle", "foo", "Foo"); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(2.12 + 3.14)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(2.12 + 3.14)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(2.12 + 3.14 * 2)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(2.12 + 3.14 * 2)); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java index 4a6a49d7a40..0248de5072f 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/technicaldebt/functions/LinearWithThresholdFunctionTest.java @@ -17,26 +17,24 @@ * 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.plugins.core.technicaldebt.functions; +package org.sonar.core.technicaldebt.functions; import com.google.common.collect.Lists; +import org.hamcrest.core.Is; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.sonar.api.config.Settings; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -import org.sonar.plugins.core.technicaldebt.TechnicalDebtRequirement; -import org.sonar.plugins.core.technicaldebt.WorkUnit; -import org.sonar.plugins.core.technicaldebt.WorkUnitConverter; +import org.sonar.core.technicaldebt.TechnicalDebtRequirement; +import org.sonar.core.technicaldebt.WorkUnit; +import org.sonar.core.technicaldebt.WorkUnitConverter; import java.util.Collection; import java.util.Collections; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class LinearWithThresholdFunctionTest { private TechnicalDebtRequirement requirement; @@ -44,14 +42,14 @@ public class LinearWithThresholdFunctionTest { @Before public void before() { - requirement = mock(TechnicalDebtRequirement.class); - when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(2.0)); - when(requirement.getOffset()).thenReturn(WorkUnit.createInDays(5.0)); + requirement = Mockito.mock(TechnicalDebtRequirement.class); + Mockito.when(requirement.getRemediationFactor()).thenReturn(WorkUnit.createInDays(2.0)); + Mockito.when(requirement.getOffset()).thenReturn(WorkUnit.createInDays(5.0)); } @Test public void zeroIfNoViolations() { - assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), is(0.0)); + Assert.assertThat(function.calculateCost(requirement, Collections.<Violation>emptyList()), Is.is(0.0)); } @Test @@ -60,12 +58,12 @@ public class LinearWithThresholdFunctionTest { Rule rule = Rule.create("checkstyle", "foo", "Foo"); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(5.0)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(5.0)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(5.0)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(5.0)); violations.add(new Violation(rule)); - assertThat(function.calculateCost(requirement, violations), is(6.0)); + Assert.assertThat(function.calculateCost(requirement, violations), Is.is(6.0)); } } |