diff options
141 files changed, 378 insertions, 366 deletions
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java index c46bc6f3107..56b818ba53f 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java @@ -83,7 +83,7 @@ public class LdapSearchTest { assertThat(search.getParameters()).isEqualTo(new String[] {"inetOrgPerson"}); assertThat(search.getReturningAttributes()).isEqualTo(new String[] {"cn"}); assertThat(search.toString()).isEqualTo("LdapSearch{baseDn=dc=example,dc=org, scope=onelevel, request=(objectClass={0}), parameters=[inetOrgPerson], attributes=[cn]}"); - assertThat(enumerationToArrayList(search.find()).size()).isEqualTo(0); + assertThat(enumerationToArrayList(search.find()).size()).isZero(); assertThat(search.findUnique()).isNull(); } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/MatchesByScoreTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/MatchesByScoreTest.java index ed1f581e66d..7bdd0b3f334 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/MatchesByScoreTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/MatchesByScoreTest.java @@ -43,7 +43,7 @@ public class MatchesByScoreTest { ScoreMatrix scoreMatrix1 = new ScoreMatrix(doesNotMatterRemovedFiles, doesNotMatterNewFiles, doesNotMatterScores, MIN_REQUIRED_SCORE - 1); MatchesByScore matchesByScore = MatchesByScore.create(scoreMatrix1); - assertThat(matchesByScore.getSize()).isEqualTo(0); + assertThat(matchesByScore.getSize()).isZero(); assertThat(matchesByScore).isEmpty(); ScoreMatrix scoreMatrix2 = new ScoreMatrix(doesNotMatterRemovedFiles, doesNotMatterNewFiles, doesNotMatterScores, MIN_REQUIRED_SCORE - 5); diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/SourceSimilarityImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/SourceSimilarityImplTest.java index d77d7327a76..86eb96a773b 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/SourceSimilarityImplTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/SourceSimilarityImplTest.java @@ -41,7 +41,7 @@ public class SourceSimilarityImplTest { public void zero_if_fully_different() { List<String> left = asList("a", "b", "c"); List<String> right = asList("d", "e"); - assertThat(underTest.score(left, right)).isEqualTo(0); + assertThat(underTest.score(left, right)).isZero(); } @Test @@ -127,6 +127,6 @@ public class SourceSimilarityImplTest { @Test public void two_empty_lists_are_not_considered_as_equal() { - assertThat(underTest.score(emptyList(), emptyList())).isEqualTo(0); + assertThat(underTest.score(emptyList(), emptyList())).isZero(); } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/DoubleValueTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/DoubleValueTest.java index 7b5d7fc8008..1da21f2c9d2 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/DoubleValueTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/DoubleValueTest.java @@ -72,7 +72,7 @@ public class DoubleValueTest { private static void verifyUnsetVariationValue(DoubleValue variationValue) { assertThat(variationValue.isSet()).isFalse(); - assertThat(variationValue.getValue()).isEqualTo(0); + assertThat(variationValue.getValue()).isZero(); } private static void verifySetVariationValue(DoubleValue variationValue, double expected) { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntValueTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntValueTest.java index 339ba5a2909..4fd80d5dbf3 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntValueTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntValueTest.java @@ -72,7 +72,7 @@ public class IntValueTest { private static void verifyUnsetVariationValue(IntValue variationValue) { assertThat(variationValue.isSet()).isFalse(); - assertThat(variationValue.getValue()).isEqualTo(0); + assertThat(variationValue.getValue()).isZero(); } private static void verifySetVariationValue(IntValue variationValue, int expected) { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java index 46a427db219..3a1157243be 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java @@ -63,7 +63,7 @@ public class AdHocRuleCreatorTest { assertThat(rule.getName()).isEqualTo("eslint:no-cond-assign"); assertThat(rule.getDescription()).isNull(); assertThat(rule.getSeverity()).isNull(); - assertThat(rule.getType()).isEqualTo(0); + assertThat(rule.getType()).isZero(); assertThat(rule.getMetadata().getAdHocName()).isNull(); assertThat(rule.getMetadata().getAdHocDescription()).isNull(); assertThat(rule.getMetadata().getAdHocSeverity()).isNull(); @@ -91,7 +91,7 @@ public class AdHocRuleCreatorTest { assertThat(rule.getName()).isEqualTo("eslint:no-cond-assign"); assertThat(rule.getDescription()).isNull(); assertThat(rule.getSeverity()).isNull(); - assertThat(rule.getType()).isEqualTo(0); + assertThat(rule.getType()).isZero(); assertThat(rule.getMetadata().getAdHocName()).isEqualTo("No condition assigned"); assertThat(rule.getMetadata().getAdHocDescription()).isEqualTo("A description"); assertThat(rule.getMetadata().getAdHocSeverity()).isEqualTo(Severity.BLOCKER); @@ -146,7 +146,7 @@ public class AdHocRuleCreatorTest { assertThat(ruleUpdated.getName()).isEqualTo("eslint:no-cond-assign"); assertThat(ruleUpdated.getDescription()).isNull(); assertThat(ruleUpdated.getSeverity()).isNull(); - assertThat(ruleUpdated.getType()).isEqualTo(0); + assertThat(ruleUpdated.getType()).isZero(); assertThat(ruleUpdated.getMetadata().getAdHocName()).isEqualTo("No condition assigned updated"); assertThat(ruleUpdated.getMetadata().getAdHocDescription()).isEqualTo("A description updated"); assertThat(ruleUpdated.getMetadata().getAdHocSeverity()).isEqualTo(Severity.CRITICAL); diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java index acad6933890..9554769ed3b 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java @@ -264,7 +264,7 @@ public class IntegrateIssuesVisitorTest { underTest.visitAny(FILE); List<DefaultIssue> issues = newArrayList(protoIssueCache.traverse()); - assertThat(issues).hasSize(0); + assertThat(issues).isEmpty(); } @Test diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactoryTest.java index 6cf74ec1b74..ee470cf2799 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactoryTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerReferenceBranchInputFactoryTest.java @@ -76,6 +76,6 @@ public class TrackerReferenceBranchInputFactoryTest { Input<DefaultIssue> input = underTest.create(component); assertThat(input.getIssues()).isEmpty(); - assertThat(input.getLineHashSequence().length()).isEqualTo(0); + assertThat(input.getLineHashSequence().length()).isZero(); } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/PostMeasuresComputationChecksStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/PostMeasuresComputationChecksStepTest.java index a26fe052f0c..dee477693ab 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/PostMeasuresComputationChecksStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/PostMeasuresComputationChecksStepTest.java @@ -103,7 +103,7 @@ public class PostMeasuresComputationChecksStepTest { ArgumentCaptor<Context> contextArgumentCaptor = ArgumentCaptor.forClass(Context.class); verify(check).onCheck(contextArgumentCaptor.capture()); - assertThat(contextArgumentCaptor.getValue().getNcloc()).isEqualTo(0); + assertThat(contextArgumentCaptor.getValue().getNcloc()).isZero(); } @Test diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStepTest.java index 95ff232ff99..665fa2bc02a 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/PersistFileSourcesStepTest.java @@ -220,7 +220,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { assertThat(data.getLines(1).getScmRevision()).isEmpty(); assertThat(data.getLines(2).getScmAuthor()).isEmpty(); - assertThat(data.getLines(2).getScmDate()).isEqualTo(0); + assertThat(data.getLines(2).getScmDate()).isZero(); assertThat(data.getLines(2).getScmRevision()).isEmpty(); verify(fileSourceDataWarnings).commitWarnings(); } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/CoverageLineReaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/CoverageLineReaderTest.java index 2e9cd1d89fe..248aea409e0 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/CoverageLineReaderTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/CoverageLineReaderTest.java @@ -73,7 +73,7 @@ public class CoverageLineReaderTest { assertThat(computeCoverageLine.read(lineBuilder)).isEmpty(); assertThat(lineBuilder.hasLineHits()).isTrue(); - assertThat(lineBuilder.getLineHits()).isEqualTo(0); + assertThat(lineBuilder.getLineHits()).isZero(); } @Test diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAdHocRulesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAdHocRulesStepTest.java index 2aa58c65beb..5221e2f6a77 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAdHocRulesStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAdHocRulesStepTest.java @@ -87,7 +87,7 @@ public class PersistAdHocRulesStepTest extends BaseStepTest { assertThat(reloaded.getRepositoryKey()).isEqualTo("external_eslint"); assertThat(reloaded.isExternal()).isTrue(); assertThat(reloaded.isAdHoc()).isTrue(); - assertThat(reloaded.getType()).isEqualTo(0); + assertThat(reloaded.getType()).isZero(); assertThat(reloaded.getSeverity()).isNull(); assertThat(reloaded.getName()).isEqualTo("eslint:no-cond-assign"); diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java index c1f87990a15..26ce6586c88 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistAnalysisPropertiesStepTest.java @@ -110,7 +110,7 @@ public class PersistAnalysisPropertiesStepTest { underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("analysis_properties")).isZero(); } @Test @@ -121,7 +121,7 @@ public class PersistAnalysisPropertiesStepTest { underTest.execute(new TestComputationStepContext()); - assertThat(dbTester.countRowsOfTable("analysis_properties")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("analysis_properties")).isZero(); } @Test diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java index 2175648c8a4..80179632e23 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java @@ -141,7 +141,7 @@ public class PersistCrossProjectDuplicationIndexStepTest { TestComputationStepContext context = new TestComputationStepContext(); underTest.execute(context); - assertThat(dbTester.countRowsOfTable("duplications_index")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("duplications_index")).isZero(); context.getStatistics().assertValue("inserts", 0); } @@ -153,7 +153,7 @@ public class PersistCrossProjectDuplicationIndexStepTest { TestComputationStepContext context = new TestComputationStepContext(); underTest.execute(context); - assertThat(dbTester.countRowsOfTable("duplications_index")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("duplications_index")).isZero(); context.getStatistics().assertValue("inserts", null); } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java index a5c16b02745..655e7f6d217 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java @@ -165,7 +165,7 @@ public class PersistDuplicationDataStepTest extends BaseStepTest { } private void assertThatNothingPersisted() { - assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isZero(); } private Optional<String> selectMeasureData(String componentUuid) { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java index 9af840e7d1b..40ea74a013c 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java @@ -265,7 +265,7 @@ public class QualityGateEventsStepTest { assertThat(notification.getFieldValue("projectKey")).isEqualTo(PROJECT_COMPONENT.getKey()); assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName()); assertThat(notification.getFieldValue("projectVersion")).isEqualTo(PROJECT_COMPONENT.getProjectAttributes().getProjectVersion()); - assertThat(notification.getFieldValue("branch")).isEqualTo(null); + assertThat(notification.getFieldValue("branch")).isNull(); reset(measureRepository, eventRepository, notificationService); } diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/container/TaskContainerImplTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/container/TaskContainerImplTest.java index ba995942112..1a22d2e5b79 100644 --- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/container/TaskContainerImplTest.java +++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/container/TaskContainerImplTest.java @@ -67,10 +67,10 @@ public class TaskContainerImplTest { }); ceContainer.bootup(); - assertThat(defaultStartable.startCalls).isEqualTo(0); - assertThat(defaultStartable.stopCalls).isEqualTo(0); + assertThat(defaultStartable.startCalls).isZero(); + assertThat(defaultStartable.stopCalls).isZero(); assertThat(eagerStartable.startCalls).isEqualTo(1); - assertThat(eagerStartable.stopCalls).isEqualTo(0); + assertThat(eagerStartable.stopCalls).isZero(); } @Test @@ -85,8 +85,8 @@ public class TaskContainerImplTest { ceContainer.close(); - assertThat(defaultStartable.startCalls).isEqualTo(0); - assertThat(defaultStartable.stopCalls).isEqualTo(0); + assertThat(defaultStartable.startCalls).isZero(); + assertThat(defaultStartable.stopCalls).isZero(); assertThat(eagerStartable.startCalls).isEqualTo(1); assertThat(eagerStartable.stopCalls).isEqualTo(1); } diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java index ff9128e32ae..b8ecf76066d 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java @@ -53,10 +53,10 @@ public abstract class CommonCEQueueStatusImplTest { @Test public void verify_just_created_instance_metrics() { - assertThat(getUnderTest().getInProgressCount()).isEqualTo(0); - assertThat(getUnderTest().getErrorCount()).isEqualTo(0); - assertThat(getUnderTest().getSuccessCount()).isEqualTo(0); - assertThat(getUnderTest().getProcessingTime()).isEqualTo(0); + assertThat(getUnderTest().getInProgressCount()).isZero(); + assertThat(getUnderTest().getErrorCount()).isZero(); + assertThat(getUnderTest().getSuccessCount()).isZero(); + assertThat(getUnderTest().getProcessingTime()).isZero(); } @Test @@ -64,9 +64,9 @@ public abstract class CommonCEQueueStatusImplTest { getUnderTest().addInProgress(); assertThat(getUnderTest().getInProgressCount()).isEqualTo(1); - assertThat(getUnderTest().getErrorCount()).isEqualTo(0); - assertThat(getUnderTest().getSuccessCount()).isEqualTo(0); - assertThat(getUnderTest().getProcessingTime()).isEqualTo(0); + assertThat(getUnderTest().getErrorCount()).isZero(); + assertThat(getUnderTest().getSuccessCount()).isZero(); + assertThat(getUnderTest().getProcessingTime()).isZero(); } @Test @@ -77,7 +77,7 @@ public abstract class CommonCEQueueStatusImplTest { } assertThat(getUnderTest().getInProgressCount()).isEqualTo(calls); - assertThat(getUnderTest().getProcessingTime()).isEqualTo(0); + assertThat(getUnderTest().getProcessingTime()).isZero(); } @Test @@ -94,7 +94,7 @@ public abstract class CommonCEQueueStatusImplTest { assertThat(getUnderTest().getInProgressCount()).isEqualTo(-1); assertThat(getUnderTest().getErrorCount()).isEqualTo(1); - assertThat(getUnderTest().getSuccessCount()).isEqualTo(0); + assertThat(getUnderTest().getSuccessCount()).isZero(); assertThat(getUnderTest().getProcessingTime()).isEqualTo(SOME_PROCESSING_TIME); } @@ -123,7 +123,7 @@ public abstract class CommonCEQueueStatusImplTest { getUnderTest().addSuccess(SOME_PROCESSING_TIME); assertThat(getUnderTest().getInProgressCount()).isEqualTo(-1); - assertThat(getUnderTest().getErrorCount()).isEqualTo(0); + assertThat(getUnderTest().getErrorCount()).isZero(); assertThat(getUnderTest().getSuccessCount()).isEqualTo(1); assertThat(getUnderTest().getProcessingTime()).isEqualTo(SOME_PROCESSING_TIME); } diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/SqlLogFormatterTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/SqlLogFormatterTest.java index 93cb7390124..98dbbe06265 100644 --- a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/SqlLogFormatterTest.java +++ b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/SqlLogFormatterTest.java @@ -74,7 +74,7 @@ public class SqlLogFormatterTest { @Test public void countArguments() { - assertThat(SqlLogFormatter.countArguments("select * from issues")).isEqualTo(0); + assertThat(SqlLogFormatter.countArguments("select * from issues")).isZero(); assertThat(SqlLogFormatter.countArguments("select * from issues where id=?")).isEqualTo(1); assertThat(SqlLogFormatter.countArguments("select * from issues where id=? and kee=?")).isEqualTo(2); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java index c6d08a72d11..faf9cee5e27 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java @@ -129,7 +129,7 @@ public class CeActivityDaoTest { insertWarnings(tasks[2], 1); assertThat(underTest.selectByUuid(dbSession, tasks[0].getUuid()).get().getWarningCount()).isEqualTo(moreThan1); - assertThat(underTest.selectByUuid(dbSession, tasks[1].getUuid()).get().getWarningCount()).isEqualTo(0); + assertThat(underTest.selectByUuid(dbSession, tasks[1].getUuid()).get().getWarningCount()).isZero(); assertThat(underTest.selectByUuid(dbSession, tasks[2].getUuid()).get().getWarningCount()).isEqualTo(1); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java index 3af142c4223..c200245a044 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java @@ -246,7 +246,7 @@ public class CeQueueDaoTest { insertPending(TASK_UUID_2, MAIN_COMPONENT_UUID_1); int deletedCount = underTest.deleteByUuid(db.getSession(), "UNKNOWN"); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_1); @@ -264,15 +264,15 @@ public class CeQueueDaoTest { insertInProgress(TASK_UUID_2, MAIN_COMPONENT_UUID_1); int deletedCount = underTest.deleteByUuid(db.getSession(), "UNKNOWN", null); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_1, new DeleteIf(IN_PROGRESS)); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_2, new DeleteIf(PENDING)); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_2)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_1, new DeleteIf(PENDING)); @@ -519,7 +519,7 @@ public class CeQueueDaoTest { int total = underTest.countByQuery(db.getSession(), query); assertThat(result).isEmpty(); - assertThat(total).isEqualTo(0); + assertThat(total).isZero(); } @Test @@ -536,7 +536,7 @@ public class CeQueueDaoTest { int total = underTest.countByQuery(db.getSession(), query); assertThat(result).isEmpty(); - assertThat(total).isEqualTo(0); + assertThat(total).isZero(); } @Test @@ -553,7 +553,7 @@ public class CeQueueDaoTest { int total = underTest.countByQuery(db.getSession(), query); assertThat(result).isEmpty(); - assertThat(total).isEqualTo(0); + assertThat(total).isZero(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskCharacteristicDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskCharacteristicDaoTest.java index 7dedd7a9d15..b466fd8bb0d 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskCharacteristicDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskCharacteristicDaoTest.java @@ -63,9 +63,9 @@ public class CeTaskCharacteristicDaoTest { insert("key3", "value3", "uuid3", "task3"); underTest.deleteByTaskUuids(dbTester.getSession(), ImmutableSet.of("task1", "task3")); - assertThat(underTest.selectByTaskUuids(dbTester.getSession(), singletonList("task1"))).hasSize(0); + assertThat(underTest.selectByTaskUuids(dbTester.getSession(), singletonList("task1"))).isEmpty(); assertThat(underTest.selectByTaskUuids(dbTester.getSession(), singletonList("task2"))).hasSize(1); - assertThat(underTest.selectByTaskUuids(dbTester.getSession(), singletonList("task3"))).hasSize(0); + assertThat(underTest.selectByTaskUuids(dbTester.getSession(), singletonList("task3"))).isEmpty(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java index d11a6687a29..bc9c42c0fa9 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java @@ -104,7 +104,7 @@ public class CeTaskInputDaoTest { underTest.deleteByUuids(dbTester.getSession(), singleton(A_UUID)); dbTester.commit(); - assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); + assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isZero(); } private void insertData(String uuid) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java index 42a5b7efb01..e521615ef5e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java @@ -560,7 +560,7 @@ public class BranchDaoTest { @Test public void countByTypeAndCreationDate() { - assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isEqualTo(0); + assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isZero(); ComponentDto project = db.components().insertPrivateProject(); ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH)); @@ -568,10 +568,10 @@ public class BranchDaoTest { ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST)); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isEqualTo(3); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW)).isEqualTo(3); - assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW + 100)).isEqualTo(0); + assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW + 100)).isZero(); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, 0L)).isEqualTo(1); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW)).isEqualTo(1); - assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW + 100)).isEqualTo(0); + assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW + 100)).isZero(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index 7f1c2e7b403..d7a05428468 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -1159,7 +1159,7 @@ public class ComponentDaoTest { Supplier<ComponentQuery.Builder> query = () -> ComponentQuery.builder().setOnProvisionedOnly(true); assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(PROJECT).build())).isEqualTo(1); - assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(Qualifiers.VIEW).build())).isEqualTo(0); + assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(Qualifiers.VIEW).build())).isZero(); assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isEqualTo(1); } @@ -1470,7 +1470,7 @@ public class ComponentDaoTest { assertThat(underTest.countByQuery(dbSession, organization2.getUuid(), ALL_PROJECTS_COMPONENT_QUERY)) .isEqualTo(1); assertThat(underTest.countByQuery(dbSession, "non existent organization uuid", ALL_PROJECTS_COMPONENT_QUERY)) - .isEqualTo(0); + .isZero(); } @Test @@ -1628,7 +1628,7 @@ public class ComponentDaoTest { int count = underTest.countByQuery(dbSession, dbQuery); assertThat(result).isEmpty(); - assertThat(count).isEqualTo(0); + assertThat(count).isZero(); } @Test @@ -1656,7 +1656,7 @@ public class ComponentDaoTest { int count = underTest.countByQuery(dbSession, dbQuery); assertThat(result).isEmpty(); - assertThat(count).isEqualTo(0); + assertThat(count).isZero(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ProjectLinkDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ProjectLinkDaoTest.java index 6d62edf795d..2615c9e7756 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ProjectLinkDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ProjectLinkDaoTest.java @@ -160,7 +160,7 @@ public class ProjectLinkDaoTest { underTest.delete(db.getSession(), link.getUuid()); db.getSession().commit(); - assertThat(db.countRowsOfTable("project_links")).isEqualTo(0); + assertThat(db.countRowsOfTable("project_links")).isZero(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java index e938671731d..e92978a03a2 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java @@ -139,9 +139,9 @@ public class DuplicationDaoTest { Assertions.assertThat(block.getComponentUuid()).isEqualTo(project3.uuid()); Assertions.assertThat(block.getHash()).isEqualTo("bb"); Assertions.assertThat(block.getAnalysisUuid()).isEqualTo(analysis3.getUuid()); - Assertions.assertThat(block.getIndexInFile()).isEqualTo(0); - Assertions.assertThat(block.getStartLine()).isEqualTo(0); - Assertions.assertThat(block.getEndLine()).isEqualTo(0); + Assertions.assertThat(block.getIndexInFile()).isZero(); + Assertions.assertThat(block.getStartLine()).isZero(); + Assertions.assertThat(block.getEndLine()).isZero(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/es/EsQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/es/EsQueueDaoTest.java index 583ea35c1b7..3388967b9ff 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/es/EsQueueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/es/EsQueueDaoTest.java @@ -81,7 +81,7 @@ public class EsQueueDaoTest { underTest.delete(dbSession, esQueueDtos); - assertThat(dbTester.countSql(dbSession, "select count(*) from es_queue")).isEqualTo(0); + assertThat(dbTester.countSql(dbSession, "select count(*) from es_queue")).isZero(); } @Test @@ -115,7 +115,7 @@ public class EsQueueDaoTest { system2.setNow(1_002L); EsQueueDto i3 = underTest.insert(dbSession, EsQueueDto.create("foo", UuidFactoryFast.getInstance().create())); - assertThat(underTest.selectForRecovery(dbSession, 999, LIMIT)).hasSize(0); + assertThat(underTest.selectForRecovery(dbSession, 999, LIMIT)).isEmpty(); assertThat(underTest.selectForRecovery(dbSession, 1_000, LIMIT)) .extracting(EsQueueDto::getUuid) .containsExactly(i1.getUuid()); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDaoTest.java index e536b4b2128..75856b03d47 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDaoTest.java @@ -214,7 +214,7 @@ public class EventDaoTest { underTest.delete(dbTester.getSession(), "E1"); dbTester.commit(); - assertThat(dbTester.countRowsOfTable("events")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("events")).isZero(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java index 6813a473440..554078dce24 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java @@ -269,31 +269,31 @@ public class IssueDaoTest { assertThat(result.stream().mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.BUG.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); - assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.CODE_SMELL.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); - assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.VULNERABILITY.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.CODE_SMELL.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); + assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.VULNERABILITY.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> g.getSeverity().equals("CRITICAL")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); assertThat(result.stream().filter(g -> g.getSeverity().equals("MAJOR")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); - assertThat(result.stream().filter(g -> g.getSeverity().equals("MINOR")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> g.getSeverity().equals("MINOR")).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> g.getStatus().equals("OPEN")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); assertThat(result.stream().filter(g -> g.getStatus().equals("RESOLVED")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); - assertThat(result.stream().filter(g -> g.getStatus().equals("CLOSED")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> g.getStatus().equals("CLOSED")).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> "FALSE-POSITIVE".equals(g.getResolution())).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); assertThat(result.stream().filter(g -> g.getResolution() == null).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); - assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); // test leak result = underTest.selectIssueGroupsByBaseComponent(db.getSession(), file, 999_999_999L); - assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); // test leak using exact creation time of criticalBug2 issue result = underTest.selectIssueGroupsByBaseComponent(db.getSession(), file, criticalBug2.getIssueCreationTime()); - assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(0); + assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java index b69e6327341..3660905b3b2 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java @@ -224,7 +224,7 @@ public class IssueMapperTest { dto.setSelectedAt(1400000000000L); int count = underTest.updateIfBeforeSelectedDate(dto); - assertThat(count).isEqualTo(0); + assertThat(count).isZero(); dbTester.getSession().commit(); // No change diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java index 004a7fc1f94..489b83e4313 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java @@ -498,7 +498,7 @@ public class LiveMeasureDaoTest { // update int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(0); + assertThat(count).isZero(); verifyPersisted(dto); verifyTableSize(1); } @@ -530,7 +530,7 @@ public class LiveMeasureDaoTest { // update int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(0); + assertThat(count).isZero(); verifyPersisted(dto); verifyTableSize(1); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java index 97043ee7491..25169daeeda 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java @@ -59,7 +59,7 @@ public class NotificationQueueDaoTest { public void should_count_notification_queue() { NotificationQueueDto notificationQueueDto = toNotificationQueueDto(new Notification("email")); - assertThat(dao.count()).isEqualTo(0); + assertThat(dao.count()).isZero(); dao.insert(Arrays.asList(notificationQueueDto)); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java index c10fb8533d1..3f602c4a785 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java @@ -565,7 +565,7 @@ public class GroupPermissionDaoTest { underTest.deleteByRootComponentUuid(dbSession, project1.uuid()); dbSession.commit(); - assertThat(db.countSql("select count(uuid) from group_roles where component_uuid='" + project1.uuid() + "'")).isEqualTo(0); + assertThat(db.countSql("select count(uuid) from group_roles where component_uuid='" + project1.uuid() + "'")).isZero(); assertThat(db.countRowsOfTable("group_roles")).isEqualTo(2); } @@ -584,7 +584,7 @@ public class GroupPermissionDaoTest { underTest.deleteByRootComponentUuid(dbSession, project1.uuid()); dbSession.commit(); - assertThat(db.countSql("select count(uuid) from group_roles where component_uuid='" + project1.uuid() + "'")).isEqualTo(0); + assertThat(db.countSql("select count(uuid) from group_roles where component_uuid='" + project1.uuid() + "'")).isZero(); assertThat(db.countRowsOfTable("group_roles")).isEqualTo(3); } @@ -770,8 +770,8 @@ public class GroupPermissionDaoTest { public void deleteByRootComponentUuidAndGroupUuid_has_no_effect_if_component_does_not_exist() { GroupDto group = db.users().insertGroup(); - assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, "1234", null)).isEqualTo(0); - assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, "1234", group.getUuid())).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, "1234", null)).isZero(); + assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, "1234", group.getUuid())).isZero(); } @Test @@ -779,15 +779,15 @@ public class GroupPermissionDaoTest { ComponentDto project = randomPublicOrPrivateProject(); GroupDto group = db.users().insertGroup(); - assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), null)).isEqualTo(0); - assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), group.getUuid())).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), null)).isZero(); + assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), group.getUuid())).isZero(); } @Test public void deleteByRootComponentUuidAndGroupUuid_has_no_effect_if_group_does_not_exist() { ComponentDto project = randomPublicOrPrivateProject(); - assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), "5678")).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), "5678")).isZero(); } @Test @@ -804,7 +804,7 @@ public class GroupPermissionDaoTest { int deletedCount = underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), null); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, null, project.uuid())) .isEmpty(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, group1.getUuid(), project.uuid())) @@ -826,7 +826,7 @@ public class GroupPermissionDaoTest { int deletedCount = underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, project.uuid(), group2.getUuid()); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, group1.getUuid(), project.uuid())) .containsOnly("p1"); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, group2.getUuid(), project.uuid())) @@ -876,7 +876,7 @@ public class GroupPermissionDaoTest { db.users().insertPermissionOnAnyone("p1"); db.users().insertPermissionOnGroup(group, "p1"); - assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, project.uuid(), "p1")).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, project.uuid(), "p1")).isZero(); assertThat(getGlobalPermissionsForAnyone()).containsOnly("p1"); assertThat(getGlobalPermissionsForGroup(group)).containsOnly("p1"); @@ -893,7 +893,7 @@ public class GroupPermissionDaoTest { db.users().insertProjectPermissionOnGroup(group, "p1", project); db.users().insertProjectPermissionOnAnyone("p1", project); - assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, "1324", "p1")).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, "1324", "p1")).isZero(); assertThat(getGlobalPermissionsForAnyone()).containsOnly("p1"); assertThat(getGlobalPermissionsForGroup(group)).containsOnly("p1"); @@ -908,7 +908,7 @@ public class GroupPermissionDaoTest { db.users().insertPermissionOnAnyone("p1"); db.users().insertPermissionOnGroup(group, "p1"); - assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, project.uuid(), "p1")).isEqualTo(0); + assertThat(underTest.deleteByRootComponentUuidAndPermission(dbSession, project.uuid(), "p1")).isZero(); } private Collection<String> getGlobalPermissionsForAnyone() { @@ -945,7 +945,7 @@ public class GroupPermissionDaoTest { } private void assertThatNoPermission(String permission) { - assertThat(db.countSql("select count(uuid) from group_roles where role='" + permission + "'")).isEqualTo(0); + assertThat(db.countSql("select count(uuid) from group_roles where role='" + permission + "'")).isZero(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/PermissionQueryTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/PermissionQueryTest.java index 0b200fe912b..1fbce9a9e9a 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/PermissionQueryTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/PermissionQueryTest.java @@ -65,7 +65,7 @@ public class PermissionQueryTest { PermissionQuery query = PermissionQuery.builder() .build(); - assertThat(query.getPageOffset()).isEqualTo(0); + assertThat(query.getPageOffset()).isZero(); assertThat(query.getPageSize()).isEqualTo(20); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java index b27de1c0ad7..253dbbd4de2 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java @@ -381,7 +381,7 @@ public class UserPermissionDaoTest { // global permission exists -> delete it, but not the project permission with the same name ! underTest.deleteGlobalPermission(dbSession, user1.getUuid(), "perm1"); - assertThat(db.countSql(dbSession, "select count(uuid) from user_roles where role='perm1' and component_uuid is null")).isEqualTo(0); + assertThat(db.countSql(dbSession, "select count(uuid) from user_roles where role='perm1' and component_uuid is null")).isZero(); assertThat(db.countRowsOfTable(dbSession, "user_roles")).isEqualTo(4); } @@ -523,7 +523,7 @@ public class UserPermissionDaoTest { int deletedCount = underTest.deleteProjectPermissionOfAnyUser(dbSession, "124", SCAN.getKey()); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectGlobalPermissionsOfUser(dbSession, user.getUuid())).containsOnly(SCAN.getKey()); } @@ -535,7 +535,7 @@ public class UserPermissionDaoTest { int deletedCount = underTest.deleteProjectPermissionOfAnyUser(dbSession, project.uuid(), SCAN.getKey()); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectGlobalPermissionsOfUser(dbSession, user.getUuid())).containsOnly(SCAN.getKey()); } @@ -548,7 +548,7 @@ public class UserPermissionDaoTest { int deletedCount = underTest.deleteProjectPermissionOfAnyUser(dbSession, project.uuid(), "p1"); - assertThat(deletedCount).isEqualTo(0); + assertThat(deletedCount).isZero(); assertThat(underTest.selectGlobalPermissionsOfUser(dbSession, user.getUuid())).containsOnly(SCAN.getKey()); assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user.getUuid(), project.uuid())).containsOnly(SCAN.getKey()); } @@ -647,11 +647,11 @@ public class UserPermissionDaoTest { private void assertThatProjectPermissionDoesNotExist(UserDto user, String permission, ComponentDto project) { assertThat(db.countSql(dbSession, "select count(uuid) from user_roles where role='" + permission + "' and user_uuid='" + user.getUuid() + "' and component_uuid='" + project.uuid() + "'")) - .isEqualTo(0); + .isZero(); } private void assertThatProjectHasNoPermissions(ComponentDto project) { - assertThat(db.countSql(dbSession, "select count(uuid) from user_roles where component_uuid='" + project.uuid() + "'")).isEqualTo(0); + assertThat(db.countSql(dbSession, "select count(uuid) from user_roles where component_uuid='" + project.uuid() + "'")).isZero(); } private void assertGlobalPermissionsOfUser(UserDto user, GlobalPermission... permissions) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java index 1277cc03065..0d451498d13 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java @@ -172,7 +172,7 @@ public class ProjectDaoTest { projectDao.insert(db.getSession(), dto3); List<ProjectDto> projectsByUuids = projectDao.selectByUuids(db.getSession(), Collections.emptySet()); - assertThat(projectsByUuids).hasSize(0); + assertThat(projectsByUuids).isEmpty(); } private void assertProject(ProjectDto dto, String name, String kee, String org, String uuid, String desc, @Nullable String tags, boolean isPrivate) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java index ea01da4cdf1..366f3cd8147 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java @@ -165,7 +165,7 @@ public class InternalComponentPropertiesDaoTest { public void delete_by_component_uuid_and_key_does_nothing_if_property_doesnt_exist() { saveDto(); - assertThat(underTest.deleteByComponentUuid(dbSession, "other_component")).isEqualTo(0); + assertThat(underTest.deleteByComponentUuid(dbSession, "other_component")).isZero(); assertThat(underTest.selectByComponentUuidAndKey(dbSession, SOME_COMPONENT, SOME_KEY)).isNotEmpty(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index 1c94f954b0c..80810c1917b 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -248,10 +248,10 @@ public class PurgeDaoTest { IssueDto openOnEnabledComponent = db.issues().insert(rule, project, enabledFile, issue -> issue.setStatus("OPEN")); IssueDto confirmOnEnabledComponent = db.issues().insert(rule, project, enabledFile, issue -> issue.setStatus("CONFIRM")); - assertThat(db.countSql("select count(*) from snapshots where purge_status = 1")).isEqualTo(0); + assertThat(db.countSql("select count(*) from snapshots where purge_status = 1")).isZero(); - assertThat(db.countSql("select count(*) from issues where status = 'CLOSED'")).isEqualTo(0); - assertThat(db.countSql("select count(*) from issues where resolution = 'REMOVED'")).isEqualTo(0); + assertThat(db.countSql("select count(*) from issues where status = 'CLOSED'")).isZero(); + assertThat(db.countSql("select count(*) from issues where resolution = 'REMOVED'")).isZero(); db.fileSources().insertFileSource(srcFile); FileSourceDto nonSelectedFileSource = db.fileSources().insertFileSource(enabledFile); @@ -826,7 +826,7 @@ public class PurgeDaoTest { dbSession.commit(); assertThat(db.countRowsOfTable("ce_queue")).isEqualTo(1); - assertThat(db.countSql("select count(*) from ce_queue where main_component_uuid='" + projectToBeDeleted.uuid() + "'")).isEqualTo(0); + assertThat(db.countSql("select count(*) from ce_queue where main_component_uuid='" + projectToBeDeleted.uuid() + "'")).isZero(); } @Test @@ -1160,7 +1160,7 @@ public class PurgeDaoTest { assertThat(selectActivity("VERY_OLD_1")).isEmpty(); assertThat(selectTaskInput("VERY_OLD_1")).isEmpty(); - assertThat(selectTaskCharacteristic("VERY_OLD_1")).hasSize(0); + assertThat(selectTaskCharacteristic("VERY_OLD_1")).isEmpty(); assertThat(scannerContextExists("VERY_OLD_1")).isFalse(); assertThat(selectActivity("VERY_OLD_2")).isNotEmpty(); assertThat(selectTaskInput("VERY_OLD_2")).isNotEmpty(); @@ -1169,7 +1169,7 @@ public class PurgeDaoTest { assertThat(selectActivity("JUST_OLD_ENOUGH_1")).isEmpty(); assertThat(selectTaskInput("JUST_OLD_ENOUGH_1")).isEmpty(); - assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH_1")).hasSize(0); + assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH_1")).isEmpty(); assertThat(scannerContextExists("JUST_OLD_ENOUGH_1")).isFalse(); assertThat(selectActivity("JUST_OLD_ENOUGH_2")).isNotEmpty(); assertThat(selectTaskInput("JUST_OLD_ENOUGH_2")).isNotEmpty(); @@ -1218,7 +1218,7 @@ public class PurgeDaoTest { assertThat(selectActivity("VERY_OLD_1")).isEmpty(); assertThat(selectTaskInput("VERY_OLD_1")).isEmpty(); - assertThat(selectTaskCharacteristic("VERY_OLD_1")).hasSize(0); + assertThat(selectTaskCharacteristic("VERY_OLD_1")).isEmpty(); assertThat(scannerContextExists("VERY_OLD_1")).isFalse(); assertThat(selectActivity("VERY_OLD_2")).isEmpty(); assertThat(selectTaskInput("VERY_OLD_2")).isEmpty(); @@ -1227,7 +1227,7 @@ public class PurgeDaoTest { assertThat(selectActivity("JUST_OLD_ENOUGH_1")).isEmpty(); assertThat(selectTaskInput("JUST_OLD_ENOUGH_1")).isEmpty(); - assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH_1")).hasSize(0); + assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH_1")).isEmpty(); assertThat(scannerContextExists("JUST_OLD_ENOUGH_1")).isFalse(); assertThat(selectActivity("JUST_OLD_ENOUGH_2")).isEmpty(); assertThat(selectTaskInput("JUST_OLD_ENOUGH_2")).isEmpty(); @@ -1561,12 +1561,12 @@ public class PurgeDaoTest { assertThat(selectActivity("VERY_OLD")).isEmpty(); assertThat(selectTaskInput("VERY_OLD")).isEmpty(); - assertThat(selectTaskCharacteristic("VERY_OLD")).hasSize(0); + assertThat(selectTaskCharacteristic("VERY_OLD")).isEmpty(); assertThat(scannerContextExists("VERY_OLD")).isFalse(); assertThat(selectActivity("JUST_OLD_ENOUGH")).isEmpty(); assertThat(selectTaskInput("JUST_OLD_ENOUGH")).isEmpty(); - assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH")).hasSize(0); + assertThat(selectTaskCharacteristic("JUST_OLD_ENOUGH")).isEmpty(); assertThat(scannerContextExists("JUST_OLD_ENOUGH")).isFalse(); assertThat(selectActivity("NOT_OLD_ENOUGH")).isNotEmpty(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java index 20ce6764f80..5a81dd9421f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java @@ -526,7 +526,7 @@ public class ActiveRuleDaoTest { underTest.deleteParam(dbSession, param); - assertThat(underTest.selectParamsByActiveRuleUuid(dbSession, activeRule.getUuid())).hasSize(0); + assertThat(underTest.selectParamsByActiveRuleUuid(dbSession, activeRule.getUuid())).isEmpty(); } @Test @@ -593,7 +593,7 @@ public class ActiveRuleDaoTest { underTest.deleteParamsByActiveRuleUuids(dbSession, singletonList(ar1.getUuid())); - assertThat(underTest.selectParamsByActiveRuleUuid(dbSession, ar1.getUuid())).hasSize(0); + assertThat(underTest.selectParamsByActiveRuleUuid(dbSession, ar1.getUuid())).isEmpty(); assertThat(underTest.selectParamsByActiveRuleUuid(dbSession, ar2.getUuid())).hasSize(1); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java index 18c9815f66c..f6f2d0c4451 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java @@ -198,11 +198,11 @@ public class QProfileChangeDaoTest { assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isEqualTo(2); assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isEqualTo(1); - assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery("does_not_exist"))).isEqualTo(0); + assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery("does_not_exist"))).isZero(); QProfileChangeQuery query = new QProfileChangeQuery(profile1.getKee()); query.setToExcluded(start); - assertThat(underTest.countByQuery(dbSession, query)).isEqualTo(0); + assertThat(underTest.countByQuery(dbSession, query)).isZero(); QProfileChangeQuery query2 = new QProfileChangeQuery(profile1.getKee()); query2.setToExcluded(end); @@ -219,7 +219,7 @@ public class QProfileChangeDaoTest { underTest.deleteByRulesProfileUuids(dbSession, asList(profile1.getRulesProfileUuid())); - assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isEqualTo(0); + assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isZero(); assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isEqualTo(1); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java index 0f45bb7f4db..c4b78983b83 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java @@ -448,7 +448,7 @@ public class RuleDaoTest { assertThat(ruleDto.getRuleKey()).isEqualTo("NewRuleKey"); assertThat(ruleDto.getRepositoryKey()).isEqualTo("plugin"); assertThat(ruleDto.getConfigKey()).isEqualTo("NewConfigKey"); - assertThat(ruleDto.getSeverity()).isEqualTo(0); + assertThat(ruleDto.getSeverity()).isZero(); assertThat(ruleDto.getLanguage()).isEqualTo("dart"); assertThat(ruleDto.isTemplate()).isTrue(); assertThat(ruleDto.isExternal()).isTrue(); @@ -505,7 +505,7 @@ public class RuleDaoTest { assertThat(ruleDto.getRuleKey()).isEqualTo("NewRuleKey"); assertThat(ruleDto.getRepositoryKey()).isEqualTo("plugin"); assertThat(ruleDto.getConfigKey()).isEqualTo("NewConfigKey"); - assertThat(ruleDto.getSeverity()).isEqualTo(0); + assertThat(ruleDto.getSeverity()).isZero(); assertThat(ruleDto.getLanguage()).isEqualTo("dart"); assertThat(ruleDto.isTemplate()).isTrue(); assertThat(ruleDto.isExternal()).isTrue(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java index b047b2c3481..d348092715e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java @@ -141,7 +141,7 @@ public class RuleRepositoryDaoTest { RuleRepositoryDto dto1 = new RuleRepositoryDto("findbugs", "java", "Findbugs"); underTest.insertOrUpdate(dbSession, asList(dto1)); - assertThat(underTest.selectByLanguage(dbSession, "missing")).hasSize(0); + assertThat(underTest.selectByLanguage(dbSession, "missing")).isEmpty(); } private long selectCreatedAtByKey(DbSession dbSession, String key) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java index 0acd7441556..25052001869 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java @@ -163,7 +163,7 @@ public class FileSourceDaoTest { FileSourceDto res = underTest.selectByFileUuid(dbSession, fileSourceDto.getFileUuid()); - assertThat(res.getLineCount()).isEqualTo(0); + assertThat(res.getLineCount()).isZero(); assertThat(res.getLineHashes()).isEmpty(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java index 671922b5e83..5f4ce8a4e22 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java @@ -216,6 +216,6 @@ public class GroupDaoTest { underTest.deleteByUuid(dbSession, aGroup.getUuid()); - assertThat(db.countRowsOfTable(dbSession, "groups")).isEqualTo(0); + assertThat(db.countRowsOfTable(dbSession, "groups")).isZero(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java index 41989df68b3..e4fecb88010 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -214,7 +214,7 @@ public class UserDaoTest { @Test public void countRootUsersButLogin_returns_0_when_there_is_no_user_at_all() { - assertThat(underTest.countRootUsersButLogin(session, "bla")).isEqualTo(0); + assertThat(underTest.countRootUsersButLogin(session, "bla")).isZero(); } @Test @@ -222,7 +222,7 @@ public class UserDaoTest { underTest.insert(session, newUserDto()); session.commit(); - assertThat(underTest.countRootUsersButLogin(session, "bla")).isEqualTo(0); + assertThat(underTest.countRootUsersButLogin(session, "bla")).isZero(); } @Test @@ -231,7 +231,7 @@ public class UserDaoTest { insertInactiveRootUser(newUserDto()); session.commit(); - assertThat(underTest.countRootUsersButLogin(session, "bla")).isEqualTo(0); + assertThat(underTest.countRootUsersButLogin(session, "bla")).isZero(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java index c6b67a5dd2e..96c999c6c87 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java @@ -225,7 +225,7 @@ public class WebhookDeliveryDaoTest { public void deleteComponentBeforeDate_does_nothing_on_empty_table() { underTest.deleteComponentBeforeDate(dbSession, "COMPONENT_1", 1_500_000L); - assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isEqualTo(0); + assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isZero(); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerImplTest.java index b34233ddef2..e55d53fa1e5 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerImplTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerImplTest.java @@ -48,7 +48,7 @@ public class MigrationContainerImplTest { @Test public void migration_container_lazily_instance_components() { - assertThat(StartCallCounter.startCalls).isEqualTo(0); + assertThat(StartCallCounter.startCalls).isZero(); StartCallCounter startCallCounter = underTest.getComponentByType(StartCallCounter.class); diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java index 5e7583788af..2dbf7a765db 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java @@ -68,7 +68,7 @@ public class MigrationHistoryTableImplTest { } private void verifyTable() { - assertThat(dbTester.countRowsOfTable(TABLE_SCHEMA_MIGRATIONS)).isEqualTo(0); + assertThat(dbTester.countRowsOfTable(TABLE_SCHEMA_MIGRATIONS)).isZero(); dbTester.assertColumnDefinition(TABLE_SCHEMA_MIGRATIONS, "version", Types.VARCHAR, 255, false); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/UpsertImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/UpsertImplTest.java index 9066de0f911..43e5c5ffea5 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/UpsertImplTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/UpsertImplTest.java @@ -48,7 +48,7 @@ public class UpsertImplTest { underTest.setBatchSize(0); - assertThat(underTest.getMaxBatchSize()).isEqualTo(0); + assertThat(underTest.getMaxBatchSize()).isZero(); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java index d02519e4d1b..8e4df77962a 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java @@ -74,7 +74,7 @@ public class PopulateNewCodePeriodTableTest { insertProperty(0, "2019-04-05"); underTest.execute(); - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(0); + assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isZero(); } @Test @@ -82,7 +82,7 @@ public class PopulateNewCodePeriodTableTest { insertProperty(null, "2.0"); underTest.execute(); - assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isEqualTo(0); + assertThat(dbTester.countRowsOfTable(NEW_CODE_PERIODS_TABLE_NAME)).isZero(); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java index 0049edf67e5..43795e4ca5b 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/AddExcludeBranchFromPurgeColumnTest.java @@ -75,7 +75,7 @@ public class AddExcludeBranchFromPurgeColumnTest { } private void verifyMigrationResult() { - assertThat(dbTester.countSql("select count(*) from " + TABLE + " where exclude_from_purge = true")).isEqualTo(0); + assertThat(dbTester.countSql("select count(*) from " + TABLE + " where exclude_from_purge = true")).isZero(); assertThat(dbTester.countSql("select count(*) from " + TABLE + " where exclude_from_purge = false")).isEqualTo(8); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java index 57e4e507fbb..b9e963d688e 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateDefaultBranchesToKeepSettingTest.java @@ -126,7 +126,7 @@ public class MigrateDefaultBranchesToKeepSettingTest { private void verifyMigrationOfDefaultSetting(String expectedValue) { assertThat(dbTester.countRowsOfTable(PROPS_TABLE)).isEqualTo(4); - assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.branch.longLivedBranches.regex'")).isEqualTo(0); + assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.branch.longLivedBranches.regex'")).isZero(); assertThat(dbTester.countSql("select count(*) from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'")).isEqualTo(1); assertThat(dbTester.select("select resource_id, text_value from " + PROPS_TABLE + " where prop_key = 'sonar.dbcleaner.branchesToKeepWhenInactive'") .stream() diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java index 8d2854281e3..81f3c41e257 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeInCeTasksTest.java @@ -73,7 +73,7 @@ public class MigrateSlbsAndLlbsToCommonTypeInCeTasksTest { private void verifyMigrationResult() { assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(8); - assertThat(dbTester.countSql("select count(*) from " + TABLE + " where kee = 'branchType' and text_value in ('LONG', 'SHORT')")).isEqualTo(0); + assertThat(dbTester.countSql("select count(*) from " + TABLE + " where kee = 'branchType' and text_value in ('LONG', 'SHORT')")).isZero(); assertThat(dbTester.select("select uuid from " + TABLE + " where kee = 'branchType' and text_value = 'BRANCH'") .stream() .map(e -> e.get("UUID")) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java index 1cd8545c4c8..1deba5caeca 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateSlbsAndLlbsToCommonTypeTest.java @@ -80,7 +80,7 @@ public class MigrateSlbsAndLlbsToCommonTypeTest { private void verifyMigrationResult() { assertThat(dbTester.countRowsOfTable(BRANCHES_TABLE)).isEqualTo(8); - assertThat(dbTester.countSql("select count(*) from project_branches where branch_type = 'LONG' or branch_type = 'SHORT'")).isEqualTo(0); + assertThat(dbTester.countSql("select count(*) from project_branches where branch_type = 'LONG' or branch_type = 'SHORT'")).isZero(); assertThat(dbTester.select("select uuid from " + BRANCHES_TABLE + " where branch_type = 'BRANCH'") .stream() .map(e -> e.get("UUID")) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java index 4d84868b83b..0a36571bb9d 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RenameDaysBeforeDeletingInactiveSLBSettingTest.java @@ -82,7 +82,7 @@ public class RenameDaysBeforeDeletingInactiveSLBSettingTest { int numberOfPropsWithNewName = dbTester.countSql("select count(*) from " + TABLE + " where prop_key = '" + NEW_PROPERTY_NAME + "'"); int numberOfPropsWithOldName = dbTester.countSql("select count(*) from " + TABLE + " where prop_key = '" + OLD_PROPERTY_NAME + "'"); assertThat(numberOfPropsWithNewName).isEqualTo(TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 1); - assertThat(numberOfPropsWithOldName).isEqualTo(0); + assertThat(numberOfPropsWithOldName).isZero(); } private void insertProperty(@Nullable Long projectId, String propertyKey, String propertyValue) { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java index c753636a229..27a0c5a704c 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/EnsureHotspotDefaultStatusIsToReviewTest.java @@ -55,7 +55,7 @@ public class EnsureHotspotDefaultStatusIsToReviewTest { public void does_not_fail_if_table_is_empty() throws SQLException { underTest.execute(); - assertThat(db.countRowsOfTable("issues")).isEqualTo(0); + assertThat(db.countRowsOfTable("issues")).isZero(); } @Test diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsLoggingTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsLoggingTest.java index c78627d1c78..7e6a9e2ee9b 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsLoggingTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsLoggingTest.java @@ -104,7 +104,7 @@ public class EsLoggingTest { } private static Props newProps(String... propertyKeysAndValues) { - assertThat(propertyKeysAndValues.length % 2).describedAs("Number of parameters must be even").isEqualTo(0); + assertThat(propertyKeysAndValues.length % 2).describedAs("Number of parameters must be even").isZero(); Properties properties = new Properties(); for (int i = 0; i < propertyKeysAndValues.length; i++) { properties.put(propertyKeysAndValues[i++], propertyKeysAndValues[i]); @@ -114,9 +114,9 @@ public class EsLoggingTest { private void verifyProperties(Properties properties, String... expectedPropertyKeysAndValuesOrdered) { if (expectedPropertyKeysAndValuesOrdered.length == 0) { - assertThat(properties.size()).isEqualTo(0); + assertThat(properties.size()).isZero(); } else { - assertThat(expectedPropertyKeysAndValuesOrdered.length % 2).describedAs("Number of parameters must be even").isEqualTo(0); + assertThat(expectedPropertyKeysAndValuesOrdered.length % 2).describedAs("Number of parameters must be even").isZero(); Set<String> keys = new HashSet<>(expectedPropertyKeysAndValuesOrdered.length / 2 + 1); keys.add("status"); for (int i = 0; i < expectedPropertyKeysAndValuesOrdered.length; i++) { diff --git a/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java index 1a70413b89b..dc4a362796b 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java +++ b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java @@ -268,7 +268,7 @@ public class FileUtils2Test { public void sizeOf_is_zero_on_empty_files() throws IOException { File file = temporaryFolder.newFile(); - assertThat(FileUtils2.sizeOf(file.toPath())).isEqualTo(0); + assertThat(FileUtils2.sizeOf(file.toPath())).isZero(); } @Test diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java index c944cb2e583..e98fdbfba6f 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java @@ -482,7 +482,7 @@ public class Log4JPropertiesBuilderTest { private static Log4JPropertiesBuilder newLog4JPropertiesBuilder(String... propertyKeysAndValues) { Properties properties = new Properties(); - assertThat(propertyKeysAndValues.length % 2).describedAs("propertyKeysAndValues must have even length").isEqualTo(0); + assertThat(propertyKeysAndValues.length % 2).describedAs("propertyKeysAndValues must have even length").isZero(); for (int i = 0; i < propertyKeysAndValues.length; i++) { properties.put(propertyKeysAndValues[i++], propertyKeysAndValues[i]); } @@ -534,7 +534,7 @@ public class Log4JPropertiesBuilderTest { if (expectedPropertyKeysAndValuesOrdered.length == 0) { assertThat(properties.size()).isEqualTo(1); } else { - assertThat(expectedPropertyKeysAndValuesOrdered.length % 2).describedAs("Number of parameters must be even").isEqualTo(0); + assertThat(expectedPropertyKeysAndValuesOrdered.length % 2).describedAs("Number of parameters must be even").isZero(); Set<String> keys = new HashSet<>(expectedPropertyKeysAndValuesOrdered.length / 2 + 1); keys.add("status"); for (int i = 0; i < expectedPropertyKeysAndValuesOrdered.length; i++) { diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java index a16c33ddeee..63d5d66b3ee 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java @@ -70,7 +70,7 @@ public class LogLevelConfigTest { assertThat(underTest.getConfiguredByProperties()).hasSize(1); assertThat(underTest.getConfiguredByProperties().get(rootLoggerName)) .containsExactly("sonar.log.level", "sonar.log.level.es"); - assertThat(underTest.getConfiguredByHardcodedLevel()).hasSize(0); + assertThat(underTest.getConfiguredByHardcodedLevel()).isEmpty(); } @Test @@ -132,7 +132,7 @@ public class LogLevelConfigTest { assertThat(underTest.getConfiguredByProperties()).hasSize(1); assertThat(underTest.getConfiguredByProperties().get("foo")) .containsExactly("sonar.log.level", "sonar.log.level.web", "sonar.log.level.web.sql"); - assertThat(underTest.getConfiguredByHardcodedLevel()).hasSize(0); + assertThat(underTest.getConfiguredByHardcodedLevel()).isEmpty(); } @Test diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java index 3fa05bebd51..ec66760a137 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java @@ -165,7 +165,7 @@ public class LogbackHelperTest { julLogger.severe("Message1"); // JUL bridge has not been initialized, nothing in logs - assertThat(memoryAppender.getLogs()).hasSize(0); + assertThat(memoryAppender.getLogs()).isEmpty(); // Enabling JUL bridge LoggerContextListener propagator = underTest.enableJulChangePropagation(ctx); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java index 11fe9a7ac0e..30073889618 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java @@ -228,7 +228,7 @@ public class ComponentIndexerTest { result = recover(); assertThat(result.getTotal()).isEqualTo(1L); assertThat(result.getFailures()).isEqualTo(1L); - assertThat(es.countDocuments(TYPE_COMPONENT)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_COMPONENT)).isZero(); es.unlockWrites(TYPE_COMPONENT); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerConcurrentRequestCalculationTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerConcurrentRequestCalculationTest.java index 0e0874fd2d9..8c27c7640fd 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerConcurrentRequestCalculationTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerConcurrentRequestCalculationTest.java @@ -31,13 +31,13 @@ public class BulkIndexerConcurrentRequestCalculationTest { @Test public void should_not_parallelize_if_regular_size() { assertConcurrentRequests(BulkIndexer.Size.REGULAR, cores(4)) - .isEqualTo(0); + .isZero(); } @Test public void should_not_parallelize_if_large_indexing_but_few_cores() { assertConcurrentRequests(BulkIndexer.Size.LARGE, cores(4)) - .isEqualTo(0); + .isZero(); } /** diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerTest.java index 52a0ef0a73b..ea6cbc5821a 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/BulkIndexerTest.java @@ -62,7 +62,7 @@ public class BulkIndexerTest { indexer.start(); indexer.stop(); - assertThat(count()).isEqualTo(0); + assertThat(count()).isZero(); } @Test @@ -73,7 +73,7 @@ public class BulkIndexerTest { indexer.add(newIndexRequest(78)); // request is not sent yet - assertThat(count()).isEqualTo(0); + assertThat(count()).isZero(); // send remaining requests indexer.stop(); @@ -89,7 +89,7 @@ public class BulkIndexerTest { indexer.start(); // replicas are temporarily disabled - assertThat(replicas()).isEqualTo(0); + assertThat(replicas()).isZero(); for (int i = 0; i < 10; i++) { indexer.add(newIndexRequest(i)); @@ -98,7 +98,7 @@ public class BulkIndexerTest { assertThat(result.isSuccess()).isTrue(); assertThat(result.getSuccess()).isEqualTo(10); - assertThat(result.getFailures()).isEqualTo(0); + assertThat(result.getFailures()).isZero(); assertThat(result.getTotal()).isEqualTo(10); assertThat(count()).isEqualTo(10); // replicas are re-enabled diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/IndexingResultTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/IndexingResultTest.java index a9b9a0b7584..63dd2906739 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/es/IndexingResultTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/IndexingResultTest.java @@ -32,9 +32,9 @@ public class IndexingResultTest { @Test public void test_empty() { - assertThat(underTest.getFailures()).isEqualTo(0); - assertThat(underTest.getSuccess()).isEqualTo(0); - assertThat(underTest.getTotal()).isEqualTo(0); + assertThat(underTest.getFailures()).isZero(); + assertThat(underTest.getSuccess()).isZero(); + assertThat(underTest.getTotal()).isZero(); assertThat(underTest.getSuccessRatio()).isEqualTo(1.0, DOUBLE_OFFSET); assertThat(underTest.isSuccess()).isTrue(); } @@ -46,7 +46,7 @@ public class IndexingResultTest { underTest.incrementSuccess(); underTest.incrementSuccess(); - assertThat(underTest.getFailures()).isEqualTo(0); + assertThat(underTest.getFailures()).isZero(); assertThat(underTest.getSuccess()).isEqualTo(2); assertThat(underTest.getTotal()).isEqualTo(2); assertThat(underTest.getSuccessRatio()).isEqualTo(1.0, DOUBLE_OFFSET); @@ -59,7 +59,7 @@ public class IndexingResultTest { underTest.incrementRequests(); assertThat(underTest.getFailures()).isEqualTo(2); - assertThat(underTest.getSuccess()).isEqualTo(0); + assertThat(underTest.getSuccess()).isZero(); assertThat(underTest.getTotal()).isEqualTo(2); assertThat(underTest.getSuccessRatio()).isEqualTo(0.0, DOUBLE_OFFSET); assertThat(underTest.isSuccess()).isFalse(); @@ -82,9 +82,9 @@ public class IndexingResultTest { @Test public void correctness_even_with_no_data() { - assertThat(underTest.getFailures()).isEqualTo(0); - assertThat(underTest.getSuccess()).isEqualTo(0); - assertThat(underTest.getTotal()).isEqualTo(0); + assertThat(underTest.getFailures()).isZero(); + assertThat(underTest.getSuccess()).isZero(); + assertThat(underTest.getTotal()).isZero(); assertThat(underTest.getSuccessRatio()).isEqualTo(1.0); assertThat(underTest.isSuccess()).isTrue(); } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/SearchOptionsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/SearchOptionsTest.java index f0f7f7a27f2..73fd5835db4 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/es/SearchOptionsTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/SearchOptionsTest.java @@ -41,7 +41,7 @@ public class SearchOptionsTest { assertThat(options.getFacets()).isEmpty(); assertThat(options.getFields()).isEmpty(); - assertThat(options.getOffset()).isEqualTo(0); + assertThat(options.getOffset()).isZero(); assertThat(options.getLimit()).isEqualTo(10); assertThat(options.getPage()).isEqualTo(1); } @@ -58,7 +58,7 @@ public class SearchOptionsTest { public void page_starts_at_one() { SearchOptions options = new SearchOptions().setPage(1, 10); assertThat(options.getLimit()).isEqualTo(10); - assertThat(options.getOffset()).isEqualTo(0); + assertThat(options.getOffset()).isZero(); assertThat(options.getPage()).isEqualTo(1); } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesStatisticsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesStatisticsTest.java index 0c85a703e82..8073a816dfe 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesStatisticsTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesStatisticsTest.java @@ -159,7 +159,7 @@ public class NewIssuesStatisticsTest { DistributedMetricStatsInt assigneeDistribution = underTest.getAssigneesStatistics().get(assignee).getDistributedMetricStats(Metric.COMPONENT); Stream.of(globalDistribution, assigneeDistribution) .forEach(distribution -> { - assertThat(distribution.getTotal()).isEqualTo(0); + assertThat(distribution.getTotal()).isZero(); assertThat(distribution.getForLabel(null).isPresent()).isFalse(); }); } @@ -204,7 +204,7 @@ public class NewIssuesStatisticsTest { DistributedMetricStatsInt assigneeDistribution = underTest.getAssigneesStatistics().get(assignee).getDistributedMetricStats(Metric.RULE); Stream.of(globalDistribution, assigneeDistribution) .forEach(distribution -> { - assertThat(distribution.getTotal()).isEqualTo(0); + assertThat(distribution.getTotal()).isZero(); assertThat(distribution.getForLabel(null).isPresent()).isFalse(); }); } @@ -249,14 +249,14 @@ public class NewIssuesStatisticsTest { assignees.forEach(assignee -> { NewIssuesStatistics.Stats stats = underTest.getAssigneesStatistics().get(assignee); DistributedMetricStatsInt assigneeStats = stats.getDistributedMetricStats(Metric.ASSIGNEE); - assertThat(assigneeStats.getOnCurrentAnalysis()).isEqualTo(0); + assertThat(assigneeStats.getOnCurrentAnalysis()).isZero(); assertThat(assigneeStats.getTotal()).isEqualTo(1); assignees.forEach(s -> { Optional<MetricStatsInt> forLabelOpts = assigneeStats.getForLabel(s); if (s.equals(assignee)) { assertThat(forLabelOpts.isPresent()).isTrue(); MetricStatsInt forLabel = forLabelOpts.get(); - assertThat(forLabel.getOnCurrentAnalysis()).isEqualTo(0); + assertThat(forLabel.getOnCurrentAnalysis()).isZero(); assertThat(forLabel.getTotal()).isEqualTo(1); } else { assertThat(forLabelOpts.isPresent()).isFalse(); @@ -270,7 +270,7 @@ public class NewIssuesStatisticsTest { underTest.add(new DefaultIssue().setType(randomRuleTypeExceptHotspot).setAssigneeUuid(null).setNew(new Random().nextBoolean())); DistributedMetricStatsInt globalDistribution = underTest.globalStatistics().getDistributedMetricStats(Metric.ASSIGNEE); - assertThat(globalDistribution.getTotal()).isEqualTo(0); + assertThat(globalDistribution.getTotal()).isZero(); assertThat(globalDistribution.getForLabel(null).isPresent()).isFalse(); assertThat(underTest.getAssigneesStatistics()).isEmpty(); } @@ -308,7 +308,7 @@ public class NewIssuesStatisticsTest { DistributedMetricStatsInt assigneeDistribution = underTest.getAssigneesStatistics().get(assignee).getDistributedMetricStats(Metric.TAG); Stream.of(globalDistribution, assigneeDistribution) .forEach(distribution -> { - assertThat(distribution.getTotal()).isEqualTo(0); + assertThat(distribution.getTotal()).isZero(); assertThat(distribution.getForLabel(null).isPresent()).isFalse(); }); } @@ -328,7 +328,7 @@ public class NewIssuesStatisticsTest { Stream.of(globalDistribution, assigneeDistribution) .forEach(distribution -> { assertThat(distribution.getOnCurrentAnalysis()).isEqualTo(expected); - assertThat(distribution.getOffCurrentAnalysis()).isEqualTo(0); + assertThat(distribution.getOffCurrentAnalysis()).isZero(); assertThat(distribution.getTotal()).isEqualTo(expected); }); } @@ -347,7 +347,7 @@ public class NewIssuesStatisticsTest { MetricStatsLong assigneeDistribution = underTest.getAssigneesStatistics().get(assignee).effort(); Stream.of(globalDistribution, assigneeDistribution) .forEach(distribution -> { - assertThat(distribution.getOnCurrentAnalysis()).isEqualTo(0); + assertThat(distribution.getOnCurrentAnalysis()).isZero(); assertThat(distribution.getOffCurrentAnalysis()).isEqualTo(expected); assertThat(distribution.getTotal()).isEqualTo(expected); }); @@ -361,7 +361,7 @@ public class NewIssuesStatisticsTest { MetricStatsLong globalDistribution = underTest.globalStatistics().effort(); MetricStatsLong assigneeDistribution = underTest.getAssigneesStatistics().get(assignee).effort(); Stream.of(globalDistribution, assigneeDistribution) - .forEach(distribution -> assertThat(distribution.getTotal()).isEqualTo(0)); + .forEach(distribution -> assertThat(distribution.getTotal()).isZero()); } @Test diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java index f8a3dbe9dcb..d03deb7c831 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java @@ -244,7 +244,7 @@ public class ProjectMeasuresIndexerTest { db.getDbClient().purgeDao().deleteProject(db.getSession(), project.uuid()); IndexingResult result = indexProject(project, PROJECT_DELETION); - assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isZero(); assertThat(result.getTotal()).isEqualTo(1L); assertThat(result.getSuccess()).isEqualTo(1L); } @@ -257,7 +257,7 @@ public class ProjectMeasuresIndexerTest { underTest.index(db.getSession(), emptyList()); - assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isZero(); } @Test @@ -273,7 +273,7 @@ public class ProjectMeasuresIndexerTest { result = recover(); assertThat(result.getTotal()).isEqualTo(1L); assertThat(result.getFailures()).isEqualTo(1L); - assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isZero(); assertThatEsQueueTableHasSize(1); es.unlockWrites(TYPE_PROJECT_MEASURES); @@ -292,7 +292,7 @@ public class ProjectMeasuresIndexerTest { underTest.indexOnAnalysis(branch.uuid()); - assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isZero(); } private IndexingResult indexProject(ComponentDto project, ProjectIndexer.Cause cause) { diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java index 7997c3f1f82..7f88a5b4c08 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java @@ -107,7 +107,7 @@ public class DefaultNotificationManagerTest { assertThat(underTest.getChannels()).containsOnly(emailChannel, twitterChannel); underTest = new DefaultNotificationManager(new NotificationChannel[] {}, dbClient); - assertThat(underTest.getChannels()).hasSize(0); + assertThat(underTest.getChannels()).isEmpty(); } @Test @@ -150,7 +150,7 @@ public class DefaultNotificationManagerTest { @Test public void shouldFindNoRecipient() { assertThat(underTest.findSubscribedRecipientsForDispatcher(dispatcher, "uuid_45", new SubscriberPermissionsOnProject(UserRole.USER)).asMap().entrySet()) - .hasSize(0); + .isEmpty(); } @Test diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProviderTest.java index e37f3dd598d..48d6f10f0fa 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProviderTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProviderTest.java @@ -66,12 +66,12 @@ public class ProcessInfoProviderTest { new TestSystemInfoSection("foo"), new TestSystemInfoSection("bar")}); - assertThat(ProcessInfoProvider.provide().getSectionsCount()).isEqualTo(0); + assertThat(ProcessInfoProvider.provide().getSectionsCount()).isZero(); underTest.start(); assertThat(ProcessInfoProvider.provide().getSectionsCount()).isEqualTo(2); underTest.stop(); - assertThat(ProcessInfoProvider.provide().getSectionsCount()).isEqualTo(0); + assertThat(ProcessInfoProvider.provide().getSectionsCount()).isZero(); } } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java index b159e414d40..c67de1a8af6 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java @@ -119,7 +119,7 @@ public class ActiveRuleIndexerTest { underTest.commitAndIndex(db.getSession(), Collections.emptyList()); - assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isZero(); assertThatEsQueueTableIsEmpty(); } @@ -144,7 +144,7 @@ public class ActiveRuleIndexerTest { db.getDbClient().activeRuleDao().delete(db.getSession(), ar.getKey()); commitAndIndex(rule1, ar); - assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isZero(); assertThatEsQueueTableIsEmpty(); } @@ -156,7 +156,7 @@ public class ActiveRuleIndexerTest { underTest.index(db.getSession(), singletonList(item)); assertThatEsQueueTableIsEmpty(); - assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isEqualTo(0); + assertThat(es.countDocuments(TYPE_ACTIVE_RULE)).isZero(); } @Test @@ -184,7 +184,7 @@ public class ActiveRuleIndexerTest { } private void assertThatEsQueueTableIsEmpty() { - assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isZero(); } private void assertThatEsQueueContainsExactly(EsQueueDto expected) { diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java index be13bf85728..0f465d8eeba 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java @@ -324,7 +324,7 @@ public class RuleIndexTest { SearchOptions options = new SearchOptions().addFacets(FACET_TAGS); // do not fail - assertThat(underTest.search(query, options).getTotal()).isEqualTo(0); + assertThat(underTest.search(query, options).getTotal()).isZero(); } @Test diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/SynchronousWebHooksImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/SynchronousWebHooksImplTest.java index 52ac0374bac..b4f52fd565b 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/SynchronousWebHooksImplTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/SynchronousWebHooksImplTest.java @@ -98,7 +98,7 @@ public class SynchronousWebHooksImplTest { underTest.sendProjectAnalysisUpdate(new WebHooks.Analysis(componentDto.uuid(), "1", "#1"), () -> mock); - assertThat(caller.countSent()).isEqualTo(0); + assertThat(caller.countSent()).isZero(); assertThat(logTester.logs(DEBUG)).isEmpty(); verifyZeroInteractions(deliveryStorage); } @@ -109,7 +109,7 @@ public class SynchronousWebHooksImplTest { underTest.sendProjectAnalysisUpdate(new WebHooks.Analysis(componentDto.uuid(), "1", "#1"), () -> mock, taskStatistics); - assertThat(caller.countSent()).isEqualTo(0); + assertThat(caller.countSent()).isZero(); assertThat(logTester.logs(DEBUG)).isEmpty(); verifyZeroInteractions(deliveryStorage); verifyLogStatistics(0, 0); diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java index 57dee7d4e35..80ae43aec20 100644 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java +++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java @@ -252,7 +252,7 @@ public class PluginDownloaderTest { @Test public void getDownloadedPluginFilenames_reads_plugin_info_of_files_in_download_folder() throws Exception { pluginDownloader.start(); - assertThat(pluginDownloader.getDownloadedPlugins()).hasSize(0); + assertThat(pluginDownloader.getDownloadedPlugins()).isEmpty(); File file1 = new File(downloadDir, "file1.jar"); file1.createNewFile(); diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtCsrfVerifierTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtCsrfVerifierTest.java index cfe99b6f942..03fd7671e10 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtCsrfVerifierTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtCsrfVerifierTest.java @@ -167,7 +167,7 @@ public class JwtCsrfVerifierTest { verify(response).addCookie(cookieArgumentCaptor.capture()); Cookie cookie = cookieArgumentCaptor.getValue(); assertThat(cookie.getValue()).isNull(); - assertThat(cookie.getMaxAge()).isEqualTo(0); + assertThat(cookie.getMaxAge()).isZero(); } private void verifyCookie(Cookie cookie) { diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImplTest.java index 70316548b5f..9e33c050632 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImplTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImplTest.java @@ -191,6 +191,6 @@ public class OAuth2AuthenticationParametersImplTest { assertThat(updatedCookie.getName()).isEqualTo(AUTHENTICATION_COOKIE_NAME); assertThat(updatedCookie.getValue()).isNull(); assertThat(updatedCookie.getPath()).isEqualTo("/"); - assertThat(updatedCookie.getMaxAge()).isEqualTo(0); + assertThat(updatedCookie.getMaxAge()).isZero(); } } diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuthCsrfVerifierTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuthCsrfVerifierTest.java index 3689055ffa8..be57dae887c 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuthCsrfVerifierTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuthCsrfVerifierTest.java @@ -83,7 +83,7 @@ public class OAuthCsrfVerifierTest { assertThat(updatedCookie.getName()).isEqualTo("OAUTHSTATE"); assertThat(updatedCookie.getValue()).isNull(); assertThat(updatedCookie.getPath()).isEqualTo("/"); - assertThat(updatedCookie.getMaxAge()).isEqualTo(0); + assertThat(updatedCookie.getMaxAge()).isZero(); } @Test @@ -99,7 +99,7 @@ public class OAuthCsrfVerifierTest { assertThat(updatedCookie.getName()).isEqualTo("OAUTHSTATE"); assertThat(updatedCookie.getValue()).isNull(); assertThat(updatedCookie.getPath()).isEqualTo("/"); - assertThat(updatedCookie.getMaxAge()).isEqualTo(0); + assertThat(updatedCookie.getMaxAge()).isZero(); } @Test diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/ce/http/CeHttpClientImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/ce/http/CeHttpClientImplTest.java index bbd1e5f9b40..0b17ed1b096 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/ce/http/CeHttpClientImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/ce/http/CeHttpClientImplTest.java @@ -77,7 +77,7 @@ public class CeHttpClientImplTest { setUpWithHttpUrl(ProcessId.COMPUTE_ENGINE); Optional<ProtobufSystemInfo.SystemInfo> info = underTest.retrieveSystemInfo(); - assertThat(info.get().getSectionsCount()).isEqualTo(0); + assertThat(info.get().getSectionsCount()).isZero(); } @Test diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java index 39a67cee288..744d312b44a 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java @@ -208,7 +208,7 @@ public class NotificationMediumTest { Settings settings = new MapSettings().setProperty("sonar.notifications.delay", 1L); service = new NotificationService(dbClient); - assertThat(service.getDispatchers()).hasSize(0); + assertThat(service.getDispatchers()).isEmpty(); } @Test diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index 0227e4908f3..d1cad4df23f 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -452,7 +452,7 @@ public class RegisterRulesTest { assertThat(rule1.getDescription()).isEqualTo("Description"); assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name2"), new SearchOptions()).getTotal()).isEqualTo(1); - assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isZero(); } @Test @@ -533,7 +533,7 @@ public class RegisterRulesTest { SearchIdResult<String> searchRule2 = ruleIndex.search(new RuleQuery().setQueryText("Name2"), new SearchOptions()); assertThat(searchRule2.getUuids()).containsOnly(rule2.getUuid()); assertThat(searchRule2.getTotal()).isEqualTo(1); - assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isZero(); } @Test @@ -575,7 +575,7 @@ public class RegisterRulesTest { SearchIdResult<String> searchRule2 = ruleIndex.search(new RuleQuery().setQueryText("Name2"), new SearchOptions()); assertThat(searchRule2.getUuids()).containsOnly(rule2.getUuid()); assertThat(searchRule2.getTotal()).isEqualTo(1); - assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(ruleIndex.search(new RuleQuery().setQueryText("Name1"), new SearchOptions()).getTotal()).isZero(); } @Test @@ -691,7 +691,7 @@ public class RegisterRulesTest { assertThat(rule1.getDescription()).isEqualTo("Desc2"); assertThat(ruleIndex.search(new RuleQuery().setQueryText("Desc2"), new SearchOptions()).getTotal()).isEqualTo(1); - assertThat(ruleIndex.search(new RuleQuery().setQueryText("Desc1"), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(ruleIndex.search(new RuleQuery().setQueryText("Desc1"), new SearchOptions()).getTotal()).isZero(); } @Test @@ -748,7 +748,7 @@ public class RegisterRulesTest { RuleDto rule = dbClient.ruleDao().selectOrFailByKey(db.getSession(), RULE_KEY1); assertThat(rule.getStatus()).isEqualTo(REMOVED); - assertThat(ruleIndex.search(new RuleQuery().setKey(RULE_KEY1.toString()), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(ruleIndex.search(new RuleQuery().setKey(RULE_KEY1.toString()), new SearchOptions()).getTotal()).isZero(); // Re-install rule system.setNow(DATE3.getTime()); @@ -899,7 +899,7 @@ public class RegisterRulesTest { assertThat(dbClient.ruleDao().selectAllDefinitions(db.getSession())).hasSize(1); deprecatedRuleKeys = dbClient.ruleDao().selectAllDeprecatedRuleKeys(db.getSession()); - assertThat(deprecatedRuleKeys).hasSize(0); + assertThat(deprecatedRuleKeys).isEmpty(); } @Test diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java index 4d78374bbd7..2e3e2b9fee0 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java @@ -245,7 +245,7 @@ public class IndexCreatorTest { // keep existing metadata .doesNotContain("Create type metadatas/metadata"); // index has been dropped and re-created - assertThat(es.countDocuments(FakeIndexDefinition.INDEX_TYPE)).isEqualTo(0); + assertThat(es.countDocuments(FakeIndexDefinition.INDEX_TYPE)).isZero(); } private ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappings() { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java index a975d001517..c2e3289101f 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java @@ -105,7 +105,7 @@ public class PermissionIndexerTest { underTest.index(db.getSession(), esQueueDtos); - assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isZero(); assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(1); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java index a8faae732fc..165582467eb 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java @@ -161,7 +161,7 @@ public class ActivityActionTest { .setParam("status", "FAILED,IN_PROGRESS,SUCCESS") .setParam(PARAM_MAX_EXECUTED_AT, "2016-02-15")); - assertThat(activityResponse.getTasksCount()).isEqualTo(0); + assertThat(activityResponse.getTasksCount()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java index 5d47f920fa2..a3038fa8c63 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java @@ -144,8 +144,8 @@ public class ActivityStatusActionTest { public void empty_status() { Ce.ActivityStatusWsResponse result = call(); - assertThat(result.getPending()).isEqualTo(0); - assertThat(result.getFailing()).isEqualTo(0); + assertThat(result.getPending()).isZero(); + assertThat(result.getFailing()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java index ea4df38a0b1..759f86258b8 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java @@ -82,7 +82,7 @@ public class ComponentActionTest { .setParam(PARAM_COMPONENT, project.getKey()) .executeProtobuf(Ce.ComponentResponse.class); - assertThat(response.getQueueCount()).isEqualTo(0); + assertThat(response.getQueueCount()).isZero(); assertThat(response.hasCurrent()).isFalse(); } @@ -167,7 +167,7 @@ public class ComponentActionTest { Ce.ComponentResponse response = ws.newRequest() .setParam(PARAM_COMPONENT, project.getKey()) .executeProtobuf(Ce.ComponentResponse.class); - assertThat(response.getQueueCount()).isEqualTo(0); + assertThat(response.getQueueCount()).isZero(); // T3 is the latest task executed on PROJECT_1 ignoring Canceled ones assertThat(response.hasCurrent()).isTrue(); Ce.Task current = response.getCurrent(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java index 230d59b2012..c161cbb81cd 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java @@ -321,11 +321,11 @@ public class SearchProjectsActionTest { SearchProjectsWsResponse result = call(request); - assertThat(result.getComponentsCount()).isEqualTo(0); + assertThat(result.getComponentsCount()).isZero(); Common.Paging paging = result.getPaging(); assertThat(paging.getPageIndex()).isEqualTo(1); assertThat(paging.getPageSize()).isEqualTo(100); - assertThat(paging.getTotal()).isEqualTo(0); + assertThat(paging.getTotal()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java index 8afb0bff82a..68e98c3f3fb 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java @@ -308,7 +308,7 @@ public class TreeActionTest { assertThat(response.getBaseComponent().getKey()).isEqualTo(project.getDbKey()); assertThat(response.getComponentsList()).isEmpty(); - assertThat(response.getPaging().getTotal()).isEqualTo(0); + assertThat(response.getPaging().getTotal()).isZero(); assertThat(response.getPaging().getPageSize()).isEqualTo(100); assertThat(response.getPaging().getPageIndex()).isEqualTo(1); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java index a4a70e1cc40..d902436a5fd 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java @@ -98,7 +98,7 @@ public class SearchActionTest { public void empty_list() { SearchResponse result = call(); - assertThat(result.getFavoritesCount()).isEqualTo(0); + assertThat(result.getFavoritesCount()).isZero(); assertThat(result.getFavoritesList()).isEmpty(); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java index 3882011f0ef..3e3e655e708 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java @@ -164,7 +164,7 @@ public class WebIssueStorageTest { underTest.save(db.getSession(), singletonList(issue)); assertThat(db.countRowsOfTable("issues")).isEqualTo(1); - assertThat(db.countRowsOfTable("issue_changes")).isEqualTo(0); + assertThat(db.countRowsOfTable("issue_changes")).isZero(); DefaultIssue updated = new DefaultIssue() .setKey(issue.key()) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java index 6aab3109298..9e087c9ff47 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java @@ -250,7 +250,7 @@ public class LiveMeasureComputerImplTest { public void do_nothing_if_project_has_not_been_analyzed() { // project has no snapshots List<QGChangeEvent> result = run(file1, newIncrementalFormula()); - assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isZero(); assertThatProjectNotChanged(result, project); } @@ -258,7 +258,7 @@ public class LiveMeasureComputerImplTest { public void do_nothing_if_input_components_are_empty() { List<QGChangeEvent> result = run(emptyList(), newIncrementalFormula()); - assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isZero(); assertThatProjectNotChanged(result, project); } @@ -507,6 +507,6 @@ public class LiveMeasureComputerImplTest { private void assertThatProjectNotChanged(List<QGChangeEvent> events, ComponentDto project) { assertThat(projectIndexer.hasBeenCalled(project.uuid(), ProjectIndexer.Cause.MEASURE_CHANGE)).isFalse(); - assertThat(events).hasSize(0); + assertThat(events).isEmpty(); } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java index c9d672e0db7..68ace74a17d 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java @@ -98,7 +98,7 @@ public class ComponentActionTest { assertThat(response.getMetrics().getMetricsCount()).isEqualTo(1); assertThat(response.hasPeriod()).isFalse(); - assertThat(response.getPeriods().getPeriodsCount()).isEqualTo(0); + assertThat(response.getPeriods().getPeriodsCount()).isZero(); assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey()); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java index 6080cebae15..4790e657094 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java @@ -524,7 +524,7 @@ public class ComponentTreeActionTest { .executeProtobuf(ComponentTreeWsResponse.class); assertThat(result.getBaseComponent().getKey()).isEqualTo(project.getKey()); - assertThat(result.getComponentsCount()).isEqualTo(0); + assertThat(result.getComponentsCount()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java index ecbaebd9b8c..18b35e2d157 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java @@ -269,7 +269,7 @@ public class SearchActionTest { userSession.setNonRoot(); SearchWsResponse result = call(singletonList(project1.getDbKey()), singletonList(metric.getKey())); - assertThat(result.getMeasuresCount()).isEqualTo(0); + assertThat(result.getMeasuresCount()).isZero(); userSession.setRoot(); result = call(singletonList(project1.getDbKey()), singletonList(metric.getKey())); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java index 3ec17c18333..b2209f6c6a8 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java @@ -119,7 +119,7 @@ public class SearchHistoryActionTest { SearchHistoryResponse result = call(request); assertThat(result.getMeasuresList()).hasSize(1); - assertThat(result.getMeasures(0).getHistoryCount()).isEqualTo(0); + assertThat(result.getMeasures(0).getHistoryCount()).isZero(); assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal) // pagination is applied to the number of analyses diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java index 600efa98b43..9f641537a97 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java @@ -88,7 +88,7 @@ public class CreateActionTest { assertThat(metric.getDomain()).isNull(); assertThat(metric.isUserManaged()).isTrue(); assertThat(metric.isEnabled()).isTrue(); - assertThat(metric.getDirection()).isEqualTo(0); + assertThat(metric.getDirection()).isZero(); assertThat(metric.isQualitative()).isFalse(); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java index 5d487bf550a..3beca41305b 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/UnsetActionTest.java @@ -218,7 +218,7 @@ public class UnsetActionTest { } private void assertTableEmpty() { - assertThat(db.countRowsOfTable(dbSession, "new_code_periods")).isEqualTo(0); + assertThat(db.countRowsOfTable(dbSession, "new_code_periods")).isZero(); } private void assertTableContainsOnly(@Nullable String projectUuid, @Nullable String branchUuid, NewCodePeriodType type, @Nullable String value) { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/NotificationCenterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/NotificationCenterTest.java index c6a2b99afed..512a1324e31 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/NotificationCenterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/NotificationCenterTest.java @@ -67,10 +67,10 @@ public class NotificationCenterTest { assertThat(underTest.getChannels()).hasSize(1); underTest = new NotificationCenter(); - assertThat(underTest.getChannels()).hasSize(0); + assertThat(underTest.getChannels()).isEmpty(); underTest = new NotificationCenter(new NotificationDispatcherMetadata[] {NotificationDispatcherMetadata.create("Dispatcher1").setProperty("global", "true")}); - assertThat(underTest.getChannels()).hasSize(0); + assertThat(underTest.getChannels()).isEmpty(); assertThat(underTest.getDispatcherKeysForProperty("global", null)).hasSize(1); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java index 8cfea6a1501..172669a78db 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java @@ -217,7 +217,7 @@ public class OrganizationDeleterTest { assertThat(db.getDbClient().organizationMemberDao().select(db.getSession(), org.getUuid(), user1.getUuid())).isNotPresent(); assertThat(db.getDbClient().organizationMemberDao().select(db.getSession(), org.getUuid(), user2.getUuid())).isNotPresent(); assertThat(db.getDbClient().organizationMemberDao().select(db.getSession(), otherOrg.getUuid(), user1.getUuid())).isPresent(); - assertThat(userIndex.search(UserQuery.builder().setOrganizationUuid(org.getUuid()).build(), new SearchOptions()).getTotal()).isEqualTo(0); + assertThat(userIndex.search(UserQuery.builder().setOrganizationUuid(org.getUuid()).build(), new SearchOptions()).getTotal()).isZero(); assertThat(userIndex.search(UserQuery.builder().setOrganizationUuid(otherOrg.getUuid()).build(), new SearchOptions()).getTotal()).isEqualTo(1); verify(projectLifeCycleListeners).onProjectsDeleted(emptySet()); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java index 253fccbdbbf..a2052388d4a 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java @@ -68,7 +68,7 @@ public class SearchGlobalPermissionsActionTest extends BasePermissionWsTest<Sear if (permission.getKey().equals(SCAN_EXECUTION)) { assertThat(permission.getUsersCount()).isEqualTo(1); } else { - assertThat(permission.getUsersCount()).isEqualTo(0); + assertThat(permission.getUsersCount()).isZero(); } } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java index 45ceef49382..6211bf2afa0 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java @@ -612,7 +612,7 @@ public class SearchActionTest { assertThat(result.hasPaging()).isTrue(); assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 0); - assertThat(result.getAnalysesCount()).isEqualTo(0); + assertThat(result.getAnalysesCount()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java index d77aa95e4da..8d909e4910e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java @@ -282,7 +282,7 @@ public class ProjectStatusActionTest { .executeProtobuf(ProjectStatusResponse.class); assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE); - assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0); + assertThat(result.getProjectStatus().getConditionsCount()).isZero(); } @Test @@ -296,7 +296,7 @@ public class ProjectStatusActionTest { .executeProtobuf(ProjectStatusResponse.class); assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE); - assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0); + assertThat(result.getProjectStatus().getConditionsCount()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileRuleImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileRuleImplTest.java index f741a145e4a..f774587d03d 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileRuleImplTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileRuleImplTest.java @@ -422,7 +422,7 @@ public class QProfileRuleImplTest { List<ActiveRuleChange> changes = deactivate(profile, rule); verifyNoActiveRules(); - assertThat(changes).hasSize(0); + assertThat(changes).isEmpty(); } @Test @@ -576,7 +576,7 @@ public class QProfileRuleImplTest { List<ActiveRuleChange> changes = activate(childProfile, overrideActivation); assertThatRuleIsUpdated(childProfile, rule, MAJOR, INHERITED, of(param.getName(), "foo")); - assertThat(changes).hasSize(0); + assertThat(changes).isEmpty(); } @Test @@ -702,7 +702,7 @@ public class QProfileRuleImplTest { RuleActivation resetActivation = RuleActivation.createReset(rule.getUuid()); List<ActiveRuleChange> changes = activate(parentProfile, resetActivation); verifyNoActiveRules(); - assertThat(changes).hasSize(0); + assertThat(changes).isEmpty(); } @Test @@ -724,7 +724,7 @@ public class QProfileRuleImplTest { BulkChangeResult bulkChangeResult = underTest.bulkActivateAndCommit(db.getSession(), profile, ruleQuery, MINOR); - assertThat(bulkChangeResult.countFailed()).isEqualTo(0); + assertThat(bulkChangeResult.countFailed()).isZero(); assertThat(bulkChangeResult.countSucceeded()).isEqualTo(bulkSize); assertThat(bulkChangeResult.getChanges()).hasSize(bulkSize); assertThat(db.getDbClient().activeRuleDao().selectByProfile(db.getSession(), profile)).hasSize(bulkSize); @@ -751,7 +751,7 @@ public class QProfileRuleImplTest { BulkChangeResult bulkChangeResult = underTest.bulkActivateAndCommit(db.getSession(), profile, ruleQuery, MINOR); - assertThat(bulkChangeResult.countFailed()).isEqualTo(0); + assertThat(bulkChangeResult.countFailed()).isZero(); assertThat(bulkChangeResult.countSucceeded()).isEqualTo(bulkSize); assertThat(bulkChangeResult.getChanges()).hasSize(bulkSize); assertThat(db.getDbClient().activeRuleDao().selectByProfile(db.getSession(), profile)).hasSize(bulkSize); @@ -759,10 +759,10 @@ public class QProfileRuleImplTest { // Now deactivate all rules bulkChangeResult = underTest.bulkDeactivateAndCommit(db.getSession(), profile, ruleQuery); - assertThat(bulkChangeResult.countFailed()).isEqualTo(0); + assertThat(bulkChangeResult.countFailed()).isZero(); assertThat(bulkChangeResult.countSucceeded()).isEqualTo(bulkSize); assertThat(bulkChangeResult.getChanges()).hasSize(bulkSize); - assertThat(db.getDbClient().activeRuleDao().selectByProfile(db.getSession(), profile)).hasSize(0); + assertThat(db.getDbClient().activeRuleDao().selectByProfile(db.getSession(), profile)).isEmpty(); rules.stream().forEach( r -> assertThatRuleIsNotPresent(profile, r.getDefinition())); } @@ -784,8 +784,8 @@ public class QProfileRuleImplTest { BulkChangeResult bulkChangeResult = underTest.bulkDeactivateAndCommit(db.getSession(), childProfile, ruleQuery); assertThat(bulkChangeResult.countFailed()).isEqualTo(1); - assertThat(bulkChangeResult.countSucceeded()).isEqualTo(0); - assertThat(bulkChangeResult.getChanges()).hasSize(0); + assertThat(bulkChangeResult.countSucceeded()).isZero(); + assertThat(bulkChangeResult.getChanges()).isEmpty(); assertThatRuleIsActivated(parentProfile, rule, null, rule.getSeverityString(), null, emptyMap()); assertThatRuleIsActivated(childProfile, rule, null, rule.getSeverityString(), INHERITED, emptyMap()); } @@ -810,7 +810,7 @@ public class QProfileRuleImplTest { assertThat(result.getChanges()).hasSize(3); assertThat(result.countSucceeded()).isEqualTo(1); - assertThat(result.countFailed()).isEqualTo(0); + assertThat(result.countFailed()).isZero(); // Rule1 must be activated with BLOCKER on all profiles assertThatRuleIsActivated(parentProfile, rule1, null, BLOCKER, null, emptyMap()); @@ -954,7 +954,7 @@ public class QProfileRuleImplTest { } private void verifyNoActiveRules() { - assertThat(db.countRowsOfTable(db.getSession(), "active_rules")).isEqualTo(0); + assertThat(db.countRowsOfTable(db.getSession(), "active_rules")).isZero(); } private RuleDefinitionDto createRule() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index eed8dd286eb..16e3dfd4fc8 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -175,7 +175,7 @@ public class QProfilesWsMediumTest { dbSession.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, profile.getKee())).hasSize(0); + assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, profile.getKee())).isEmpty(); assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, php.getKee())).hasSize(2); } @@ -339,7 +339,7 @@ public class QProfilesWsMediumTest { dbSession.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, profile.getKee())).hasSize(0); + assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, profile.getKee())).isEmpty(); // 1. Activate Rule with query returning 1 hits wsActivateRules.newRequest().setMethod("POST") diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java index 0dd76c5e6a1..0f65e4760aa 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java @@ -147,7 +147,7 @@ public class SearchActionTest { assertThat(response.getTotal()).isEqualTo(0L); assertThat(response.getP()).isEqualTo(1); - assertThat(response.getRulesCount()).isEqualTo(0); + assertThat(response.getRulesCount()).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java index 971b767aefa..936d0ec9afc 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java @@ -83,7 +83,7 @@ public class CheckSecretKeyActionTest { assertThat(definition.isInternal()).isTrue(); assertThat(definition.since()).isEqualTo("6.1"); assertThat(definition.responseExampleAsString()).isNotEmpty(); - assertThat(definition.params()).hasSize(0); + assertThat(definition.params()).isEmpty(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java index ffa3862a6fb..7e18aebf2d5 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java @@ -71,7 +71,7 @@ public class GenerateSecretKeyActionTest { assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isTrue(); assertThat(definition.responseExampleAsString()).isNotEmpty(); - assertThat(definition.params()).hasSize(0); + assertThat(definition.params()).isEmpty(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/DeleteActionTest.java index c0425a33b5e..e18792c4152 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/DeleteActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/DeleteActionTest.java @@ -113,7 +113,7 @@ public class DeleteActionTest { assertThat(reloaded).isEmpty(); int deliveriesCount = deliveryDao.countDeliveriesByWebhookUuid(dbSession, dto.getUuid()); - assertThat(deliveriesCount).isEqualTo(0); + assertThat(deliveriesCount).isZero(); } @@ -136,7 +136,7 @@ public class DeleteActionTest { assertThat(reloaded).isEmpty(); int deliveriesCount = deliveryDao.countDeliveriesByWebhookUuid(dbSession, dto.getUuid()); - assertThat(deliveriesCount).isEqualTo(0); + assertThat(deliveriesCount).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java index a67677fdb0b..592d133ef9c 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java @@ -92,7 +92,7 @@ public class WebhookDeliveriesActionTest { .setParam("componentKey", project.getDbKey()) .executeProtobuf(Webhooks.DeliveriesWsResponse.class); - assertThat(response.getDeliveriesCount()).isEqualTo(0); + assertThat(response.getDeliveriesCount()).isZero(); } @Test @@ -103,7 +103,7 @@ public class WebhookDeliveriesActionTest { .setParam("ceTaskId", "t1") .executeProtobuf(Webhooks.DeliveriesWsResponse.class); - assertThat(response.getDeliveriesCount()).isEqualTo(0); + assertThat(response.getDeliveriesCount()).isZero(); } @Test @@ -114,7 +114,7 @@ public class WebhookDeliveriesActionTest { .setParam("webhook", "t1") .executeProtobuf(Webhooks.DeliveriesWsResponse.class); - assertThat(response.getDeliveriesCount()).isEqualTo(0); + assertThat(response.getDeliveriesCount()).isZero(); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java index 1aa2c1c1864..6d05c75ffd5 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java @@ -219,6 +219,6 @@ public class DefaultIssueTest { issue.addChange(null); - assertThat(issue.changes()).hasSize(0); + assertThat(issue.changes()).isEmpty(); } } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/FieldDiffsTest.java b/sonar-core/src/test/java/org/sonar/core/issue/FieldDiffsTest.java index 752f1125ee1..f4f917b44f6 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/FieldDiffsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/FieldDiffsTest.java @@ -159,16 +159,16 @@ public class FieldDiffsTest { assertThat(diff.newValue()).isEqualTo("FIXED"); diff = diffs.diffs().get("donut"); - assertThat(diff.oldValue()).isEqualTo(null); + assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("new"); diff = diffs.diffs().get("gambas"); - assertThat(diff.oldValue()).isEqualTo(null); + assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("miam"); diff = diffs.diffs().get("acme"); assertThat(diff.oldValue()).isEqualTo("old"); - assertThat(diff.newValue()).isEqualTo(null); + assertThat(diff.newValue()).isNull(); } @Test @@ -191,12 +191,12 @@ public class FieldDiffsTest { assertThat(diffs.diffs()).hasSize(2); FieldDiffs.Diff diff = diffs.diffs().get("severity"); - assertThat(diff.oldValue()).isEqualTo(null); + assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("INFO"); diff = diffs.diffs().get("resolution"); - assertThat(diff.oldValue()).isEqualTo(null); - assertThat(diff.newValue()).isEqualTo(null); + assertThat(diff.oldValue()).isNull(); + assertThat(diff.newValue()).isNull(); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/issue/tracking/BlockRecognizerTest.java b/sonar-core/src/test/java/org/sonar/core/issue/tracking/BlockRecognizerTest.java index 89c17cefed7..4a7ae3600a4 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/tracking/BlockRecognizerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/tracking/BlockRecognizerTest.java @@ -37,7 +37,7 @@ public class BlockRecognizerTest { assertThat(compute(seq("abcde"), seq("abcde"), 4, 4)).isEqualTo(5); assertThat(compute(seq("abcde"), seq("abcd"), 4, 4)).isEqualTo(4); - assertThat(compute(seq("bcde"), seq("abcde"), 4, 4)).isEqualTo(0); + assertThat(compute(seq("bcde"), seq("abcde"), 4, 4)).isZero(); assertThat(compute(seq("bcde"), seq("abcde"), 3, 4)).isEqualTo(4); } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/tracking/TrackerTest.java b/sonar-core/src/test/java/org/sonar/core/issue/tracking/TrackerTest.java index ea06b929239..ed6703835e7 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/tracking/TrackerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/tracking/TrackerTest.java @@ -444,7 +444,7 @@ public class TrackerTest { Issue raw2 = rawInput.createIssue(RULE_MISSING_PACKAGE_INFO, "[com.test:abc] Missing package-info.java in package."); Tracking<Issue, Issue> tracking = tracker.trackNonClosed(rawInput, baseInput); - assertThat(tracking.getUnmatchedBases()).hasSize(0); + assertThat(tracking.getUnmatchedBases()).isEmpty(); assertThat(tracking.baseFor(raw1)).isEqualTo(base2); assertThat(tracking.baseFor(raw2)).isEqualTo(base1); } diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java index c65ec20adaa..b2db57adbeb 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java @@ -44,13 +44,13 @@ public class NullProfilerTest { @Test public void stop_methods_returns_0() { underTest.start(); - assertThat(underTest.stopInfo()).isEqualTo(0); - assertThat(underTest.stopInfo("msg")).isEqualTo(0); - assertThat(underTest.stopDebug()).isEqualTo(0); - assertThat(underTest.stopDebug("msg")).isEqualTo(0); - assertThat(underTest.stopTrace()).isEqualTo(0); - assertThat(underTest.stopTrace("msg")).isEqualTo(0); - assertThat(underTest.stopError("msg")).isEqualTo(0); + assertThat(underTest.stopInfo()).isZero(); + assertThat(underTest.stopInfo("msg")).isZero(); + assertThat(underTest.stopDebug()).isZero(); + assertThat(underTest.stopDebug("msg")).isZero(); + assertThat(underTest.stopTrace()).isZero(); + assertThat(underTest.stopTrace("msg")).isZero(); + assertThat(underTest.stopError("msg")).isZero(); } } diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java index 122c292ec61..a88a9504b08 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java @@ -378,8 +378,8 @@ public class MoreCollectorsTest { @Test public void index_empty_stream_returns_empty_map() { - assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId)).size()).isEqualTo(0); - assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId, MyObj::getText)).size()).isEqualTo(0); + assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId)).size()).isZero(); + assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId, MyObj::getText)).size()).isZero(); } @Test @@ -474,8 +474,8 @@ public class MoreCollectorsTest { @Test public void unorderedIndex_empty_stream_returns_empty_map() { - assertThat(Collections.<MyObj>emptyList().stream().collect(unorderedIndex(MyObj::getId)).size()).isEqualTo(0); - assertThat(Collections.<MyObj>emptyList().stream().collect(unorderedIndex(MyObj::getId, MyObj::getText)).size()).isEqualTo(0); + assertThat(Collections.<MyObj>emptyList().stream().collect(unorderedIndex(MyObj::getId)).size()).isZero(); + assertThat(Collections.<MyObj>emptyList().stream().collect(unorderedIndex(MyObj::getId, MyObj::getText)).size()).isZero(); } @Test @@ -572,7 +572,7 @@ public class MoreCollectorsTest { public void unorderedFlattenIndex_empty_stream_returns_empty_map() { assertThat(Collections.<MyObj2>emptyList().stream() .collect(unorderedFlattenIndex(MyObj2::getId, MyObj2::getTexts)) - .size()).isEqualTo(0); + .size()).isZero(); } @Test diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java index 888b7ea81c7..e9b5c82a50f 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java @@ -177,7 +177,7 @@ public class DefaultInputFileTest { Metadata metadata = new Metadata(2, 2, "", new int[] {0, 10}, new int[] {9, 15}, 16); DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata)); assertThat(file.newPointer(1, 0).line()).isEqualTo(1); - assertThat(file.newPointer(1, 0).lineOffset()).isEqualTo(0); + assertThat(file.newPointer(1, 0).lineOffset()).isZero(); // Don't fail file.newPointer(1, 9); file.newPointer(2, 0); @@ -214,14 +214,14 @@ public class DefaultInputFileTest { Metadata metadata = new Metadata(2, 2, "", new int[] {0, 10}, new int[] {8, 15}, 16); DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata)); assertThat(file.newPointer(0).line()).isEqualTo(1); - assertThat(file.newPointer(0).lineOffset()).isEqualTo(0); + assertThat(file.newPointer(0).lineOffset()).isZero(); assertThat(file.newPointer(9).line()).isEqualTo(1); // Ignore eol characters assertThat(file.newPointer(9).lineOffset()).isEqualTo(8); assertThat(file.newPointer(10).line()).isEqualTo(2); - assertThat(file.newPointer(10).lineOffset()).isEqualTo(0); + assertThat(file.newPointer(10).lineOffset()).isZero(); assertThat(file.newPointer(15).line()).isEqualTo(2); assertThat(file.newPointer(15).lineOffset()).isEqualTo(5); @@ -277,15 +277,15 @@ public class DefaultInputFileTest { DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata)); assertThat(file.selectLine(1).start().line()).isEqualTo(1); - assertThat(file.selectLine(1).start().lineOffset()).isEqualTo(0); + assertThat(file.selectLine(1).start().lineOffset()).isZero(); assertThat(file.selectLine(1).end().line()).isEqualTo(1); assertThat(file.selectLine(1).end().lineOffset()).isEqualTo(9); // Don't fail when selecting empty line assertThat(file.selectLine(3).start().line()).isEqualTo(3); - assertThat(file.selectLine(3).start().lineOffset()).isEqualTo(0); + assertThat(file.selectLine(3).start().lineOffset()).isZero(); assertThat(file.selectLine(3).end().line()).isEqualTo(3); - assertThat(file.selectLine(3).end().lineOffset()).isEqualTo(0); + assertThat(file.selectLine(3).end().lineOffset()).isZero(); try { file.selectLine(5); @@ -301,7 +301,7 @@ public class DefaultInputFileTest { DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata)); TextRange newRange = file.newRange(10, 13); assertThat(newRange.start().line()).isEqualTo(2); - assertThat(newRange.start().lineOffset()).isEqualTo(0); + assertThat(newRange.start().lineOffset()).isZero(); assertThat(newRange.end().line()).isEqualTo(2); assertThat(newRange.end().lineOffset()).isEqualTo(3); } diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java index 00642518985..a1946838ab9 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java @@ -64,7 +64,7 @@ public class FileMetadataTest { Metadata metadata = new FileMetadata(analysisWarnings).readMetadata(new FileInputStream(tempFile), StandardCharsets.UTF_8, tempFile.getName()); assertThat(metadata.lines()).isEqualTo(1); - assertThat(metadata.nonBlankLines()).isEqualTo(0); + assertThat(metadata.nonBlankLines()).isZero(); assertThat(metadata.hash()).isNotEmpty(); assertThat(metadata.originalLineStartOffsets()).containsOnly(0); assertThat(metadata.originalLineEndOffsets()).containsOnly(0); diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java index f4fdc67c8b9..b9bc7ba5612 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java @@ -47,9 +47,9 @@ public class DefaultRulesTest { newRules.add(createRule("key2", "repo", "internal")); DefaultRules rules = new DefaultRules(newRules); - assertThat(rules.findByInternalKey("xx", "xx")).hasSize(0); + assertThat(rules.findByInternalKey("xx", "xx")).isEmpty(); assertThat(rules.find(RuleKey.of("xxx", "xx"))).isNull(); - assertThat(rules.findByRepository("xxxx")).hasSize(0); + assertThat(rules.findByRepository("xxxx")).isEmpty(); } @Test diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java index 6cf2c86c021..0c1014bd093 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java @@ -219,7 +219,7 @@ public class MapSettingsTest { @Test public void default_number_values_are_zero() { Settings settings = new MapSettings(); - assertThat(settings.getInt("foo")).isEqualTo(0); + assertThat(settings.getInt("foo")).isZero(); assertThat(settings.getLong("foo")).isEqualTo(0L); } @@ -471,7 +471,7 @@ public class MapSettingsTest { @Test public void getStringLines_no_value() { - Assertions.assertThat(new MapSettings().getStringLines("foo")).hasSize(0); + Assertions.assertThat(new MapSettings().getStringLines("foo")).isEmpty(); } @Test @@ -517,7 +517,7 @@ public class MapSettingsTest { assertThat(settings.getKeysStartingWith("sonar")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username", "sonar.security"); assertThat(settings.getKeysStartingWith("sonar.jdbc")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username"); - assertThat(settings.getKeysStartingWith("other")).hasSize(0); + assertThat(settings.getKeysStartingWith("other")).isEmpty(); } @Test diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java index a4f2cc322ee..d32a88fb13c 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java @@ -45,8 +45,8 @@ public class WorkDurationTest { public void create_from_value_and_unit() { WorkDuration result = WorkDuration.createFromValueAndUnit(1, WorkDuration.UNIT.DAYS, HOURS_IN_DAY); assertThat(result.days()).isEqualTo(1); - assertThat(result.hours()).isEqualTo(0); - assertThat(result.minutes()).isEqualTo(0); + assertThat(result.hours()).isZero(); + assertThat(result.minutes()).isZero(); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); assertThat(result.toMinutes()).isEqualTo(ONE_DAY_IN_MINUTES); @@ -58,40 +58,40 @@ public class WorkDurationTest { @Test public void create_from_minutes() { WorkDuration workDuration = WorkDuration.createFromMinutes(ONE_MINUTE, HOURS_IN_DAY); - assertThat(workDuration.days()).isEqualTo(0); - assertThat(workDuration.hours()).isEqualTo(0); + assertThat(workDuration.days()).isZero(); + assertThat(workDuration.hours()).isZero(); assertThat(workDuration.minutes()).isEqualTo(1); workDuration = WorkDuration.createFromMinutes(ONE_HOUR_IN_MINUTES, HOURS_IN_DAY); - assertThat(workDuration.days()).isEqualTo(0); + assertThat(workDuration.days()).isZero(); assertThat(workDuration.hours()).isEqualTo(1); - assertThat(workDuration.minutes()).isEqualTo(0); + assertThat(workDuration.minutes()).isZero(); workDuration = WorkDuration.createFromMinutes(ONE_DAY_IN_MINUTES, HOURS_IN_DAY); assertThat(workDuration.days()).isEqualTo(1); - assertThat(workDuration.hours()).isEqualTo(0); - assertThat(workDuration.minutes()).isEqualTo(0); + assertThat(workDuration.hours()).isZero(); + assertThat(workDuration.minutes()).isZero(); } @Test public void create_from_working_long() { // 1 minute WorkDuration workDuration = WorkDuration.createFromLong(1L, HOURS_IN_DAY); - assertThat(workDuration.days()).isEqualTo(0); - assertThat(workDuration.hours()).isEqualTo(0); + assertThat(workDuration.days()).isZero(); + assertThat(workDuration.hours()).isZero(); assertThat(workDuration.minutes()).isEqualTo(1); // 1 hour workDuration = WorkDuration.createFromLong(100L, HOURS_IN_DAY); - assertThat(workDuration.days()).isEqualTo(0); + assertThat(workDuration.days()).isZero(); assertThat(workDuration.hours()).isEqualTo(1); - assertThat(workDuration.minutes()).isEqualTo(0); + assertThat(workDuration.minutes()).isZero(); // 1 day workDuration = WorkDuration.createFromLong(10000L, HOURS_IN_DAY); assertThat(workDuration.days()).isEqualTo(1); - assertThat(workDuration.hours()).isEqualTo(0); - assertThat(workDuration.minutes()).isEqualTo(0); + assertThat(workDuration.hours()).isZero(); + assertThat(workDuration.minutes()).isZero(); } @Test @@ -126,12 +126,12 @@ public class WorkDurationTest { WorkDuration result = WorkDuration.createFromValueAndUnit(4, WorkDuration.UNIT.HOURS, HOURS_IN_DAY).add(WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY)); assertThat(result.days()).isEqualTo(1); assertThat(result.hours()).isEqualTo(1); - assertThat(result.minutes()).isEqualTo(0); + assertThat(result.minutes()).isZero(); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); // 40 m + 30m = 1h 10m result = WorkDuration.createFromValueAndUnit(40, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY).add(WorkDuration.createFromValueAndUnit(30, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY)); - assertThat(result.days()).isEqualTo(0); + assertThat(result.days()).isZero(); assertThat(result.hours()).isEqualTo(1); assertThat(result.minutes()).isEqualTo(10); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); @@ -148,15 +148,15 @@ public class WorkDurationTest { public void subtract() { // 1d 1h - 5h = 4h WorkDuration result = WorkDuration.create(1, 1, 0, HOURS_IN_DAY).subtract(WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY)); - assertThat(result.days()).isEqualTo(0); + assertThat(result.days()).isZero(); assertThat(result.hours()).isEqualTo(4); - assertThat(result.minutes()).isEqualTo(0); + assertThat(result.minutes()).isZero(); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); // 1h 10m - 30m = 40m result = WorkDuration.create(0, 1, 10, HOURS_IN_DAY).subtract(WorkDuration.createFromValueAndUnit(30, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY)); - assertThat(result.days()).isEqualTo(0); - assertThat(result.hours()).isEqualTo(0); + assertThat(result.days()).isZero(); + assertThat(result.hours()).isZero(); assertThat(result.minutes()).isEqualTo(40); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); @@ -173,7 +173,7 @@ public class WorkDurationTest { WorkDuration result = WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY).multiply(2); assertThat(result.days()).isEqualTo(1); assertThat(result.hours()).isEqualTo(2); - assertThat(result.minutes()).isEqualTo(0); + assertThat(result.minutes()).isZero(); assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/ce/measure/RangeDistributionBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/ce/measure/RangeDistributionBuilderTest.java index 4d9c9a3f6b2..63b517ab4cd 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/ce/measure/RangeDistributionBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/ce/measure/RangeDistributionBuilderTest.java @@ -33,7 +33,7 @@ public class RangeDistributionBuilderTest { assertThat(limits[0]).isEqualTo(4); assertThat(limits[1]).isEqualTo(2); - assertThat(limits[2]).isEqualTo(0); + assertThat(limits[2]).isZero(); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java index c183a902c67..1af1faa142c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java @@ -366,8 +366,8 @@ public class RequestTest { assertThat(emptyAsNull).isNotSameAs(stringParam); assertThat(emptyAsNull.isPresent()).isTrue(); expectSupplierCanNotBeNullNPE(() -> emptyAsNull.or(null)); - assertThat(emptyAsNull.or(() -> "bar")).isEqualTo(null); - assertThat(emptyAsNull.getValue()).isEqualTo(null); + assertThat(emptyAsNull.or(() -> "bar")).isNull(); + assertThat(emptyAsNull.getValue()).isNull(); } @Test @@ -427,8 +427,8 @@ public class RequestTest { assertThat(emptyAsNull).isNotSameAs(stringParam); assertThat(emptyAsNull.isPresent()).isTrue(); expectSupplierCanNotBeNullNPE(() -> emptyAsNull.or(null)); - assertThat(emptyAsNull.or(() -> "bar")).isEqualTo(null); - assertThat(emptyAsNull.getValue()).isEqualTo(null); + assertThat(emptyAsNull.or(() -> "bar")).isNull(); + assertThat(emptyAsNull.getValue()).isNull(); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/task/TaskDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/task/TaskDefinitionTest.java index f1258df716f..7444240b3bd 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/task/TaskDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/task/TaskDefinitionTest.java @@ -61,7 +61,7 @@ public class TaskDefinitionTest { TaskDefinition bar = TaskDefinition.builder().key("bar").taskClass(FooTask.class).description("Bar").build(); assertThat(foo.compareTo(bar)).isGreaterThan(0); - assertThat(foo.compareTo(foo)).isEqualTo(0); + assertThat(foo).isEqualByComparingTo(foo); assertThat(bar.compareTo(foo)).isLessThan(0); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java index 1281b641b07..f0122c75e0e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java @@ -134,7 +134,7 @@ public class DateUtilsTest { public void date_to_long() { Date date = new Date(); assertThat(DateUtils.dateToLong(date)).isEqualTo(date.getTime()); - assertThat(DateUtils.dateToLong(null)).isEqualTo(null); + assertThat(DateUtils.dateToLong(null)).isNull(); } @DataProvider diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/PagingTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/PagingTest.java index c233dadde6d..d2c43d7fe6a 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/PagingTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/PagingTest.java @@ -38,13 +38,13 @@ public class PagingTest { assertThat(paging.pageIndex()).isEqualTo(1); assertThat(paging.total()).isEqualTo(20); - assertThat(paging.offset()).isEqualTo(0); + assertThat(paging.offset()).isZero(); assertThat(paging.pages()).isEqualTo(4); } @Test public void test_offset() { - assertThat(forPageIndex(1).withPageSize(5).andTotal(20).offset()).isEqualTo(0); + assertThat(forPageIndex(1).withPageSize(5).andTotal(20).offset()).isZero(); assertThat(forPageIndex(2).withPageSize(5).andTotal(20).offset()).isEqualTo(5); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java index 8c00c020e77..e79f1ff72a5 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/VersionTest.java @@ -77,8 +77,8 @@ public class VersionTest { @Test public void test_compareTo() { - assertThat(parse("1.2").compareTo(parse("1.2.0"))).isEqualTo(0); - assertThat(parse("1.2.3").compareTo(parse("1.2.3"))).isEqualTo(0); + assertThat(parse("1.2")).isEqualByComparingTo(parse("1.2.0")); + assertThat(parse("1.2.3")).isEqualByComparingTo(parse("1.2.3")); assertThat(parse("1.2.3").compareTo(parse("1.2.4"))).isLessThan(0); assertThat(parse("1.2.3").compareTo(parse("1.3"))).isLessThan(0); assertThat(parse("1.2.3").compareTo(parse("2.1"))).isLessThan(0); @@ -88,7 +88,7 @@ public class VersionTest { @Test public void compareTo_handles_build_number() { - assertThat(parse("1.2").compareTo(parse("1.2.0.0"))).isEqualTo(0); + assertThat(parse("1.2")).isEqualByComparingTo(parse("1.2.0.0")); assertThat(parse("1.2.3.1234").compareTo(parse("1.2.3.4567"))).isLessThan(0); assertThat(parse("1.2.3.1234").compareTo(parse("1.2.3"))).isGreaterThan(0); assertThat(parse("1.2.3.1234").compareTo(parse("1.2.4"))).isLessThan(0); @@ -99,7 +99,7 @@ public class VersionTest { public void qualifier_is_ignored_from_comparison() { assertThat(parse("1.2.3")).isEqualTo(parse("1.2.3-build1")); assertThat(parse("1.2.3")).isEqualTo(parse("1.2.3-build1")); - assertThat(parse("1.2.3").compareTo(parse("1.2.3-build1"))).isEqualTo(0); + assertThat(parse("1.2.3")).isEqualByComparingTo(parse("1.2.3-build1")); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java index a158ec4972a..e758c6ff468 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java @@ -62,7 +62,7 @@ public class CommandExecutorTest { StreamConsumer stdErrConsumer = line -> stdErrBuilder.append(line).append(SystemUtils.LINE_SEPARATOR); Command command = Command.create(getScript("output")).setDirectory(workDir); int exitCode = CommandExecutor.create().execute(command, stdOutConsumer, stdErrConsumer, 1000L); - assertThat(exitCode).isEqualTo(0); + assertThat(exitCode).isZero(); String stdOut = stdOutBuilder.toString(); String stdErr = stdErrBuilder.toString(); @@ -103,7 +103,7 @@ public class CommandExecutorTest { .addArgument("1") .setEnvironmentVariable("ENVVAR", "2"); int exitCode = CommandExecutor.create().execute(command, 1000L); - assertThat(exitCode).isEqualTo(0); + assertThat(exitCode).isZero(); File logFile = new File(workDir, "echo.log"); assertThat(logFile).exists(); String log = FileUtils.readFileToString(logFile); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/LoggingConfiguratorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/LoggingConfiguratorTest.java index 0b69d4917d4..ac2b3ea5cc2 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/LoggingConfiguratorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/bootstrapper/LoggingConfiguratorTest.java @@ -107,7 +107,7 @@ public class LoggingConfiguratorTest { logger.error(TEST_STR); logger.info(TEST_STR); logger.debug(TEST_STR); - assertThat(out.size()).isEqualTo(0); + assertThat(out.size()).isZero(); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java index 2878464e325..dd6d43348bd 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java @@ -91,7 +91,7 @@ public class PluginFilesTest { verifySameContent(result, jar); // no requests to server - assertThat(server.getRequestCount()).isEqualTo(0); + assertThat(server.getRequestCount()).isZero(); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java index f8614ce4fcc..88c0f065dfd 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java @@ -275,7 +275,7 @@ public class CpdExecutorTest { if (otherFileRef != null) { assertThat(d.getDuplicate(0).getOtherFileRef()).isEqualTo(otherFileRef); } else { - assertThat(d.getDuplicate(0).getOtherFileRef()).isEqualTo(0); + assertThat(d.getDuplicate(0).getOtherFileRef()).isZero(); } assertThat(d.getDuplicate(0).getRange().getStartLine()).isEqualTo(rangeStartLine); assertThat(d.getDuplicate(0).getRange().getEndLine()).isEqualTo(rangeEndLine); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java index 3d845f72376..46ec1f34b40 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java @@ -132,7 +132,7 @@ public class ExternalIssueImporterTest { assertThat(context.allExternalIssues()).hasSize(1); TextRange got = context.allExternalIssues().iterator().next().primaryLocation().textRange(); assertThat(got.start().line()).isEqualTo(input.startLine); - assertThat(got.start().lineOffset()).isEqualTo(0); + assertThat(got.start().lineOffset()).isZero(); assertThat(got.end().line()).isEqualTo(input.startLine); assertThat(got.end().lineOffset()).isEqualTo(sourceFile.selectLine(input.startLine).end().lineOffset()); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java index 2737c635d61..20d679705c1 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java @@ -69,11 +69,11 @@ public class GenericCoverageReportParserTest { parser.parse(new File(this.getClass().getResource("coverage.xml").toURI()), context); assertThat(parser.numberOfMatchedFiles()).isEqualTo(1); - assertThat(context.lineHits(fileWithoutBranch.key(), 2)).isEqualTo(0); + assertThat(context.lineHits(fileWithoutBranch.key(), 2)).isZero(); assertThat(context.lineHits(fileWithoutBranch.key(), 3)).isEqualTo(1); assertThat(context.lineHits(fileWithoutBranch.key(), 4)).isNull(); assertThat(context.lineHits(fileWithoutBranch.key(), 5)).isEqualTo(1); - assertThat(context.lineHits(fileWithoutBranch.key(), 6)).isEqualTo(0); + assertThat(context.lineHits(fileWithoutBranch.key(), 6)).isZero(); } @Test @@ -90,7 +90,7 @@ public class GenericCoverageReportParserTest { assertThat(context.conditions(fileWithBranches.key(), 4)).isEqualTo(2); assertThat(context.coveredConditions(fileWithBranches.key(), 3)).isEqualTo(5); - assertThat(context.coveredConditions(fileWithBranches.key(), 4)).isEqualTo(0); + assertThat(context.coveredConditions(fileWithBranches.key(), 4)).isZero(); } @Test(expected = MessageException.class) diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializerTest.java index cbb6acfb109..c1f58c9cb85 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializerTest.java @@ -42,7 +42,7 @@ public class IssueExclusionPatternInitializerTest { public void testNoConfiguration() { patternsInitializer = new IssueExclusionPatternInitializer(settings.asConfig()); assertThat(patternsInitializer.hasConfiguredPatterns()).isFalse(); - assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isEqualTo(0); + assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isZero(); } @Test(expected = MessageException.class) @@ -75,9 +75,9 @@ public class IssueExclusionPatternInitializerTest { assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); assertThat(patternsInitializer.hasFileContentPattern()).isTrue(); assertThat(patternsInitializer.hasMulticriteriaPatterns()).isFalse(); - assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isEqualTo(0); + assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isZero(); assertThat(patternsInitializer.getBlockPatterns().size()).isEqualTo(3); - assertThat(patternsInitializer.getAllFilePatterns().size()).isEqualTo(0); + assertThat(patternsInitializer.getAllFilePatterns().size()).isZero(); } @Test(expected = MessageException.class) @@ -98,8 +98,8 @@ public class IssueExclusionPatternInitializerTest { assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); assertThat(patternsInitializer.hasFileContentPattern()).isTrue(); assertThat(patternsInitializer.hasMulticriteriaPatterns()).isFalse(); - assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isEqualTo(0); - assertThat(patternsInitializer.getBlockPatterns().size()).isEqualTo(0); + assertThat(patternsInitializer.getMulticriteriaPatterns().size()).isZero(); + assertThat(patternsInitializer.getBlockPatterns().size()).isZero(); assertThat(patternsInitializer.getAllFilePatterns().size()).isEqualTo(2); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java index df1a9f9f14b..7c8f2eabaf1 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java @@ -277,8 +277,8 @@ public class CoverageMediumTest { assertThat(result.coverageFor(file, 1)).isNull(); assertThat(result.coverageFor(file, 2).getHits()).isFalse(); - assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(0); - assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(0); + assertThat(result.coverageFor(file, 2).getConditions()).isZero(); + assertThat(result.coverageFor(file, 2).getCoveredConditions()).isZero(); assertThat(result.coverageFor(file, 3).getHits()).isFalse(); assertThat(result.coverageFor(file, 4)).isNull(); @@ -351,8 +351,8 @@ public class CoverageMediumTest { assertThat(result.coverageFor(file1, 1)).isNull(); assertThat(result.coverageFor(file1, 2).getHits()).isFalse(); - assertThat(result.coverageFor(file1, 2).getConditions()).isEqualTo(0); - assertThat(result.coverageFor(file1, 2).getCoveredConditions()).isEqualTo(0); + assertThat(result.coverageFor(file1, 2).getConditions()).isZero(); + assertThat(result.coverageFor(file1, 2).getCoveredConditions()).isZero(); assertThat(result.coverageFor(file1, 3).getHits()).isFalse(); assertThat(result.coverageFor(file1, 4)).isNull(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumTest.java index bd2e1f3cdd7..2400a31d898 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumTest.java @@ -52,8 +52,8 @@ public class GenericCoverageMediumTest { InputFile noConditions = result.inputFile("xources/hello/NoConditions.xoo"); assertThat(result.coverageFor(noConditions, 6).getHits()).isTrue(); - assertThat(result.coverageFor(noConditions, 6).getConditions()).isEqualTo(0); - assertThat(result.coverageFor(noConditions, 6).getCoveredConditions()).isEqualTo(0); + assertThat(result.coverageFor(noConditions, 6).getConditions()).isZero(); + assertThat(result.coverageFor(noConditions, 6).getCoveredConditions()).isZero(); assertThat(result.coverageFor(noConditions, 7).getHits()).isFalse(); @@ -79,8 +79,8 @@ public class GenericCoverageMediumTest { InputFile noConditions = result.inputFile("xources/hello/NoConditions.xoo"); assertThat(result.coverageFor(noConditions, 6).getHits()).isTrue(); - assertThat(result.coverageFor(noConditions, 6).getConditions()).isEqualTo(0); - assertThat(result.coverageFor(noConditions, 6).getCoveredConditions()).isEqualTo(0); + assertThat(result.coverageFor(noConditions, 6).getConditions()).isZero(); + assertThat(result.coverageFor(noConditions, 6).getCoveredConditions()).isZero(); assertThat(result.coverageFor(noConditions, 7).getHits()).isTrue(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java index b30f7455091..2ecec04dea2 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumTest.java @@ -122,37 +122,25 @@ public class ExternalIssuesMediumTest { // precise issue location ExternalIssue issue = externalIssues.get(0); - assertThat(issue.getFlowCount()).isZero(); - assertThat(issue.getMsg()).isEqualTo("fix the issue here"); - assertThat(issue.getEngineId()).isEqualTo("externalXoo"); - assertThat(issue.getRuleId()).isEqualTo("rule1"); - assertThat(issue.getSeverity()).isEqualTo(Severity.MAJOR); - assertThat(issue.getEffort()).isEqualTo(50l); - assertThat(issue.getType()).isEqualTo(IssueType.CODE_SMELL); - assertThat(issue.getTextRange().getStartLine()).isEqualTo(5); - assertThat(issue.getTextRange().getEndLine()).isEqualTo(5); - assertThat(issue.getTextRange().getStartOffset()).isEqualTo(3); - assertThat(issue.getTextRange().getEndOffset()).isEqualTo(41); + assertPreciseIssueLocation(issue); // location on a line issue = externalIssues.get(1); - assertThat(issue.getFlowCount()).isZero(); - assertThat(issue.getMsg()).isEqualTo("fix the bug here"); - assertThat(issue.getEngineId()).isEqualTo("externalXoo"); - assertThat(issue.getRuleId()).isEqualTo("rule2"); - assertThat(issue.getSeverity()).isEqualTo(Severity.CRITICAL); - assertThat(issue.getType()).isEqualTo(IssueType.BUG); - assertThat(issue.getEffort()).isZero(); - assertThat(issue.getTextRange().getStartLine()).isEqualTo(3); - assertThat(issue.getTextRange().getEndLine()).isEqualTo(3); - assertThat(issue.getTextRange().getStartOffset()).isEqualTo(0); - assertThat(issue.getTextRange().getEndOffset()).isEqualTo(24); + assertIssueLocationLine(issue); // One file-level issue in helloscala, with secondary location List<ExternalIssue> externalIssues2 = result.externalIssuesFor(result.inputFile("xources/hello/helloscala.xoo")); assertThat(externalIssues2).hasSize(1); issue = externalIssues2.iterator().next(); + assertSecondaryLocation(issue); + + // one issue is located in a non-existing file + assertThat(logs.logs()).contains("External issues ignored for 1 unknown files, including: invalidFile"); + + } + + private void assertSecondaryLocation(ExternalIssue issue) { assertThat(issue.getFlowCount()).isEqualTo(2); assertThat(issue.getMsg()).isEqualTo("fix the bug here"); assertThat(issue.getEngineId()).isEqualTo("externalXoo"); @@ -164,9 +152,33 @@ public class ExternalIssuesMediumTest { assertThat(issue.getFlow(0).getLocation(0).getTextRange().getStartLine()).isOne(); assertThat(issue.getFlow(1).getLocationCount()).isOne(); assertThat(issue.getFlow(1).getLocation(0).getTextRange().getStartLine()).isEqualTo(3); + } - // one issue is located in a non-existing file - assertThat(logs.logs()).contains("External issues ignored for 1 unknown files, including: invalidFile"); + private void assertIssueLocationLine(ExternalIssue issue) { + assertThat(issue.getFlowCount()).isZero(); + assertThat(issue.getMsg()).isEqualTo("fix the bug here"); + assertThat(issue.getEngineId()).isEqualTo("externalXoo"); + assertThat(issue.getRuleId()).isEqualTo("rule2"); + assertThat(issue.getSeverity()).isEqualTo(Severity.CRITICAL); + assertThat(issue.getType()).isEqualTo(IssueType.BUG); + assertThat(issue.getEffort()).isZero(); + assertThat(issue.getTextRange().getStartLine()).isEqualTo(3); + assertThat(issue.getTextRange().getEndLine()).isEqualTo(3); + assertThat(issue.getTextRange().getStartOffset()).isZero(); + assertThat(issue.getTextRange().getEndOffset()).isEqualTo(24); + } + private void assertPreciseIssueLocation(ExternalIssue issue) { + assertThat(issue.getFlowCount()).isZero(); + assertThat(issue.getMsg()).isEqualTo("fix the issue here"); + assertThat(issue.getEngineId()).isEqualTo("externalXoo"); + assertThat(issue.getRuleId()).isEqualTo("rule1"); + assertThat(issue.getSeverity()).isEqualTo(Severity.MAJOR); + assertThat(issue.getEffort()).isEqualTo(50l); + assertThat(issue.getType()).isEqualTo(IssueType.CODE_SMELL); + assertThat(issue.getTextRange().getStartLine()).isEqualTo(5); + assertThat(issue.getTextRange().getEndLine()).isEqualTo(5); + assertThat(issue.getTextRange().getStartOffset()).isEqualTo(3); + assertThat(issue.getTextRange().getEndOffset()).isEqualTo(41); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesMediumTest.java index 64f99bb2ac9..c444ce342bd 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesMediumTest.java @@ -229,7 +229,7 @@ public class IssuesMediumTest { assertThat(logTester.logs(LoggerLevel.WARN)).contains("Specifying module-relative paths at project level in property 'sonar.issue.ignore.multicriteria' is deprecated. To continue matching files like 'moduleA/src/sampleA.xoo', update this property so that patterns refer to project-relative paths."); List<Issue> issues = result.issuesFor(result.inputFile("moduleA/src/sampleA.xoo")); - assertThat(issues).hasSize(0); + assertThat(issues).isEmpty(); issues = result.issuesFor(result.inputFile("moduleB/src/sampleB.xoo")); assertThat(issues).hasSize(10); @@ -376,7 +376,7 @@ public class IssuesMediumTest { assertThat(issues).hasSize(10); issues = result.issuesFor(result.inputFile("moduleB/src/sampleB.xoo")); - assertThat(issues).hasSize(0); + assertThat(issues).isEmpty(); } private void activateTODORule() { diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java index 74bc606295f..58d31feebf6 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java @@ -124,7 +124,7 @@ public class ComponentsPublisherTest { Component rootProtobuf = reader.readComponent(1); assertThat(rootProtobuf.getKey()).isEqualTo("foo"); assertThat(rootProtobuf.getDescription()).isEqualTo("Root description"); - assertThat(rootProtobuf.getLinkCount()).isEqualTo(0); + assertThat(rootProtobuf.getLinkCount()).isZero(); assertThat(reader.readComponent(4).getStatus()).isEqualTo(FileStatus.SAME); assertThat(reader.readComponent(6).getStatus()).isEqualTo(FileStatus.CHANGED); @@ -195,7 +195,7 @@ public class ComponentsPublisherTest { assertThat(rootProtobuf.getKey()).isEqualTo("foo"); assertThat(rootProtobuf.getName()).isEqualTo(""); assertThat(rootProtobuf.getDescription()).isEqualTo("Root description"); - assertThat(rootProtobuf.getLinkCount()).isEqualTo(0); + assertThat(rootProtobuf.getLinkCount()).isZero(); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetectorTest.java index 86942280267..a123b6656ed 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetectorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetectorTest.java @@ -87,7 +87,7 @@ public class ByteCharsetDetectorTest { when(validation.isUTF16(any(byte[].class), anyBoolean())).thenReturn(new Result(Validation.MAYBE, null)); when(validation.isValidWindows1252(any(byte[].class))).thenReturn(Result.INVALID); - assertThat(charsets.detect(new byte[1])).isEqualTo(null); + assertThat(charsets.detect(new byte[1])).isNull(); } @Test @@ -96,7 +96,7 @@ public class ByteCharsetDetectorTest { when(validation.isUTF16(any(byte[].class), anyBoolean())).thenReturn(Result.newValid(StandardCharsets.UTF_16)); when(validation.isValidUTF16(any(byte[].class), anyBoolean())).thenReturn(true); - assertThat(charsets.detect(new byte[1])).isEqualTo(null); + assertThat(charsets.detect(new byte[1])).isNull(); } @Test diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java index 656fb421fb2..1648a6315fd 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/MultiModuleProjectRepositoryTest.java @@ -54,7 +54,7 @@ public class MultiModuleProjectRepositoryTest { repository.addFileDataToModule("module1", null, fileData); - assertThat(repository.repositoriesByModule()).hasSize(0); + assertThat(repository.repositoriesByModule()).isEmpty(); } @Test @@ -63,6 +63,6 @@ public class MultiModuleProjectRepositoryTest { repository.addFileDataToModule("module2", "/Abc.java", fileData); - assertThat(repository.repositoriesByModule()).hasSize(0); + assertThat(repository.repositoriesByModule()).isEmpty(); } } diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java index dc34d9f8589..6c5f5819f16 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/SingleProjectRepositoryTest.java @@ -50,7 +50,7 @@ public class SingleProjectRepositoryTest { repository.addFileData(null, fileData); - assertThat(repository.fileData()).hasSize(0); + assertThat(repository.fileData()).isEmpty(); } @Test @@ -59,6 +59,6 @@ public class SingleProjectRepositoryTest { repository.addFileData("/Abc.java", fileData); - assertThat(repository.fileData()).hasSize(0); + assertThat(repository.fileData()).isEmpty(); } } |