@@ -146,7 +146,7 @@ public class MeasureRepositoryImpl implements MeasureRepository { | |||
addLocal(component, metric, measure, OverridePolicy.OVERRIDE); | |||
} | |||
private void checkValueTypeConsistency(Metric metric, Measure measure) { | |||
private static void checkValueTypeConsistency(Metric metric, Measure measure) { | |||
checkArgument( | |||
measure.getValueType() == Measure.ValueType.NO_VALUE || measure.getValueType() == metric.getType().getValueType(), | |||
format( |
@@ -52,7 +52,7 @@ public class QualityGateDetailsData { | |||
return details.toString(); | |||
} | |||
private JsonObject toJson(EvaluatedCondition evaluatedCondition) { | |||
private static JsonObject toJson(EvaluatedCondition evaluatedCondition) { | |||
Condition condition = evaluatedCondition.getCondition(); | |||
JsonObject result = new JsonObject(); |
@@ -34,6 +34,7 @@ import org.sonar.server.computation.period.Period; | |||
import org.sonar.server.computation.period.PeriodsHolder; | |||
import static java.util.Objects.requireNonNull; | |||
import static org.sonar.server.computation.measure.Measure.Level.ERROR; | |||
public final class EvaluationResultTextConverterImpl implements EvaluationResultTextConverter { | |||
private static final String VARIATION_METRIC_PREFIX = "new_"; | |||
@@ -91,7 +92,7 @@ public final class EvaluationResultTextConverterImpl implements EvaluationResult | |||
} | |||
private String alertValue(Condition condition, Measure.Level level) { | |||
String value = (level == Measure.Level.ERROR ? condition.getErrorThreshold() : condition.getWarningThreshold()); | |||
String value = level == ERROR ? condition.getErrorThreshold() : condition.getWarningThreshold(); | |||
if (condition.getMetric().getType() == Metric.MetricType.WORK_DUR) { | |||
return formatDuration(value); | |||
} |
@@ -84,8 +84,7 @@ public class QualityGateLoadingStep implements ComputationStep { | |||
Optional<QualityGate> qualityGate = qualityGateService.findById(qualityGateId); | |||
if (qualityGate.isPresent()) { | |||
qualityGateHolder.setQualityGate(qualityGate.get()); | |||
} | |||
else { | |||
} else { | |||
qualityGateHolder.setNoQualityGate(); | |||
} | |||
} catch (NumberFormatException e) { |
@@ -19,13 +19,12 @@ | |||
*/ | |||
package org.sonar.server.platform; | |||
import com.google.common.collect.Lists; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Properties; | |||
import javax.annotation.CheckForNull; | |||
import javax.servlet.ServletContext; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
@@ -40,8 +39,6 @@ import org.sonar.server.platform.platformlevel.PlatformLevel4; | |||
import org.sonar.server.platform.platformlevel.PlatformLevelSafeMode; | |||
import org.sonar.server.platform.platformlevel.PlatformLevelStartup; | |||
import com.google.common.collect.Lists; | |||
/** | |||
* @since 2.2 | |||
*/ | |||
@@ -53,7 +50,11 @@ public class Platform { | |||
private Properties properties; | |||
private ServletContext servletContext; | |||
private PlatformLevel level1, level2, levelSafeMode, level3, level4; | |||
private PlatformLevel level1; | |||
private PlatformLevel level2; | |||
private PlatformLevel levelSafeMode; | |||
private PlatformLevel level3; | |||
private PlatformLevel level4; | |||
private PlatformLevel currentLevel; | |||
private boolean dbConnected = false; | |||
private boolean started = false; |
@@ -26,7 +26,6 @@ import com.google.common.collect.Sets; | |||
import java.util.Set; | |||
import org.junit.Test; | |||
import org.picocontainer.ComponentAdapter; | |||
import org.reflections.Reflections; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.server.computation.ReportQueue; | |||
import org.sonar.server.computation.step.ComputationStep; | |||
@@ -59,7 +58,7 @@ public class ComputeEngineContainerImplTest { | |||
public void all_steps_from_package_step_are_present_in_container() { | |||
ComputeEngineContainerImpl ceContainer = new ComputeEngineContainerImpl(new ComponentContainer(), mock(ReportQueue.Item.class)); | |||
Set<String> stepsCanonicalNames = retrieveStepPackageStepsCanonicalNames(); | |||
Set<String> stepsCanonicalNames = StepsExplorer.retrieveStepPackageStepsCanonicalNames(); | |||
Set<String> typesInContainer = Sets.newHashSet( | |||
Iterables.transform( | |||
@@ -68,7 +67,7 @@ public class ComputeEngineContainerImplTest { | |||
ceContainer.getPicoContainer().getComponentAdapters(), | |||
ComponentAdapterToImplementationClass.INSTANCE), | |||
IsComputationStep.INSTANCE), | |||
ClassToCanonicalName.INSTANCE)); | |||
StepsExplorer.ClassToCanonicalName.INSTANCE)); | |||
assertThat(typesInContainer).isEqualTo(stepsCanonicalNames); | |||
} | |||
@@ -80,24 +79,6 @@ public class ComputeEngineContainerImplTest { | |||
assertThat(new ComputeEngineContainerImpl(new ComponentContainer(), item).getItem()).isSameAs(item); | |||
} | |||
/** | |||
* Compute set of canonical names of classes implementing ComputationStep in package step using reflection. | |||
*/ | |||
private Set<String> retrieveStepPackageStepsCanonicalNames() { | |||
Reflections reflections = new Reflections("org.sonar.server.computation.step"); | |||
return Sets.newHashSet(Iterables.transform(reflections.getSubTypesOf(ComputationStep.class), ClassToCanonicalName.INSTANCE)); | |||
} | |||
private enum ClassToCanonicalName implements Function<Class<?>, String> { | |||
INSTANCE; | |||
@Override | |||
public String apply(Class<?> input) { | |||
return input.getCanonicalName(); | |||
} | |||
} | |||
private enum ComponentAdapterToImplementationClass implements Function<ComponentAdapter<?>, Class<?>> { | |||
INSTANCE; | |||
@@ -0,0 +1,47 @@ | |||
/* | |||
* 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.computation.container; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Sets; | |||
import java.util.Set; | |||
import org.reflections.Reflections; | |||
import org.sonar.server.computation.step.ComputationStep; | |||
public class StepsExplorer { | |||
/** | |||
* Compute set of canonical names of classes implementing ComputationStep in package step using reflection. | |||
*/ | |||
static Set<String> retrieveStepPackageStepsCanonicalNames() { | |||
Reflections reflections = new Reflections("org.sonar.server.computation.step"); | |||
return Sets.newHashSet(Iterables.transform(reflections.getSubTypesOf(ComputationStep.class), ClassToCanonicalName.INSTANCE)); | |||
} | |||
enum ClassToCanonicalName implements Function<Class<?>, String> { | |||
INSTANCE; | |||
@Override | |||
public String apply(Class<?> input) { | |||
return input.getCanonicalName(); | |||
} | |||
} | |||
} |
@@ -38,6 +38,7 @@ import org.sonar.api.database.DatabaseProperties; | |||
import org.sonar.api.resources.Language; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.process.ProcessProperties; | |||
import org.sonar.server.es.EsServerHolder; | |||
import org.sonar.server.platform.BackendCleanup; | |||
@@ -234,6 +235,10 @@ public class ServerTester extends ExternalResource { | |||
return platform.getContainer().getComponentByType(component); | |||
} | |||
public ComponentContainer getContainer() { | |||
return platform.getContainer(); | |||
} | |||
public WsTester wsTester() { | |||
return get(WsTester.class); | |||
} |