case LEVEL:
return toLevelMeasure(builder, batchMeasure);
case NO_VALUE:
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
default:
throw new IllegalArgumentException("Unsupported Measure.ValueType " + metric.getType().getValueType());
}
private static Optional<Measure> toIntegerMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
return of(builder.create(batchMeasure.getIntValue().getValue(), trimToNull(batchMeasure.getIntValue().getData())));
}
private static Optional<Measure> toLongMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
return of(builder.create(batchMeasure.getLongValue().getValue(), trimToNull(batchMeasure.getLongValue().getData())));
}
private static Optional<Measure> toDoubleMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
return of(builder.create(batchMeasure.getDoubleValue().getValue(),
// Decimals are not truncated in scanner report, so an arbitrary decimal scale is applied when reading values from report
private static Optional<Measure> toBooleanMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
return of(builder.create(batchMeasure.getBooleanValue().getValue(), trimToNull(batchMeasure.getBooleanValue().getData())));
}
private static Optional<Measure> toStringMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
return of(builder.create(batchMeasure.getStringValue().getValue()));
}
private static Optional<Measure> toLevelMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
if (batchMeasure.getValueCase() == ValueCase.VALUE_NOT_SET) {
- return toNoValueMeasure(builder, batchMeasure);
+ return toNoValueMeasure(builder);
}
Optional<Measure.Level> level = Measure.Level.toLevel(batchMeasure.getStringValue().getValue());
- if (!level.isPresent()) {
- return toNoValueMeasure(builder, batchMeasure);
+ if (level.isEmpty()) {
+ return toNoValueMeasure(builder);
}
return of(builder.create(level.get()));
}
- private static Optional<Measure> toNoValueMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) {
+ private static Optional<Measure> toNoValueMeasure(Measure.NewMeasureBuilder builder) {
return of(builder.createNoValue());
}
}
import java.util.Optional;
import java.util.stream.Collectors;
import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.System2;
-import org.sonar.ce.task.log.CeTaskMessages;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.component.ComponentVisitor;
import static org.sonar.core.component.ComponentKeys.isValidProjectKey;
public class ValidateProjectStep implements ComputationStep {
-
private static final Joiner MESSAGES_JOINER = Joiner.on("\n o ");
private final DbClient dbClient;
private final TreeRootHolder treeRootHolder;
private final AnalysisMetadataHolder analysisMetadataHolder;
- public ValidateProjectStep(DbClient dbClient, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder, CeTaskMessages taskMessages, System2 system2) {
+ public ValidateProjectStep(DbClient dbClient, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder) {
this.dbClient = dbClient;
this.treeRootHolder = treeRootHolder;
this.analysisMetadataHolder = analysisMetadataHolder;
return Optional.of(baseComponent);
}
}
-
}
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.impl.utils.TestSystem2;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import static org.mockito.Mockito.when;
public class ValidateProjectStepTest {
-
static long PAST_ANALYSIS_TIME = 1_420_088_400_000L; // 2015-01-01
static long DEFAULT_ANALYSIS_TIME = 1_433_131_200_000L; // 2015-06-01
- static long NOW = 1_500_000_000_000L;
static final String PROJECT_KEY = "PROJECT_KEY";
static final Branch DEFAULT_BRANCH = new DefaultBranchImpl();
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
.setAnalysisDate(new Date(DEFAULT_ANALYSIS_TIME))
.setBranch(DEFAULT_BRANCH);
- private final System2 system2 = new TestSystem2().setNow(NOW);
private final CeTaskMessages taskMessages = mock(CeTaskMessages.class);
private final DbClient dbClient = db.getDbClient();
- private final ValidateProjectStep underTest = new ValidateProjectStep(dbClient, treeRootHolder, analysisMetadataHolder, taskMessages, system2);
+ private final ValidateProjectStep underTest = new ValidateProjectStep(dbClient, treeRootHolder, analysisMetadataHolder);
@Test
public void dont_fail_for_long_forked_from_master_with_modules() {
@ComputeEngineSide
@ServerSide
public class ServerImpl extends Server {
-
private final Configuration config;
private final StartupMetadata state;
- private final ServerFileSystem fs;
private final UrlSettings urlSettings;
private final SonarRuntime runtime;
- public ServerImpl(Configuration config, StartupMetadata state, ServerFileSystem fs, UrlSettings urlSettings, SonarRuntime runtime) {
+ public ServerImpl(Configuration config, StartupMetadata state, UrlSettings urlSettings, SonarRuntime runtime) {
this.config = config;
this.state = state;
- this.fs = fs;
this.urlSettings = urlSettings;
this.runtime = runtime;
}
public boolean isSecured() {
return urlSettings.isSecured();
}
-
}
import static org.sonar.server.user.index.UserIndexDefinition.TYPE_USER;
public class UserIndexer implements ResilientIndexer {
-
private final DbClient dbClient;
private final EsClient esClient;
dbClient.esQueueDao().insert(dbSession, items);
dbSession.commit();
- postCommit(dbSession, users.stream().map(UserDto::getLogin).collect(toList()), items);
+ postCommit(dbSession, items);
}
- /**
- * Entry point for Byteman tests. See directory tests/resilience.
- * The parameter "logins" is used only by the Byteman script.
- */
- private void postCommit(DbSession dbSession, Collection<String> logins, Collection<EsQueueDto> items) {
+ private void postCommit(DbSession dbSession, Collection<EsQueueDto> items) {
index(dbSession, items);
}
*/
package org.sonar.server.platform;
-import java.io.File;
-import java.io.IOException;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
import org.sonar.api.SonarRuntime;
import org.sonar.api.config.internal.MapSettings;
import static org.mockito.Mockito.when;
public class ServerImplTest {
-
private MapSettings settings = new MapSettings();
private StartupMetadata state = mock(StartupMetadata.class);
- private ServerFileSystem fs = mock(ServerFileSystem.class);
private UrlSettings urlSettings = mock(UrlSettings.class);
private SonarRuntime runtime = mock(SonarRuntime.class);
- private ServerImpl underTest = new ServerImpl(settings.asConfig(), state, fs, urlSettings, runtime);
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
+ private ServerImpl underTest = new ServerImpl(settings.asConfig(), state, urlSettings, runtime);
@Test
public void test_url_information() {
assertThat(underTest.isSecured()).isFalse();
}
- @Test
- public void test_file_system_information() throws IOException {
- File home = temp.newFolder();
- when(fs.getHomeDir()).thenReturn(home);
- }
-
@Test
public void test_startup_information() {
long time = 123_456_789L;