* 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());
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;
}
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());
}
@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);
*/
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;
* 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;
}
@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);
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) {
}
@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) {
assertThat(underTest.getDescription()).isEqualTo("Export components");
}
- @Test
- public void name() {
- System.err.println(new Date(1313272860000L));
-
- }
}
underTest.execute(new TestComputationStepContext());
ProjectDump.IssueChange issueChange = getSingleMessage();
- assertThat(issueChange.getCreatedAt()).isEqualTo(0L);
+ assertThat(issueChange.getCreatedAt()).isZero();
}
@Test
@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());
@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'}");
}
}
.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
"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
"",
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
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