@@ -28,7 +28,7 @@ import javax.annotation.concurrent.Immutable; | |||
* File element in the dump report. | |||
*/ | |||
@Immutable | |||
public class DumpElement<MSG extends Message> { | |||
public class DumpElement<M extends Message> { | |||
public static final long NO_DATETIME = 0; | |||
public static final DumpElement<ProjectDump.Metadata> METADATA = new DumpElement<>("metadata.pb", ProjectDump.Metadata.parser()); | |||
@@ -50,9 +50,9 @@ public class DumpElement<MSG extends Message> { | |||
public static final DumpElement<ProjectDump.NewCodePeriod> NEW_CODE_PERIODS = new DumpElement<>("new_code_periods.pb", ProjectDump.NewCodePeriod.parser()); | |||
private final String filename; | |||
private final Parser<MSG> parser; | |||
private final Parser<M> parser; | |||
private DumpElement(String filename, Parser<MSG> parser) { | |||
private DumpElement(String filename, Parser<M> parser) { | |||
this.filename = filename; | |||
this.parser = parser; | |||
} | |||
@@ -61,14 +61,14 @@ public class DumpElement<MSG extends Message> { | |||
return filename; | |||
} | |||
public Parser<MSG> parser() { | |||
public Parser<M> parser() { | |||
return parser; | |||
} | |||
public static class IssueDumpElement extends DumpElement<ProjectDump.Issue> { | |||
public final int NO_LINE = 0; | |||
public final double NO_GAP = -1; | |||
public final long NO_EFFORT = -1; | |||
public static final int NO_LINE = 0; | |||
public static final double NO_GAP = -1; | |||
public static final long NO_EFFORT = -1; | |||
public IssueDumpElement() { | |||
super("issues.pb", ProjectDump.Issue.parser()); |
@@ -69,7 +69,7 @@ public class DumpWriterImpl implements DumpWriter { | |||
} | |||
@Override | |||
public <MSG extends Message> StreamWriter<MSG> newStreamWriter(DumpElement<MSG> elt) { | |||
public <M extends Message> StreamWriter<M> newStreamWriter(DumpElement<M> elt) { | |||
checkNotPublished(); | |||
File file = new File(rootDir, elt.filename()); | |||
return StreamWriterImpl.create(file); |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.ce.task.projectexport.steps; | |||
import com.google.common.collect.ImmutableSet; | |||
import com.sonarsource.governance.projectdump.protobuf.ProjectDump; | |||
import java.util.List; | |||
import java.util.Set; | |||
@@ -41,7 +40,7 @@ public class ExportSettingsStep implements ComputationStep { | |||
* These properties are not exported as values depend on environment data that are not | |||
* exported within the dump (Quality Gate, users). | |||
*/ | |||
private static final Set<String> IGNORED_KEYS = ImmutableSet.of("sonar.issues.defaultAssigneeLogin"); | |||
private static final Set<String> IGNORED_KEYS = Set.of("sonar.issues.defaultAssigneeLogin"); | |||
private final DbClient dbClient; | |||
private final ProjectHolder projectHolder; |
@@ -78,7 +78,7 @@ public class MutableDumpReaderImpl implements MutableDumpReader { | |||
} | |||
@Override | |||
public <MSG extends Message> MessageStream<MSG> stream(DumpElement<MSG> elt) { | |||
public <M extends Message> MessageStream<M> stream(DumpElement<M> elt) { | |||
File file = new File(tempRootDir(), elt.filename()); | |||
checkState(file.exists(), "Missing file: %s", file); | |||
@@ -52,7 +52,7 @@ public class Protobuf2 { | |||
return this; | |||
} | |||
public <MSG extends Message> MSG parseFrom(Parser<MSG> parser, InputStream input) { | |||
public <M extends Message> M parseFrom(Parser<M> parser, InputStream input) { | |||
try { | |||
return parser.parseFrom(input); | |||
} catch (InvalidProtocolBufferException e) { | |||
@@ -61,7 +61,7 @@ public class Protobuf2 { | |||
} | |||
@CheckForNull | |||
public <MSG extends Message> MSG parseDelimitedFrom(Parser<MSG> parser, InputStream input) { | |||
public <M extends Message> M parseDelimitedFrom(Parser<M> parser, InputStream input) { | |||
try { | |||
return parser.parseDelimitedFrom(input); | |||
} catch (InvalidProtocolBufferException e) { |
@@ -168,9 +168,4 @@ public class ExportComponentsStepTest { | |||
assertThat(underTest.getDescription()).isEqualTo("Export components"); | |||
} | |||
@Test | |||
public void name() { | |||
System.err.println(new Date(1313272860000L)); | |||
} | |||
} |
@@ -197,7 +197,7 @@ public class ExportIssuesChangelogStepTest { | |||
underTest.execute(new TestComputationStepContext()); | |||
ProjectDump.IssueChange issueChange = getSingleMessage(); | |||
assertThat(issueChange.getCreatedAt()).isEqualTo(0L); | |||
assertThat(issueChange.getCreatedAt()).isZero(); | |||
} | |||
@Test |
@@ -64,7 +64,7 @@ public class RuleTest { | |||
@Test | |||
public void hashcode_is_based_on_repository_and_key() { | |||
assertThat(underTest.hashCode()).isEqualTo(new Rule(SOME_DUMP_UUID, SOME_REPOSITORY, SOME_KEY).hashCode()); | |||
assertThat(underTest).hasSameHashCodeAs(new Rule(SOME_DUMP_UUID, SOME_REPOSITORY, SOME_KEY)); | |||
assertThat(underTest.hashCode()).isNotEqualTo(new Rule(SOME_DUMP_UUID, SOME_KEY, SOME_REPOSITORY).hashCode()); | |||
assertThat(underTest.hashCode()).isNotEqualTo(new Rule(SOME_DUMP_UUID, "other repository", SOME_KEY).hashCode()); | |||
assertThat(underTest.hashCode()).isNotEqualTo(new Rule(SOME_DUMP_UUID, SOME_REPOSITORY, "other key").hashCode()); | |||
@@ -72,12 +72,12 @@ public class RuleTest { | |||
@Test | |||
public void hashcode_ignores_dump_id() { | |||
assertThat(underTest.hashCode()).isEqualTo(new Rule("uuid-8888", SOME_REPOSITORY, SOME_KEY).hashCode()); | |||
assertThat(underTest).hasSameHashCodeAs(new Rule("uuid-8888", SOME_REPOSITORY, SOME_KEY)); | |||
} | |||
@Test | |||
public void toString_displays_all_fields() { | |||
assertThat(underTest.toString()).isEqualTo("Rule{ref='uuid-12334', repository='some repository', key='some key'}"); | |||
assertThat(underTest).hasToString("Rule{ref='uuid-12334', repository='some repository', key='some key'}"); | |||
} | |||
} |
@@ -89,7 +89,7 @@ public class ExportLiveMeasuresStepTest { | |||
.extracting(ProjectDump.LiveMeasure::getMetricRef, m -> m.getDoubleValue().getValue(), ProjectDump.LiveMeasure::hasVariation) | |||
.containsOnly(tuple(0, 4711.0d, false)); | |||
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported"); | |||
assertThat(metricRepository.getRefByUuid().keySet()).containsOnly(metric.getUuid()); | |||
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid()); | |||
} | |||
@Test | |||
@@ -161,7 +161,7 @@ public class ExportLiveMeasuresStepTest { | |||
"test", | |||
7.0d)); | |||
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported"); | |||
assertThat(metricRepository.getRefByUuid().keySet()).containsOnly(metric.getUuid()); | |||
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid()); | |||
} | |||
@Test | |||
@@ -191,7 +191,7 @@ public class ExportLiveMeasuresStepTest { | |||
"", | |||
false)); | |||
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported"); | |||
assertThat(metricRepository.getRefByUuid().keySet()).containsOnly(metric.getUuid()); | |||
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid()); | |||
} | |||
@Test |
@@ -142,7 +142,7 @@ public class ExportMeasuresStepTest { | |||
assertThat(exportedMeasures).extracting(ProjectDump.Measure::getAnalysisUuid).containsOnly(firstAnalysis.getUuid(), secondAnalysis.getUuid()); | |||
assertThat(exportedMeasures).extracting(ProjectDump.Measure::getMetricRef).containsOnly(0); | |||
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 measures exported"); | |||
assertThat(metricRepository.getRefByUuid().keySet()).containsOnly(NCLOC.getUuid()); | |||
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(NCLOC.getUuid()); | |||
} | |||
@Test |