@@ -54,7 +54,7 @@ public class GsonEmailTest { | |||
@Test | |||
public void should_have_no_arg_constructor() { | |||
assertThat(new GsonEmail().getEmail()).isEqualTo(""); | |||
assertThat(new GsonEmail().getEmail()).isEmpty(); | |||
} | |||
} |
@@ -67,8 +67,8 @@ public class GsonTeamTest { | |||
@Test | |||
public void should_have_no_arg_constructor() { | |||
assertThat(new GsonTeam().getId()).isEqualTo(""); | |||
assertThat(new GsonTeam.GsonOrganization().getLogin()).isEqualTo(""); | |||
assertThat(new GsonTeam().getId()).isEmpty(); | |||
assertThat(new GsonTeam.GsonOrganization().getLogin()).isEmpty(); | |||
} | |||
} |
@@ -63,7 +63,7 @@ public class LdapAutodiscoveryTest { | |||
assertThat(new LdapSrvRecord("http://foo:389", 1, 1)).isEqualTo(new LdapSrvRecord("http://foo:389", 2, 0)); | |||
assertThat(new LdapSrvRecord("http://foo:389", 1, 1)).isNotEqualTo(new LdapSrvRecord("http://foo:388", 1, 1)); | |||
assertThat(new LdapSrvRecord("http://foo:389", 1, 1).hashCode()).isEqualTo(new LdapSrvRecord("http://foo:389", 1, 1).hashCode()); | |||
assertThat(new LdapSrvRecord("http://foo:389", 1, 1)).hasSameHashCodeAs(new LdapSrvRecord("http://foo:389", 1, 1).hashCode()); | |||
} | |||
@Test | |||
@@ -74,7 +74,7 @@ public class LdapAutodiscoveryTest { | |||
NamingEnumeration namingEnumeration = mock(NamingEnumeration.class); | |||
when(context.getAttributes(Mockito.anyString(), Mockito.anyObject())).thenReturn(attributes); | |||
when(attributes.get(Mockito.eq("srv"))).thenReturn(attribute); | |||
when(attributes.get("srv")).thenReturn(attribute); | |||
when(attribute.getAll()).thenReturn(namingEnumeration); | |||
when(namingEnumeration.hasMore()).thenReturn(true, true, true, true, true, false); | |||
when(namingEnumeration.next()) |
@@ -35,7 +35,7 @@ public class LdapGroupMappingTest { | |||
assertThat(groupMapping.getRequest()).isEqualTo("(&(objectClass=groupOfUniqueNames)(uniqueMember={0}))"); | |||
assertThat(groupMapping.getRequiredUserAttributes()).isEqualTo(new String[] {"dn"}); | |||
assertThat(groupMapping.toString()).isEqualTo("LdapGroupMapping{" + | |||
assertThat(groupMapping).hasToString("LdapGroupMapping{" + | |||
"baseDn=null," + | |||
" idAttribute=cn," + | |||
" requiredUserAttributes=[dn]," + |
@@ -126,8 +126,8 @@ public class DuplicationMeasures { | |||
blocks++; | |||
addLines(duplication.getOriginal(), duplicatedLineNumbers); | |||
InnerDuplicate[] innerDuplicates = Arrays.stream(duplication.getDuplicates()) | |||
.filter(x -> x instanceof InnerDuplicate) | |||
.map(d -> (InnerDuplicate) d) | |||
.filter(InnerDuplicate.class::isInstance) | |||
.map(InnerDuplicate.class::cast) | |||
.toArray(InnerDuplicate[]::new); | |||
for (InnerDuplicate innerDuplicate : innerDuplicates) { |
@@ -49,7 +49,7 @@ public class AverageFormula implements Formula<AverageFormula.AverageCounter> { | |||
if (mainValueOptional.isPresent() && byValueOptional.isPresent()) { | |||
double mainValue = mainValueOptional.get(); | |||
double byValue = byValueOptional.get(); | |||
if (byValue > 0d) { | |||
if (byValue > 0D) { | |||
return Optional.of(Measure.newMeasureBuilder().create(mainValue / byValue, context.getMetric().getDecimalScale())); | |||
} | |||
} | |||
@@ -101,8 +101,8 @@ public class AverageFormula implements Formula<AverageFormula.AverageCounter> { | |||
private boolean initialized = false; | |||
private double mainValue = 0d; | |||
private double byValue = 0d; | |||
private double mainValue = 0D; | |||
private double byValue = 0D; | |||
@Override | |||
public void aggregate(AverageCounter counter) { |
@@ -50,7 +50,7 @@ public final class CoverageUtils { | |||
static double getMeasureVariations(CounterInitializationContext counterContext, String metricKey) { | |||
Optional<Measure> measure = counterContext.getMeasure(metricKey); | |||
if (!measure.isPresent() || !measure.get().hasVariation()) { | |||
return 0d; | |||
return 0D; | |||
} | |||
return measure.get().getVariation(); | |||
} |
@@ -149,7 +149,7 @@ public class NewEffortAggregator extends IssueVisitor { | |||
private boolean isEmpty = true; | |||
void add(long newEffort) { | |||
double previous = MoreObjects.firstNonNull(this.newEffort, 0d); | |||
double previous = MoreObjects.firstNonNull(this.newEffort, 0D); | |||
this.newEffort = previous + newEffort; | |||
isEmpty = false; | |||
} |
@@ -67,7 +67,7 @@ public class BestValueOptimization implements Predicate<Measure> { | |||
} | |||
private static boolean isVariationEmptyOrBestValue(double variation, Double bestValue) { | |||
return compare(variation, 0d) == 0 || compare(variation, bestValue) == 0; | |||
return compare(variation, 0D) == 0 || compare(variation, bestValue) == 0; | |||
} | |||
private static boolean isBestValue(Measure measure, Double bestValue) { |
@@ -470,7 +470,7 @@ public interface Measure { | |||
} | |||
public Measure create(long value, @Nullable String data) { | |||
return createInternal(ValueType.LONG, (double) value, data); | |||
return createInternal(ValueType.LONG, value, data); | |||
} | |||
public Measure create(long value) { |
@@ -96,7 +96,7 @@ public class MeasureToMeasureDto { | |||
private static Double valueAsDouble(Measure measure) { | |||
switch (measure.getValueType()) { | |||
case BOOLEAN: | |||
return measure.getBooleanValue() ? 1.0d : 0.0d; | |||
return measure.getBooleanValue() ? 1.0D : 0.0D; | |||
case INT: | |||
return (double) measure.getIntValue(); | |||
case LONG: |
@@ -87,7 +87,7 @@ public class DuplicationLineReader implements LineReader { | |||
for (Duplication duplication : duplications) { | |||
duplicatedBlock.add(duplication.getOriginal()); | |||
Arrays.stream(duplication.getDuplicates()) | |||
.filter(d -> d instanceof InnerDuplicate) | |||
.filter(InnerDuplicate.class::isInstance) | |||
.forEach(duplicate -> duplicatedBlock.add(duplicate.getTextBlock())); | |||
} | |||
return duplicatedBlock; |
@@ -43,8 +43,6 @@ public class HighlightingLineReader implements LineReader { | |||
private static final Logger LOG = Loggers.get(HighlightingLineReader.class); | |||
private ReadError readError = null; | |||
private static final Map<HighlightingType, String> cssClassByType = ImmutableMap.<HighlightingType, String>builder() | |||
.put(HighlightingType.ANNOTATION, "a") | |||
.put(HighlightingType.CONSTANT, "c") | |||
@@ -60,7 +58,7 @@ public class HighlightingLineReader implements LineReader { | |||
private final Iterator<ScannerReport.SyntaxHighlightingRule> lineHighlightingIterator; | |||
private final RangeOffsetConverter rangeOffsetConverter; | |||
private final List<ScannerReport.SyntaxHighlightingRule> highlightingList; | |||
private ReadError readError = null; | |||
private ScannerReport.SyntaxHighlightingRule currentItem; | |||
public HighlightingLineReader(Component file, Iterator<ScannerReport.SyntaxHighlightingRule> lineHighlightingIterator, RangeOffsetConverter rangeOffsetConverter) { |
@@ -40,6 +40,11 @@ import org.sonar.scanner.protocol.output.ScannerReport.ComponentLink.ComponentLi | |||
import static com.google.common.base.Preconditions.checkArgument; | |||
public class PersistProjectLinksStep implements ComputationStep { | |||
private static final Map<ComponentLinkType, String> typesConverter = ImmutableMap.of( | |||
ComponentLinkType.HOME, ProjectLinkDto.TYPE_HOME_PAGE, | |||
ComponentLinkType.SCM, ProjectLinkDto.TYPE_SOURCES, | |||
ComponentLinkType.CI, ProjectLinkDto.TYPE_CI, | |||
ComponentLinkType.ISSUE, ProjectLinkDto.TYPE_ISSUE_TRACKER); | |||
private final AnalysisMetadataHolder analysisMetadataHolder; | |||
private final DbClient dbClient; | |||
@@ -47,12 +52,6 @@ public class PersistProjectLinksStep implements ComputationStep { | |||
private final BatchReportReader reportReader; | |||
private final UuidFactory uuidFactory; | |||
private static final Map<ComponentLinkType, String> typesConverter = ImmutableMap.of( | |||
ComponentLinkType.HOME, ProjectLinkDto.TYPE_HOME_PAGE, | |||
ComponentLinkType.SCM, ProjectLinkDto.TYPE_SOURCES, | |||
ComponentLinkType.CI, ProjectLinkDto.TYPE_CI, | |||
ComponentLinkType.ISSUE, ProjectLinkDto.TYPE_ISSUE_TRACKER); | |||
public PersistProjectLinksStep(AnalysisMetadataHolder analysisMetadataHolder, DbClient dbClient, TreeRootHolder treeRootHolder, | |||
BatchReportReader reportReader, UuidFactory uuidFactory) { | |||
this.analysisMetadataHolder = analysisMetadataHolder; |
@@ -399,7 +399,7 @@ public class MeasureRepositoryImplTest { | |||
Map<String, Measure> rawMeasures = underTest.getRawMeasures(FILE_COMPONENT); | |||
assertThat(rawMeasures.keySet()).hasSize(2); | |||
assertThat(rawMeasures.get(METRIC_KEY_1)).isEqualTo(addedMeasure); | |||
assertThat(rawMeasures).containsEntry(METRIC_KEY_1, addedMeasure); | |||
assertThat(rawMeasures.get(METRIC_KEY_2)).extracting(Measure::getStringValue).isEqualTo("some value"); | |||
} | |||
@@ -87,8 +87,8 @@ public class MetricImplTest { | |||
@Test | |||
public void all_fields_are_displayed_in_toString() { | |||
assertThat(new MetricImpl(SOME_UUID, SOME_KEY, SOME_NAME, Metric.MetricType.FLOAT, 1, 951d, true, false).toString()) | |||
.isEqualTo("MetricImpl{uuid=uuid, key=key, name=name, type=FLOAT, bestValue=951.0, bestValueOptimized=true, deleteHistoricalData=false}"); | |||
assertThat(new MetricImpl(SOME_UUID, SOME_KEY, SOME_NAME, Metric.MetricType.FLOAT, 1, 951d, true, false)) | |||
.hasToString("MetricImpl{uuid=uuid, key=key, name=name, type=FLOAT, bestValue=951.0, bestValueOptimized=true, deleteHistoricalData=false}"); | |||
} | |||
} |
@@ -32,7 +32,6 @@ import org.sonar.server.es.EsTester; | |||
import org.sonar.server.issue.index.IssueIndexer; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.ArgumentMatchers.eq; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.times; | |||
import static org.mockito.Mockito.verify; | |||
@@ -81,7 +80,7 @@ public class IndexIssuesStepTest { | |||
underTest.execute(() -> null); | |||
verify(issueIndexer, times(1)).indexOnAnalysis(eq(BRANCH_UUID)); | |||
verify(issueIndexer, times(1)).indexOnAnalysis(BRANCH_UUID); | |||
Optional<BranchDto> branch = dbClient.branchDao().selectByUuid(dbTester.getSession(), BRANCH_UUID); | |||
assertThat(branch.get().isNeedIssueSync()).isFalse(); | |||
} | |||
@@ -99,7 +98,7 @@ public class IndexIssuesStepTest { | |||
underTest.execute(() -> null); | |||
verify(issueIndexer, times(0)).indexOnAnalysis(eq(BRANCH_UUID)); | |||
verify(issueIndexer, times(0)).indexOnAnalysis(BRANCH_UUID); | |||
} | |||
@Test |
@@ -182,7 +182,7 @@ public class AlmSettingDaoTest { | |||
underTest.delete(dbSession, almSettingDto); | |||
assertThat(underTest.selectByKey(dbSession, almSettingDto.getKey()).isPresent()).isFalse(); | |||
assertThat(underTest.selectByKey(dbSession, almSettingDto.getKey())).isNotPresent(); | |||
} | |||
} |
@@ -104,7 +104,7 @@ public class SnapshotDaoTest { | |||
assertThat(result.getCreatedAt()).isEqualTo(1403042400000L); | |||
assertThat(result.getRevision()).isEqualTo("sha1"); | |||
assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse(); | |||
assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST")).isNotPresent(); | |||
} | |||
@Test |
@@ -33,7 +33,6 @@ import org.sonar.db.purge.PurgeProfiler; | |||
import org.sonar.db.purge.PurgeableAnalysisDto; | |||
import static org.mockito.ArgumentMatchers.anyList; | |||
import static org.mockito.ArgumentMatchers.eq; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.times; | |||
import static org.mockito.Mockito.when; | |||
@@ -57,9 +56,9 @@ public class DefaultPeriodCleanerTest { | |||
InOrder inOrder = Mockito.inOrder(dao, filter1, filter2); | |||
inOrder.verify(filter1).log(); | |||
inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of("u999"))); | |||
inOrder.verify(dao, times(1)).deleteAnalyses(session, profiler, ImmutableList.of("u999")); | |||
inOrder.verify(filter2).log(); | |||
inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of("u456"))); | |||
inOrder.verify(dao, times(1)).deleteAnalyses(session, profiler, ImmutableList.of("u456")); | |||
inOrder.verifyNoMoreInteractions(); | |||
} | |||
@@ -102,7 +102,7 @@ public class RuleDaoTest { | |||
assertThat(underTest.selectDefinitionByKey(db.getSession(), RuleKey.of("NOT", "FOUND")).isPresent()).isFalse(); | |||
Optional<RuleDefinitionDto> reloaded = underTest.selectDefinitionByKey(db.getSession(), rule.getKey()); | |||
assertThat(reloaded.isPresent()).isTrue(); | |||
assertThat(reloaded).isPresent(); | |||
} | |||
@Test |
@@ -52,7 +52,7 @@ public class SessionTokensDaoTest { | |||
Optional<SessionTokenDto> result = underTest.selectByUuid(dbSession, dto.getUuid()); | |||
assertThat(result.isPresent()); | |||
assertThat(result).isPresent(); | |||
assertThat(result.get().getUserUuid()).isEqualTo("ABCD"); | |||
assertThat(result.get().getExpirationDate()).isEqualTo(15_000_000_000L); | |||
assertThat(result.get().getCreatedAt()).isEqualTo(NOW); | |||
@@ -72,7 +72,7 @@ public class SessionTokensDaoTest { | |||
Optional<SessionTokenDto> result = underTest.selectByUuid(dbSession, dto.getUuid()); | |||
assertThat(result.isPresent()); | |||
assertThat(result).isPresent(); | |||
assertThat(result.get().getUuid()).isNotEqualTo("SHOULD_NOT_BE_USED"); | |||
assertThat(result.get().getCreatedAt()).isEqualTo(NOW); | |||
assertThat(result.get().getUpdatedAt()).isEqualTo(NOW); |
@@ -134,7 +134,7 @@ public class UserTokenDaoTest { | |||
Map<String, Integer> result = underTest.countTokensByUsers(dbSession, singletonList(user)); | |||
assertThat(result.get(user.getUuid())).isEqualTo(2); | |||
assertThat(result).containsEntry(user.getUuid(), 2); | |||
assertThat(result.get("unknown-user_uuid")).isNull(); | |||
} | |||
} |
@@ -92,12 +92,11 @@ import static org.sonar.server.es.EsRequestDetails.computeDetailsAsString; | |||
* with context) and profiling of requests. | |||
*/ | |||
public class EsClient implements Closeable { | |||
public static final Logger LOGGER = Loggers.get("es"); | |||
private static final String ES_USERNAME = "elastic"; | |||
private final RestHighLevelClient restHighLevelClient; | |||
private final Gson gson; | |||
public static final Logger LOGGER = Loggers.get("es"); | |||
public EsClient(HttpHost... hosts) { | |||
this(new MinimalRestHighLevelClient(null, hosts)); | |||
} | |||
@@ -274,6 +273,10 @@ public class EsClient implements Closeable { | |||
super(buildHttpClient(searchPassword, hosts)); | |||
} | |||
MinimalRestHighLevelClient(RestClient restClient) { | |||
super(restClient, RestClient::close, Lists.newArrayList()); | |||
} | |||
@NotNull | |||
private static RestClientBuilder buildHttpClient(@Nullable String searchPassword, | |||
HttpHost[] hosts) { | |||
@@ -296,9 +299,6 @@ public class EsClient implements Closeable { | |||
return provider; | |||
} | |||
MinimalRestHighLevelClient(RestClient restClient) { | |||
super(restClient, RestClient::close, Lists.newArrayList()); | |||
} | |||
} | |||
<R> R execute(EsRequestExecutor<R> executor) { |
@@ -62,7 +62,7 @@ public class DebtRatingGrid { | |||
private static EnumMap<Rating, Bounds> buildRatingBounds(double[] gridValues) { | |||
checkState(gridValues.length == 4, "Rating grid should contains 4 values"); | |||
EnumMap<Rating, Bounds> ratingBounds = new EnumMap<>(Rating.class); | |||
ratingBounds.put(A, new Bounds(0d, gridValues[0])); | |||
ratingBounds.put(A, new Bounds(0D, gridValues[0])); | |||
ratingBounds.put(B, new Bounds(gridValues[0], gridValues[1])); | |||
ratingBounds.put(C, new Bounds(gridValues[1], gridValues[2])); | |||
ratingBounds.put(D, new Bounds(gridValues[2], gridValues[3])); |
@@ -217,7 +217,7 @@ public class RuleIndex { | |||
.stream().map(token -> boolQuery().should( | |||
matchQuery( | |||
SEARCH_GRAMS_ANALYZER.subField(FIELD_RULE_NAME), | |||
StringUtils.left(token, DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH)).boost(20f)) | |||
StringUtils.left(token, DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH)).boost(20F)) | |||
.should( | |||
matchPhraseQuery( | |||
ENGLISH_HTML_ANALYZER.subField(FIELD_RULE_HTML_DESCRIPTION), |
@@ -91,7 +91,7 @@ public class IssueIteratorFactoryTest { | |||
assertThat(issue.directoryPath()).isEqualTo("src/main/java"); | |||
assertThat(issue.filePath()).isEqualTo("src/main/java/Action.java"); | |||
assertThat(issue.getTags()).containsOnly("tag1", "tag2", "tag3"); | |||
assertThat(issue.effort().toMinutes()).isGreaterThan(0L); | |||
assertThat(issue.effort().toMinutes()).isPositive(); | |||
assertThat(issue.type().getDbConstant()).isEqualTo(2); | |||
} | |||
@@ -59,21 +59,20 @@ public class ProjectTest { | |||
Project project1 = new Project("U1", "K1", "N1", null, emptyList()); | |||
Project project2 = new Project("U1", "K1", "N1", "D1", emptyList()); | |||
assertThat(project1).isEqualTo(project1); | |||
assertThat(project1).isNotEqualTo(null); | |||
assertThat(project1).isNotEqualTo(new Object()); | |||
assertThat(project1).isEqualTo(new Project("U1", "K1", "N1", null, emptyList())); | |||
assertThat(project1).isNotEqualTo(new Project("U1", "K2", "N1", null, emptyList())); | |||
assertThat(project1).isNotEqualTo(new Project("U1", "K1", "N2", null, emptyList())); | |||
assertThat(project1).isEqualTo(project2); | |||
assertThat(project1).isEqualTo(project1) | |||
.isNotEqualTo(null) | |||
.isNotEqualTo(new Object()) | |||
.isEqualTo(new Project("U1", "K1", "N1", null, emptyList())) | |||
.isNotEqualTo(new Project("U1", "K2", "N1", null, emptyList())) | |||
.isNotEqualTo(new Project("U1", "K1", "N2", null, emptyList())) | |||
.isEqualTo(project2); | |||
assertThat(project1.hashCode()).isEqualTo(project1.hashCode()); | |||
assertThat(project1.hashCode()).isNotEqualTo(null); | |||
assertThat(project1).hasSameHashCodeAs(project1); | |||
assertThat(project1.hashCode()).isNotEqualTo(new Object().hashCode()); | |||
assertThat(project1.hashCode()).isEqualTo(new Project("U1", "K1", "N1", null, emptyList()).hashCode()); | |||
assertThat(project1).hasSameHashCodeAs(new Project("U1", "K1", "N1", null, emptyList())); | |||
assertThat(project1.hashCode()).isNotEqualTo(new Project("U1", "K2", "N1", null, emptyList()).hashCode()); | |||
assertThat(project1.hashCode()).isNotEqualTo(new Project("U1", "K1", "N2", null, emptyList()).hashCode()); | |||
assertThat(project1.hashCode()).isEqualTo(project2.hashCode()); | |||
assertThat(project1).hasSameHashCodeAs(project2); | |||
} | |||
} |
@@ -63,7 +63,7 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(description); | |||
assertThat(result.getRisk()).contains(description); | |||
assertThat(result.getVulnerable()).isEmpty(); | |||
assertThat(result.getFixIt()).isEmpty(); | |||
} | |||
@@ -85,8 +85,8 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk()).isEmpty(); | |||
assertThat(result.getVulnerable().get()).isEqualTo(ASKATRISK); | |||
assertThat(result.getFixIt().get()).isEqualTo(RECOMMENTEDCODINGPRACTICE); | |||
assertThat(result.getVulnerable()).contains(ASKATRISK); | |||
assertThat(result.getFixIt()).contains(RECOMMENTEDCODINGPRACTICE); | |||
} | |||
@Test | |||
@@ -95,9 +95,9 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(DESCRIPTION); | |||
assertThat(result.getRisk()).contains(DESCRIPTION); | |||
assertThat(result.getVulnerable()).isEmpty(); | |||
assertThat(result.getFixIt().get()).isEqualTo(RECOMMENTEDCODINGPRACTICE); | |||
assertThat(result.getFixIt()).contains(RECOMMENTEDCODINGPRACTICE); | |||
} | |||
@Test | |||
@@ -106,8 +106,8 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(DESCRIPTION); | |||
assertThat(result.getVulnerable().get()).isEqualTo(ASKATRISK); | |||
assertThat(result.getRisk()).contains(DESCRIPTION); | |||
assertThat(result.getVulnerable()).contains(ASKATRISK); | |||
assertThat(result.getFixIt()).isEmpty(); | |||
} | |||
@@ -117,9 +117,9 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(DESCRIPTION); | |||
assertThat(result.getVulnerable().get()).isEqualTo(NONCOMPLIANTCODE); | |||
assertThat(result.getFixIt().get()).isEqualTo(COMPLIANTCODE); | |||
assertThat(result.getRisk()).contains(DESCRIPTION); | |||
assertThat(result.getVulnerable()).contains(NONCOMPLIANTCODE); | |||
assertThat(result.getFixIt()).contains(COMPLIANTCODE); | |||
} | |||
@Test | |||
@@ -128,10 +128,10 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(DESCRIPTION); | |||
assertThat(result.getRisk()).contains(DESCRIPTION); | |||
assertThat(result.getVulnerable().get()).isEqualTo(NONCOMPLIANTCODE); | |||
assertThat(result.getFixIt().get()).isEqualTo(RECOMMENTEDCODINGPRACTICE + SEE); | |||
assertThat(result.getVulnerable()).contains(NONCOMPLIANTCODE); | |||
assertThat(result.getFixIt()).contains(RECOMMENTEDCODINGPRACTICE + SEE); | |||
} | |||
@@ -141,9 +141,9 @@ public class HotspotRuleDescriptionTest { | |||
HotspotRuleDescription result = HotspotRuleDescription.from(dto); | |||
assertThat(result.getRisk().get()).isEqualTo(DESCRIPTION); | |||
assertThat(result.getVulnerable().get()).isEqualTo(ASKATRISK + SENSITIVECODE); | |||
assertThat(result.getFixIt().get()).isEqualTo(RECOMMENTEDCODINGPRACTICE + SEE); | |||
assertThat(result.getRisk()).contains(DESCRIPTION); | |||
assertThat(result.getVulnerable()).contains(ASKATRISK + SENSITIVECODE); | |||
assertThat(result.getFixIt()).contains(RECOMMENTEDCODINGPRACTICE + SEE); | |||
} | |||
@Test |
@@ -68,10 +68,10 @@ public class SecurityReviewRatingTest { | |||
@Test | |||
public void compute_percent() { | |||
assertThat(computePercent(0, 0)).isEmpty(); | |||
assertThat(computePercent(0, 10).get()).isEqualTo(100.0); | |||
assertThat(computePercent(1, 3).get()).isEqualTo(75.0); | |||
assertThat(computePercent(0, 10)).contains(100.0); | |||
assertThat(computePercent(1, 3)).contains(75.0); | |||
assertThat(computePercent(3, 4).get()).isEqualTo(57.14, DOUBLE_OFFSET); | |||
assertThat(computePercent(10, 10).get()).isEqualTo(50.0); | |||
assertThat(computePercent(10, 0).get()).isEqualTo(0.0); | |||
assertThat(computePercent(10, 10)).contains(50.0); | |||
assertThat(computePercent(10, 0)).contains(0.0); | |||
} | |||
} |
@@ -196,7 +196,7 @@ public class PluginDownloaderTest { | |||
pluginDownloader.start(); | |||
pluginDownloader.download("foo", create("1.0")); | |||
verify(httpDownloader, never()).download(any(URI.class), any(File.class)); | |||
assertThat(noDownloadedFiles()).isGreaterThan(0); | |||
assertThat(noDownloadedFiles()).isPositive(); | |||
} | |||
@Test | |||
@@ -270,7 +270,7 @@ public class PluginDownloaderTest { | |||
file2.createNewFile(); | |||
pluginDownloader.start(); | |||
assertThat(noDownloadedFiles()).isGreaterThan(0); | |||
assertThat(noDownloadedFiles()).isPositive(); | |||
pluginDownloader.cancelDownloads(); | |||
assertThat(noDownloadedFiles()).isZero(); | |||
} |
@@ -123,8 +123,8 @@ public class QGChangeEventTest { | |||
public void overrides_toString() { | |||
QGChangeEvent underTest = new QGChangeEvent(project, branch, analysis, configuration, previousStatus, supplier); | |||
assertThat(underTest.toString()) | |||
.isEqualTo("QGChangeEvent{project=bar:foo, branch=BRANCH:bar:doh:zop, analysis=pto:8999999765" + | |||
assertThat(underTest) | |||
.hasToString("QGChangeEvent{project=bar:foo, branch=BRANCH:bar:doh:zop, analysis=pto:8999999765" + | |||
", projectConfiguration=" + configuration.toString() + | |||
", previousStatus=" + previousStatus + | |||
", qualityGateSupplier=" + supplier + "}"); |
@@ -244,7 +244,7 @@ public class CredentialsLocalAuthentication { | |||
.setSalt(saltStr); | |||
} | |||
private String hash(byte[] salt, String password, int iterations) { | |||
private static String hash(byte[] salt, String password, int iterations) { | |||
try { | |||
SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGORITHM); | |||
PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, iterations, KEY_LEN); |
@@ -133,7 +133,7 @@ public class InitFilterTest { | |||
underTest.doFilter(request, response, chain); | |||
verify(auth2AuthenticationParameters).init(eq(request), eq(response)); | |||
verify(auth2AuthenticationParameters).init(request, response); | |||
} | |||
@Test | |||
@@ -143,7 +143,7 @@ public class InitFilterTest { | |||
underTest.doFilter(request, response, chain); | |||
verify(auth2AuthenticationParameters, never()).init(eq(request), eq(response)); | |||
verify(auth2AuthenticationParameters, never()).init(request, response); | |||
} | |||
@Test | |||
@@ -263,7 +263,7 @@ public class InitFilterTest { | |||
} | |||
private void verifyDeleteAuthCookie() { | |||
verify(auth2AuthenticationParameters).delete(eq(request), eq(response)); | |||
verify(auth2AuthenticationParameters).delete(request, response); | |||
} | |||
private static class FailWithUnauthorizedExceptionIdProvider extends FakeBasicIdentityProvider { |
@@ -119,7 +119,7 @@ public class JwtHttpHandlerTest { | |||
verify(jwtSerializer).encode(jwtArgumentCaptor.capture()); | |||
JwtSerializer.JwtSession token = jwtArgumentCaptor.getValue(); | |||
assertThat(token.getProperties().get("xsrfToken")).isEqualTo(CSRF_STATE); | |||
assertThat(token.getProperties()).containsEntry("xsrfToken", CSRF_STATE); | |||
} | |||
@Test | |||
@@ -200,7 +200,7 @@ public class JwtHttpHandlerTest { | |||
Claims claims = createToken(sessionToken, NOW); | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.of(claims)); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isTrue(); | |||
assertThat(underTest.validateToken(request, response)).isPresent(); | |||
verify(jwtSerializer, never()).encode(any(JwtSerializer.JwtSession.class)); | |||
} | |||
@@ -215,7 +215,7 @@ public class JwtHttpHandlerTest { | |||
claims.put("lastRefreshTime", SIX_MINUTES_AGO); | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.of(claims)); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isTrue(); | |||
assertThat(underTest.validateToken(request, response)).isPresent(); | |||
verify(jwtSerializer).refresh(any(Claims.class), eq(NOW + 3 * 24 * 60 * 60 * 1000L)); | |||
assertThat(dbClient.sessionTokensDao().selectByUuid(dbSession, sessionToken.getUuid()).get().getExpirationDate()) | |||
@@ -233,7 +233,7 @@ public class JwtHttpHandlerTest { | |||
claims.put("lastRefreshTime", FOUR_MINUTES_AGO); | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.of(claims)); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isTrue(); | |||
assertThat(underTest.validateToken(request, response)).isPresent(); | |||
verify(jwtSerializer, never()).refresh(any(Claims.class), anyInt()); | |||
} | |||
@@ -248,7 +248,7 @@ public class JwtHttpHandlerTest { | |||
claims.put("lastRefreshTime", FOUR_MINUTES_AGO); | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.of(claims)); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -259,7 +259,7 @@ public class JwtHttpHandlerTest { | |||
Claims claims = createToken(sessionToken, NOW); | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.of(claims)); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -268,7 +268,7 @@ public class JwtHttpHandlerTest { | |||
when(jwtSerializer.decode(JWT_TOKEN)).thenReturn(Optional.empty()); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -276,7 +276,7 @@ public class JwtHttpHandlerTest { | |||
underTest.validateToken(request, response); | |||
verifyNoInteractions(httpSession, jwtSerializer); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -286,7 +286,7 @@ public class JwtHttpHandlerTest { | |||
underTest.validateToken(request, response); | |||
verifyNoInteractions(httpSession, jwtSerializer); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -314,7 +314,7 @@ public class JwtHttpHandlerTest { | |||
underTest.validateToken(request, response); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -330,7 +330,7 @@ public class JwtHttpHandlerTest { | |||
underTest.validateToken(request, response); | |||
assertThat(underTest.validateToken(request, response).isPresent()).isFalse(); | |||
assertThat(underTest.validateToken(request, response)).isEmpty(); | |||
} | |||
@Test | |||
@@ -394,7 +394,7 @@ public class JwtHttpHandlerTest { | |||
private void verifyToken(JwtSerializer.JwtSession token, UserDto user, long expectedExpirationDuration, long expectedRefreshTime) { | |||
assertThat(token.getExpirationTime()).isEqualTo(NOW + expectedExpirationDuration * 1000L); | |||
assertThat(token.getUserLogin()).isEqualTo(user.getUuid()); | |||
assertThat(token.getProperties().get("lastRefreshTime")).isEqualTo(expectedRefreshTime); | |||
assertThat(token.getProperties()).containsEntry("lastRefreshTime", expectedRefreshTime); | |||
} | |||
private Optional<Cookie> findCookie(String name) { |
@@ -209,7 +209,7 @@ public class OAuth2ContextFactoryTest { | |||
callback.redirectToRequestedPage(); | |||
verify(oAuthParameters).delete(eq(request), eq(response)); | |||
verify(oAuthParameters).delete(request, response); | |||
} | |||
private OAuth2IdentityProvider.InitContext newInitContext() { |
@@ -62,7 +62,7 @@ public class UserTokenAuthenticationTest { | |||
Optional<String> login = underTest.authenticate(token); | |||
assertThat(login.isPresent()).isTrue(); | |||
assertThat(login.get()).isEqualTo(user1.getUuid()); | |||
assertThat(login).contains(user1.getUuid()); | |||
verify(userLastConnectionDatesUpdater).updateLastConnectionDateIfNeeded(any(UserTokenDto.class)); | |||
} | |||
@@ -51,7 +51,7 @@ public abstract class AbstractSystemInfoWriter implements SystemInfoWriter { | |||
.forEach(section -> writeSection(section, json)); | |||
} | |||
private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) { | |||
private static void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) { | |||
json.name(section.getName()); | |||
json.beginObject(); | |||
for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) { |
@@ -39,13 +39,14 @@ import org.sonar.server.util.GlobalLockManager; | |||
import static org.sonar.api.measures.Metric.Level.WARN; | |||
/** | |||
* This class is regularly checking the number of projects in warning state, in order to not return the "Warning" value in the quality gate facet of the Projects page when there are no more projects in warning. | |||
* This class is regularly checking the number of projects in warning state, in order to not return the "Warning" value | |||
* in the quality gate facet of the Projects page when there are no more projects in warning. | |||
* | |||
* @see <a href="https://jira.sonarsource.com/browse/SONAR-12140">SONAR-12140</a> for more information | |||
*/ | |||
public class ProjectsInWarningDaemon implements Startable { | |||
final static String PROJECTS_IN_WARNING_INTERNAL_PROPERTY = "projectsInWarning"; | |||
static final String PROJECTS_IN_WARNING_INTERNAL_PROPERTY = "projectsInWarning"; | |||
private static final Logger LOG = Loggers.get(ProjectsInWarningDaemon.class); | |||
@@ -28,9 +28,7 @@ import org.sonar.server.es.metadata.MetadataIndex; | |||
import org.sonar.server.es.metadata.MetadataIndexImpl; | |||
import org.sonar.server.es.newindex.FakeIndexDefinition; | |||
import static org.mockito.ArgumentMatchers.any; | |||
import static org.mockito.ArgumentMatchers.anySet; | |||
import static org.mockito.ArgumentMatchers.eq; | |||
import static org.mockito.Mockito.doReturn; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.times; | |||
@@ -70,7 +68,7 @@ public class IndexerStartupTaskAsyncTest { | |||
underTest.execute(); | |||
verify(metadataIndex).setInitialized(eq(TYPE_FAKE), eq(true)); | |||
verify(metadataIndex).setInitialized(TYPE_FAKE, true); | |||
} | |||
@Test |
@@ -67,7 +67,7 @@ public class SourceServiceTest { | |||
public void get_range_of_lines() { | |||
Set<Integer> lineNumbers = new HashSet<>(Arrays.asList(1, 5, 6)); | |||
Optional<Iterable<DbFileSources.Line>> linesOpt = underTest.getLines(dbTester.getSession(), FILE_UUID, lineNumbers); | |||
assertThat(linesOpt.isPresent()).isTrue(); | |||
assertThat(linesOpt).isPresent(); | |||
List<DbFileSources.Line> lines = Lists.newArrayList(linesOpt.get()); | |||
assertThat(lines).hasSize(3); | |||
assertThat(lines.get(0).getLine()).isEqualTo(1); |
@@ -54,7 +54,7 @@ public class SkipOnboardingTutorialActionTest { | |||
call(); | |||
UserDto userDto = selectUser(user.getLogin()); | |||
assertThat(userDto.isOnboarded()).isEqualTo(true); | |||
assertThat(userDto.isOnboarded()).isTrue(); | |||
} | |||
@Test | |||
@@ -66,7 +66,7 @@ public class SkipOnboardingTutorialActionTest { | |||
call(); | |||
UserDto userDto = selectUser(user.getLogin()); | |||
assertThat(userDto.isOnboarded()).isEqualTo(true); | |||
assertThat(userDto.isOnboarded()).isTrue(); | |||
assertThat(userDto.getUpdatedAt()).isEqualTo(user.getUpdatedAt()); | |||
} | |||
@@ -126,12 +126,12 @@ public class TomcatContextsTest { | |||
public void root_context_path_must_be_blank() { | |||
props.setProperty("sonar.web.context", "/"); | |||
assertThat(TomcatContexts.getContextPath(new Props(props))).isEqualTo(""); | |||
assertThat(TomcatContexts.getContextPath(new Props(props))).isEmpty(); | |||
} | |||
@Test | |||
public void default_context_path_is_root() { | |||
String context = TomcatContexts.getContextPath(new Props(new Properties())); | |||
assertThat(context).isEqualTo(""); | |||
assertThat(context).isEmpty(); | |||
} | |||
} |
@@ -208,7 +208,7 @@ public class TestInputFileBuilder { | |||
} | |||
public TestInputFileBuilder initMetadata(String content) { | |||
AnalysisWarnings analysisWarnings = (warning) -> {}; | |||
AnalysisWarnings analysisWarnings = warning -> {}; | |||
return setMetadata(new FileMetadata(analysisWarnings).readMetadata(new StringReader(content))); | |||
} | |||
@@ -34,6 +34,7 @@ import static org.sonar.api.utils.Preconditions.checkArgument; | |||
* </p> | |||
*/ | |||
public class AlwaysIncreasingSystem2 extends System2 { | |||
private static final Random rnd = new Random(); | |||
private final AtomicLong now; | |||
private final long increment; | |||
@@ -66,6 +67,6 @@ public class AlwaysIncreasingSystem2 extends System2 { | |||
} | |||
private static long randomInitialValue() { | |||
return Math.abs(new Random().nextInt(2_000_000)); | |||
return Math.abs(rnd.nextInt(2_000_000)); | |||
} | |||
} |
@@ -22,6 +22,7 @@ package org.sonar.api.internal; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import java.nio.charset.StandardCharsets; | |||
import java.util.Locale; | |||
import java.util.Scanner; | |||
import org.sonar.api.SonarEdition; | |||
import org.sonar.api.utils.System2; | |||
@@ -68,7 +69,7 @@ public class MetadataLoader { | |||
} | |||
static SonarEdition parseEdition(String edition) { | |||
String str = trimToEmpty(edition.toUpperCase()); | |||
String str = trimToEmpty(edition.toUpperCase(Locale.ENGLISH)); | |||
try { | |||
return SonarEdition.valueOf(str); | |||
} catch (IllegalArgumentException e) { |
@@ -47,7 +47,7 @@ public class ProjectDefinitionTest { | |||
ProjectDefinition def = ProjectDefinition.create(); | |||
def.setProjectVersion(null); | |||
assertThat(def.getVersion()).isEqualTo("not provided"); | |||
assertThat(def.getOriginalVersion()).isEqualTo(""); | |||
assertThat(def.getOriginalVersion()).isEmpty(); | |||
} | |||
@Test |
@@ -80,6 +80,6 @@ public class DefaultRuleTest { | |||
DefaultNewRule rule = new DefaultNewRule("plugin", "repo", "key"); | |||
DefaultRule defaultRule = new DefaultRule(repo, rule); | |||
assertThat(defaultRule.toString()).isEqualTo("[repository=repo, key=key]"); | |||
assertThat(defaultRule).hasToString("[repository=repo, key=key]"); | |||
} | |||
} |
@@ -134,8 +134,8 @@ public class DurationTest { | |||
assertThat(durationWithDifferentValue).isNotEqualTo(duration); | |||
assertThat(duration).isNotEqualTo(null); | |||
assertThat(duration.hashCode()).isEqualTo(duration.hashCode()); | |||
assertThat(durationWithSameValue.hashCode()).isEqualTo(duration.hashCode()); | |||
assertThat(duration).hasSameHashCodeAs(duration); | |||
assertThat(durationWithSameValue).hasSameHashCodeAs(duration); | |||
assertThat(durationWithDifferentValue.hashCode()).isNotEqualTo(duration.hashCode()); | |||
} | |||
@@ -37,7 +37,7 @@ import org.sonar.scanner.externalissue.ReportParser.Location; | |||
import org.sonar.scanner.externalissue.ReportParser.Report; | |||
public class ExternalIssueImporter { | |||
private static final Logger LOG = Loggers.get(ExternalIssuesImportSensor.class); | |||
private static final Logger LOG = Loggers.get(ExternalIssueImporter.class); | |||
private static final int MAX_UNKNOWN_FILE_PATHS_TO_PRINT = 5; | |||
private final SensorContext context; |
@@ -26,14 +26,13 @@ import org.sonar.api.notifications.AnalysisWarnings; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.utils.log.Profiler; | |||
import org.sonar.scanner.report.ChangedLinesPublisher; | |||
import org.sonar.scanner.scan.branch.BranchConfiguration; | |||
import org.sonar.scanner.scan.branch.ProjectBranches; | |||
import org.sonar.scanner.scm.ScmConfiguration; | |||
import org.sonarqube.ws.NewCodePeriods; | |||
public class ForkDateSupplier { | |||
private static final Logger LOG = Loggers.get(ChangedLinesPublisher.class); | |||
private static final Logger LOG = Loggers.get(ForkDateSupplier.class); | |||
private static final String LOG_MSG_WS = "Load New Code definition"; | |||
private final NewCodePeriodLoader newCodePeriodLoader; |
@@ -83,7 +83,7 @@ public class DefaultFileLinesContextTest { | |||
fileLineMeasures.setIntValue(HITS_METRIC_KEY, 3, 0); | |||
fileLineMeasures.save(); | |||
assertThat(fileLineMeasures.toString()).isEqualTo("DefaultFileLinesContext{{hits={1=2, 3=0}}}"); | |||
assertThat(fileLineMeasures).hasToString("DefaultFileLinesContext{{hits={1=2, 3=0}}}"); | |||
ArgumentCaptor<DefaultMeasure> captor = ArgumentCaptor.forClass(DefaultMeasure.class); | |||
verify(sensorStorage).store(captor.capture()); |
@@ -183,7 +183,7 @@ public class ChangedLinesPublisherTest { | |||
} | |||
private void assertNotPublished() { | |||
assertThat(temp.getRoot().list()).isEmpty(); | |||
assertThat(temp.getRoot()).isEmptyDirectory(); | |||
} | |||
} |
@@ -193,7 +193,7 @@ public class ComponentsPublisherTest { | |||
ScannerReportReader reader = new ScannerReportReader(outputDir); | |||
Component rootProtobuf = reader.readComponent(1); | |||
assertThat(rootProtobuf.getKey()).isEqualTo("foo"); | |||
assertThat(rootProtobuf.getName()).isEqualTo(""); | |||
assertThat(rootProtobuf.getName()).isEmpty(); | |||
assertThat(rootProtobuf.getDescription()).isEqualTo("Root description"); | |||
assertThat(rootProtobuf.getLinkCount()).isZero(); | |||
} |
@@ -32,7 +32,6 @@ import org.sonar.scanner.rule.QualityProfiles; | |||
import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.ArgumentMatchers.eq; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.verifyNoMoreInteractions; | |||
@@ -72,12 +71,12 @@ public class QualityProfileProviderTest { | |||
@Test | |||
public void testProfileProp() { | |||
when(loader.load(eq("project"))).thenReturn(response); | |||
when(loader.load("project")).thenReturn(response); | |||
QualityProfiles qps = qualityProfileProvider.provide(loader, props); | |||
assertResponse(qps); | |||
verify(loader).load(eq("project")); | |||
verify(loader).load("project"); | |||
verifyNoMoreInteractions(loader); | |||
} | |||
@@ -30,13 +30,14 @@ public class QProfileTest { | |||
QProfile q2 = new QProfile("k1", "name2", null, null); | |||
QProfile q3 = new QProfile("k3", "name3", null, null); | |||
assertThat(q1).isEqualTo(q2); | |||
assertThat(q1).isNotEqualTo(q3); | |||
assertThat(q1) | |||
.isEqualTo(q2) | |||
.isNotEqualTo(q3) | |||
.isNotEqualTo(null) | |||
.isNotEqualTo("str"); | |||
assertThat(q2).isNotEqualTo(q3); | |||
assertThat(q1).isNotEqualTo(null); | |||
assertThat(q1).isNotEqualTo("str"); | |||
assertThat(q1.hashCode()).isEqualTo(q2.hashCode()); | |||
assertThat(q1).hasSameHashCodeAs(q2); | |||
assertThat(q1.hashCode()).isNotEqualTo(q3.hashCode()); | |||
assertThat(q2.hashCode()).isNotEqualTo(q3.hashCode()); | |||
} |
@@ -102,7 +102,7 @@ public class DefaultInputModuleHierarchyTest { | |||
moduleHierarchy = new DefaultInputModuleHierarchy(root, parents); | |||
assertThat(moduleHierarchy.relativePathToRoot(root)).isEqualTo(""); | |||
assertThat(moduleHierarchy.relativePathToRoot(root)).isEmpty(); | |||
assertThat(moduleHierarchy.relativePathToRoot(mod1)).isEqualTo("mod1"); | |||
assertThat(moduleHierarchy.relativePathToRoot(mod2)).isEqualTo("mod2"); | |||
assertThat(moduleHierarchy.relativePathToRoot(mod3)).isNull(); |
@@ -42,7 +42,7 @@ public class DirectoryLockTest { | |||
@Test | |||
public void tryLock() { | |||
assertThat(temp.getRoot().list()).isEmpty(); | |||
assertThat(temp.getRoot()).isEmptyDirectory(); | |||
lock.tryLock(); | |||
assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists(); | |||
lock.unlock(); |
@@ -118,7 +118,7 @@ public class ProjectExclusionFiltersTest { | |||
@Test | |||
public void trim_pattern() { | |||
assertThat(ProjectExclusionFilters.prepareMainExclusions(new String[] {" **/*Dao.java "}, new String[0])[0].toString()).isEqualTo("**/*Dao.java"); | |||
assertThat(ProjectExclusionFilters.prepareMainExclusions(new String[] {" **/*Dao.java "}, new String[0])[0]).hasToString("**/*Dao.java"); | |||
} | |||
} |
@@ -322,7 +322,7 @@ public class JGitBlameCommandTest { | |||
.matches(s -> s.contains("This git repository references another local repository which is not well supported")); | |||
// contains commits referenced from the old clone and commits in the new clone | |||
assertThat(output.blame.keySet()).contains(inputFile); | |||
assertThat(output.blame).containsKey(inputFile); | |||
assertThat(output.blame.get(inputFile).stream().map(BlameLine::revision)) | |||
.containsOnly("6b3aab35a3ea32c1636fee56f996e677653c48ea", "843c7c30d7ebd9a479e8f1daead91036c75cbc4e", "0d269c1acfb8e6d4d33f3c43041eb87e0df0f5e7"); | |||
verifyZeroInteractions(analysisWarnings); |