@@ -170,8 +170,8 @@ subprojects { | |||
exclude 'org.eclipse.jdt.core.compiler:ecj' | |||
} | |||
} | |||
dependency 'org.assertj:assertj-core:3.9.1' | |||
dependency 'org.assertj:assertj-guava:3.2.0' | |||
dependency 'org.assertj:assertj-core:3.12.2' | |||
dependency 'org.assertj:assertj-guava:3.2.1' | |||
dependency('org.codehaus.sonar:sonar-channel:4.1') { | |||
exclude 'org.slf4j:slf4j-api' | |||
} |
@@ -83,7 +83,7 @@ public class BatchReportReaderImplTest { | |||
FileUtils.write(scannerLogFile, "log1\nlog2"); | |||
CloseableIterator<String> logs = underTest.readScannerLogs(); | |||
assertThat(logs).containsExactly("log1", "log2"); | |||
assertThat(logs).toIterable().containsExactly("log1", "log2"); | |||
} | |||
@Test | |||
@@ -94,7 +94,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentMeasures_returns_empty_list_if_there_is_no_measure() { | |||
assertThat(underTest.readComponentMeasures(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentMeasures(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -155,7 +155,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentIssues_returns_empty_list_if_file_does_not_exist() { | |||
assertThat(underTest.readComponentIssues(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentIssues(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -177,7 +177,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentDuplications_returns_empty_list_if_file_does_not_exist() { | |||
assertThat(underTest.readComponentDuplications(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentDuplications(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -199,7 +199,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentDuplicationBlocks_returns_empty_list_if_file_does_not_exist() { | |||
assertThat(underTest.readCpdTextBlocks(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readCpdTextBlocks(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -221,7 +221,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentSymbols_returns_empty_list_if_file_does_not_exist() { | |||
assertThat(underTest.readComponentSymbols(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentSymbols(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -243,7 +243,7 @@ public class BatchReportReaderImplTest { | |||
@Test | |||
public void readComponentSyntaxHighlighting_returns_empty_CloseableIterator_when_file_does_not_exist() { | |||
assertThat(underTest.readComponentSyntaxHighlighting(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentSyntaxHighlighting(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -251,13 +251,13 @@ public class BatchReportReaderImplTest { | |||
writer.writeComponentSyntaxHighlighting(COMPONENT_REF, of(SYNTAX_HIGHLIGHTING_1, SYNTAX_HIGHLIGHTING_2)); | |||
CloseableIterator<ScannerReport.SyntaxHighlightingRule> res = underTest.readComponentSyntaxHighlighting(COMPONENT_REF); | |||
assertThat(res).containsExactly(SYNTAX_HIGHLIGHTING_1, SYNTAX_HIGHLIGHTING_2); | |||
assertThat(res).toIterable().containsExactly(SYNTAX_HIGHLIGHTING_1, SYNTAX_HIGHLIGHTING_2); | |||
res.close(); | |||
} | |||
@Test | |||
public void readComponentCoverage_returns_empty_CloseableIterator_when_file_does_not_exist() { | |||
assertThat(underTest.readComponentCoverage(COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentCoverage(COMPONENT_REF)).isExhausted(); | |||
} | |||
@Test | |||
@@ -265,7 +265,7 @@ public class BatchReportReaderImplTest { | |||
writer.writeComponentCoverage(COMPONENT_REF, of(COVERAGE_1, COVERAGE_2)); | |||
CloseableIterator<ScannerReport.LineCoverage> res = underTest.readComponentCoverage(COMPONENT_REF); | |||
assertThat(res).containsExactly(COVERAGE_1, COVERAGE_2); | |||
assertThat(res).toIterable().containsExactly(COVERAGE_1, COVERAGE_2); | |||
res.close(); | |||
} | |||
@@ -280,7 +280,7 @@ public class BatchReportReaderImplTest { | |||
FileUtils.writeLines(file, of("1", "2", "3")); | |||
CloseableIterator<String> res = underTest.readFileSource(COMPONENT_REF).get(); | |||
assertThat(res).containsExactly("1", "2", "3"); | |||
assertThat(res).toIterable().containsExactly("1", "2", "3"); | |||
res.close(); | |||
} | |||
@@ -292,7 +292,7 @@ public class BatchReportReaderImplTest { | |||
writer.writeAnalysisWarnings(warnings); | |||
CloseableIterator<ScannerReport.AnalysisWarning> res = underTest.readAnalysisWarnings(); | |||
assertThat(res).containsExactlyElementsOf(warnings); | |||
assertThat(res).toIterable().containsExactlyElementsOf(warnings); | |||
res.close(); | |||
} | |||
} |
@@ -725,7 +725,7 @@ public class NotificationFactoryTest { | |||
assertThat(builder.getChange()) | |||
.isInstanceOf(AnalysisChange.class) | |||
.extracting(IssuesChangesNotificationBuilder.Change::getDate) | |||
.containsOnly(analysisDate); | |||
.isEqualTo(analysisDate); | |||
} | |||
@Test |
@@ -48,14 +48,14 @@ public class SourceLinesRepositoryImplTest { | |||
public void read_lines_from_report() { | |||
reportReader.putFileSourceLines(FILE_REF, "line1", "line2"); | |||
assertThat(underTest.readLines(createComponent(2))).containsOnly("line1", "line2"); | |||
assertThat(underTest.readLines(createComponent(2))).toIterable().containsOnly("line1", "line2"); | |||
} | |||
@Test | |||
public void read_lines_adds_one_extra_empty_line_when_sourceLine_has_elements_count_equals_to_lineCount_minus_1() { | |||
reportReader.putFileSourceLines(FILE_REF, "line1", "line2"); | |||
assertThat(underTest.readLines(createComponent(3))).containsOnly("line1", "line2", ""); | |||
assertThat(underTest.readLines(createComponent(3))).toIterable().containsOnly("line1", "line2", ""); | |||
} | |||
@Test |
@@ -40,7 +40,7 @@ public class DiskCacheTest { | |||
public void write_and_read() throws Exception { | |||
DiskCache<String> cache = new DiskCache<>(temp.newFile(), System2.INSTANCE); | |||
try (CloseableIterator<String> traverse = cache.traverse()) { | |||
assertThat(traverse).isEmpty(); | |||
assertThat(traverse).isExhausted(); | |||
} | |||
cache.newAppender() | |||
@@ -48,7 +48,7 @@ public class DiskCacheTest { | |||
.append("bar") | |||
.close(); | |||
try (CloseableIterator<String> traverse = cache.traverse()) { | |||
assertThat(traverse).containsExactly("foo", "bar"); | |||
assertThat(traverse).toIterable().containsExactly("foo", "bar"); | |||
} | |||
} | |||
@@ -499,7 +499,7 @@ public class BranchDaoTest { | |||
assertThat(underTest.selectByUuid(db.getSession(), branch1.uuid()).get()) | |||
.extracting(BranchDto::getUuid) | |||
.containsExactlyInAnyOrder(branch1.uuid()); | |||
.isEqualTo(branch1.uuid()); | |||
assertThat(underTest.selectByUuid(db.getSession(), project.uuid())).isNotPresent(); | |||
assertThat(underTest.selectByUuid(db.getSession(), "unknown")).isNotPresent(); | |||
} |
@@ -540,7 +540,7 @@ public class QualityProfileDaoTest { | |||
assertThat(underTest.selectByRuleProfileUuid(dbSession, db.getDefaultOrganization().getUuid(), qprofile1.getRulesProfileUuid())) | |||
.extracting(QProfileDto::getName) | |||
.containsOnly(qprofile1.getName()); | |||
.isEqualTo(qprofile1.getName()); | |||
assertThat(underTest.selectByRuleProfileUuid(dbSession, "A", qprofile1.getRulesProfileUuid())) | |||
.isNull(); |
@@ -155,10 +155,10 @@ public class WebhookDeliveryDaoTest { | |||
Map<String, WebhookDeliveryLiteDto> map = underTest.selectLatestDeliveries(dbSession, of(webhook1, webhook2)); | |||
assertThat(map).containsKeys(webhook1.getUuid()); | |||
assertThat(map.get(webhook1.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH1-DELIVERY-2-UUID"); | |||
assertThat(map.get(webhook1.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).isEqualTo("WH1-DELIVERY-2-UUID"); | |||
assertThat(map).containsKeys(webhook2.getUuid()); | |||
assertThat(map.get(webhook2.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH2-DELIVERY-2-UUID"); | |||
assertThat(map.get(webhook2.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).isEqualTo("WH2-DELIVERY-2-UUID"); | |||
} | |||
@Test | |||
@@ -205,7 +205,8 @@ public class WebhookDeliveryDaoTest { | |||
underTest.deleteByWebhook(dbSession, webhookDto); | |||
assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isEqualTo(1); } | |||
assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isEqualTo(1); | |||
} | |||
@Test | |||
public void deleteComponentBeforeDate_deletes_rows_before_date() { |
@@ -90,7 +90,7 @@ public class AppLoggingTest { | |||
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME); | |||
ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) rootLogger.getAppender("APP_CONSOLE"); | |||
verifyAppFormattedLogEncoder(consoleAppender.getEncoder()); | |||
assertThat(rootLogger.iteratorForAppenders()).hasSize(1); | |||
assertThat(rootLogger.iteratorForAppenders()).toIterable().hasSize(1); | |||
} | |||
@Test | |||
@@ -101,7 +101,7 @@ public class AppLoggingTest { | |||
Logger gobblerLogger = ctx.getLogger(LOGGER_GOBBLER); | |||
verifyGobblerConsoleAppender(gobblerLogger); | |||
assertThat(gobblerLogger.iteratorForAppenders()).hasSize(1); | |||
assertThat(gobblerLogger.iteratorForAppenders()).toIterable().hasSize(1); | |||
} | |||
@Test | |||
@@ -113,7 +113,7 @@ public class AppLoggingTest { | |||
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME); | |||
verifyAppConsoleAppender(rootLogger.getAppender("APP_CONSOLE")); | |||
verifySonarLogFileAppender(rootLogger.getAppender("file_sonar")); | |||
assertThat(rootLogger.iteratorForAppenders()).hasSize(2); | |||
assertThat(rootLogger.iteratorForAppenders()).toIterable().hasSize(2); | |||
// verify no other logger writes to sonar.log | |||
ctx.getLoggerList() | |||
@@ -130,7 +130,7 @@ public class AppLoggingTest { | |||
Logger gobblerLogger = ctx.getLogger(LOGGER_GOBBLER); | |||
verifyGobblerConsoleAppender(gobblerLogger); | |||
assertThat(gobblerLogger.iteratorForAppenders()).hasSize(1); | |||
assertThat(gobblerLogger.iteratorForAppenders()).toIterable().hasSize(1); | |||
} | |||
@Test | |||
@@ -142,7 +142,7 @@ public class AppLoggingTest { | |||
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME); | |||
verifyAppConsoleAppender(rootLogger.getAppender("APP_CONSOLE")); | |||
verifySonarLogFileAppender(rootLogger.getAppender("file_sonar")); | |||
assertThat(rootLogger.iteratorForAppenders()).hasSize(2); | |||
assertThat(rootLogger.iteratorForAppenders()).toIterable().hasSize(2); | |||
ctx.getLoggerList() | |||
.stream() | |||
@@ -158,7 +158,7 @@ public class AppLoggingTest { | |||
Logger gobblerLogger = ctx.getLogger(LOGGER_GOBBLER); | |||
verifyGobblerConsoleAppender(gobblerLogger); | |||
assertThat(gobblerLogger.iteratorForAppenders()).hasSize(1); | |||
assertThat(gobblerLogger.iteratorForAppenders()).toIterable().hasSize(1); | |||
} | |||
@Test |
@@ -223,8 +223,9 @@ public class IssueFieldsSetterTest { | |||
assertThat(issue.line()).isNull(); | |||
assertThat(issue.mustSendNotifications()).isFalse(); | |||
assertThat(issue.currentChange()) | |||
.extracting(FieldDiffs::diffs) | |||
.hasSize(1); | |||
.extracting(f -> f.diffs().size()) | |||
.isEqualTo(1); | |||
FieldDiffs.Diff diff = issue.currentChange().diffs().get("line"); | |||
assertThat(diff.oldValue()).isEqualTo(line); | |||
assertThat(diff.newValue()).isEqualTo(""); |
@@ -66,7 +66,7 @@ public class DefaultMetricFinderTest { | |||
MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); | |||
db.commit(); | |||
assertThat(underTest.findById(firstMetric.getId())).extracting(Metric::getKey).containsExactly(firstMetric.getKey()); | |||
assertThat(underTest.findById(firstMetric.getId())).extracting(Metric::getKey).isEqualTo(firstMetric.getKey()); | |||
} | |||
@Test | |||
@@ -75,6 +75,6 @@ public class DefaultMetricFinderTest { | |||
MetricDto secondMetric = db.getDbClient().metricDao().insert(db.getSession(), newMetricDto()); | |||
db.commit(); | |||
assertThat(underTest.findByKey(secondMetric.getKey())).extracting(Metric::getKey).containsExactly(secondMetric.getKey()); | |||
assertThat(underTest.findByKey(secondMetric.getKey())).extracting(Metric::getKey).isEqualTo(secondMetric.getKey()); | |||
} | |||
} |
@@ -1080,13 +1080,13 @@ public class RuleIndexTest { | |||
index(); | |||
// key | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("X001"))).hasSize(2); | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("X001"))).toIterable().hasSize(2); | |||
// partial key does not match | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("X00"))).isEmpty(); | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("X00"))).toIterable().isEmpty(); | |||
// repo:key -> nice-to-have ! | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("javascript:X001"))).hasSize(1); | |||
assertThat(underTest.searchAll(new RuleQuery().setQueryText("javascript:X001"))).toIterable().hasSize(1); | |||
} | |||
@Test | |||
@@ -1105,10 +1105,12 @@ public class RuleIndexTest { | |||
List<SearchHit> ruleDocs = es.getDocuments(TYPE_RULE); | |||
List<SearchHit> activeRuleDocs = es.getDocuments(TYPE_ACTIVE_RULE); | |||
assertThat(underTest.searchAll(new RuleQuery().setActivation(false).setQProfile(profile2))) | |||
.toIterable() | |||
.containsOnly(rule2.getId(), rule3.getId()); | |||
// active rules on profile | |||
assertThat(underTest.searchAll(new RuleQuery().setActivation(true).setQProfile(profile2))) | |||
.toIterable() | |||
.containsOnly(rule1.getId()); | |||
} | |||
@@ -160,6 +160,7 @@ public class IssuesActionTest { | |||
addPermissionTo(project); | |||
try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) { | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactlyInAnyOrder( | |||
tuple(issueOnFile.getKey(), module.getKey()), | |||
@@ -188,6 +189,7 @@ public class IssuesActionTest { | |||
addPermissionTo(project); | |||
try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) { | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactlyInAnyOrder( | |||
tuple(issueOnFile.getKey(), module.getKey()), | |||
@@ -210,6 +212,7 @@ public class IssuesActionTest { | |||
addPermissionTo(project); | |||
try (CloseableIterator<ServerIssue> result = callStream(module.getKey(), null)) { | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactlyInAnyOrder( | |||
tuple(issueOnFile.getKey(), module.getKey()), | |||
@@ -230,6 +233,7 @@ public class IssuesActionTest { | |||
addPermissionTo(project); | |||
try (CloseableIterator<ServerIssue> result = callStream(file.getKey(), null)) { | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactlyInAnyOrder( | |||
tuple(issueOnFile.getKey(), module.getKey())); | |||
@@ -295,6 +299,7 @@ public class IssuesActionTest { | |||
try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) { | |||
// Module key of removed file should be returned | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactly(tuple(issue.getKey(), module.getKey())); | |||
} | |||
@@ -354,6 +359,7 @@ public class IssuesActionTest { | |||
private void assertResult(String componentKey, String branch, Tuple... tuples) { | |||
try (CloseableIterator<ServerIssue> result = callStream(componentKey, branch)) { | |||
assertThat(result) | |||
.toIterable() | |||
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey) | |||
.containsExactlyInAnyOrder(tuples); | |||
} |
@@ -46,6 +46,7 @@ public class MigrationEsClientImplTest { | |||
underTest.deleteIndexes("as"); | |||
assertThat(loadExistingIndices()) | |||
.toIterable() | |||
.doesNotContain("as") | |||
.contains("bs", "cs"); | |||
assertThat(logTester.logs(LoggerLevel.INFO)) | |||
@@ -57,6 +58,7 @@ public class MigrationEsClientImplTest { | |||
underTest.deleteIndexes("as", "xxx", "cs"); | |||
assertThat(loadExistingIndices()) | |||
.toIterable() | |||
.doesNotContain("as", "cs") | |||
.contains("bs"); | |||
assertThat(logTester.logs(LoggerLevel.INFO)) |
@@ -313,7 +313,7 @@ public class ServerIdManagerTest { | |||
private void verifyDb(ServerId expectedServerId, String expectedChecksum) { | |||
assertThat(dbClient.propertiesDao().selectGlobalProperty(dbSession, CoreProperties.SERVER_ID)) | |||
.extracting(PropertyDto::getValue) | |||
.containsExactly(expectedServerId.toString()); | |||
.isEqualTo(expectedServerId.toString()); | |||
assertThat(dbClient.internalPropertiesDao().selectByKey(dbSession, InternalProperties.SERVER_ID_CHECKSUM)) | |||
.hasValue(expectedChecksum); | |||
} |
@@ -156,7 +156,7 @@ public class ListActionTest { | |||
assertThat(response.getActions()) | |||
.extracting(ListWsResponse.RootActions::getCreate) | |||
.containsExactlyInAnyOrder(true); | |||
.isEqualTo(true); | |||
assertThat(response.getQualitygatesList()) | |||
.extracting(QualityGate::getName, | |||
qg -> qg.getActions().getRename(), qg -> qg.getActions().getDelete(), qg -> qg.getActions().getManageConditions(), | |||
@@ -181,7 +181,7 @@ public class ListActionTest { | |||
assertThat(response.getActions()) | |||
.extracting(ListWsResponse.RootActions::getCreate) | |||
.containsExactlyInAnyOrder(false); | |||
.isEqualTo(false); | |||
assertThat(response.getQualitygatesList()) | |||
.extracting(QualityGate::getName, | |||
qg -> qg.getActions().getRename(), qg -> qg.getActions().getDelete(), qg -> qg.getActions().getManageConditions(), |
@@ -153,7 +153,7 @@ public class CreateActionTest { | |||
QProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage(dbSession, organization, "New Profile", XOO_LANGUAGE); | |||
assertThat(dto.getKee()).isNotNull(); | |||
assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, dto.getKee())).hasSize(1); | |||
assertThat(ruleIndex.searchAll(new RuleQuery().setQProfile(dto).setActivation(true))).hasSize(1); | |||
assertThat(ruleIndex.searchAll(new RuleQuery().setQProfile(dto).setActivation(true))).toIterable().hasSize(1); | |||
} | |||
@Test |
@@ -382,7 +382,7 @@ public class QProfilesWsMediumTest { | |||
.setQProfile(profile) | |||
.setKey(rule0.getKey().toString()) | |||
.setActiveSeverities(Collections.singleton("MINOR")) | |||
.setActivation(true))).hasSize(1); | |||
.setActivation(true))).toIterable().hasSize(1); | |||
} | |||
@Test |
@@ -294,7 +294,7 @@ public class ShowActionTest { | |||
assertThat(result.getProfile()) | |||
.extracting(QualityProfile::getKey) | |||
.containsExactly(qualityProfile.getKee()); | |||
.isEqualTo(qualityProfile.getKee()); | |||
} | |||
@Test |
@@ -98,7 +98,7 @@ public class ShowActionTest { | |||
.setParam(PARAM_KEY, rule.getKey().toString()) | |||
.executeProtobuf(ShowResponse.class); | |||
assertThat(result.getRule()).extracting(Rule::getKey).containsExactly(rule.getKey().toString()); | |||
assertThat(result.getRule()).extracting(Rule::getKey).isEqualTo(rule.getKey().toString()); | |||
} | |||
@Test |
@@ -390,7 +390,7 @@ public class UserUpdaterUpdateTest { | |||
assertThat(dbClient.userDao().selectByLogin(session, DEFAULT_LOGIN)) | |||
.extracting(UserDto::getExternalId) | |||
.containsOnly("ABCD"); | |||
.isEqualTo("ABCD"); | |||
} | |||
@Test |
@@ -224,7 +224,7 @@ public class CreateActionTest { | |||
assertThat(db.users().selectUserByLogin("john").get()) | |||
.extracting(UserDto::getExternalLogin) | |||
.containsOnly("john"); | |||
.isEqualTo("john"); | |||
} | |||
@Test |
@@ -79,7 +79,7 @@ public class CurrentActionHomepageTest { | |||
assertThat(response.getHomepage()) | |||
.extracting(CurrentWsResponse.Homepage::getType) | |||
.containsExactly(CurrentWsResponse.HomepageType.MY_PROJECTS); | |||
.isEqualTo(CurrentWsResponse.HomepageType.MY_PROJECTS); | |||
} | |||
@Test | |||
@@ -91,7 +91,7 @@ public class CurrentActionHomepageTest { | |||
assertThat(response.getHomepage()) | |||
.extracting(CurrentWsResponse.Homepage::getType) | |||
.containsExactly(CurrentWsResponse.HomepageType.PORTFOLIOS); | |||
.isEqualTo(CurrentWsResponse.HomepageType.PORTFOLIOS); | |||
} | |||
@Test | |||
@@ -119,7 +119,7 @@ public class CurrentActionHomepageTest { | |||
assertThat(response.getHomepage()) | |||
.extracting(CurrentWsResponse.Homepage::getType) | |||
.containsExactly(CurrentWsResponse.HomepageType.PROJECTS); | |||
.isEqualTo(CurrentWsResponse.HomepageType.PROJECTS); | |||
} | |||
@Test | |||
@@ -147,7 +147,7 @@ public class CurrentActionHomepageTest { | |||
assertThat(response.getHomepage()) | |||
.extracting(CurrentWsResponse.Homepage::getType) | |||
.containsExactly(CurrentWsResponse.HomepageType.PROJECTS); | |||
.isEqualTo(CurrentWsResponse.HomepageType.PROJECTS); | |||
} | |||
@Test | |||
@@ -173,7 +173,7 @@ public class CurrentActionHomepageTest { | |||
assertThat(response.getHomepage()) | |||
.extracting(CurrentWsResponse.Homepage::getType) | |||
.containsExactly(CurrentWsResponse.HomepageType.PROJECTS); | |||
.isEqualTo(CurrentWsResponse.HomepageType.PROJECTS); | |||
} | |||
@Test |
@@ -115,15 +115,15 @@ public class ListActionTest { | |||
List<Webhooks.ListResponseElement> elements = response.getWebhooksList(); | |||
assertThat(elements.size()).isEqualTo(2); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).containsExactly(webhook1.getUuid()); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).containsExactly("aaa"); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid()); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa"); | |||
assertThat(elements.get(0).getLatestDelivery()).isNotNull(); | |||
assertThat(elements.get(0).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).containsExactly("WH1-DELIVERY-2-UUID"); | |||
assertThat(elements.get(0).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH1-DELIVERY-2-UUID"); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).containsExactly(webhook2.getUuid()); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).containsExactly("bbb"); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid()); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb"); | |||
assertThat(elements.get(1).getLatestDelivery()).isNotNull(); | |||
assertThat(elements.get(1).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).containsExactly("WH2-DELIVERY-2-UUID"); | |||
assertThat(elements.get(1).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH2-DELIVERY-2-UUID"); | |||
} | |||
@Test | |||
@@ -138,12 +138,12 @@ public class ListActionTest { | |||
List<Webhooks.ListResponseElement> elements = response.getWebhooksList(); | |||
assertThat(elements.size()).isEqualTo(2); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).containsExactly(webhook1.getUuid()); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).containsExactly("aaa"); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid()); | |||
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa"); | |||
assertThat(elements.get(0).hasLatestDelivery()).isFalse(); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).containsExactly(webhook2.getUuid()); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).containsExactly("bbb"); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid()); | |||
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb"); | |||
assertThat(elements.get(1).hasLatestDelivery()).isFalse(); | |||
} | |||
@@ -25,6 +25,8 @@ import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.zip.ZipEntry; | |||
import java.util.zip.ZipFile; | |||
@@ -54,7 +56,7 @@ public class ZipUtilsTest { | |||
assertThat(zip).exists().isFile(); | |||
assertThat(zip.length()).isGreaterThan(1L); | |||
Iterator<? extends ZipEntry> zipEntries = Iterators.forEnumeration(new ZipFile(zip).entries()); | |||
ArrayList<? extends ZipEntry> zipEntries = Collections.list(new ZipFile(zip).entries()); | |||
assertThat(zipEntries).hasSize(4); | |||
File unzipDir = temp.newFolder(); |
@@ -102,7 +102,7 @@ public class CpdExecutorTest { | |||
@Test | |||
public void dont_fail_if_nothing_to_save() { | |||
executor.saveDuplications(batchComponent1, Collections.<CloneGroup>emptyList()); | |||
assertThat(reader.readComponentDuplications(batchComponent1.scannerId())).hasSize(0); | |||
assertThat(reader.readComponentDuplications(batchComponent1.scannerId())).isExhausted(); | |||
} | |||
@Test | |||
@@ -157,7 +157,7 @@ public class CpdExecutorTest { | |||
} | |||
executor.saveDuplications(batchComponent1, dups); | |||
assertThat(reader.readComponentDuplications(batchComponent1.scannerId())).hasSize(CpdExecutor.MAX_CLONE_GROUP_PER_FILE); | |||
assertThat(reader.readComponentDuplications(batchComponent1.scannerId())).toIterable().hasSize(CpdExecutor.MAX_CLONE_GROUP_PER_FILE); | |||
assertThat(logTester.logs(LoggerLevel.WARN)) | |||
.contains("Too many duplication groups on file " + batchComponent1 + ". Keep only the first " + CpdExecutor.MAX_CLONE_GROUP_PER_FILE + " groups."); | |||
@@ -243,7 +243,7 @@ public class CpdExecutorTest { | |||
} | |||
private Duplication[] readDuplications(DefaultInputFile file, int expected) { | |||
assertThat(reader.readComponentDuplications(file.scannerId())).hasSize(expected); | |||
assertThat(reader.readComponentDuplications(file.scannerId())).toIterable().hasSize(expected); | |||
Duplication[] duplications = new Duplication[expected]; | |||
CloseableIterator<Duplication> dups = reader.readComponentDuplications(file.scannerId()); | |||
@@ -99,8 +99,8 @@ public class ScannerReportReaderTest { | |||
.build(); | |||
writer.writeComponentIssues(1, asList(issue)); | |||
assertThat(underTest.readComponentIssues(1)).hasSize(1); | |||
assertThat(underTest.readComponentIssues(200)).isEmpty(); | |||
assertThat(underTest.readComponentIssues(1)).toIterable().hasSize(1); | |||
assertThat(underTest.readComponentIssues(200)).isExhausted(); | |||
} | |||
@Test | |||
@@ -110,13 +110,13 @@ public class ScannerReportReaderTest { | |||
.build(); | |||
writer.appendComponentExternalIssue(1, issue); | |||
assertThat(underTest.readComponentExternalIssues(1)).hasSize(1); | |||
assertThat(underTest.readComponentExternalIssues(200)).isEmpty(); | |||
assertThat(underTest.readComponentExternalIssues(1)).toIterable().hasSize(1); | |||
assertThat(underTest.readComponentExternalIssues(200)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
public void empty_list_if_no_issue_found() { | |||
assertThat(underTest.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentIssues(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -126,12 +126,12 @@ public class ScannerReportReaderTest { | |||
.setStringValue(StringValue.newBuilder().setValue("value_a")); | |||
writer.appendComponentMeasure(1, measure.build()); | |||
assertThat(underTest.readComponentMeasures(1)).hasSize(1); | |||
assertThat(underTest.readComponentMeasures(1)).toIterable().hasSize(1); | |||
} | |||
@Test | |||
public void empty_list_if_no_measure_found() { | |||
assertThat(underTest.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentMeasures(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -175,12 +175,12 @@ public class ScannerReportReaderTest { | |||
writer.writeComponentDuplications(1, asList(duplication)); | |||
ScannerReportReader sut = new ScannerReportReader(dir); | |||
assertThat(sut.readComponentDuplications(1)).hasSize(1); | |||
assertThat(sut.readComponentDuplications(1)).toIterable().hasSize(1); | |||
} | |||
@Test | |||
public void empty_list_if_no_duplication_found() { | |||
assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -201,12 +201,12 @@ public class ScannerReportReaderTest { | |||
writer.writeCpdTextBlocks(1, singletonList(duplicationBlock)); | |||
ScannerReportReader sut = new ScannerReportReader(dir); | |||
assertThat(sut.readCpdTextBlocks(1)).hasSize(1); | |||
assertThat(sut.readCpdTextBlocks(1)).toIterable().hasSize(1); | |||
} | |||
@Test | |||
public void empty_list_if_no_duplication_block_found() { | |||
assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -238,7 +238,7 @@ public class ScannerReportReaderTest { | |||
@Test | |||
public void return_empty_if_no_highlighting_found() { | |||
assertThat(underTest.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -266,12 +266,12 @@ public class ScannerReportReaderTest { | |||
.build())); | |||
underTest = new ScannerReportReader(dir); | |||
assertThat(underTest.readComponentSymbols(1)).hasSize(1); | |||
assertThat(underTest.readComponentSymbols(1)).toIterable().hasSize(1); | |||
} | |||
@Test | |||
public void empty_list_if_no_symbol_found() { | |||
assertThat(underTest.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentSymbols(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test | |||
@@ -309,7 +309,7 @@ public class ScannerReportReaderTest { | |||
@Test | |||
public void return_empty_iterator_if_no_coverage_found() { | |||
assertThat(underTest.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isEmpty(); | |||
assertThat(underTest.readComponentCoverage(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); | |||
} | |||
@Test |
@@ -301,7 +301,7 @@ public class ScannerReportWriterTest { | |||
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1); | |||
assertThat(file).exists().isFile(); | |||
try (CloseableIterator<ScannerReport.Symbol> read = Protobuf.readStream(file, ScannerReport.Symbol.parser())) { | |||
assertThat(read).hasSize(1); | |||
assertThat(read).toIterable().hasSize(1); | |||
} | |||
} | |||