aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-12-09 09:34:43 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-10 20:46:09 +0100
commitd1fd889554bccbb50122550899dbb66b90b04f78 (patch)
tree9cad838366292ee79b77ac3513403f7489b06355 /server
parentf86a1094588e4e47b3abf612891af0431653cd0e (diff)
downloadsonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz
sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server')
-rw-r--r--server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java4
-rw-r--r--server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java23
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitor.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryImpl.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationEmailTemplate.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java24
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestTrackerExecutionTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryImplTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryRule.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerBaseInputFactoryTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDtoTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryRule.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImplTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/DbMigrationsStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCommentMeasuresStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCoverageMeasuresStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryRule.java1
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java13
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java3
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java2
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java2
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java2
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java2
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java2
-rw-r--r--server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java7
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java3
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/metric/MetricDao.java8
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java6
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupMembershipDao.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/dump/DumpSQSchema.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeProfilerTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java1
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/GroupTesting.java3
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/MssqlCharsetHandlerTest.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerImplTest.java7
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImplTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java10
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java69
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImplTest.java3
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/ProcessLauncherImplTest.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/process/EsManagedProcessTest.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java4
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java16
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java11
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java6
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinition.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinitionHash.java12
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilder.java2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleExtensionDoc.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/user/index/UserDoc.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewDoc.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java6
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java3
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/OneToManyResilientIndexingListenerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/OneToOneResilientIndexingListenerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/SortingTest.java10
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java3
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowTest.java8
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeEmailTemplateTest.java3
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java3
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/setting/ThreadLocalSettingsTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java14
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java2
-rw-r--r--server/sonar-server-common/src/testFixtures/java/org/elasticsearch/transport/MockTcpTransport.java6
-rw-r--r--server/sonar-server-common/src/testFixtures/java/org/sonar/server/es/FakeDoc.java4
-rw-r--r--server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java4
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java2
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginFileSystemTest.java9
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java1
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java3
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java2
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java2
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/BaseContextFactoryTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java4
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtCsrfVerifierTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImplTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuthCsrfVerifierTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQPChangeNotificationTemplateTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java6
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java4
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java11
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java2
-rw-r--r--server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java4
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java5
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java3
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/debt/DebtModelPluginRepositoryTest.java13
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java6
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/CachingRuleFinderTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java50
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/WebServerRuleFinderImplTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/search/BaseDocTest.java8
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java4
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java2
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java4
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java4
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java14
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/Result.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/AvailableAction.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/PluginUpdateAggregator.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/NewCustomRule.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdate.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/DeleteAction.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/UpdateAction.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LogoutActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/CommentActionTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueFinderTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionServiceTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveMeasureComputerImplTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java21
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java13
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java24
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DestroyActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/RawActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/DeleteActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ws/ws/ResponseExampleActionTest.java2
-rw-r--r--server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java4
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java2
-rw-r--r--server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java6
-rw-r--r--server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java3
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java3
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java4
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java8
280 files changed, 494 insertions, 681 deletions
diff --git a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java
index 272f2ed19c5..04af2ddd440 100644
--- a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java
+++ b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubSettings.java
@@ -142,7 +142,7 @@ public class GitHubSettings {
.category(CATEGORY)
.subCategory(SUBCATEGORY)
.type(STRING)
- .defaultValue(valueOf("https://api.github.com/"))
+ .defaultValue("https://api.github.com/")
.index(7)
.build(),
PropertyDefinition.builder(WEB_URL)
@@ -152,7 +152,7 @@ public class GitHubSettings {
.category(CATEGORY)
.subCategory(SUBCATEGORY)
.type(STRING)
- .defaultValue(valueOf("https://github.com/"))
+ .defaultValue("https://github.com/")
.index(8)
.build(),
PropertyDefinition.builder(ORGANIZATIONS)
diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
index c13360733c6..6748c4b166a 100644
--- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
+++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
@@ -32,7 +32,7 @@ public class Krb5LoginConfiguration extends Configuration {
static {
String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
AppConfigurationEntry.LoginModuleControlFlag flag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
- CONFIG_LIST[0] = new AppConfigurationEntry(loginModule, flag, new HashMap<String, Object>());
+ CONFIG_LIST[0] = new AppConfigurationEntry(loginModule, flag, new HashMap<>());
}
/**
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
index 989a3305fd7..7cfa94a1073 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
@@ -73,7 +73,7 @@ public class LdapAutodiscoveryTest {
Attribute attribute = mock(Attribute.class);
NamingEnumeration namingEnumeration = mock(NamingEnumeration.class);
- when(context.getAttributes(Mockito.anyString(), Mockito.<String[]>anyObject())).thenReturn(attributes);
+ when(context.getAttributes(Mockito.anyString(), Mockito.anyObject())).thenReturn(attributes);
when(attributes.get(Mockito.eq("srv"))).thenReturn(attribute);
when(attribute.getAll()).thenReturn(namingEnumeration);
when(namingEnumeration.hasMore()).thenReturn(true, true, true, true, true, false);
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
index a2aab4bc3c0..7859f415903 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
@@ -44,7 +44,7 @@ public class LdapGroupsProviderTest {
public static LdapServer infosupportServer = new LdapServer(USERS_INFOSUPPORT_COM_LDIF, "infosupport.com", "dc=infosupport,dc=com");
@Test
- public void defaults() throws Exception {
+ public void defaults() {
MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, null);
LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery());
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
index 88d16dedec8..02780a2af32 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
@@ -62,7 +62,7 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testContextFactoriesWithSingleLdap() throws Exception {
+ public void testContextFactoriesWithSingleLdap() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateSingleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getContextFactories().size()).isEqualTo(1);
@@ -71,11 +71,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapContextFactory}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testContextFactoriesWithMultipleLdap() throws Exception {
+ public void testContextFactoriesWithMultipleLdap() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getContextFactories().size()).isEqualTo(2);
@@ -84,7 +82,7 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testAutodiscover() throws Exception {
+ public void testAutodiscover() {
LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class);
LdapSrvRecord ldap1 = new LdapSrvRecord("ldap://localhost:189", 1, 1);
LdapSrvRecord ldap2 = new LdapSrvRecord("ldap://localhost:1899", 1, 1);
@@ -95,9 +93,9 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testAutodiscoverFailed() throws Exception {
+ public void testAutodiscoverFailed() {
LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class);
- when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Collections.<LdapSrvRecord>emptyList());
+ when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Collections.emptyList());
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateAutodiscoverSettings(), ldapAutodiscovery);
@@ -110,11 +108,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapUserMapping}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testUserMappings() throws Exception {
+ public void testUserMappings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getUserMappings().size()).isEqualTo(2);
@@ -125,11 +121,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapGroupMapping}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testGroupMappings() throws Exception {
+ public void testGroupMappings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getGroupMappings().size()).isEqualTo(2);
@@ -140,10 +134,9 @@ public class LdapSettingsManagerTest {
/**
* Test what happens when no configuration is set.
* Normally there will be a contextFactory, but the autodiscovery doesn't work for the test server.
- * @throws Exception
*/
@Test
- public void testEmptySettings() throws Exception {
+ public void testEmptySettings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
new MapSettings(), new LdapAutodiscovery());
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
index 90e61e59fea..ff2c503a044 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
@@ -43,7 +43,7 @@ public class LdapUsersProviderTest {
public static LdapServer infosupportServer = new LdapServer(USERS_INFOSUPPORT_COM_LDIF, "infosupport.com", "dc=infosupport,dc=com");
@Test
- public void test() throws Exception {
+ public void test() {
Settings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer);
LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery());
LdapUsersProvider usersProvider = new LdapUsersProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings());
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitor.java
index 4a091871d84..f21fa89ed5a 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitor.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/CloseIssuesOnRemovedComponentsVisitor.java
@@ -54,8 +54,7 @@ public class CloseIssuesOnRemovedComponentsVisitor extends TypeAwareVisitorAdapt
}
private void closeIssuesForDeletedComponentUuids(Set<String> deletedComponentUuids) {
- DiskCache<DefaultIssue>.DiskAppender cacheAppender = issueCache.newAppender();
- try {
+ try (DiskCache<DefaultIssue>.DiskAppender cacheAppender = issueCache.newAppender()) {
for (String deletedComponentUuid : deletedComponentUuids) {
List<DefaultIssue> issues = issuesLoader.loadOpenIssues(deletedComponentUuid);
for (DefaultIssue issue : issues) {
@@ -66,8 +65,6 @@ public class CloseIssuesOnRemovedComponentsVisitor extends TypeAwareVisitorAdapt
cacheAppender.append(issue);
}
}
- } finally {
- cacheAppender.close();
}
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
index df7a4865df5..1a540c7eb3c 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
@@ -196,7 +196,7 @@ public class ComponentIssuesLoader {
i.addComment(c.toComment());
break;
default:
- throw new IllegalStateException("Unknow change type: " + c.getChangeType());
+ throw new IllegalStateException("Unknown change type: " + c.getChangeType());
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java
index cbb25a73897..de736bb91d4 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueCounter.java
@@ -200,7 +200,7 @@ public class IssueCounter extends IssueVisitor {
if (!periodHolder.hasPeriod() && !analysisMetadataHolder.isPullRequest()) {
return;
}
- double unresolvedVariations = (double) currentCounters.counterForPeriod().unresolved;
+ double unresolvedVariations = currentCounters.counterForPeriod().unresolved;
measureRepository.add(component, metricRepository.getByKey(NEW_VIOLATIONS_KEY), Measure.newMeasureBuilder()
.setVariation(unresolvedVariations)
.createNoValue());
@@ -211,7 +211,7 @@ public class IssueCounter extends IssueVisitor {
Multiset<String> bag = currentCounters.counterForPeriod().severityBag;
Metric metric = metricRepository.getByKey(metricKey);
measureRepository.add(component, metric, Measure.newMeasureBuilder()
- .setVariation((double) bag.count(severity))
+ .setVariation(bag.count(severity))
.createNoValue());
}
@@ -223,7 +223,7 @@ public class IssueCounter extends IssueVisitor {
Multiset<RuleType> bag = currentCounters.counterForPeriod().typeBag;
Metric metric = metricRepository.getByKey(metricKey);
measureRepository.add(component, metric, Measure.newMeasureBuilder()
- .setVariation((double) bag.count(type))
+ .setVariation(bag.count(type))
.createNoValue());
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
index 61cf97bc13f..98aaf4f56a2 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
@@ -31,7 +31,6 @@ import org.sonar.core.issue.DefaultIssueComment;
import org.sonar.core.issue.FieldDiffs;
import org.sonar.core.issue.IssueChangeContext;
import org.sonar.core.util.Uuids;
-import org.sonar.db.component.KeyType;
import org.sonar.server.issue.IssueFieldsSetter;
import org.sonar.server.issue.workflow.IssueWorkflow;
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java
index 3e5b684d24f..7d58909ad26 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/LiveMeasureDtoToMeasure.java
@@ -77,7 +77,7 @@ public class LiveMeasureDtoToMeasure {
}
return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto)
- .create(value.doubleValue(), org.sonar.api.measures.Metric.MAX_DECIMAL_SCALE, data));
+ .create(value, org.sonar.api.measures.Metric.MAX_DECIMAL_SCALE, data));
}
private static Optional<Measure> toBooleanMeasure(LiveMeasureDto measureDto, @Nullable Double value, @Nullable String data) {
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java
index 96f9530be16..673708246a2 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java
@@ -458,7 +458,7 @@ public interface Measure {
}
public Measure create(int value, @Nullable String data) {
- return createInternal(ValueType.INT, (double) value, data);
+ return createInternal(ValueType.INT, value, data);
}
public Measure create(int value) {
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java
index 7a634d4fdec..5e5c370a9b1 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureDtoToMeasure.java
@@ -77,7 +77,7 @@ public class MeasureDtoToMeasure {
}
return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto)
- .create(value.doubleValue(), org.sonar.api.measures.Metric.MAX_DECIMAL_SCALE, data));
+ .create(value, org.sonar.api.measures.Metric.MAX_DECIMAL_SCALE, data));
}
private static Optional<Measure> toBooleanMeasure(MeasureDto measureDto, @Nullable Double value, String data) {
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryImpl.java
index ced2f5d0d73..769213feeb1 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryImpl.java
@@ -48,13 +48,10 @@ public class MetricRepositoryImpl implements MetricRepository, Startable {
@Override
public void start() {
- DbSession dbSession = dbClient.openSession(false);
- try {
+ try (DbSession dbSession = dbClient.openSession(false)) {
List<MetricDto> metricList = dbClient.metricDao().selectEnabled(dbSession);
this.metricsByKey = from(metricList).transform(MetricDtoToMetric.INSTANCE).uniqueIndex(MetricToKey.INSTANCE);
this.metricsById = from(metricList).transform(MetricDtoToMetric.INSTANCE).uniqueIndex(MetricToId.INSTANCE);
- } finally {
- dbSession.close();
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationEmailTemplate.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationEmailTemplate.java
index 280fdd3fd11..74374ac54a9 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationEmailTemplate.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationEmailTemplate.java
@@ -27,6 +27,7 @@ import org.sonar.api.notifications.Notification;
import org.sonar.server.issue.notification.EmailMessage;
import org.sonar.server.issue.notification.EmailTemplate;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.sonar.api.utils.DateUtils.formatDateTime;
public class ReportAnalysisFailureNotificationEmailTemplate implements EmailTemplate {
@@ -94,7 +95,7 @@ public class ReportAnalysisFailureNotificationEmailTemplate implements EmailTemp
private static String encode(String toEncode) {
try {
- return URLEncoder.encode(toEncode, "UTF-8");
+ return URLEncoder.encode(toEncode, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Encoding not supported", e);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
index b86b8a8ca3b..289db4cc0ac 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
@@ -109,7 +109,7 @@ public class PostProjectAnalysisTasksExecutorTest {
new PostProjectAnalysisTask[] {postProjectAnalysisTask});
@Before
- public void setUp() throws Exception {
+ public void setUp() {
qualityGateHolder.setQualityGate(new QualityGate(QUALITY_GATE_ID, QUALITY_GATE_NAME, of(CONDITION_1, CONDITION_2)));
qualityGateStatusHolder.setStatus(QualityGateStatus.OK, ImmutableMap.of(
CONDITION_1, ConditionStatus.create(ConditionStatus.EvaluationStatus.OK, "value"),
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java
index 2d76be70a4b..fa3a1335cb1 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/CrawlerDepthLimitTest.java
@@ -20,13 +20,13 @@
package org.sonar.ce.task.projectanalysis.component;
import com.google.common.base.Function;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.util.Arrays;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
@@ -43,18 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(DataProviderRunner.class)
public class CrawlerDepthLimitTest {
- private static final Set<Type> REPORT_TYPES = from(asList(Type.values())).filter(new Predicate<Type>() {
- @Override
- public boolean apply(Type input) {
- return input.isReportType();
- }
- }).toSet();
- private static final Set<Type> VIEWS_TYPES = from(asList(Type.values())).filter(new Predicate<Type>() {
- @Override
- public boolean apply(Type input) {
- return input.isViewsType();
- }
- }).toSet();
+ private static final Set<Type> REPORT_TYPES = Arrays.stream(Type.values()).filter(Type::isReportType).collect(Collectors.toSet());
+ private static final Set<Type> VIEWS_TYPES = Arrays.stream(Type.values()).filter(Type::isViewsType).collect(Collectors.toSet());
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -258,7 +248,7 @@ public class CrawlerDepthLimitTest {
for (Type type : types) {
assertThat(depthLimit.isHigherThan(type)).as("isHigherThan(%s)", type).isTrue();
}
- for (Type reportType : from(REPORT_TYPES).filter(not(in(Arrays.asList(types))))) {
+ for (Type reportType : from(REPORT_TYPES).filter(not(in(asList(types))))) {
assertThat(depthLimit.isHigherThan(reportType)).as("isHigherThan(%s)", reportType).isFalse();
}
}
@@ -267,7 +257,7 @@ public class CrawlerDepthLimitTest {
for (Type type : types) {
assertThat(depthLimit.isHigherThan(type)).as("isHigherThan(%s)", type).isTrue();
}
- for (Type reportType : from(VIEWS_TYPES).filter(not(in(Arrays.asList(types))))) {
+ for (Type reportType : from(VIEWS_TYPES).filter(not(in(asList(types))))) {
assertThat(depthLimit.isHigherThan(reportType)).as("isHigherThan(%s)", reportType).isFalse();
}
}
@@ -276,7 +266,7 @@ public class CrawlerDepthLimitTest {
for (Type type : types) {
assertThat(depthLimit.isDeeperThan(type)).as("isDeeperThan(%s)", type).isTrue();
}
- for (Type reportType : from(REPORT_TYPES).filter(not(in(Arrays.asList(types))))) {
+ for (Type reportType : from(REPORT_TYPES).filter(not(in(asList(types))))) {
assertThat(depthLimit.isDeeperThan(reportType)).as("isDeeperThan(%s)", reportType).isFalse();
}
}
@@ -285,7 +275,7 @@ public class CrawlerDepthLimitTest {
for (Type type : types) {
assertThat(depthLimit.isDeeperThan(type)).as("isDeeperThan(%s)", type).isTrue();
}
- for (Type reportType : from(VIEWS_TYPES).filter(not(in(Arrays.asList(types))))) {
+ for (Type reportType : from(VIEWS_TYPES).filter(not(in(asList(types))))) {
assertThat(depthLimit.isDeeperThan(reportType)).as("isDeeperThan(%s)", reportType).isFalse();
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
index 63d6cd19a90..26b54e507c9 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
@@ -64,7 +64,7 @@ public class ScoreMatrixDumperImplTest {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
FileUtils.listFiles(tempDir.toFile(), new AbstractFileFilter() {
@Override
public boolean accept(File file) {
@@ -119,7 +119,7 @@ public class ScoreMatrixDumperImplTest {
};
}
- private static Collection<File> listDumpFilesForTaskUuid(String taskUuid) throws IOException {
+ private static Collection<File> listDumpFilesForTaskUuid(String taskUuid) {
return FileUtils.listFiles(tempDir.toFile(), new AbstractFileFilter() {
@Override
public boolean accept(File file) {
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java
index c5b14a98b1b..5a702e672f2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/AverageFormulaExecutionTest.java
@@ -57,10 +57,10 @@ public class AverageFormulaExecutionTest {
@Rule
public PeriodHolderRule periodsHolder = new PeriodHolderRule();
- FormulaExecutorComponentVisitor underTest;
+ private FormulaExecutorComponentVisitor underTest;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
underTest = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(Lists.newArrayList(
AverageFormula.Builder.newBuilder()
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java
index 8237e2d3fdb..188f44d830a 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/ReportFormulaExecutorComponentVisitorTest.java
@@ -315,7 +315,7 @@ public class ReportFormulaExecutorComponentVisitorTest {
}
}
- private class FakeCounter implements Counter<FakeCounter> {
+ private static class FakeCounter implements Counter<FakeCounter> {
private int value = 0;
@Override
@@ -364,7 +364,7 @@ public class ReportFormulaExecutorComponentVisitorTest {
}
}
- private class FakeVariationCounter implements Counter<FakeVariationCounter> {
+ private static class FakeVariationCounter implements Counter<FakeVariationCounter> {
private final IntValue values = new IntValue();
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java
index cdaec5e99d6..d631cef2706 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/SumFormulaExecutionTest.java
@@ -53,7 +53,7 @@ public class SumFormulaExecutionTest {
FormulaExecutorComponentVisitor underTest;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
underTest = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(Lists.newArrayList(createIntSumFormula(LINES_KEY)));
}
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 24b8edf5bd7..7e4414feb13 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
@@ -152,7 +152,6 @@ public class IntegrateIssuesVisitorTest {
tracker = new TrackerExecution(baseInputFactory, rawInputFactory, closedIssuesInputFactory, new Tracker<>(), issuesLoader, analysisMetadataHolder);
prBranchTracker = new PullRequestTrackerExecution(baseInputFactory, rawInputFactory, new Tracker<>(), newLinesRepository);
mergeBranchTracker = new ReferenceBranchTrackerExecution(rawInputFactory, mergeInputFactory, new Tracker<>());
-
trackingDelegator = new IssueTrackingDelegator(prBranchTracker, mergeBranchTracker, tracker, analysisMetadataHolder);
treeRootHolder.setRoot(PROJECT);
issueCache = new IssueCache(temp.newFile(), System2.INSTANCE);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitorTest.java
index d1e51f4281b..d9821109256 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssuesRepositoryVisitorTest.java
@@ -57,7 +57,7 @@ public class IssuesRepositoryVisitorTest {
IssuesRepositoryVisitor underTest = new IssuesRepositoryVisitor(componentIssuesRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(PROJECT);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java
index 386bf4a2231..3456a7a33b4 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/MovedIssueVisitorTest.java
@@ -60,7 +60,7 @@ public class MovedIssueVisitorTest {
private MovedIssueVisitor underTest = new MovedIssueVisitor(analysisMetadataHolder, movedFilesRepository, new IssueFieldsSetter());
@Before
- public void setUp() throws Exception {
+ public void setUp() {
analysisMetadataHolder.setAnalysisDate(ANALYSIS_DATE);
when(movedFilesRepository.getOriginalFile(any(Component.class)))
.thenReturn(Optional.absent());
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestTrackerExecutionTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestTrackerExecutionTest.java
index f7a7fe26fb0..aa7816f7e22 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestTrackerExecutionTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/PullRequestTrackerExecutionTest.java
@@ -66,7 +66,7 @@ public class PullRequestTrackerExecutionTest {
private List<DefaultIssue> baseIssues = new ArrayList<>();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(rawFactory.create(FILE)).thenReturn(createInput(rawIssues));
when(baseFactory.create(FILE)).thenReturn(createInput(baseIssues));
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryImplTest.java
index 6f694130957..c9a46a270f5 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryImplTest.java
@@ -81,7 +81,7 @@ public class RuleRepositoryImplTest {
private RuleRepositoryImpl underTest = new RuleRepositoryImpl(adHocRuleCreator, dbClient, analysisMetadataHolder);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.openSession(anyBoolean())).thenReturn(dbSession);
when(dbClient.ruleDao()).thenReturn(ruleDao);
when(ruleDao.selectAll(any(DbSession.class), eq(ORGANIZATION_UUID))).thenReturn(ImmutableList.of(AB_RULE));
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryRule.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryRule.java
index 1393647e054..fbcd53dd11e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/RuleRepositoryRule.java
@@ -81,7 +81,7 @@ public class RuleRepositoryRule extends ExternalResource implements RuleReposito
public RuleRepositoryRule add(DumbRule rule) {
rulesByKey.put(requireNonNull(rule.getKey()), rule);
- rulesById.put(requireNonNull(rule.getId()), rule);
+ rulesById.put(rule.getId(), rule);
return this;
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerBaseInputFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerBaseInputFactoryTest.java
index f9562921b33..ae446e9fc73 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerBaseInputFactoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerBaseInputFactoryTest.java
@@ -61,7 +61,7 @@ public class TrackerBaseInputFactoryTest {
new IssueFieldsSetter(), mock(ComponentsWithUnprocessedIssues.class));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.openSession(false)).thenReturn(dbSession);
when(dbClient.fileSourceDao()).thenReturn(fileSourceDao);
when(movedFilesRepository.getOriginalFile(any(Component.class)))
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java
index f6883521632..3e18e0c5b01 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimizationTest.java
@@ -146,9 +146,9 @@ public class BestValueOptimizationTest {
Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.RATING, A.getIndex()), FILE_COMPONENT);
assertThat(underTest.test(newMeasureBuilder().create(A.getIndex()))).isTrue();
- assertThat(underTest.test(newMeasureBuilder().setVariation((double) A.getIndex()).createNoValue())).isTrue();
+ assertThat(underTest.test(newMeasureBuilder().setVariation(A.getIndex()).createNoValue())).isTrue();
assertThat(underTest.test(newMeasureBuilder().create(B.getIndex()))).isFalse();
- assertThat(underTest.test(newMeasureBuilder().setVariation((double) B.getIndex()).createNoValue())).isFalse();
+ assertThat(underTest.test(newMeasureBuilder().setVariation(B.getIndex()).createNoValue())).isFalse();
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
index 68253569a7d..e74bc2ecd06 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
@@ -20,7 +20,6 @@
package org.sonar.ce.task.projectanalysis.measure;
import com.google.common.base.Function;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
@@ -277,12 +276,7 @@ public class MeasureRepositoryImplTest {
}
private Measure getSomeMeasureByValueType(final Metric.MetricType metricType) {
- return from(MEASURES).filter(new Predicate<Measure>() {
- @Override
- public boolean apply(@Nullable Measure input) {
- return input.getValueType() == metricType.getValueType();
- }
- }).first().get();
+ return from(MEASURES).filter(input -> input.getValueType() == metricType.getValueType()).first().get();
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java
index d5e0aa80076..d8cfe10b77f 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java
@@ -218,7 +218,7 @@ public class MeasureTest {
assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create(false, null).getQualityGateStatus()).isEqualTo(someStatus);
assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create(1, null).getQualityGateStatus()).isEqualTo(someStatus);
assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create((long) 1, null).getQualityGateStatus()).isEqualTo(someStatus);
- assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create((double) 1, 1, null).getQualityGateStatus()).isEqualTo(someStatus);
+ assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create(1, 1, null).getQualityGateStatus()).isEqualTo(someStatus);
assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create("str").getQualityGateStatus()).isEqualTo(someStatus);
assertThat(newMeasureBuilder().setQualityGateStatus(someStatus).create(Measure.Level.OK).getQualityGateStatus()).isEqualTo(someStatus);
}
@@ -263,7 +263,7 @@ public class MeasureTest {
assertThat(newMeasureBuilder().create(false, someData).getData()).isEqualTo(someData);
assertThat(newMeasureBuilder().create(1, someData).getData()).isEqualTo(someData);
assertThat(newMeasureBuilder().create((long) 1, someData).getData()).isEqualTo(someData);
- assertThat(newMeasureBuilder().create((double) 1, 1, someData).getData()).isEqualTo(someData);
+ assertThat(newMeasureBuilder().create(1, 1, someData).getData()).isEqualTo(someData);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDtoTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDtoTest.java
index 1301088a749..24458d15aa4 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDtoTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureToMeasureDtoTest.java
@@ -61,7 +61,7 @@ public class MeasureToMeasureDtoTest {
private MeasureToMeasureDto underTest = new MeasureToMeasureDto(analysisMetadataHolder, treeRootHolder);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
analysisMetadataHolder.setUuid(ANALYSIS_UUID);
}
@@ -81,7 +81,7 @@ public class MeasureToMeasureDtoTest {
{Measure.newMeasureBuilder().create(true, SOME_DATA), SOME_BOOLEAN_METRIC},
{Measure.newMeasureBuilder().create(1, SOME_DATA), SOME_INT_METRIC},
{Measure.newMeasureBuilder().create((long) 1, SOME_DATA), SOME_LONG_METRIC},
- {Measure.newMeasureBuilder().create((double) 2, 1, SOME_DATA), SOME_DOUBLE_METRIC},
+ {Measure.newMeasureBuilder().create(2, 1, SOME_DATA), SOME_DOUBLE_METRIC},
{Measure.newMeasureBuilder().create(SOME_STRING), SOME_STRING_METRIC},
{Measure.newMeasureBuilder().create(Measure.Level.OK), SOME_LEVEL_METRIC}
};
@@ -160,7 +160,7 @@ public class MeasureToMeasureDtoTest {
@Test
public void toMeasureDto_maps_value_and_data_from_data_field_for_DOUBLE_metric() {
- MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create((double) 789, 1, SOME_DATA), SOME_DOUBLE_METRIC, SOME_COMPONENT);
+ MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create(789, 1, SOME_DATA), SOME_DOUBLE_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isEqualTo(789);
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_DATA);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java
index 0dc856ed72b..587254a4c41 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java
@@ -60,7 +60,7 @@ public class QualityGateServiceImplTest {
private QualityGateServiceImpl underTest = new QualityGateServiceImpl(dbClient, metricRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.qualityGateDao()).thenReturn(qualityGateDao);
when(dbClient.gateConditionDao()).thenReturn(qualityGateConditionDao);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java
index 1931072d0aa..1d5258eb770 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/NewMaintainabilityMeasuresVisitorTest.java
@@ -92,7 +92,7 @@ public class NewMaintainabilityMeasuresVisitorTest {
private VisitorsCrawler underTest;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(ratingSettings.getDebtRatingGrid()).thenReturn(new DebtRatingGrid(RATING_GRID));
underTest = new VisitorsCrawler(Arrays.asList(new NewMaintainabilityMeasuresVisitor(metricRepository, measureRepository, newLinesRepository, ratingSettings)));
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java
index a0418e92b89..be723bb6a2f 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderTest.java
@@ -43,7 +43,6 @@ import org.sonar.db.source.FileSourceDto;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.sonar.api.utils.log.LoggerLevel.TRACE;
import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryRule.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryRule.java
index 756c5c25975..a61a4610ccc 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryRule.java
@@ -49,7 +49,7 @@ public class ScmInfoRepositoryRule extends ExternalResource implements ScmInfoRe
}
public ScmInfoRepositoryRule setScmInfo(int fileRef, Map<Integer, Changeset> changesets) {
- scmInfoByFileRef.put(fileRef, new ScmInfoImpl(changesets.values().stream().toArray(Changeset[]::new)));
+ scmInfoByFileRef.put(fileRef, new ScmInfoImpl(changesets.values().toArray(new Changeset[0])));
return this;
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImplTest.java
index 238d9759ef4..f49a78727ef 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/SourceLinesDiffImplTest.java
@@ -62,7 +62,7 @@ public class SourceLinesDiffImplTest {
};
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.openSession(false)).thenReturn(dbSession);
when(dbClient.componentDao()).thenReturn(componentDao);
when(dbClient.fileSourceDao()).thenReturn(fileSourceDao);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/DbMigrationsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/DbMigrationsStepTest.java
index aeaf7580cb0..41d87e78205 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/DbMigrationsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/DbMigrationsStepTest.java
@@ -52,7 +52,7 @@ public class DbMigrationsStepTest {
ProjectAnalysisDataChange[] dataChanges = IntStream.range(0, 5 + new Random().nextInt(5))
.mapToObj(i -> mock(ProjectAnalysisDataChange.class))
.toArray(ProjectAnalysisDataChange[]::new);
- InOrder inOrder = Mockito.inOrder((Object[]) dataChanges);
+ InOrder inOrder = Mockito.inOrder(dataChanges);
when(projectAnalysisDataChanges.getDataChanges()).thenReturn(Arrays.asList(dataChanges));
underTest.execute(new TestComputationStepContext());
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
index a7e92cc0664..0683436fddc 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
@@ -207,7 +207,7 @@ public class ExecuteVisitorsStepTest {
}
}
- public class Counter {
+ public static class Counter {
private int value = 0;
public void add(int value) {
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
index 67406258bd1..4870c3bc825 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadCrossProjectDuplicationsRepositoryStepTest.java
@@ -103,7 +103,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest {
integrateCrossProjectDuplications, dbClient);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert());
dbClient.componentDao().insert(dbSession, project);
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
index 01966886f92..47f9b6bf042 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
@@ -101,7 +101,7 @@ public class LoadPeriodsStepTest extends BaseStepTest {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
organization = dbTester.organizations().insert();
project = dbTester.components().insertMainBranch(organization);
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 3dca5219162..ef827047fcb 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
@@ -84,7 +84,7 @@ public class PersistCrossProjectDuplicationIndexStepTest {
private ComputationStep underTest;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(baseAnalysis.getUuid()).thenReturn(BASE_ANALYSIS_UUID);
analysisMetadataHolder.setUuid(ANALYSIS_UUID);
analysisMetadataHolder.setBaseAnalysis(baseAnalysis);
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 987c834ad91..b7f36b3bc26 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
@@ -79,7 +79,7 @@ public class PersistDuplicationDataStepTest extends BaseStepTest {
public MetricRepositoryRule metricRepository = new MetricRepositoryRule();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MetricDto metric = db.measures().insertMetric(m -> m.setKey(DUPLICATIONS_DATA_KEY).setValueType(Metric.ValueType.STRING.name()));
insertComponent(PROJECT_KEY, PROJECT_UUID);
insertComponent(FILE_1_KEY, FILE_1_UUID);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java
index fbcd8650fa2..e49b8231f13 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCommentMeasuresStepTest.java
@@ -72,7 +72,7 @@ public class ReportCommentMeasuresStepTest {
ComputationStep underTest = new CommentMeasuresStep(treeRootHolder, metricRepository, measureRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(
builder(PROJECT, ROOT_REF)
.addChildren(
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java
index 052e07e1277..a1c07268841 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportCoverageMeasuresStepTest.java
@@ -75,7 +75,7 @@ public class ReportCoverageMeasuresStepTest {
CoverageMeasuresStep underTest = new CoverageMeasuresStep(treeRootHolder, metricRepository, measureRepository, reportReader);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(
builder(PROJECT, ROOT_REF)
.addChildren(
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java
index 6bfcc3f31ae..2f92cbe943c 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportLanguageDistributionMeasuresStepTest.java
@@ -66,7 +66,7 @@ public class ReportLanguageDistributionMeasuresStepTest {
ComputationStep underTest = new LanguageDistributionMeasuresStep(treeRootHolder, metricRepository, measureRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(
builder(PROJECT, ROOT_REF)
.addChildren(
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
index e3171b9a66a..89c23047b41 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
@@ -87,7 +87,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
private Date now;
private MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS);
private PersistComponentsStep underTest;
- private BranchPersister branchPersister;
@Before
public void setup() throws Exception {
@@ -95,7 +94,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
when(system2.now()).thenReturn(now.getTime());
db.organizations().insertForUuid(ORGANIZATION_UUID);
- branchPersister = mock(BranchPersister.class);
+ BranchPersister branchPersister = mock(BranchPersister.class);
underTest = new PersistComponentsStep(dbClient, treeRootHolder, dbIdsRepository, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCommentMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCommentMeasuresStepTest.java
index 222b367b2c3..11f0f2a102a 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCommentMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCommentMeasuresStepTest.java
@@ -74,7 +74,7 @@ public class ViewsCommentMeasuresStepTest {
ComputationStep underTest = new CommentMeasuresStep(treeRootHolder, metricRepository, measureRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(
builder(VIEW, ROOT_REF)
.addChildren(
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCoverageMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCoverageMeasuresStepTest.java
index 5c2ef23cb4e..f704e8464cc 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCoverageMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsCoverageMeasuresStepTest.java
@@ -65,7 +65,7 @@ public class ViewsCoverageMeasuresStepTest {
CoverageMeasuresStep underTest = new CoverageMeasuresStep(treeRootHolder, metricRepository, measureRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(
builder(VIEW, ROOT_REF)
.addChildren(
diff --git a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
index 1858d25a7f7..04d3d1b36bc 100644
--- a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
@@ -117,7 +117,6 @@ public class AnalysisMetadataHolderRule extends ExternalResource implements Muta
@Override
public AnalysisMetadataHolderRule setAnalysisDate(long date) {
- checkNotNull(date, "Date must not be null");
this.analysisDate.setProperty(date);
return this;
}
diff --git a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryRule.java b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryRule.java
index 7f781ff34b0..9d3f601703f 100644
--- a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/metric/MetricRepositoryRule.java
@@ -73,7 +73,6 @@ public class MetricRepositoryRule extends ExternalResource implements MetricRepo
public MetricRepositoryRule add(Metric metric) {
requireNonNull(metric.getKey(), "key can not be null");
- requireNonNull(metric.getId(), "id can not be null");
checkState(!metricsByKey.containsKey(metric.getKey()), format("Repository already contains a metric for key %s", metric.getKey()));
checkState(!metricsById.containsKey((long) metric.getId()), format("Repository already contains a metric for id %s", metric.getId()));
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
index f17cbf65d9e..d1bc0882f79 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
@@ -19,21 +19,18 @@
*/
package org.sonar.ce.taskprocessor;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.sonar.ce.task.CeTask;
import org.sonar.ce.task.taskprocessor.CeTaskProcessor;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.FluentIterable.from;
import static java.lang.String.CASE_INSENSITIVE_ORDER;
import static java.lang.String.format;
@@ -42,8 +39,6 @@ import static java.lang.String.format;
* PicoContainer the current object belongs to.
*/
public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository {
- private static final Joiner COMMA_JOINER = Joiner.on(", ");
-
private final Map<String, CeTaskProcessor> taskProcessorByCeTaskType;
public CeTaskProcessorRepositoryImpl(CeTaskProcessor[] taskProcessors) {
@@ -58,7 +53,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository
private static Map<String, CeTaskProcessor> indexTaskProcessors(CeTaskProcessor[] taskProcessors) {
Multimap<String, CeTaskProcessor> permissiveIndex = buildPermissiveCeTaskProcessorIndex(taskProcessors);
checkUniqueHandlerPerCeTaskType(permissiveIndex);
- return ImmutableMap.copyOf(Maps.transformValues(permissiveIndex.asMap(), CeTaskProcessorCollectionToFirstElement.INSTANCE));
+ return permissiveIndex.asMap().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, y -> CeTaskProcessorCollectionToFirstElement.INSTANCE.apply(y.getValue())));
}
private static Multimap<String, CeTaskProcessor> buildPermissiveCeTaskProcessorIndex(CeTaskProcessor[] taskProcessors) {
@@ -79,7 +74,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository
"There can be only one CeTaskProcessor instance registered as the processor for CeTask type %s. " +
"More than one found. Please fix your configuration: %s",
entry.getKey(),
- COMMA_JOINER.join(from(entry.getValue()).transform(ToClassName.INSTANCE).toSortedList(CASE_INSENSITIVE_ORDER))));
+ entry.getValue().stream().map(ToClassName.INSTANCE).sorted(CASE_INSENSITIVE_ORDER).collect(Collectors.joining(", "))));
}
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
index 38d50609779..e5ac953aeb5 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
@@ -104,8 +104,7 @@ public class CeDistributedInformationImplTest {
connectedClients.add(clientUUID1);
connectedClients.add(clientUUID2);
connectedClients.add(clientUUID3);
- Map modifiableWorkerMap = new HashMap();
- modifiableWorkerMap.putAll(workerMap);
+ Map modifiableWorkerMap = new HashMap(workerMap);
when(hzClientWrapper.getUuid()).thenReturn(clientUUID1);
when(hzClientWrapper.getMemberUuids()).thenReturn(connectedClients);
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java
index ed29b66a014..7a9ff48a625 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java
@@ -89,7 +89,7 @@ public class CePluginJarExploderTest {
return new File("src/test/plugins/sonar-test2-plugin/target/sonar-test2-plugin-0.1-SNAPSHOT.jar");
}
- private class DumbFileSystem implements ServerFileSystem {
+ private static class DumbFileSystem implements ServerFileSystem {
private final TemporaryFolder temp;
private File tempDir;
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java
index c002d288e26..3af53faea9b 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java
@@ -19,9 +19,9 @@
*/
package org.sonar.ce.container;
-import com.google.common.collect.Maps;
import java.io.File;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.Rule;
@@ -144,7 +144,7 @@ public class CePluginRepositoryTest {
*/
@Override
public Map<String, Plugin> load(Map<String, PluginInfo> infoByKeys) {
- Map<String, Plugin> result = Maps.newHashMap();
+ Map<String, Plugin> result = new HashMap<>();
for (String pluginKey : infoByKeys.keySet()) {
result.put(pluginKey, mock(Plugin.class));
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index d6bf03851e6..aa6aedf7c59 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -138,7 +138,7 @@ public class ComputeEngineContainerImplTest {
.map(ComponentAdapter::getComponentImplementation)
.collect(Collectors.toList())).doesNotContain(
(Class) CeDistributedInformationImpl.class).contains(
- (Class) StandaloneCeDistributedInformation.class);
+ StandaloneCeDistributedInformation.class);
assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull();
} finally {
underTest.stop();
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
index e686c1ea019..9c4c86b2db6 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
@@ -281,7 +281,7 @@ public class CeProcessingSchedulerImplTest {
processingExecutorService.runFutures();
}
- private class TestCeWorkerFactory implements CeWorkerFactory {
+ private static class TestCeWorkerFactory implements CeWorkerFactory {
private final Iterator<CeWorker> ceWorkers;
private TestCeWorkerFactory(CeWorker... ceWorkers) {
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java
index fe3f2845d8e..5b665121e8f 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java
@@ -40,7 +40,7 @@ class ProfilingPreparedStatementHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().startsWith("execute")) {
Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start();
- Object result = null;
+ Object result;
try {
result = InvocationUtils.invokeQuietly(statement, method, args);
} finally {
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java
index 92b4373b311..88b2119027e 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java
@@ -36,7 +36,7 @@ class ProfilingStatementHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().startsWith("execute")) {
Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start();
- Object result = null;
+ Object result;
try {
result = InvocationUtils.invokeQuietly(statement, method, args);
} finally {
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java
index 40ee287d0e6..3d3fe1d03f5 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java
@@ -146,7 +146,7 @@ public class DatabaseUtilsTest {
public void toUniqueAndSortedList_throws_NPE_if_arg_is_a_set_containing_a_null() {
expectedException.expect(NullPointerException.class);
- toUniqueAndSortedList(new HashSet<>(asList("A", (String) null, "C")));
+ toUniqueAndSortedList(new HashSet<>(asList("A", null, "C")));
}
@Test
diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java
index 0b9bb16bc6e..4c7b2f35584 100644
--- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java
+++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java
@@ -37,6 +37,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -54,8 +55,6 @@ import org.sonar.core.util.stream.MoreCollectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Lists.asList;
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Maps.newHashMap;
import static java.sql.ResultSetMetaData.columnNoNulls;
import static java.sql.ResultSetMetaData.columnNullable;
import static org.assertj.core.api.Assertions.assertThat;
@@ -209,9 +208,9 @@ public class AbstractDbTester<T extends TestDb> extends ExternalResource {
private static List<Map<String, Object>> getHashMap(ResultSet resultSet) throws Exception {
ResultSetMetaData metaData = resultSet.getMetaData();
int colCount = metaData.getColumnCount();
- List<Map<String, Object>> rows = newArrayList();
+ List<Map<String, Object>> rows = new ArrayList<>();
while (resultSet.next()) {
- Map<String, Object> columns = newHashMap();
+ Map<String, Object> columns = new HashMap<>();
for (int i = 1; i <= colCount; i++) {
Object value = resultSet.getObject(i);
if (value instanceof Clob) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java
index 214dfb66006..115d1661ac0 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java
@@ -22,7 +22,6 @@ package org.sonar.db.component;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -128,7 +127,7 @@ public class ComponentKeyUpdaterDao implements Dao {
branchModules.forEach(module -> branchBaseKeys.put(module.getKey(), branchBaseKey(module.getKey())));
});
- Map<ResourceDto, List<ResourceDto>> allResourcesByModuleMap = Maps.newHashMap();
+ Map<ResourceDto, List<ResourceDto>> allResourcesByModuleMap = new HashMap<>();
for (ResourceDto module : modules) {
allResourcesByModuleMap.put(module, mapper.selectProjectResources(module.getUuid()));
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/metric/MetricDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/metric/MetricDao.java
index ea7584a007c..e99075f7a52 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/metric/MetricDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/metric/MetricDao.java
@@ -22,9 +22,9 @@ package org.sonar.db.metric;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,9 +68,11 @@ public class MetricDao implements Dao {
}
public List<MetricDto> selectEnabled(DbSession session, @Nullable Boolean isCustom, int offset, int limit) {
- Map<String, Object> properties = Maps.newHashMapWithExpectedSize(1);
+ Map<String, Object> properties;
if (isCustom != null) {
- properties.put("isCustom", isCustom);
+ properties = Collections.singletonMap("isCustom", isCustom);
+ } else {
+ properties = Collections.emptyMap();
}
return mapper(session).selectAllEnabled(properties, new RowBounds(offset, limit));
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
index 77129395c49..2b2e7d57bf3 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
@@ -303,9 +303,9 @@ public class PropertiesDao implements Dao {
public void saveGlobalProperties(Map<String, String> properties) {
try (DbSession session = mybatis.openSession(false)) {
PropertiesMapper mapper = getMapper(session);
- properties.entrySet().forEach(entry -> {
- mapper.deleteGlobalProperty(entry.getKey());
- save(mapper, entry.getKey(), null, null, entry.getValue());
+ properties.forEach((key, value) -> {
+ mapper.deleteGlobalProperty(key);
+ save(mapper, key, null, null, value);
});
session.commit();
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupMembershipDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupMembershipDao.java
index c1807736483..3b735c1213b 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupMembershipDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupMembershipDao.java
@@ -21,10 +21,10 @@ package org.sonar.db.user;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
@@ -56,7 +56,7 @@ public class GroupMembershipDao implements Dao {
}
public Map<String, Integer> countUsersByGroups(DbSession session, Collection<Integer> groupIds) {
- Map<String, Integer> result = Maps.newHashMap();
+ Map<String, Integer> result = new HashMap<>();
executeLargeInputs(
groupIds,
input -> {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingDaoTest.java
index df6b6ebd527..f51a0ff4314 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingDaoTest.java
@@ -236,7 +236,7 @@ public class ProjectAlmBindingDaoTest {
underTest.insertOrUpdate(dbSession, BITBUCKETCLOUD, ANOTHER_REPO, "foo", null, "http://foo");
assertThat(underTest.selectByRepoIds(dbSession, GITHUB, Arrays.asList(A_REPO, ANOTHER_REPO, "foo")))
- .extracting(ProjectAlmBindingDto::getUuid, t -> t.getAlm(), ProjectAlmBindingDto::getRepoId, ProjectAlmBindingDto::getProjectUuid,
+ .extracting(ProjectAlmBindingDto::getUuid, ProjectAlmBindingDto::getAlm, ProjectAlmBindingDto::getRepoId, ProjectAlmBindingDto::getProjectUuid,
ProjectAlmBindingDto::getUrl, ProjectAlmBindingDto::getGithubSlug)
.containsExactlyInAnyOrder(
tuple("uuid1", GITHUB, A_REPO, A_UUID, A_URL, A_GITHUB_SLUG),
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
index cff43fe24cb..b6a85927a0e 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
@@ -64,7 +64,7 @@ public class ComponentKeyUpdaterDaoTest {
dbSession.commit();
assertThat(db.select("select uuid as \"UUID\", kee as \"KEE\" from projects"))
- .extracting(t -> (String) t.get("UUID"), t -> (String) t.get("KEE"))
+ .extracting(t -> t.get("UUID"), t -> t.get("KEE"))
.containsOnly(
Tuple.tuple("A", "org.struts:struts"),
Tuple.tuple("B", "struts:core"),
@@ -278,7 +278,7 @@ public class ComponentKeyUpdaterDaoTest {
dbSession.commit();
assertThat(db.select("select uuid as \"UUID\", kee as \"KEE\" from projects"))
- .extracting(t -> (String) t.get("UUID"), t -> (String) t.get("KEE"))
+ .extracting(t -> t.get("UUID"), t -> t.get("KEE"))
.containsOnly(
Tuple.tuple("A", "org.apache.struts:struts"),
Tuple.tuple("B", "org.apache.struts:struts-core"),
@@ -298,7 +298,7 @@ public class ComponentKeyUpdaterDaoTest {
dbSession.commit();
assertThat(db.select("select uuid as \"UUID\", kee as \"KEE\" from projects"))
- .extracting(t -> (String) t.get("UUID"), t -> (String) t.get("KEE"))
+ .extracting(t -> t.get("UUID"), t -> t.get("KEE"))
.containsOnly(
Tuple.tuple("A", "org.struts:struts"),
Tuple.tuple("B", "org.struts:struts-core"),
@@ -337,7 +337,7 @@ public class ComponentKeyUpdaterDaoTest {
dbSession.commit();
assertThat(db.select("select uuid as \"UUID\", kee as \"KEE\" from projects"))
- .extracting(t -> (String) t.get("UUID"), t -> (String) t.get("KEE"))
+ .extracting(t -> t.get("UUID"), t -> t.get("KEE"))
.containsOnly(
Tuple.tuple("A", "org.apache.struts:struts"),
Tuple.tuple("B", "org.apache.struts:struts-core"),
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/dump/DumpSQSchema.java b/server/sonar-db-dao/src/test/java/org/sonar/db/dump/DumpSQSchema.java
index 49ebe22c378..cd16a5794db 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/dump/DumpSQSchema.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/dump/DumpSQSchema.java
@@ -25,6 +25,8 @@ import java.nio.charset.Charset;
import java.sql.SQLException;
import org.apache.commons.io.FileUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class DumpSQSchema {
public static void main(String[] args) {
@@ -36,7 +38,7 @@ public class DumpSQSchema {
System.exit(1);
}
- Charset charset = Charset.forName("UTF8");
+ Charset charset = UTF_8;
String oldContent = FileUtils.readFileToString(targetFile, charset);
String newContent = dumper.dumpToText();
boolean upToDate = newContent.equals(oldContent);
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 04bd0f63e8b..413de4c4ea1 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
@@ -73,7 +73,7 @@ public class IssueMapperTest {
private System2 system2 = new AlwaysIncreasingSystem2();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
OrganizationDto organizationDto = dbTester.organizations().insert();
project = ComponentTesting.newPrivateProjectDto(organizationDto);
dbTester.getDbClient().componentDao().insert(dbSession, project);
@@ -458,7 +458,7 @@ public class IssueMapperTest {
ComponentDto component = randomComponent(organization);
IssueDto issue = insertNewClosedIssue(component, ruleType);
Date date = new Date();
- IssueChangeDto changes[] = new IssueChangeDto[] {
+ IssueChangeDto[] changes = new IssueChangeDto[] {
insertToClosedDiff(issue, DateUtils.addDays(date, -10)),
insertToClosedDiff(issue, DateUtils.addDays(date, -60)),
insertToClosedDiff(issue, date),
@@ -485,7 +485,7 @@ public class IssueMapperTest {
ComponentDto component = randomComponent(organization);
IssueDto issue = insertNewClosedIssue(component, ruleType);
Date date = new Date();
- IssueChangeDto changes[] = new IssueChangeDto[] {
+ IssueChangeDto[] changes = new IssueChangeDto[] {
insertToClosedDiff(issue, DateUtils.addDays(date, -10), Issue.STATUS_CLOSED, Issue.STATUS_REOPENED),
insertToClosedDiff(issue, DateUtils.addDays(date, -60)),
insertToClosedDiff(issue, date),
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 464f4e8be6c..e5d2dd85496 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
@@ -58,7 +58,7 @@ public class LiveMeasureDaoTest {
private MetricDto metric;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
metric = db.measures().insertMetric();
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
index e023c37d88e..2b860045ac7 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
@@ -77,7 +77,7 @@ public class AuthorizationDaoTest {
private String randomPermission = "p" + random.nextInt();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
organization = db.organizations().insert();
user = db.users().insertUser();
group1 = db.users().insertGroup(organization, "group1");
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 8f25059396d..93964365795 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
@@ -66,7 +66,7 @@ public class GroupPermissionDaoTest {
private String defaultOrganizationUuid;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
defaultOrganizationUuid = db.getDefaultOrganization().getUuid();
}
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 b78fa9cf962..0f8681d9763 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
@@ -745,13 +745,13 @@ public class UserPermissionDaoTest {
assertThat(underTest.selectUserIdsByQuery(dbSession, query)).containsExactly(expectedUserIds.toArray(new Integer[0]));
List<UserPermissionDto> currentPermissions = underTest.selectUserPermissionsByQuery(dbSession, query, expectedUserIds);
assertThat(currentPermissions).hasSize(expectedPermissions.length);
- List<Tuple> expectedPermissionsAsTuple = Arrays.stream(expectedPermissions)
+ Tuple[] expectedPermissionsAsTuple = Arrays.stream(expectedPermissions)
.map(expectedPermission -> tuple(expectedPermission.getUserId(), expectedPermission.getPermission(), expectedPermission.getComponentId(),
expectedPermission.getOrganizationUuid()))
- .collect(Collectors.toList());
+ .toArray(Tuple[]::new);
assertThat(currentPermissions)
.extracting(UserPermissionDto::getUserId, UserPermissionDto::getPermission, UserPermissionDto::getComponentId, UserPermissionDto::getOrganizationUuid)
- .containsOnly(expectedPermissionsAsTuple.toArray(new Tuple[0]));
+ .containsOnly(expectedPermissionsAsTuple);
// test method "countUsers()"
long distinctUsers = stream(expectedPermissions).mapToLong(UserPermissionDto::getUserId).distinct().count();
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
index 978855b5092..f29b64e4b38 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
@@ -65,7 +65,7 @@ public class PermissionTemplateDaoTest {
private PermissionTemplateDao underTest = new PermissionTemplateDao(system2);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(system2.now()).thenReturn(NOW.getTime());
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
index 01914170265..9b82297eab2 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
@@ -83,7 +83,7 @@ public class PurgeCommandsTest {
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
}
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 c3babddf4ea..c4591ff4cfe 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
@@ -237,7 +237,7 @@ public class PurgeDaoTest {
dbSession.commit();
assertThat(db.select("select metric_id as \"METRIC\",analysis_uuid as \"ANALYSIS\" from project_measures"))
- .extracting(t -> ((Long) t.get("METRIC")).intValue(), t -> (String) t.get("ANALYSIS"))
+ .extracting(t -> ((Long) t.get("METRIC")).intValue(), t -> t.get("ANALYSIS"))
.containsOnly(
tuple(metricWithHistory.getId(), lastAnalysis.getUuid()),
tuple(metricWithoutHistory.getId(), lastAnalysis.getUuid()),
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java
index 8560f10c75d..d0d5461dc1a 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java
@@ -41,7 +41,7 @@ public class PurgeMapperTest {
private PurgeMapper purgeMapper;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbSession = db.getDbClient().openSession(false);
purgeMapper = dbSession.getMapper(PurgeMapper.class);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeProfilerTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeProfilerTest.java
index 48fdcfd856c..02ffbc73a81 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeProfilerTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeProfilerTest.java
@@ -80,7 +80,7 @@ public class PurgeProfilerTest {
verify(logger).info(contains("bar: 5ms"));
}
- private class MockedClock extends PurgeProfiler.Clock {
+ private static class MockedClock extends PurgeProfiler.Clock {
private long now = 0;
@Override
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 4d26dcc207a..efeb18d0b40 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
@@ -33,7 +33,6 @@ import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import static java.util.Arrays.asList;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
public class QProfileChangeDaoTest {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java
index 72251e6be34..95fba0dad72 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java
@@ -51,7 +51,7 @@ public class GroupMembershipDaoTest {
private GroupMembershipDao underTest = db.getDbClient().groupMembershipDao();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
organizationDto = db.organizations().insert();
user1 = db.users().insertUser(u -> u.setLogin("admin login").setName("Admin name").setEmail("admin@email.com"));
user2 = db.users().insertUser(u -> u.setLogin("not.admin").setName("Not Admin").setEmail("Not Admin"));
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 ca072da52a1..20e303303f1 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
@@ -320,7 +320,7 @@ public class UserDaoTest {
@Test
public void insert_user() {
- Long date = DateUtils.parseDate("2014-06-20").getTime();
+ long date = DateUtils.parseDate("2014-06-20").getTime();
UserDto userDto = new UserDto()
.setId(1)
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java
index 4a4fd2eae79..677f3b4ab45 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java
@@ -172,7 +172,7 @@ public class SQDatabase extends DefaultDatabase {
new MigrationHistoryTableImpl(noopDatabase).start();
}
- private class NoopDatabase implements Database {
+ private static class NoopDatabase implements Database {
private final Dialect dialect;
private final DataSource dataSource;
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
index d984564bb08..7cd1e29e891 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java
@@ -89,7 +89,7 @@ class TestDbImpl extends CoreTestDb {
MyBatisConfExtension[] extensionArray = confExtensions.length == 0 ? null : confExtensions;
if (schemaPath == null) {
if (defaultSchemaBaseTestDb == null) {
- defaultSchemaBaseTestDb = new TestDbImpl((String) null);
+ defaultSchemaBaseTestDb = new TestDbImpl(null);
}
if (extensionArray != null) {
return defaultSchemaTestDbsWithExtensions.computeIfAbsent(
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java
index 4449bbaafc2..edcdba0316f 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java
@@ -34,12 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat;
public class NotificationDbTester {
private static final String PROP_NOTIFICATION_PREFIX = "notification";
- private final DbTester db;
private final DbClient dbClient;
private final DbSession dbSession;
public NotificationDbTester(DbTester db) {
- this.db = db;
this.dbClient = db.getDbClient();
this.dbSession = db.getSession();
}
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/GroupTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/GroupTesting.java
index cfb6379e188..4e8c6e5219d 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/GroupTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/GroupTesting.java
@@ -32,13 +32,12 @@ public class GroupTesting {
}
public static GroupDto newGroupDto() {
- GroupDto group = new GroupDto()
+ return new GroupDto()
.setId(nextInt())
.setOrganizationUuid(randomAlphanumeric(40))
.setName(randomAlphanumeric(255))
.setDescription(randomAlphanumeric(200))
.setCreatedAt(new Date(nextLong()))
.setUpdatedAt(new Date(nextLong()));
- return group;
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/MssqlCharsetHandlerTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/MssqlCharsetHandlerTest.java
index 61d43082291..4350ada0cec 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/MssqlCharsetHandlerTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/MssqlCharsetHandlerTest.java
@@ -152,7 +152,7 @@ public class MssqlCharsetHandlerTest {
});
}
}
- return res.stream().toArray(Object[][]::new);
+ return res.toArray(new Object[0][]);
}
@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 75fb66b43ae..7d8c7703c75 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
@@ -27,12 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MigrationContainerImplTest {
private ComponentContainer parent = new ComponentContainer();
- private MigrationContainerPopulator populator = new MigrationContainerPopulator() {
- @Override
- public void populateContainer(MigrationContainer container) {
- container.add(StartCallCounter.class);
- }
- };
+ private MigrationContainerPopulator populator = container -> container.add(StartCallCounter.class);
private MigrationContainerImpl underTest = new MigrationContainerImpl(parent, populator);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImplTest.java
index 26be6a4f96e..a0e7cf59a1d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationContainerPopulatorImplTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.platform.db.migration.engine;
-import java.sql.SQLException;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Test;
@@ -43,7 +42,7 @@ public class MigrationContainerPopulatorImplTest {
private MigrationContainerPopulatorImpl underTest = new MigrationContainerPopulatorImpl();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
migrationContainer.add(migrationSteps);
}
@@ -116,7 +115,7 @@ public class MigrationContainerPopulatorImplTest {
private static abstract class NoopMigrationStep implements MigrationStep {
@Override
- public void execute() throws SQLException {
+ public void execute() {
throw new UnsupportedOperationException("execute not implemented");
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java
index 9f02622b7a8..1d4302bd6ce 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.platform.db.migration.engine;
-import java.sql.SQLException;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
@@ -47,12 +46,7 @@ public class MigrationEngineImplTest {
private MigrationHistory migrationHistory = mock(MigrationHistory.class);
private ComponentContainer serverContainer = new ComponentContainer();
private MigrationStepsExecutor stepsExecutor = mock(MigrationStepsExecutor.class);
- private MigrationContainerPopulator populator = new MigrationContainerPopulator() {
- @Override
- public void populateContainer(MigrationContainer container) {
- container.add(stepsExecutor);
- }
- };
+ private MigrationContainerPopulator populator = container -> container.add(stepsExecutor);
private MigrationSteps migrationSteps = mock(MigrationSteps.class);
private MapSettings settings = new MapSettings();
@@ -117,7 +111,7 @@ public class MigrationEngineImplTest {
private static class TestBlueGreenMigrationStep implements MigrationStep {
@Override
- public void execute() throws SQLException {
+ public void execute() {
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
index dbb50739b78..568e82a9ff1 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
@@ -119,11 +119,8 @@ public class DataChangeTest {
new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
- context.prepareSelect("select id from persons where id>=?").setLong(1, 2L).get(new RowReader<Long>() {
- @Override
- public Long read(Row row) {
- throw new IllegalStateException("Unexpected error");
- }
+ context.prepareSelect("select id from persons where id>=?").setLong(1, 2L).get((RowReader<Long>) row -> {
+ throw new IllegalStateException("Unexpected error");
});
}
}.execute();
@@ -140,11 +137,8 @@ public class DataChangeTest {
new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
- context.prepareSelect("select id from persons where id>=?").setLong(1, 2L).list(new RowReader<Long>() {
- @Override
- public Long read(Row row) {
- throw new IllegalStateException("Unexpected error");
- }
+ context.prepareSelect("select id from persons where id>=?").setLong(1, 2L).list((RowReader<Long>) row -> {
+ throw new IllegalStateException("Unexpected error");
});
}
}.execute();
@@ -155,12 +149,11 @@ public class DataChangeTest {
public void bad_parameterized_query() throws Exception {
insertPersons();
- final List<Long> ids = new ArrayList<>();
DataChange change = new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
// parameter value is not set
- ids.addAll(context.prepareSelect("select id from persons where id>=?").list(Select.LONG_READER));
+ context.prepareSelect("select id from persons where id>=?").list(Select.LONG_READER);
}
};
@@ -177,12 +170,7 @@ public class DataChangeTest {
new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
- context.prepareSelect("select id from persons order by id desc").scroll(new Select.RowHandler() {
- @Override
- public void handle(Row row) throws SQLException {
- ids.add(row.getNullableLong(1));
- }
- });
+ context.prepareSelect("select id from persons order by id desc").scroll(row -> ids.add(row.getNullableLong(1)));
}
}.execute();
assertThat(ids).containsExactly(3L, 2L, 1L);
@@ -372,11 +360,8 @@ public class DataChangeTest {
@Override
public void execute(Context context) throws SQLException {
final Upsert upsert = context.prepareUpsert("update persons set login=?, age=? where id=?");
- context.prepareSelect("select id from persons").scroll(new Select.RowHandler() {
- @Override
- public void handle(Row row) {
- throw new IllegalStateException("Unexpected error");
- }
+ context.prepareSelect("select id from persons").scroll(row -> {
+ throw new IllegalStateException("Unexpected error");
});
upsert.commit().close();
}
@@ -393,16 +378,13 @@ public class DataChangeTest {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select id from persons where id>=?").setLong(1, 2L);
massUpdate.update("update persons set login=?, age=? where id=?");
- massUpdate.execute(new MassUpdate.Handler() {
- @Override
- public boolean handle(Row row, SqlStatement update) throws SQLException {
- long id = row.getNullableLong(1);
- update
- .setString(1, "login" + id)
- .setInt(2, 10 + (int) id)
- .setLong(3, id);
- return true;
- }
+ massUpdate.execute((row, update) -> {
+ long id = row.getNullableLong(1);
+ update
+ .setString(1, "login" + id)
+ .setInt(2, 10 + (int) id)
+ .setLong(3, id);
+ return true;
});
}
}.execute();
@@ -425,11 +407,8 @@ public class DataChangeTest {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select id from persons where id>=?").setLong(1, 2L);
massUpdate.update("update persons set login=?, age=? where id=?");
- massUpdate.execute(new MassUpdate.Handler() {
- @Override
- public boolean handle(Row row, SqlStatement update) {
- throw new IllegalStateException("Unexpected error");
- }
+ massUpdate.execute((row, update) -> {
+ throw new IllegalStateException("Unexpected error");
});
}
}.execute();
@@ -445,12 +424,7 @@ public class DataChangeTest {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select id from persons where id>=?").setLong(1, 2L);
massUpdate.update("update persons set login=?, age=? where id=?");
- massUpdate.execute(new MassUpdate.Handler() {
- @Override
- public boolean handle(Row row, SqlStatement update) {
- return false;
- }
- });
+ massUpdate.execute((row, update) -> false);
}
}.execute();
@@ -467,12 +441,7 @@ public class DataChangeTest {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select id from persons where id>=?").setLong(1, 2L);
// update is not set
- massUpdate.execute(new MassUpdate.Handler() {
- @Override
- public boolean handle(Row row, SqlStatement update) {
- return false;
- }
- });
+ massUpdate.execute((row, update) -> false);
}
};
try {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImplTest.java
index 3ea74ba75e9..10da24889de 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImplTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.platform.db.migration.step;
-import java.sql.SQLException;
import java.util.List;
import java.util.Random;
import org.junit.Rule;
@@ -109,7 +108,7 @@ public class MigrationStepRegistryImplTest {
private static abstract class NoopMigrationStep implements MigrationStep {
@Override
- public void execute() throws SQLException {
+ public void execute() {
throw new IllegalStateException("execute is not implemented");
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
index f14bc8ba76e..cc668de1c0d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
@@ -165,7 +165,7 @@ public class MigrationStepsExecutorImplTest {
private boolean called = false;
@Override
- public void execute() throws SQLException {
+ public void execute() {
checkState(!called, "execute must not be called twice");
this.called = true;
calledSteps.add(getClass());
@@ -205,7 +205,7 @@ public class MigrationStepsExecutorImplTest {
private static final RuntimeException THROWN_EXCEPTION = new RuntimeException("Faking failing migration step");
@Override
- public void execute() throws SQLException {
+ public void execute() {
throw THROWN_EXCEPTION;
}
}
diff --git a/server/sonar-main/src/test/java/org/sonar/application/ProcessLauncherImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/ProcessLauncherImplTest.java
index 3b17fc77d9e..657bd8cef74 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/ProcessLauncherImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/ProcessLauncherImplTest.java
@@ -164,7 +164,7 @@ public class ProcessLauncherImplTest {
File homeDir = temp.newFolder();
File dataDir = temp.newFolder();
File logDir = temp.newFolder();
- ProcessLauncher underTest = new ProcessLauncherImpl(tempDir, commands, () -> new TestProcessBuilder());
+ ProcessLauncher underTest = new ProcessLauncherImpl(tempDir, commands, TestProcessBuilder::new);
EsScriptCommand command = createEsScriptCommand(tempDir, homeDir, dataDir, logDir);
File outdatedEsDir = new File(dataDir, "es");
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java
index ad86c41ffd2..4aa1eaaef74 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/AppNodesClusterHostsConsistencyTest.java
@@ -144,7 +144,7 @@ public class AppNodesClusterHostsConsistencyTest {
return member;
}
- private class TestHazelcastMember implements HazelcastMember {
+ private static class TestHazelcastMember implements HazelcastMember {
private final Map<Member, List<String>> hostsPerMember;
private final Cluster cluster = mock(Cluster.class);
diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java
index 5ab518cbb16..21e89533baf 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java
@@ -52,7 +52,7 @@ public class WebJvmOptionsTest {
}
@Test
- public void constructor_sets_mandatory_JVM_options_for_java11() throws IOException {
+ public void constructor_sets_mandatory_JVM_options_for_java11() {
when(javaVersion.isAtLeastJava11()).thenReturn(true);
underTest = new WebJvmOptions(tmpDir, javaVersion);
diff --git a/server/sonar-main/src/test/java/org/sonar/application/process/EsManagedProcessTest.java b/server/sonar-main/src/test/java/org/sonar/application/process/EsManagedProcessTest.java
index f3c36b6442d..8f5bb52bdb1 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/process/EsManagedProcessTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/process/EsManagedProcessTest.java
@@ -125,7 +125,7 @@ public class EsManagedProcessTest {
);
}
- private class MemoryAppender<E> extends AppenderBase<E> {
+ private static class MemoryAppender<E> extends AppenderBase<E> {
private final List<E> events = new ArrayList();
@Override
diff --git a/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java b/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java
index c5b24a04d95..18a46ae849a 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java
@@ -150,7 +150,7 @@ public class Log4JPropertiesBuilder extends AbstractLogHelper {
}
private void applyLevelByProperty(Props props, String loggerKey, List<String> properties) {
- putLevel(loggerKey, resolveLevel(props, properties.stream().toArray(String[]::new)));
+ putLevel(loggerKey, resolveLevel(props, properties.toArray(new String[0])));
}
private void applyHardcodedLevel(String loggerName, Level newLevel) {
diff --git a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java b/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java
index e1810fd3ffa..0e6af6b5f77 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java
@@ -124,8 +124,8 @@ public class LogbackHelper extends AbstractLogHelper {
return rootContext;
}
- private void applyLevelByProperty(Props props, Logger logger, List<String> properties) {
- logger.setLevel(resolveLevel(props, properties.stream().toArray(String[]::new)));
+ private static void applyLevelByProperty(Props props, Logger logger, List<String> properties) {
+ logger.setLevel(resolveLevel(props, properties.toArray(new String[0])));
}
private static void applyHardcodedLevel(LoggerContext rootContext, String loggerName, Level newLevel) {
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
index 9de9e9ea187..42b52e0ad76 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
@@ -19,17 +19,17 @@
*/
package org.sonar.process;
-import com.google.common.collect.Maps;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.test.TestUtils;
-import java.io.File;
-import java.util.Map;
-import java.util.Properties;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
@@ -44,7 +44,7 @@ public class ConfigurationUtilsTest {
input.setProperty("hello", "world");
input.setProperty("url", "${env:SONAR_JDBC_URL}");
input.setProperty("do_not_change", "${SONAR_JDBC_URL}");
- Map<String, String> variables = Maps.newHashMap();
+ Map<String, String> variables = new HashMap<>();
variables.put("SONAR_JDBC_URL", "jdbc:h2:mem");
Properties output = ConfigurationUtils.interpolateVariables(input, variables);
@@ -74,7 +74,7 @@ public class ConfigurationUtilsTest {
@Test
public void loadPropsFromCommandLineArgs_load_properties_from_file() throws Exception {
File propsFile = temp.newFile();
- FileUtils.write(propsFile, "foo=bar");
+ FileUtils.write(propsFile, "foo=bar", StandardCharsets.UTF_8);
Props result = ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()});
assertThat(result.value("foo")).isEqualTo("bar");
@@ -87,7 +87,7 @@ public class ConfigurationUtilsTest {
FileUtils.deleteQuietly(propsFile);
try {
- ConfigurationUtils.loadPropsFromCommandLineArgs(new String[]{propsFile.getAbsolutePath()});
+ ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()});
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Could not read properties from file: " + propsFile.getAbsolutePath());
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
index 43b7dd06118..22f66eebe88 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
@@ -140,13 +140,10 @@ public class ProcessEntryPointTest {
final ProcessEntryPoint entryPoint = new ProcessEntryPoint(props, exit, commands, runtime);
final StandardProcess process = new StandardProcess();
- Thread runner = new Thread() {
- @Override
- public void run() {
- // starts and waits until terminated
- entryPoint.launch(process);
- }
- };
+ Thread runner = new Thread(() -> {
+ // starts and waits until terminated
+ entryPoint.launch(process);
+ });
runner.start();
waitForOperational(process, commands);
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java
index dd4b39b1de1..943950243f8 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java
@@ -115,7 +115,7 @@ public class ProcessPropertiesTest {
processProperties.completeDefaults(p);
}
- private class FakeExtension1 implements CoreExtension {
+ private static class FakeExtension1 implements CoreExtension {
@Override
public String getName() {
@@ -135,7 +135,7 @@ public class ProcessPropertiesTest {
}
}
- private class FakeExtension2 implements CoreExtension {
+ private static class FakeExtension2 implements CoreExtension {
@Override
public String getName() {
@@ -155,7 +155,7 @@ public class ProcessPropertiesTest {
}
}
- private class FakeExtension3 implements CoreExtension {
+ private static class FakeExtension3 implements CoreExtension {
@Override
public String getName() {
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java
index 8090920dc39..b94af6ec8f0 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java
@@ -115,7 +115,7 @@ public class SharedHealthStateImplTest {
when(hazelcastMember.getClusterTime()).thenReturn(clusterTime);
assertThat(underTest.readAll())
- .containsOnly(expected.values().stream().toArray(NodeHealth[]::new));
+ .containsOnly(expected.values().toArray(new NodeHealth[0]));
assertThat(logging.getLogs()).isEmpty();
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinition.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinition.java
index 09005233a0e..1a8b92e2976 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinition.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinition.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.es;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.sonar.api.server.ServerSide;
import org.sonar.server.es.newindex.NewAuthorizedIndex;
@@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkArgument;
public interface IndexDefinition {
class IndexDefinitionContext {
- private final Map<String, NewIndex> byKey = Maps.newHashMap();
+ private final Map<String, NewIndex> byKey = new HashMap<>();
public NewRegularIndex create(Index index, SettingsConfiguration settingsConfiguration) {
String indexName = index.getName();
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinitionHash.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinitionHash.java
index 2465e70cbd2..29ab3d874a8 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinitionHash.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/IndexDefinitionHash.java
@@ -49,15 +49,15 @@ class IndexDefinitionHash {
index.getAttributes());
}
- private static String of(String str, Map<?,?>... maps) {
+ private static String of(String str, Map<?, ?>... maps) {
StringBuilder sb = new StringBuilder(str);
- for (Map<?,?> map : maps) {
+ for (Map<?, ?> map : maps) {
appendMap(sb, map);
}
return DigestUtils.sha256Hex(sb.toString());
}
- private static void appendMap(StringBuilder sb, Map<?,?> attributes) {
+ private static void appendMap(StringBuilder sb, Map<?, ?> attributes) {
for (Object entry : sort(attributes).entrySet()) {
sb.append(((Map.Entry) entry).getKey());
sb.append(DELIMITER);
@@ -74,13 +74,13 @@ class IndexDefinitionHash {
} else if (value instanceof IndexType) {
sb.append(((IndexType) value).format());
} else {
- sb.append(String.valueOf(value));
+ sb.append(value);
}
}
- private static SortedMap<?,?> sort(Map<?,?> map) {
+ private static SortedMap<?, ?> sort(Map<?, ?> map) {
if (map instanceof ImmutableSortedMap) {
- return (ImmutableSortedMap<?,?>) map;
+ return (ImmutableSortedMap<?, ?>) map;
}
return ImmutableSortedMap.copyOf(map);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
index ee54f4a6d9f..1b410e8c77f 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
@@ -22,11 +22,11 @@ package org.sonar.server.issue.index;
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterators;
-import com.google.common.collect.Maps;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -190,7 +190,7 @@ class IssueIteratorForSingleChunk implements IssueIterator {
@Override
protected IssueDoc read(ResultSet rs) throws SQLException {
- IssueDoc doc = new IssueDoc(Maps.newHashMapWithExpectedSize(30));
+ IssueDoc doc = new IssueDoc(new HashMap<>(30));
String key = rs.getString(1);
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
index 646979ecbcc..400aa3fa3c6 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
@@ -35,6 +35,7 @@ import org.sonar.core.i18n.I18n;
import org.sonar.server.issue.notification.NewIssuesStatistics.Metric;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Base class to create emails for new issues
@@ -65,7 +66,7 @@ public abstract class AbstractNewIssuesEmailTemplate implements EmailTemplate {
public static String encode(String toEncode) {
try {
- return URLEncoder.encode(toEncode, "UTF-8");
+ return URLEncoder.encode(toEncode, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Encoding not supported", e);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java
index 2ef310f5964..f2aa43a65da 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java
@@ -41,6 +41,7 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Proj
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule;
import static java.net.URLEncoder.encode;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.sonar.core.util.stream.MoreCollectors.index;
public abstract class IssueChangesEmailTemplate implements EmailTemplate {
@@ -200,7 +201,7 @@ public abstract class IssueChangesEmailTemplate implements EmailTemplate {
private static String urlEncode(String str) {
try {
- return encode(str, "UTF-8");
+ return encode(str, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilder.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilder.java
index a0fadc8fd92..c894b33867f 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilder.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilder.java
@@ -371,7 +371,7 @@ public class IssuesChangesNotificationBuilder {
protected final long date;
private Change(long date) {
- this.date = requireNonNull(date, "date can't be null");
+ this.date = date;
}
public long getDate() {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
index 6b225d9e367..19d6f000f9f 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.notification;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
@@ -43,7 +43,7 @@ public final class NotificationDispatcherMetadata {
private NotificationDispatcherMetadata(String dispatcherKey) {
this.dispatcherKey = dispatcherKey;
- this.properties = Maps.newHashMap();
+ this.properties = new HashMap<>();
}
/**
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleExtensionDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleExtensionDoc.java
index d75627e3291..c34aa929763 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleExtensionDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleExtensionDoc.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.rule.index;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
@@ -36,7 +36,7 @@ public class RuleExtensionDoc extends BaseDoc {
}
public RuleExtensionDoc() {
- super(TYPE_RULE_EXTENSION, Maps.newHashMapWithExpectedSize(4));
+ super(TYPE_RULE_EXTENSION, new HashMap<>(4));
}
@Override
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/user/index/UserDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/user/index/UserDoc.java
index ed435fadfa7..5bcecedff3a 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/user/index/UserDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/user/index/UserDoc.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.user.index;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@@ -35,7 +35,7 @@ public class UserDoc extends BaseDoc {
}
public UserDoc() {
- this(Maps.newHashMap());
+ this(new HashMap<>());
}
@Override
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewDoc.java
index bff2c49ac2b..db9d0e0f33e 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewDoc.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.view.index;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sonar.server.es.BaseDoc;
@@ -33,7 +33,7 @@ public class ViewDoc extends BaseDoc {
}
public ViewDoc() {
- super(TYPE_VIEW, Maps.newHashMap());
+ super(TYPE_VIEW, new HashMap<>());
}
@Override
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java
index 5a7c581ac84..2dc241e6880 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/view/index/ViewIndexer.java
@@ -21,6 +21,7 @@ package org.sonar.server.view.index;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,7 +41,6 @@ import org.sonar.server.es.IndexingResult;
import org.sonar.server.es.OneToOneResilientIndexingListener;
import org.sonar.server.es.ResilientIndexer;
-import static com.google.common.collect.Maps.newHashMap;
import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.server.view.index.ViewIndexDefinition.TYPE_VIEW;
@@ -62,7 +62,7 @@ public class ViewIndexer implements ResilientIndexer {
@Override
public void indexOnStartup(Set<IndexType> uninitializedIndexTypes) {
try (DbSession dbSession = dbClient.openSession(false)) {
- Map<String, String> viewAndProjectViewUuidMap = newHashMap();
+ Map<String, String> viewAndProjectViewUuidMap = new HashMap<>();
for (UuidWithProjectUuidDto uuidWithProjectUuidDto : dbClient.componentDao().selectAllViewsAndSubViews(dbSession)) {
viewAndProjectViewUuidMap.put(uuidWithProjectUuidDto.getUuid(), uuidWithProjectUuidDto.getProjectUuid());
}
@@ -78,7 +78,7 @@ public class ViewIndexer implements ResilientIndexer {
*/
public void index(String rootViewUuid) {
try (DbSession dbSession = dbClient.openSession(false)) {
- Map<String, String> viewAndProjectViewUuidMap = newHashMap();
+ Map<String, String> viewAndProjectViewUuidMap = new HashMap<>();
for (ComponentDto viewOrSubView : dbClient.componentDao().selectEnabledDescendantModules(dbSession, rootViewUuid)) {
viewAndProjectViewUuidMap.put(viewOrSubView.uuid(), viewOrSubView.projectUuid());
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
index 774b98ccd8a..f436837c6cb 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
@@ -36,6 +36,7 @@ import org.sonar.server.qualitygate.EvaluatedCondition;
import org.sonar.server.qualitygate.EvaluatedQualityGate;
import static java.lang.String.format;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.sonar.core.config.CorePropertyDefinitions.SONAR_ANALYSIS;
@ServerSide
@@ -164,7 +165,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
private static String encode(String toEncode) {
try {
- return URLEncoder.encode(toEncode, "UTF-8");
+ return URLEncoder.encode(toEncode, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Encoding not supported", e);
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToManyResilientIndexingListenerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToManyResilientIndexingListenerTest.java
index 8bceb9261e4..3e6ea8f7b4d 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToManyResilientIndexingListenerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToManyResilientIndexingListenerTest.java
@@ -112,7 +112,7 @@ public class OneToManyResilientIndexingListenerTest {
try (DbSession otherSession = db.getDbClient().openSession(false)) {
List<String> uuidsInDb = db.getDbClient().esQueueDao().selectForRecovery(otherSession, Long.MAX_VALUE, 10)
.stream().map(EsQueueDto::getUuid).collect(toList());
- String expectedUuids[] = Arrays.stream(expected).map(EsQueueDto::getUuid).toArray(String[]::new);
+ String[] expectedUuids = Arrays.stream(expected).map(EsQueueDto::getUuid).toArray(String[]::new);
assertThat(uuidsInDb).containsExactlyInAnyOrder(expectedUuids);
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToOneResilientIndexingListenerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToOneResilientIndexingListenerTest.java
index c46a0ad3732..1cd9569c373 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToOneResilientIndexingListenerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/OneToOneResilientIndexingListenerTest.java
@@ -107,7 +107,7 @@ public class OneToOneResilientIndexingListenerTest {
try (DbSession otherSession = db.getDbClient().openSession(false)) {
List<String> uuidsInDb = db.getDbClient().esQueueDao().selectForRecovery(otherSession, Long.MAX_VALUE, 10)
.stream().map(EsQueueDto::getUuid).collect(toList());
- String expectedUuids[] = Arrays.stream(expected).map(EsQueueDto::getUuid).toArray(String[]::new);
+ String[] expectedUuids = Arrays.stream(expected).map(EsQueueDto::getUuid).toArray(String[]::new);
assertThat(uuidsInDb).containsExactlyInAnyOrder(expectedUuids);
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/SortingTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/SortingTest.java
index 7b17b13bf87..56c74591f5a 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/SortingTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/SortingTest.java
@@ -47,7 +47,7 @@ public class SortingTest {
}
@Test
- public void ascending_sort_on_single_field() throws Exception {
+ public void ascending_sort_on_single_field() {
Sorting sorting = new Sorting();
sorting.add("updatedAt");
@@ -57,7 +57,7 @@ public class SortingTest {
}
@Test
- public void descending_sort_on_single_field() throws Exception {
+ public void descending_sort_on_single_field() {
Sorting sorting = new Sorting();
sorting.add("updatedAt");
@@ -67,7 +67,7 @@ public class SortingTest {
}
@Test
- public void ascending_sort_on_single_field_with_missing_in_last_position() throws Exception {
+ public void ascending_sort_on_single_field_with_missing_in_last_position() {
Sorting sorting = new Sorting();
sorting.add("updatedAt").missingLast();
@@ -77,7 +77,7 @@ public class SortingTest {
}
@Test
- public void descending_sort_on_single_field_with_missing_in_last_position() throws Exception {
+ public void descending_sort_on_single_field_with_missing_in_last_position() {
Sorting sorting = new Sorting();
sorting.add("updatedAt").missingLast();
@@ -87,7 +87,7 @@ public class SortingTest {
}
@Test
- public void sort_on_multiple_fields() throws Exception {
+ public void sort_on_multiple_fields() {
// asc => file asc, line asc, severity desc, key asc
Sorting sorting = new Sorting();
sorting.add("fileLine", "file");
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
index 9f51b5b233b..e658991e580 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
@@ -447,8 +447,7 @@ public class ChangesOnMyIssueNotificationHandlerTest {
}
private static IssuesChangesNotification newNotification(@Nullable String projectKey, @Nullable String assignee, @Nullable String changeAuthor) {
- IssuesChangesNotification notification = mock(IssuesChangesNotification.class);
- return notification;
+ return mock(IssuesChangesNotification.class);
}
private static NotificationManager.EmailRecipient emailRecipientOf(String login) {
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
index ec1fc186f39..9ac507b85fc 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
@@ -53,7 +53,7 @@ public class MyNewIssuesEmailTemplateTest {
private MyNewIssuesEmailTemplate underTest = new MyNewIssuesEmailTemplate(new EmailSettings(settings.asConfig(), server), i18n);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getPublicRootUrl()).thenReturn("http://nemo.sonarsource.org");
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
index df611026d05..7650eb90a26 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
@@ -54,7 +54,7 @@ public class NewIssuesEmailTemplateTest {
private NewIssuesEmailTemplate template = new NewIssuesEmailTemplate(new EmailSettings(settings.asConfig(), server), i18n);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getPublicRootUrl()).thenReturn("http://nemo.sonarsource.org");
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowTest.java
index 60c6596b710..68b15254840 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.issue.workflow;
-import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
@@ -473,11 +472,6 @@ public class IssueWorkflowTest {
}
private Collection<String> keys(List<Transition> transitions) {
- return Collections2.transform(transitions, new Function<Transition, String>() {
- @Override
- public String apply(@Nullable Transition transition) {
- return transition.key();
- }
- });
+ return Collections2.transform(transitions, Transition::key);
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java
index 849a0d70d22..f891369cf1e 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java
@@ -47,7 +47,7 @@ public class InternalPropertiesImplTest {
private InternalPropertiesImpl underTest = new InternalPropertiesImpl(dbClient);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.openSession(false)).thenReturn(dbSession);
when(dbClient.internalPropertiesDao()).thenReturn(internalPropertiesDao);
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeEmailTemplateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeEmailTemplateTest.java
index 212f49b3699..03aedec2284 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeEmailTemplateTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeEmailTemplateTest.java
@@ -196,7 +196,7 @@ public class QGChangeEmailTemplateTest {
}
private Notification createNotification(String alertName, String alertText, String alertLevel, String isNewAlert) {
- Notification notification = new Notification("alerts")
+ return new Notification("alerts")
.setFieldValue("projectName", "Foo")
.setFieldValue("projectKey", "org.sonar.foo:foo")
.setFieldValue("projectId", "45")
@@ -205,7 +205,6 @@ public class QGChangeEmailTemplateTest {
.setFieldValue("alertText", alertText)
.setFieldValue("alertLevel", alertLevel)
.setFieldValue("isNewAlert", isNewAlert);
- return notification;
}
}
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 060f0e290e3..d491b47943f 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
@@ -58,7 +58,6 @@ public class ActiveRuleIndexerTest {
private ActiveRuleIndexer underTest = new ActiveRuleIndexer(db.getDbClient(), es.client());
private RuleDefinitionDto rule1;
private RuleDefinitionDto rule2;
- private OrganizationDto org;
private QProfileDto profile1;
private QProfileDto profile2;
@@ -66,7 +65,7 @@ public class ActiveRuleIndexerTest {
public void before() {
rule1 = db.rules().insert();
rule2 = db.rules().insert();
- org = db.organizations().insert();
+ OrganizationDto org = db.organizations().insert();
profile1 = db.qualityProfiles().insert(org);
profile2 = db.qualityProfiles().insert(org);
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/setting/ThreadLocalSettingsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/setting/ThreadLocalSettingsTest.java
index b3f95151083..1aab8c4f366 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/setting/ThreadLocalSettingsTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/setting/ThreadLocalSettingsTest.java
@@ -375,7 +375,7 @@ public class ThreadLocalSettingsTest {
captor.verifyValue(settings, expectedValue);
}
- private class CacheCaptorThread extends Thread {
+ private static class CacheCaptorThread extends Thread {
private final CountDownLatch latch = new CountDownLatch(1);
private ThreadLocalSettings settings;
private String value;
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java
index 637eda5e533..35fac76f8b0 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java
@@ -35,20 +35,12 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class AbstractStoppableExecutorServiceTest {
- private static final Callable<String> SOME_CALLABLE = new Callable<String>() {
- @Override
- public String call() {
- return null;
- }
- };
- private static final Runnable SOME_RUNNABLE = new Runnable() {
- @Override
- public void run() {
+ private static final Callable<String> SOME_CALLABLE = () -> null;
+ private static final Runnable SOME_RUNNABLE = () -> {
- }
};
private static final String SOME_STRING = "some string";
- private static final long SOME_LONG = 100l;
+ private static final long SOME_LONG = 100L;
private static final int TIMEOUT = 5;
private static final TimeUnit TIMEOUT_UNIT = TimeUnit.SECONDS;
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
index b33aec78e8f..09cf223f94c 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
@@ -49,7 +49,7 @@ public class WebhookPayloadFactoryImplTest {
private WebhookPayloadFactory underTest = new WebhookPayloadFactoryImpl(server, system2);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getPublicRootUrl()).thenReturn("http://foo");
when(system2.now()).thenReturn(1_500_999L);
}
diff --git a/server/sonar-server-common/src/testFixtures/java/org/elasticsearch/transport/MockTcpTransport.java b/server/sonar-server-common/src/testFixtures/java/org/elasticsearch/transport/MockTcpTransport.java
index b5d89ef054d..3ab2dd12797 100644
--- a/server/sonar-server-common/src/testFixtures/java/org/elasticsearch/transport/MockTcpTransport.java
+++ b/server/sonar-server-common/src/testFixtures/java/org/elasticsearch/transport/MockTcpTransport.java
@@ -199,7 +199,7 @@ public class MockTcpTransport extends TcpTransport {
configureSocket(socket);
success = true;
} finally {
- if (success == false) {
+ if (!success) {
IOUtils.close(socket);
}
}
@@ -233,7 +233,7 @@ public class MockTcpTransport extends TcpTransport {
}
// make sure we maintain at least the types that are supported by this profile even if we only use a single channel for them.
builder.addConnections(1, allTypesWithConnection.toArray(new TransportRequestOptions.Type[0]));
- if (allTypesWithoutConnection.isEmpty() == false) {
+ if (!allTypesWithoutConnection.isEmpty()) {
builder.addConnections(0, allTypesWithoutConnection.toArray(new TransportRequestOptions.Type[0]));
}
builder.setHandshakeTimeout(connectionProfile.getHandshakeTimeout());
@@ -479,7 +479,7 @@ public class MockTcpTransport extends TcpTransport {
super.doStart();
success = true;
} finally {
- if (success == false) {
+ if (!success) {
doStop();
}
}
diff --git a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/es/FakeDoc.java b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/es/FakeDoc.java
index d199ed9323a..01fa5a56611 100644
--- a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/es/FakeDoc.java
+++ b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/es/FakeDoc.java
@@ -19,14 +19,14 @@
*/
package org.sonar.server.es;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import static org.sonar.server.es.newindex.FakeIndexDefinition.INT_FIELD;
import static org.sonar.server.es.newindex.FakeIndexDefinition.TYPE_FAKE;
public class FakeDoc extends BaseDoc {
public FakeDoc() {
- super(TYPE_FAKE, Maps.newHashMap());
+ super(TYPE_FAKE, new HashMap<>());
}
@Override
diff --git a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
index c63f12e950c..d50bd557c38 100644
--- a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
+++ b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java
@@ -19,8 +19,8 @@
*/
package org.sonar.server.issue;
-import com.google.common.collect.Maps;
import java.util.Date;
+import java.util.HashMap;
import org.sonar.api.resources.Scopes;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.RuleType;
@@ -54,7 +54,7 @@ public class IssueDocTesting {
}
public static IssueDoc newDoc() {
- IssueDoc doc = new IssueDoc(Maps.newHashMap());
+ IssueDoc doc = new IssueDoc(new HashMap<>());
doc.setKey(Uuids.createFast());
doc.setRuleId(nextInt(1000));
doc.setType(RuleType.CODE_SMELL);
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 f984cd9bd1e..c8e171332a4 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
@@ -306,7 +306,7 @@ public class PluginDownloaderTest {
assertThat(new File(downloadDir, "testdep-1.0.jar")).exists();
}
- class HasFileName implements ArgumentMatcher<File> {
+ static class HasFileName implements ArgumentMatcher<File> {
private final String name;
HasFileName(String name) {
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginFileSystemTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginFileSystemTest.java
index bc353f99778..05b5a95f81b 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginFileSystemTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginFileSystemTest.java
@@ -40,15 +40,12 @@ public class PluginFileSystemTest {
public TemporaryFolder temp = new TemporaryFolder();
private MapSettings settings = new MapSettings();
- private Path targetJarPath;
- private Path targetFolder;
- private Path sourceFolder;
@Before
public void setUp() throws IOException {
- sourceFolder = temp.newFolder("source").toPath();
- targetFolder = temp.newFolder("target").toPath();
- targetJarPath = targetFolder.resolve("test.jar");
+ Path sourceFolder = temp.newFolder("source").toPath();
+ Path targetFolder = temp.newFolder("target").toPath();
+ Path targetJarPath = targetFolder.resolve("test.jar");
Files.createFile(targetJarPath);
}
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
index d6d9904452d..17c87fa7431 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
@@ -20,7 +20,6 @@
package org.sonar.server.plugins;
import javax.servlet.GenericServlet;
-import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
index 964637487fb..d27267a5c20 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
@@ -45,7 +45,6 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.server.qualitygate.changeevent.QGChangeEventListener.ChangedIssue;
import org.sonar.server.qualitygate.changeevent.QGChangeEventListenersImpl.ChangedIssueImpl;
-import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.Collections.singletonList;
@@ -307,7 +306,7 @@ public class QGChangeEventListenersImplTest {
.containsOnly(expected);
}
- private static final String[] POSSIBLE_STATUSES = asList(Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED).stream().toArray(String[]::new);
+ private static final String[] POSSIBLE_STATUSES = Stream.of(Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED).toArray(String[]::new);
private static int issueIdCounter = 0;
private static DefaultIssue newDefaultIssue(String projectUuid) {
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java
index 0fb88ee9b05..523bcd85c8e 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/ProjectConfigurationLoaderImplTest.java
@@ -54,7 +54,7 @@ public class ProjectConfigurationLoaderImplTest {
private ProjectConfigurationLoaderImpl underTest = new ProjectConfigurationLoaderImpl(globalSettings, dbClient);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.openSession(anyBoolean()))
.thenThrow(new IllegalStateException("ProjectConfigurationLoaderImpl should not open DB session"));
when(dbClient.propertiesDao()).thenReturn(propertiesDao);
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java
index b0e4203678a..8a23f93fd24 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java
@@ -185,7 +185,7 @@ public class HttpHeadersAuthentication implements Startable {
}
private boolean hasHeader(Map<String, String> headerValuesByNames, String settingKey) {
- return headerValuesByNames.keySet().contains(settingsByKey.get(settingKey).toLowerCase(Locale.ENGLISH));
+ return headerValuesByNames.containsKey(settingsByKey.get(settingKey).toLowerCase(Locale.ENGLISH));
}
private static class SsoIdentityProvider implements IdentityProvider {
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java
index 58feb3b73f1..5c456259430 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridge.java
@@ -73,7 +73,7 @@ public class BuiltInQProfileDefinitionsBridge implements BuiltInQualityProfilesD
private static void define(Context context, RulesProfile profile) {
NewBuiltInQualityProfile newQp = context.createBuiltInQualityProfile(profile.getName(), profile.getLanguage())
- .setDefault(profile.getDefaultProfile().booleanValue());
+ .setDefault(profile.getDefaultProfile());
for (org.sonar.api.rules.ActiveRule ar : profile.getActiveRules()) {
NewBuiltInActiveRule newActiveRule = newQp.activateRule(ar.getRepositoryKey(), ar.getRuleKey());
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/BaseContextFactoryTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/BaseContextFactoryTest.java
index dd016d5cfc1..0fe11caeb4b 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/BaseContextFactoryTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/BaseContextFactoryTest.java
@@ -65,7 +65,7 @@ public class BaseContextFactoryTest {
private BaseContextFactory underTest = new BaseContextFactory(userIdentityAuthenticator, server, jwtHttpHandler, threadLocalUserSession, userSessionFactory);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getPublicRootUrl()).thenReturn(PUBLIC_ROOT_URL);
when(identityProvider.getName()).thenReturn("GitHub");
when(identityProvider.getKey()).thenReturn("github");
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
index ef3d77e2f35..dd5e89af1b5 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
@@ -116,7 +116,7 @@ public class HttpHeadersAuthenticationTest {
private HttpHeadersAuthentication underTest = new HttpHeadersAuthentication(system2, settings.asConfig(), userIdentityAuthenticator, jwtHttpHandler, authenticationEvent);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(system2.now()).thenReturn(NOW);
group1 = db.users().insertGroup(db.getDefaultOrganization(), GROUP1);
group2 = db.users().insertGroup(db.getDefaultOrganization(), GROUP2);
@@ -414,7 +414,7 @@ public class HttpHeadersAuthenticationTest {
}
private static void setHeaders(HttpServletRequest request, Map<String, String> valuesByName) {
- valuesByName.entrySet().forEach(entry -> when(request.getHeader(entry.getKey())).thenReturn(entry.getValue()));
+ valuesByName.forEach((key, value) -> when(request.getHeader(key)).thenReturn(value));
when(request.getHeaderNames()).thenReturn(Collections.enumeration(valuesByName.keySet()));
}
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 cdf97bc3b59..0285164bc76 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
@@ -54,7 +54,7 @@ public class JwtCsrfVerifierTest {
private JwtCsrfVerifier underTest = new JwtCsrfVerifier();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getContextPath()).thenReturn("");
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java
index ed1f5c22084..a25aa0a5ff6 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/JwtHttpHandlerTest.java
@@ -84,7 +84,7 @@ public class JwtHttpHandlerTest {
private JwtHttpHandler underTest = new JwtHttpHandler(system2, dbClient, settings.asConfig(), jwtSerializer, jwtCsrfVerifier);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(system2.now()).thenReturn(NOW);
when(request.getSession()).thenReturn(httpSession);
when(jwtSerializer.encode(any(JwtSerializer.JwtSession.class))).thenReturn(JWT_TOKEN);
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 07a6fbe79e8..4e4f4b70f67 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
@@ -45,7 +45,7 @@ public class OAuth2AuthenticationParametersImplTest {
private OAuth2AuthenticationParameters underTest = new OAuth2AuthenticationParametersImpl();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getContextPath()).thenReturn("");
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
index 47c745b5d60..3819f227b7f 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
@@ -78,7 +78,7 @@ public class OAuth2CallbackFilterTest {
threadLocalUserSession);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(oAuth2ContextFactory.newCallback(request, response, oAuth2IdentityProvider)).thenReturn(mock(OAuth2IdentityProvider.CallbackContext.class));
when(request.getContextPath()).thenReturn("");
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
index 8d5d6229eb4..b15cd73a5e3 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
@@ -78,7 +78,7 @@ public class OAuth2ContextFactoryTest {
oAuthParameters);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getSession()).thenReturn(session);
when(identityProvider.getKey()).thenReturn(PROVIDER_KEY);
when(identityProvider.getName()).thenReturn(PROVIDER_NAME);
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 d1165e1aea6..496f5f94b34 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
@@ -55,7 +55,7 @@ public class OAuthCsrfVerifierTest {
private OAuthCsrfVerifier underTest = new OAuthCsrfVerifier();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getContextPath()).thenReturn("");
when(identityProvider.getName()).thenReturn(PROVIDER_NAME);
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java
index be9a12754db..b7a65aaaf54 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java
@@ -56,7 +56,7 @@ public class RequestAuthenticatorImplTest {
new CustomAuthentication[]{customAuthentication1, customAuthentication2});
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(sessionFactory.create(A_USER)).thenReturn(new MockUserSession(A_USER));
when(sessionFactory.createAnonymous()).thenReturn(new AnonymousMockUserSession());
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java
index cac1b7ceaf7..a1de284de7f 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserSessionInitializerTest.java
@@ -64,7 +64,7 @@ public class UserSessionInitializerTest {
private UserSessionInitializer underTest = new UserSessionInitializer(settings.asConfig(), threadLocalSession, authenticationEvent, authenticator);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getContextPath()).thenReturn("");
when(request.getRequestURI()).thenReturn("/measures");
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
index 7ea7b9be47a..25a4a209124 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
@@ -53,7 +53,7 @@ public class AuthenticationEventImplTest {
private AuthenticationEventImpl underTest = new AuthenticationEventImpl();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
logTester.setLevel(LoggerLevel.DEBUG);
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQPChangeNotificationTemplateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQPChangeNotificationTemplateTest.java
index 3324486882b..ca0b822d4f6 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQPChangeNotificationTemplateTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQPChangeNotificationTemplateTest.java
@@ -39,7 +39,7 @@ public class BuiltInQPChangeNotificationTemplateTest {
private BuiltInQPChangeNotificationTemplate underTest = new BuiltInQPChangeNotificationTemplate(server);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(server.getPublicRootUrl()).thenReturn("http://" + randomAlphanumeric(10));
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java
index 7d0791b2007..7cbd3dad208 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/qualityprofile/BuiltInQProfileDefinitionsBridgeTest.java
@@ -73,7 +73,7 @@ public class BuiltInQProfileDefinitionsBridgeTest {
.extracting(BuiltInQualityProfilesDefinition.OverriddenParam::key, BuiltInQualityProfilesDefinition.OverriddenParam::overriddenValue).containsOnly(tuple("param", "value"));
}
- private class Profile1 extends ProfileDefinition {
+ private static class Profile1 extends ProfileDefinition {
@Override
public RulesProfile createProfile(ValidationMessages validation) {
RulesProfile profile1 = RulesProfile.create("Profile 1", "xoo");
@@ -89,14 +89,14 @@ public class BuiltInQProfileDefinitionsBridgeTest {
}
}
- private class NullProfile extends ProfileDefinition {
+ private static class NullProfile extends ProfileDefinition {
@Override
public RulesProfile createProfile(ValidationMessages validation) {
return null;
}
}
- private class ProfileWithError extends ProfileDefinition {
+ private static class ProfileWithError extends ProfileDefinition {
@Override
public RulesProfile createProfile(ValidationMessages validation) {
validation.addErrorText("Foo");
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java
index 8db859ef91f..c2e09d39037 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java
@@ -19,12 +19,12 @@
*/
package org.sonar.server.tester;
-import com.google.common.collect.Maps;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.EventListener;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.servlet.Filter;
@@ -167,7 +167,7 @@ class AttributeHolderServletContext implements ServletContext {
return Collections.enumeration(this.attributes.keySet());
}
- private final Map<String, Object> attributes = Maps.newHashMap();
+ private final Map<String, Object> attributes = new HashMap<>();
@Override
public void setAttribute(String s, Object o) {
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java
index adc98994b25..b6bedbe246d 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java
@@ -28,7 +28,6 @@ import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.SessionTrackingMode;
@@ -84,7 +83,7 @@ public class AttributeHolderServletContextTest {
}
@Test(expected = UnsupportedOperationException.class)
- public void getResource_is_not_supported() throws Exception {
+ public void getResource_is_not_supported() {
servletContext.getResource(SOME_STRING);
}
@@ -106,7 +105,7 @@ public class AttributeHolderServletContextTest {
}
@Test(expected = UnsupportedOperationException.class)
- public void getServlet_is_not_supported() throws ServletException {
+ public void getServlet_is_not_supported() {
servletContext.getServlet(SOME_STRING);
}
@@ -250,7 +249,7 @@ public class AttributeHolderServletContextTest {
}
@Test(expected = UnsupportedOperationException.class)
- public void createServlet_is_not_supported() throws ServletException {
+ public void createServlet_is_not_supported() {
servletContext.createServlet(Servlet.class);
}
@@ -295,7 +294,7 @@ public class AttributeHolderServletContextTest {
}
@Test(expected = UnsupportedOperationException.class)
- public void createFilter_is_not_supported() throws ServletException {
+ public void createFilter_is_not_supported() {
servletContext.createFilter(Filter.class);
}
@@ -346,7 +345,7 @@ public class AttributeHolderServletContextTest {
}
@Test(expected = UnsupportedOperationException.class)
- public void createListener_is_not_supported() throws ServletException {
+ public void createListener_is_not_supported() {
servletContext.createListener(EventListener.class);
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
index d280c1af117..fd38826ebc1 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
@@ -70,7 +70,7 @@ public class UserUpdaterReactivateTest {
private MapSettings settings = new MapSettings();
private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
private UserUpdater underTest = new UserUpdater(system2, newUserNotifier, dbClient, userIndexer, organizationFlags, defaultOrganizationProvider,
- new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);;
+ new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);
@Test
public void reactivate_user() {
diff --git a/server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java b/server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java
index 26c8e103942..d1468d95fbd 100644
--- a/server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java
+++ b/server/sonar-webserver-auth/src/testFixtures/java/org/sonar/server/tester/AbstractMockUserSession.java
@@ -22,6 +22,7 @@ package org.sonar.server.tester;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
@@ -33,7 +34,6 @@ import org.sonar.db.permission.OrganizationPermission;
import org.sonar.server.user.AbstractUserSession;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.Maps.newHashMap;
public abstract class AbstractMockUserSession<T extends AbstractMockUserSession> extends AbstractUserSession {
private static final Set<String> PUBLIC_PERMISSIONS = ImmutableSet.of(UserRole.USER, UserRole.CODEVIEWER); // FIXME to check with Simon
@@ -41,7 +41,7 @@ public abstract class AbstractMockUserSession<T extends AbstractMockUserSession>
private final Class<T> clazz;
private HashMultimap<String, String> projectUuidByPermission = HashMultimap.create();
private final HashMultimap<String, OrganizationPermission> permissionsByOrganizationUuid = HashMultimap.create();
- private Map<String, String> projectUuidByComponentUuid = newHashMap();
+ private Map<String, String> projectUuidByComponentUuid = new HashMap<>();
private Set<String> projectPermissions = new HashSet<>();
private Set<String> organizationMembership = new HashSet<>();
private boolean systemAdministrator = false;
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
index 1b99932ed9b..9ae4525969d 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -21,7 +21,6 @@ package org.sonar.server.rule;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collection;
@@ -224,7 +223,7 @@ public class RegisterRules implements Startable {
RuleDefinitionDto rule = dbRulesByRuleId.get(ruleId);
if (rule == null) {
LOG.warn("Could not retrieve rule with id %s referenced by a deprecated rule key. " +
- "The following deprecated rule keys seem to be referencing a non-existing rule",
+ "The following deprecated rule keys seem to be referencing a non-existing rule",
ruleId, entry.getValue());
} else {
entry.getValue().forEach(d -> builder.put(d.getOldRuleKeyAsRuleKey(), rule));
@@ -537,7 +536,7 @@ public class RegisterRules implements Startable {
private void mergeParams(RulesDefinition.Rule ruleDef, RuleDefinitionDto rule, DbSession session) {
List<RuleParamDto> paramDtos = dbClient.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey());
- Map<String, RuleParamDto> existingParamsByName = Maps.newHashMap();
+ Map<String, RuleParamDto> existingParamsByName = new HashMap<>();
Profiler profiler = Profiler.create(Loggers.get(getClass()));
for (RuleParamDto paramDto : paramDtos) {
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
index 615d91cef80..37ead127fa9 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
@@ -20,7 +20,6 @@
package org.sonar.server.startup;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -113,7 +112,7 @@ public class RegisterMetrics implements Startable {
@VisibleForTesting
List<Metric> getPluginMetrics() {
List<Metric> metricsToRegister = newArrayList();
- Map<String, Metrics> metricsByRepository = Maps.newHashMap();
+ Map<String, Metrics> metricsByRepository = new HashMap<>();
for (Metrics metrics : metricsRepositories) {
checkMetrics(metricsByRepository, metrics);
metricsToRegister.addAll(metrics.getMetrics());
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/debt/DebtModelPluginRepositoryTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/debt/DebtModelPluginRepositoryTest.java
index 5275d006954..702408f7b0e 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/debt/DebtModelPluginRepositoryTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/debt/DebtModelPluginRepositoryTest.java
@@ -20,12 +20,12 @@
package org.sonar.server.debt;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.io.Resources;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
@@ -111,7 +111,7 @@ public class DebtModelPluginRepositoryTest {
}
private void initModel() {
- Map<String, ClassLoader> contributingPluginKeyToClassLoader = Maps.newHashMap();
+ Map<String, ClassLoader> contributingPluginKeyToClassLoader = new HashMap<>();
contributingPluginKeyToClassLoader.put("csharp", newClassLoader());
contributingPluginKeyToClassLoader.put("java", newClassLoader());
underTest = new DebtModelPluginRepository(contributingPluginKeyToClassLoader, TEST_XML_PREFIX_PATH);
@@ -119,15 +119,12 @@ public class DebtModelPluginRepositoryTest {
private ClassLoader newClassLoader() {
ClassLoader loader = mock(ClassLoader.class);
- when(loader.getResourceAsStream(anyString())).thenAnswer(new Answer<InputStream>() {
- public InputStream answer(InvocationOnMock invocation) throws Throwable {
- return new FileInputStream(Resources.getResource((String) invocation.getArguments()[0]).getPath());
- }
- });
+ when(loader.getResourceAsStream(anyString())).thenAnswer(
+ (Answer<InputStream>) invocation -> new FileInputStream(Resources.getResource((String) invocation.getArguments()[0]).getPath()));
return loader;
}
- class FakePlugin implements Plugin {
+ static class FakePlugin implements Plugin {
@Override public void define(Context context) {
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java
index de10b8e1905..71a77c31e99 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java
@@ -47,7 +47,7 @@ public class IndexerStartupTaskTest {
private final IndexerStartupTask underTest = new IndexerStartupTask(es.client(), settings.asConfig(), metadataIndex, indexer);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
doReturn(ImmutableSet.of(TYPE_FAKE)).when(indexer).getIndexTypes();
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
index 9d90900df71..49592d6fc9b 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
@@ -34,7 +34,7 @@ public class NotificationChannelTest {
assertThat(channel.toString()).isEqualTo("FakeNotificationChannel");
}
- private class FakeNotificationChannel extends NotificationChannel {
+ private static class FakeNotificationChannel extends NotificationChannel {
@Override
public boolean deliver(Notification notification, String username) {
return true;
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java
index 8a24e6b092c..499b1f8e135 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationDaemonTest.java
@@ -42,7 +42,7 @@ public class NotificationDaemonTest {
private InOrder inOrder;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MapSettings settings = new MapSettings(new PropertyDefinitions(NotificationDaemon.class)).setProperty("sonar.notifications.delay", 1L);
underTest = new NotificationDaemon(settings.asConfig(), manager, notificationService);
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java
index 050fc56cbac..c5782c68e5c 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java
@@ -39,7 +39,7 @@ public class DefaultServerUpgradeStatusTest {
private DefaultServerUpgradeStatus underTest = new DefaultServerUpgradeStatus(dbVersion, migrationSteps, new ConfigurationBridge(settings));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(migrationSteps.getMaxMigrationNumber()).thenReturn(LAST_VERSION);
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java
index 0875ad0fcb2..ed0919cffff 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java
@@ -346,7 +346,7 @@ public class ServerIdManagerTest {
}
private void insertServerId(String serverId) {
- dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(CoreProperties.SERVER_ID).setValue(serverId.toString()));
+ dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(CoreProperties.SERVER_ID).setValue(serverId));
dbSession.commit();
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
index b86a3a547a2..07f543ac10c 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
@@ -72,7 +72,7 @@ public class ProjectsInWarningDaemonTest {
private ProjectsInWarningDaemon underTest = new ProjectsInWarningDaemon(db.getDbClient(), projectMeasuresIndex, settings.asConfig(), lockManager, projectsInWarning);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
settings.setProperty("sonar.projectsInWarning.frequencyInMilliseconds", "100");
}
@@ -100,7 +100,6 @@ public class ProjectsInWarningDaemonTest {
public void update_projects_in_warning_when_new_project_in_warning() throws InterruptedException {
allowLockToBeAcquired();
MetricDto qualityGateStatus = insertQualityGateStatusMetric();
- ;
insertProjectInWarning(qualityGateStatus);
insertProjectInWarning(qualityGateStatus);
// Setting does not exist
@@ -118,7 +117,6 @@ public class ProjectsInWarningDaemonTest {
public void stop_thread_when_number_of_projects_in_warning_reach_zero() throws InterruptedException {
allowLockToBeAcquired();
MetricDto qualityGateStatus = insertQualityGateStatusMetric();
- ;
ComponentDto project = insertProjectInWarning(qualityGateStatus);
underTest.notifyStart();
@@ -167,7 +165,6 @@ public class ProjectsInWarningDaemonTest {
public void do_not_compute_projects_in_warning_when_internal_property_is_zero() throws InterruptedException {
allowLockToBeAcquired();
MetricDto qualityGateStatus = insertQualityGateStatusMetric();
- ;
insertProjectInWarning(qualityGateStatus);
// Setting contains 0, even if there are projects in warning it will stay 0 (as it's not possible to have new projects in warning)
db.getDbClient().internalPropertiesDao().save(db.getSession(), PROJECTS_IN_WARNING_INTERNAL_PROPERTY, "0");
@@ -183,7 +180,6 @@ public class ProjectsInWarningDaemonTest {
public void do_not_store_projects_in_warning_in_db_when_cannot_acquire_lock() throws InterruptedException {
when(lockManager.tryLock(any(), anyInt())).thenReturn(false);
MetricDto qualityGateStatus = insertQualityGateStatusMetric();
- ;
insertProjectInWarning(qualityGateStatus);
underTest.notifyStart();
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/CachingRuleFinderTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/CachingRuleFinderTest.java
index 6c19c1a0ef0..7dbd209503e 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/CachingRuleFinderTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/CachingRuleFinderTest.java
@@ -408,7 +408,7 @@ public class CachingRuleFinderTest {
assertThat(rule.getUpdatedAt().getTime()).isEqualTo(ruleDefinition.getUpdatedAt());
assertThat(rule.getRepositoryKey()).isEqualTo(ruleDefinition.getRepositoryKey());
assertThat(rule.getSeverity().name()).isEqualTo(ruleDefinition.getSeverityString());
- assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().stream().toArray(String[]::new));
+ assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().toArray(new String[0]));
assertThat(rule.getTags()).isEmpty();
assertThat(rule.getId()).isEqualTo(ruleDefinition.getId());
assertThat(rule.getDescription()).isEqualTo(ruleDefinition.getDescription());
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 43987b4889f..b1401160563 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
@@ -367,7 +367,7 @@ public class RegisterRulesTest {
@Test
public void add_new_tag() {
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule1")
.setName("Rule One")
@@ -380,7 +380,7 @@ public class RegisterRulesTest {
RuleDto rule = dbClient.ruleDao().selectOrFailByKey(db.getSession(), defaultOrganization, RULE_KEY1);
assertThat(rule.getSystemTags()).containsOnly("tag1");
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule1")
.setName("Rule One")
@@ -395,7 +395,7 @@ public class RegisterRulesTest {
@Test
public void add_new_security_standards() {
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule1")
.setName("Rule One")
@@ -409,7 +409,7 @@ public class RegisterRulesTest {
RuleDto rule = dbClient.ruleDao().selectOrFailByKey(db.getSession(), defaultOrganization, RULE_KEY1);
assertThat(rule.getSecurityStandards()).containsOnly("cwe:123", "owaspTop10:a1");
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule1")
.setName("Rule One")
@@ -426,7 +426,7 @@ public class RegisterRulesTest {
@Test
public void update_only_rule_name() {
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule")
.setName("Name1")
@@ -435,7 +435,7 @@ public class RegisterRulesTest {
});
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule")
.setName("Name2")
@@ -459,8 +459,8 @@ public class RegisterRulesTest {
String repository = "fake";
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository, "java");
repo.createRule(ruleKey1)
.setName("Name1")
.setHtmlDescription("Description");
@@ -473,8 +473,8 @@ public class RegisterRulesTest {
assertThat(searchRule1.getTotal()).isEqualTo(1);
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository, "java");
repo.createRule(ruleKey2)
.setName("Name2")
.setHtmlDescription("Description")
@@ -501,8 +501,8 @@ public class RegisterRulesTest {
String repository2 = "fake2";
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository1, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository1, "java");
repo.createRule(ruleKey)
.setName("Name1")
.setHtmlDescription("Description");
@@ -515,8 +515,8 @@ public class RegisterRulesTest {
assertThat(searchRule1.getTotal()).isEqualTo(1);
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository2, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository2, "java");
repo.createRule(ruleKey)
.setName("Name2")
.setHtmlDescription("Description")
@@ -542,8 +542,8 @@ public class RegisterRulesTest {
String name = "Name1";
String description = "Description";
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repo1, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repo1, "java");
repo.createRule(ruleKey1)
.setName(name)
.setHtmlDescription(description);
@@ -555,8 +555,8 @@ public class RegisterRulesTest {
.containsOnly(rule1.getId());
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repo2, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repo2, "java");
repo.createRule(ruleKey2)
.setName(name)
.setHtmlDescription(description)
@@ -591,8 +591,8 @@ public class RegisterRulesTest {
String repository2 = "fake2";
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository1, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository1, "java");
repo.createRule(ruleKey1)
.setName("Name1")
.setHtmlDescription("Description");
@@ -604,8 +604,8 @@ public class RegisterRulesTest {
.containsOnly(rule1.getId());
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
- RulesDefinition.NewRepository repo = context.createRepository(repository2, "java");
+ execute(context -> {
+ NewRepository repo = context.createRepository(repository2, "java");
repo.createRule(ruleKey2)
.setName("Name2")
.setHtmlDescription("Description")
@@ -626,7 +626,7 @@ public class RegisterRulesTest {
@Test
public void update_only_rule_description() {
when(system.now()).thenReturn(DATE1.getTime());
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule")
.setName("Name")
@@ -635,7 +635,7 @@ public class RegisterRulesTest {
});
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule")
.setName("Name")
@@ -656,7 +656,7 @@ public class RegisterRulesTest {
public void rule_previously_created_as_adhoc_becomes_none_adhoc() {
RuleDefinitionDto rule = db.rules().insert(r -> r.setRepositoryKey("external_fake").setIsExternal(true).setIsAdHoc(true));
when(system.now()).thenReturn(DATE2.getTime());
- execute((RulesDefinition) context -> {
+ execute(context -> {
NewRepository repo = context.createExternalRepository("fake", rule.getLanguage());
repo.createRule(rule.getRuleKey())
.setName(rule.getName())
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/WebServerRuleFinderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/WebServerRuleFinderImplTest.java
index 5fdac77d9e8..80fe7bce48c 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/WebServerRuleFinderImplTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/WebServerRuleFinderImplTest.java
@@ -37,7 +37,7 @@ public class WebServerRuleFinderImplTest {
private WebServerRuleFinderImpl underTest = new WebServerRuleFinderImpl(dbClient, defaultOrganizationProvider);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(dbClient.ruleDao()).thenReturn(mock(RuleDao.class));
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/search/BaseDocTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/search/BaseDocTest.java
index 450bf1b96d2..9c09a330891 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/search/BaseDocTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/search/BaseDocTest.java
@@ -20,9 +20,9 @@
package org.sonar.server.search;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
@@ -43,7 +43,7 @@ public class BaseDocTest {
@Test
public void getField() {
- Map<String, Object> fields = Maps.newHashMap();
+ Map<String, Object> fields = new HashMap<>();
fields.put("a_string", "foo");
fields.put("a_int", 42);
fields.put("a_null", null);
@@ -81,7 +81,7 @@ public class BaseDocTest {
@Test
public void getFieldAsDate() {
- BaseDoc doc = new BaseDoc(someType, Maps.newHashMap()) {
+ BaseDoc doc = new BaseDoc(someType, new HashMap<>()) {
@Override
public String getId() {
return null;
@@ -98,7 +98,7 @@ public class BaseDocTest {
@Test
public void getNullableFieldAsDate() {
- BaseDoc doc = new BaseDoc(someType, Maps.newHashMap()) {
+ BaseDoc doc = new BaseDoc(someType, new HashMap<>()) {
@Override
public String getId() {
return null;
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
index b5fc51496cd..7bbac6a2b2b 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
@@ -196,7 +196,7 @@ public class RegisterMetricsTest {
new RegisterMetrics(dbClient, new Metrics[] {plugin}).start();
}
- private class TestMetrics implements Metrics {
+ private static class TestMetrics implements Metrics {
private final List<Metric> metrics;
public TestMetrics(Metric... metrics) {
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
index 079be37fd2b..31f7f87e2ed 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
@@ -107,8 +107,8 @@ public class WebhookQGChangeEventListenerTest {
.toArray(Metric.Level[]::new);
Object[][] res = new Object[levelsAndNull.length * levelsAndNull.length][2];
int i = 0;
- for (Metric.Level previousStatus : Arrays.asList(levelsAndNull)) {
- for (Metric.Level newStatus : Arrays.asList(levelsAndNull)) {
+ for (Metric.Level previousStatus : levelsAndNull) {
+ for (Metric.Level newStatus : levelsAndNull) {
res[i][0] = previousStatus;
res[i][1] = newStatus;
i++;
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java
index 0a45e823dbe..afa9977ca48 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexCreator.java
@@ -114,7 +114,7 @@ public class IndexCreator implements Startable {
String indexName = mainType.getIndex().getName();
String readOnly = client.nativeClient().admin().indices().getSettings(new GetSettingsRequest().indices(indexName)).actionGet()
.getSetting(indexName, "index.blocks.read_only_allow_delete");
- return readOnly != null && "true".equalsIgnoreCase(readOnly);
+ return "true".equalsIgnoreCase(readOnly);
}
private void removeReadOnly(IndexType.IndexMainType mainType) {
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java
index 22b8b59b0c3..bbd8b1dbd39 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/es/IndexDefinitions.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.es;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.picocontainer.Startable;
import org.sonar.api.config.Configuration;
@@ -33,7 +33,7 @@ import org.sonar.server.es.newindex.NewIndex;
@ServerSide
public class IndexDefinitions implements Startable {
- private final Map<String, BuiltIndex> byKey = Maps.newHashMap();
+ private final Map<String, BuiltIndex> byKey = new HashMap<>();
private final IndexDefinition[] defs;
private final Configuration config;
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
index 295c8576cb2..6406a47025b 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
@@ -510,7 +510,7 @@ public class IssueIndex {
String facetName = ASSIGNEES.getName();
// Same as in super.stickyFacetBuilder
- Map<String, QueryBuilder> assigneeFilters = Maps.newHashMap(filters);
+ Map<String, QueryBuilder> assigneeFilters = new HashMap<>(filters);
assigneeFilters.remove(IS_ASSIGNED_FILTER);
assigneeFilters.remove(fieldName);
StickyFacetBuilder stickyFacetBuilder = newStickyFacetBuilder(query, assigneeFilters, queryBuilder);
@@ -895,8 +895,8 @@ public class IssueIndex {
private static AggregationBuilder createAggregation(String categoryField, String category, boolean includeCwe, Optional<Map<String, Set<String>>> categoryToCwesMap) {
return addSecurityReportSubAggregations(AggregationBuilders
- .filter(category, boolQuery()
- .filter(termQuery(categoryField, category))),
+ .filter(category, boolQuery()
+ .filter(termQuery(categoryField, category))),
includeCwe, categoryToCwesMap.map(m -> m.get(category)));
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
index 8f9bf8b324f..d680ccbd0a4 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
@@ -450,7 +450,7 @@ public class RecoveryIndexerTest {
}
}
- private class HardFailingFakeIndexer implements ResilientIndexer {
+ private static class HardFailingFakeIndexer implements ResilientIndexer {
private final Set<IndexType> types;
private final List<Collection<EsQueueDto>> called = new ArrayList<>();
@@ -476,7 +476,7 @@ public class RecoveryIndexerTest {
}
}
- private class SoftFailingFakeIndexer implements ResilientIndexer {
+ private static class SoftFailingFakeIndexer implements ResilientIndexer {
private final Set<IndexType> types;
private final List<Collection<EsQueueDto>> called = new ArrayList<>();
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 1dda0b4e89a..d7070fad5bb 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
@@ -391,8 +391,7 @@ public class PermissionIndexerTest {
}
private ComponentDto createUnindexedPublicProject() {
- ComponentDto project = db.components().insertPublicProject();
- return project;
+ return db.components().insertPublicProject();
}
private ComponentDto createAndIndexPrivateProject() {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java
index b1f127ef490..a4005789e54 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/IssuesAction.java
@@ -23,6 +23,7 @@ import com.google.common.base.Splitter;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sonar.api.resources.Scopes;
@@ -42,7 +43,6 @@ import org.sonar.server.user.UserSession;
import org.sonarqube.ws.MediaTypes;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.Maps.newHashMap;
import static java.lang.String.format;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
@@ -160,7 +160,7 @@ public class IssuesAction implements BatchWsAction {
}
private Map<String, String> keysByUUid(DbSession session, ComponentDto component) {
- Map<String, String> keysByUUid = newHashMap();
+ Map<String, String> keysByUUid = new HashMap<>();
if (Scopes.PROJECT.equals(component.scope())) {
List<ComponentDto> modulesTree = dbClient.componentDao().selectDescendantModules(session, component.uuid());
for (ComponentDto componentDto : modulesTree) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
index a262c8f7121..0947915b3b7 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
@@ -20,6 +20,7 @@
package org.sonar.server.batch;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@@ -39,7 +40,6 @@ import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.user.UserSession;
-import static com.google.common.collect.Maps.newHashMap;
import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
@@ -98,7 +98,7 @@ public class ProjectDataLoader {
}
private static void addFileDataPerModule(MultiModuleProjectRepository data, List<ComponentDto> moduleChildren, List<FilePathWithHashDto> files) {
- Map<String, String> moduleKeysByUuid = newHashMap();
+ Map<String, String> moduleKeysByUuid = new HashMap<>();
for (ComponentDto module : moduleChildren) {
moduleKeysByUuid.put(module.uuid(), module.getKey());
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java
index 3694122ddfe..d7724ecc73a 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java
@@ -84,12 +84,7 @@ class IssuesFinderSort {
abstract static class TextSortIssueProcessor implements IssueProcessor {
@Override
public Function sortFieldFunction() {
- return new Function<IssueDto, String>() {
- @Override
- public String apply(IssueDto issueDto) {
- return sortField(issueDto);
- }
- };
+ return (Function<IssueDto, String>) this::sortField;
}
abstract String sortField(IssueDto issueDto);
@@ -130,12 +125,7 @@ class IssuesFinderSort {
abstract static class DateSortRowProcessor implements IssueProcessor {
@Override
public Function sortFieldFunction() {
- return new Function<IssueDto, Date>() {
- @Override
- public Date apply(IssueDto issueDto) {
- return sortField(issueDto);
- }
- };
+ return (Function<IssueDto, Date>) this::sortField;
}
abstract Date sortField(IssueDto issueDto);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/Result.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/Result.java
index 4d09fa750ab..9a95f873d22 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/Result.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/Result.java
@@ -32,7 +32,7 @@ import static com.google.common.collect.Lists.newArrayList;
*/
public class Result<T> {
- private T object = null;
+ private T object;
private final List<Message> errors = newArrayList();
private Result(@Nullable T object) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index 1144a6f83a0..5d6735c96d1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -258,7 +258,7 @@ public class SearchAction implements IssuesWsAction, Startable {
action.createParam(PARAM_TYPES)
.setDescription("Comma-separated list of types.")
.setSince("5.5")
- .setPossibleValues((Object[]) RuleType.values())
+ .setPossibleValues(RuleType.values())
.setExampleValue(format("%s,%s", RuleType.CODE_SMELL, RuleType.BUG));
action.createParam(PARAM_OWASP_TOP_10)
.setDescription("Comma-separated list of OWASP Top 10 lowercase categories.")
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
index 15b2c5f0c01..efd6413abed 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
@@ -185,10 +185,6 @@ public class SearchResponseData {
@CheckForNull
UserDto getUserByUuid(@Nullable String userUuid) {
- UserDto userDto = usersByUuid.get(userUuid);
- if (userDto == null) {
- return null;
- }
- return userDto;
+ return usersByUuid.get(userUuid);
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java
index 436eba98c33..e125040bc3f 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SetTagsAction.java
@@ -92,7 +92,7 @@ public class SetTagsAction implements IssuesWsAction {
@Override
public void handle(Request request, Response response) throws Exception {
String key = request.mandatoryParam(PARAM_ISSUE);
- List<String> tags = MoreObjects.firstNonNull(request.paramAsStrings(PARAM_TAGS), Collections.<String>emptyList());
+ List<String> tags = MoreObjects.firstNonNull(request.paramAsStrings(PARAM_TAGS), Collections.emptyList());
SearchResponseData preloadedSearchResponseData = setTags(key, tags);
responseWriter.write(key, preloadedSearchResponseData, request, response);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java
index 41098e90d5e..32817d8df51 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CustomMeasureJsonWriter.java
@@ -83,7 +83,7 @@ public class CustomMeasureJsonWriter {
private static String measureValue(CustomMeasureDto measure, MetricDto metric) {
Metric.ValueType metricType = Metric.ValueType.valueOf(metric.getValueType());
- Double doubleValue = measure.getValue();
+ double doubleValue = measure.getValue();
String stringValue = measure.getTextValue();
switch (metricType) {
@@ -91,9 +91,8 @@ public class CustomMeasureJsonWriter {
return doubleValue == 1.0d ? "true" : "false";
case INT:
case MILLISEC:
- return String.valueOf(doubleValue.intValue());
+ return String.valueOf((int) doubleValue);
case WORK_DUR:
- return String.valueOf(doubleValue.longValue());
case FLOAT:
case PERCENT:
case RATING:
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java
index 7dac198818c..a6c51580fae 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/MeasureMatrix.java
@@ -103,7 +103,7 @@ class MeasureMatrix {
void setValue(ComponentDto component, String metricKey, Rating value) {
changeCell(component, metricKey, m -> {
Double initialValue = m.getValue();
- if (initialValue != null && Double.compare(initialValue, (double) value.getIndex()) == 0) {
+ if (initialValue != null && Double.compare(initialValue, value.getIndex()) == 0) {
return false;
}
m.setData(value.name());
@@ -141,7 +141,7 @@ class MeasureMatrix {
}
void setLeakValue(ComponentDto component, String metricKey, Rating variation) {
- setLeakValue(component, metricKey, (double) variation.getIndex());
+ setLeakValue(component, metricKey, variation.getIndex());
}
Stream<LiveMeasureDto> getChanged() {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
index 9f885f3214d..d8400dfbb6a 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
@@ -91,8 +91,8 @@ public class ComponentAction implements MeasuresWsAction {
@Override
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction(ACTION_COMPONENT)
- .setDescription(format("Return component with specified measures.<br>" +
- "Requires the following permission: 'Browse' on the project of specified component."))
+ .setDescription("Return component with specified measures.<br>" +
+ "Requires the following permission: 'Browse' on the project of specified component.")
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.4")
.setChangelog(
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
index 015742db8f8..c4b9e898ef9 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
@@ -136,8 +136,8 @@ public class ListAction implements NotificationsWsAction {
.filter(isComponentInDb)
.map(toWsNotification(notification, organizationsByUuid, componentsById))
.sorted(comparing(Notification::getProject, nullsFirst(naturalOrder()))
- .thenComparing(comparing(Notification::getChannel))
- .thenComparing(comparing(Notification::getType)))
+ .thenComparing(Notification::getChannel)
+ .thenComparing(Notification::getType))
.forEach(response::addNotifications);
return response;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java
index fcfbdf0cdeb..b1f56aba029 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java
@@ -119,7 +119,7 @@ public class UpdateAction implements OrganizationsWsAction {
private OrganizationDto getDto(DbSession dbSession, String key) {
Optional<OrganizationDto> organizationDto = dbClient.organizationDao().selectByKey(dbSession, key);
if (!organizationDto.isPresent()) {
- throw new NotFoundException(format("Organization not found for key '%s'", (Object) key));
+ throw new NotFoundException(format("Organization not found for key '%s'", key));
}
return organizationDto.get();
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
index aeecbd20b92..f6a84af15ca 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
@@ -68,8 +68,7 @@ public class DbMigrationStatusAction implements SystemWsAction {
Optional<Long> currentVersion = databaseVersion.getVersion();
checkState(currentVersion.isPresent(), NO_CONNECTION_TO_DB);
- JsonWriter json = response.newJsonWriter();
- try {
+ try (JsonWriter json = response.newJsonWriter()) {
DatabaseVersion.Status status = databaseVersion.getStatus();
if (status == DatabaseVersion.Status.UP_TO_DATE || status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
write(json, databaseMigrationState);
@@ -89,8 +88,6 @@ public class DbMigrationStatusAction implements SystemWsAction {
throw new IllegalArgumentException(UNSUPPORTED_DATABASE_MIGRATION_STATUS);
}
}
- } finally {
- json.close();
}
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java
index 3f0b3be8010..949de46d33d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java
@@ -76,8 +76,7 @@ public class MigrateDbAction implements SystemWsAction {
Optional<Long> currentVersion = databaseVersion.getVersion();
checkState(currentVersion.isPresent(), NO_CONNECTION_TO_DB);
- JsonWriter json = response.newJsonWriter();
- try {
+ try (JsonWriter json = response.newJsonWriter()) {
DatabaseVersion.Status status = databaseVersion.getStatus();
if (status == DatabaseVersion.Status.UP_TO_DATE || status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
write(json, migrationState);
@@ -98,8 +97,6 @@ public class MigrateDbAction implements SystemWsAction {
throw new IllegalArgumentException(UNSUPPORTED_DATABASE_MIGRATION_STATUS);
}
}
- } finally {
- json.close();
}
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/AvailableAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/AvailableAction.java
index df2e98b29e7..45ad0e16390 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/AvailableAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/AvailableAction.java
@@ -68,7 +68,7 @@ public class AvailableAction implements PluginsWsAction {
}
@Override
- public void handle(Request request, Response response) throws Exception {
+ public void handle(Request request, Response response) {
userSession.checkIsSystemAdministrator();
JsonWriter jsonWriter = response.newJsonWriter();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/PluginUpdateAggregator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/PluginUpdateAggregator.java
index 50efcf6588d..992af65a1a2 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/PluginUpdateAggregator.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/PluginUpdateAggregator.java
@@ -22,9 +22,9 @@ package org.sonar.server.plugins.ws;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@@ -43,7 +43,7 @@ public class PluginUpdateAggregator {
return Collections.emptyList();
}
- Map<Plugin, PluginUpdateAggregateBuilder> builders = Maps.newHashMap();
+ Map<Plugin, PluginUpdateAggregateBuilder> builders = new HashMap<>();
for (PluginUpdate pluginUpdate : pluginUpdates) {
Plugin plugin = pluginUpdate.getPlugin();
PluginUpdateAggregateBuilder builder = builders.get(plugin);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java
index 01a960c6061..ac0ffa53337 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java
@@ -33,7 +33,6 @@ import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.web.UserRole;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.db.component.BranchDao;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.component.SnapshotQuery;
@@ -65,13 +64,11 @@ public class SearchAction implements ProjectAnalysesWsAction {
private final DbClient dbClient;
private final ComponentFinder componentFinder;
private final UserSession userSession;
- private final BranchDao branchDao;
- public SearchAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, BranchDao branchDao) {
+ public SearchAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession) {
this.dbClient = dbClient;
this.componentFinder = componentFinder;
this.userSession = userSession;
- this.branchDao = branchDao;
}
@Override
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java
index fb9400b9525..57877966536 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java
@@ -231,10 +231,9 @@ public class QualityGateConditionsUpdater {
return isNullOrEmpty(value) || RATING_VALID_INT_VALUES.contains(value);
}
- @SuppressWarnings("unchecked")
private static boolean check(boolean expression, List<String> errors, String message, String... args) {
if (!expression) {
- errors.add(format(message, (Object[]) args));
+ errors.add(format(message, args));
}
return expression;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
index 03bd79fcd43..a214e334dcb 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
@@ -93,10 +93,10 @@ public class QProfileComparison {
private final QProfileDto left;
private final QProfileDto right;
- private final Map<RuleKey, ActiveRuleDto> inLeft = Maps.newHashMap();
- private final Map<RuleKey, ActiveRuleDto> inRight = Maps.newHashMap();
- private final Map<RuleKey, ActiveRuleDiff> modified = Maps.newHashMap();
- private final Map<RuleKey, ActiveRuleDto> same = Maps.newHashMap();
+ private final Map<RuleKey, ActiveRuleDto> inLeft = new HashMap<>();
+ private final Map<RuleKey, ActiveRuleDto> inRight = new HashMap<>();
+ private final Map<RuleKey, ActiveRuleDiff> modified = new HashMap<>();
+ private final Map<RuleKey, ActiveRuleDto> same = new HashMap<>();
public QProfileComparisonResult(QProfileDto left, QProfileDto right) {
this.left = left;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/NewCustomRule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/NewCustomRule.java
index e64880ceb07..67171f4cec9 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/NewCustomRule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/NewCustomRule.java
@@ -21,7 +21,7 @@ package org.sonar.server.rule;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -39,7 +39,7 @@ public class NewCustomRule {
private String severity;
private RuleStatus status;
private RuleType type;
- private final Map<String, String> parameters = Maps.newHashMap();
+ private final Map<String, String> parameters = new HashMap<>();
private boolean preventReactivation = false;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdate.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdate.java
index 9df29ada1a9..2d1a8dfcddb 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdate.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdate.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.rule;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.annotation.CheckForNull;
@@ -55,7 +55,7 @@ public class RuleUpdate {
private String markdownDescription;
private String severity;
private RuleStatus status;
- private final Map<String, String> parameters = Maps.newHashMap();
+ private final Map<String, String> parameters = new HashMap<>();
private OrganizationDto organization;
private RuleUpdate(RuleKey ruleKey, RuleUpdateUseCase useCase) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java
index 94d70e4ba5f..f02babaef76 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java
@@ -168,7 +168,7 @@ public class CurrentAction implements UsersWsAction {
}
private Optional<CurrentWsResponse.Homepage> projectHomepage(DbSession dbSession, UserDto user) {
- Optional<ComponentDto> projectOptional = ofNullable(dbClient.componentDao().selectByUuid(dbSession, of(user.getHomepageParameter()).orElse(EMPTY)).orElse(null));
+ Optional<ComponentDto> projectOptional = dbClient.componentDao().selectByUuid(dbSession, of(user.getHomepageParameter()).orElse(EMPTY));
if (shouldCleanProjectHomepage(projectOptional)) {
cleanUserHomepageInDb(dbSession, user);
return empty();
@@ -186,7 +186,7 @@ public class CurrentAction implements UsersWsAction {
}
private Optional<CurrentWsResponse.Homepage> applicationAndPortfolioHomepage(DbSession dbSession, UserDto user) {
- Optional<ComponentDto> componentOptional = ofNullable(dbClient.componentDao().selectByUuid(dbSession, of(user.getHomepageParameter()).orElse(EMPTY)).orElse(null));
+ Optional<ComponentDto> componentOptional = dbClient.componentDao().selectByUuid(dbSession, of(user.getHomepageParameter()).orElse(EMPTY));
if (shouldCleanApplicationOrPortfolioHomepage(componentOptional)) {
cleanUserHomepageInDb(dbSession, user);
return empty();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
index 6b3d29f6292..6110d91ce64 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
@@ -146,8 +146,7 @@ public class DeactivateAction implements UsersWsAction {
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject();
json.name("user");
- Set<String> groups = new HashSet<>();
- groups.addAll(dbClient.groupMembershipDao().selectGroupsByLogins(dbSession, singletonList(login)).get(login));
+ Set<String> groups = new HashSet<>(dbClient.groupMembershipDao().selectGroupsByLogins(dbSession, singletonList(login)).get(login));
userWriter.write(json, user, groups, UserJsonWriter.FIELDS);
json.endObject();
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java
index 21410bf8a2f..e849b7d59af 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/UpdateLoginAction.java
@@ -26,7 +26,6 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.OrganizationUpdater;
import org.sonar.server.user.UpdateUser;
import org.sonar.server.user.UserSession;
import org.sonar.server.user.UserUpdater;
@@ -43,13 +42,11 @@ public class UpdateLoginAction implements UsersWsAction {
private final DbClient dbClient;
private final UserSession userSession;
private final UserUpdater userUpdater;
- private final OrganizationUpdater organizationUpdater;
- public UpdateLoginAction(DbClient dbClient, UserSession userSession, UserUpdater userUpdater, OrganizationUpdater organizationUpdater) {
+ public UpdateLoginAction(DbClient dbClient, UserSession userSession, UserUpdater userUpdater) {
this.dbClient = dbClient;
this.userSession = userSession;
this.userUpdater = userUpdater;
- this.organizationUpdater = organizationUpdater;
}
@Override
@@ -81,7 +78,8 @@ public class UpdateLoginAction implements UsersWsAction {
String newLogin = request.mandatoryParam(PARAM_NEW_LOGIN);
try (DbSession dbSession = dbClient.openSession(false)) {
UserDto user = getUser(dbSession, login);
- userUpdater.updateAndCommit(dbSession, user, new UpdateUser().setLogin(newLogin), u -> {});
+ userUpdater.updateAndCommit(dbSession, user, new UpdateUser().setLogin(newLogin), u -> {
+ });
response.noContent();
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/DeleteAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/DeleteAction.java
index 33d4efc43ee..26295408dba 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/DeleteAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/DeleteAction.java
@@ -30,7 +30,6 @@ import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.webhook.WebhookDto;
import org.sonar.server.user.UserSession;
-import static java.util.Optional.ofNullable;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.DELETE_ACTION;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.KEY_PARAM;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.KEY_PARAM_MAXIMUM_LENGTH;
@@ -87,7 +86,7 @@ public class DeleteAction implements WebhooksWsAction {
String projectUuid = webhookDto.getProjectUuid();
if (projectUuid != null) {
- Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orElse(null));
+ Optional<ComponentDto> optionalDto = dbClient.componentDao().selectByUuid(dbSession, projectUuid);
ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
webhookSupport.checkPermission(componentDto);
deleteWebhook(dbSession, webhookDto);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/UpdateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/UpdateAction.java
index 89fa228a260..d839856c9b1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/UpdateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/webhook/ws/UpdateAction.java
@@ -31,7 +31,6 @@ import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.webhook.WebhookDto;
import org.sonar.server.user.UserSession;
-import static java.util.Optional.ofNullable;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.KEY_PARAM;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.KEY_PARAM_MAXIMUM_LENGTH;
import static org.sonar.server.webhook.ws.WebhooksWsParameters.NAME_PARAM;
@@ -122,7 +121,7 @@ public class UpdateAction implements WebhooksWsAction {
String projectUuid = webhookDto.getProjectUuid();
if (projectUuid != null) {
- Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orElse(null));
+ Optional<ComponentDto> optionalDto = dbClient.componentDao().selectByUuid(dbSession, projectUuid);
ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
webhookSupport.checkPermission(componentDto);
updateWebhook(dbSession, webhookDto, name, url, secret);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java
index 4c77e88e5e2..f6c7038007b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java
@@ -19,9 +19,7 @@
*/
package org.sonar.server.authentication.ws;
-import java.io.IOException;
import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
@@ -81,7 +79,7 @@ public class LoginActionTest {
private LoginAction underTest = new LoginAction(credentialsAuthentication, jwtHttpHandler, threadLocalUserSession, authenticationEvent, userSessionFactory);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
threadLocalUserSession.unload();
dbClient.userDao().insert(dbSession, user);
dbSession.commit();
@@ -171,7 +169,7 @@ public class LoginActionTest {
verify(authenticationEvent).loginFailure(eq(request), any(AuthenticationException.class));
}
- private void executeRequest(String login, String password) throws IOException, ServletException {
+ private void executeRequest(String login, String password) {
when(request.getMethod()).thenReturn("POST");
when(request.getParameter("login")).thenReturn(login);
when(request.getParameter("password")).thenReturn(password);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LogoutActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LogoutActionTest.java
index 9ad434f109f..244eca45859 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LogoutActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/authentication/ws/LogoutActionTest.java
@@ -19,11 +19,9 @@
*/
package org.sonar.server.authentication.ws;
-import java.io.IOException;
import java.util.Collections;
import java.util.Optional;
import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Rule;
@@ -88,7 +86,7 @@ public class LogoutActionTest {
}
@Test
- public void return_400_on_get_request() throws Exception {
+ public void return_400_on_get_request() {
when(request.getMethod()).thenReturn("GET");
underTest.doFilter(request, response, chain);
@@ -132,7 +130,7 @@ public class LogoutActionTest {
verifyZeroInteractions(chain);
}
- private void executeRequest() throws IOException, ServletException {
+ private void executeRequest() {
when(request.getMethod()).thenReturn("POST");
underTest.doFilter(request, response, chain);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java
index a874f2b6071..4dc2b5afc54 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java
@@ -98,7 +98,7 @@ public class ReportSubmitterTest {
private ReportSubmitter underTest = new ReportSubmitter(queue, userSession, componentUpdater, permissionTemplateService, db.getDbClient(), ossEditionBranchSupport);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
defaultOrganizationKey = db.getDefaultOrganization().getKey();
defaultOrganizationUuid = db.getDefaultOrganization().getUuid();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java
index 099874e2161..64bdaa26704 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java
@@ -292,7 +292,7 @@ public class TaskFormatterTest {
.setAnalysisUuid("U1");
}
- private class TestActivityDto extends CeActivityDto {
+ private static class TestActivityDto extends CeActivityDto {
public TestActivityDto(CeQueueDto queueDto) {
super(queueDto);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
index 66583ddfbf2..89c843b92ea 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentServiceUpdateKeyTest.java
@@ -228,8 +228,7 @@ public class ComponentServiceUpdateKeyTest {
}
private ComponentDto insertProject(String key) {
- ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey(key));
- return project;
+ return componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey(key));
}
private void assertComponentKeyHasBeenUpdated(String oldKey, String newKey) {
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 2fb20536bf0..b628cea3975 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
@@ -138,7 +138,7 @@ public class SearchProjectsActionTest {
private RequestBuilder request = SearchProjectsRequest.builder();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
projectsInWarning.update(0L);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java
index 994e9d83e92..f726834f35a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java
@@ -81,13 +81,13 @@ public class ShowActionTest {
}
@Test
- public void get_duplications_by_file_key() throws Exception {
+ public void get_duplications_by_file_key() {
TestRequest request = newBaseRequest();
verifyCallToFileWithDuplications(file -> request.setParam("key", file.getDbKey()));
}
@Test
- public void get_duplications_by_file_id() throws Exception {
+ public void get_duplications_by_file_id() {
TestRequest request = newBaseRequest();
verifyCallToFileWithDuplications(file -> request.setParam("uuid", file.uuid()));
}
@@ -238,7 +238,7 @@ public class ShowActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
index e16069b3233..4d852c87c82 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/AddActionTest.java
@@ -137,7 +137,7 @@ public class AddActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
ComponentDto branch = db.components().insertProjectBranch(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
index 05e050e2e63..148e9e2f2ef 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/favorite/ws/RemoveActionTest.java
@@ -106,7 +106,7 @@ public class RemoveActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
index 84893a43792..220a4216c39 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
@@ -202,7 +202,7 @@ public class HealthCheckerImplTest {
.map(HardcodedHealthClusterCheck::new)
.map(ClusterHealthCheck.class::cast)
.toArray(ClusterHealthCheck[]::new);
- String[] expectedCauses = causesGroups.stream().flatMap(Arrays::stream).collect(Collectors.toSet()).stream().toArray(String[]::new);
+ String[] expectedCauses = causesGroups.stream().flatMap(Arrays::stream).toArray(String[]::new);
HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
index fe6a79e456f..c831bb4ddf0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
@@ -41,7 +41,6 @@ public class AddTagsActionTest {
private AddTagsAction underTest = new AddTagsAction(issueUpdater);
@Test
- @SuppressWarnings("unchecked")
public void should_execute() {
Map<String, Object> properties = new HashMap<>();
properties.put("tags", "tag2,tag3");
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
index cdfe07d39a4..36e950eae5f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
@@ -59,7 +59,6 @@ public class AssignActionTest {
private IssueChangeContext issueChangeContext = IssueChangeContext.createUser(new Date(), "user_uuid");
private DefaultIssue issue = new DefaultIssue().setKey("ABC").setAssigneeUuid(ISSUE_CURRENT_ASSIGNEE_UUID);
- private ComponentDto project;
private Action.Context context;
private OrganizationDto issueOrganizationDto;
@@ -68,7 +67,7 @@ public class AssignActionTest {
@Before
public void setUp() throws Exception {
issueOrganizationDto = db.organizations().insert();
- project = db.components().insertPrivateProject(issueOrganizationDto);
+ ComponentDto project = db.components().insertPrivateProject(issueOrganizationDto);
context = new ActionContext(issue, issueChangeContext, project);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/CommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/CommentActionTest.java
index 2e1d68afb1f..8e9675bcbe1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/CommentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/CommentActionTest.java
@@ -19,7 +19,8 @@
*/
package org.sonar.server.issue;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -27,7 +28,7 @@ import org.sonar.api.issue.Issue;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.server.tester.AnonymousMockUserSession;
-import static com.google.common.collect.Maps.newHashMap;
+import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
@@ -51,7 +52,7 @@ public class CommentActionTest {
@Test
public void should_execute() {
String comment = "My bulk change comment";
- Map<String, Object> properties = newHashMap();
+ Map<String, Object> properties = new HashMap<>();
properties.put("comment", comment);
DefaultIssue issue = mock(DefaultIssue.class);
@@ -64,10 +65,9 @@ public class CommentActionTest {
@Test
public void should_verify_fail_if_parameter_not_found() {
- Map<String, Object> properties = newHashMap();
- properties.put("unknwown", "unknown value");
+ Map<String, Object> properties = singletonMap("unknwown", "unknown value");
try {
- action.verify(properties, Lists.newArrayList(), new AnonymousMockUserSession());
+ action.verify(properties, new ArrayList<>(), new AnonymousMockUserSession());
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Missing parameter : 'comment'");
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueFinderTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueFinderTest.java
index 51f1566f9d0..e0394b512f9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueFinderTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueFinderTest.java
@@ -61,8 +61,7 @@ public class IssueFinderTest {
@Test
public void get_by_issue_key() {
IssueDto issueDto = insertIssue();
- String permission = USER;
- addProjectPermission(issueDto, permission);
+ addProjectPermission(issueDto, USER);
IssueDto result = underTest.getByKey(db.getSession(), issueDto.getKey());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
index 9ad3bc3d751..141bb69604e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
@@ -20,6 +20,7 @@
package org.sonar.server.issue;
import com.google.common.collect.ImmutableSet;
+import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
@@ -27,7 +28,6 @@ import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import org.sonar.core.issue.DefaultIssue;
-import static com.google.common.collect.Maps.newHashMap;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -41,9 +41,8 @@ public class RemoveTagsActionTest {
private RemoveTagsAction action = new RemoveTagsAction(issueUpdater);
@Test
- @SuppressWarnings("unchecked")
public void should_execute() {
- Map<String, Object> properties = newHashMap();
+ Map<String, Object> properties = new HashMap<>();
properties.put("tags", "tag2,tag3");
DefaultIssue issue = mock(DefaultIssue.class);
@@ -61,7 +60,7 @@ public class RemoveTagsActionTest {
throwable.expect(IllegalArgumentException.class);
throwable.expectMessage("Tag 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
- Map<String, Object> properties = newHashMap();
+ Map<String, Object> properties = new HashMap<>();
properties.put("tags", "th ag");
DefaultIssue issue = mock(DefaultIssue.class);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
index 8a2866dfd97..9d7b2f3c9ea 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
@@ -66,7 +66,7 @@ public class TransitionActionTest {
private TransitionAction action = new TransitionAction(transitionService);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
workflow.start();
when(context.issue()).thenReturn(issue);
when(context.issueChangeContext()).thenReturn(IssueChangeContext.createUser(new Date(), "user_uuid"));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionServiceTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionServiceTest.java
index 69729235480..3abbaff55f8 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionServiceTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionServiceTest.java
@@ -58,7 +58,7 @@ public class TransitionServiceTest {
private TransitionService underTest = new TransitionService(userSession, workflow);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
workflow.start();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
index d5f01f3cf05..752cd8d68c8 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
@@ -103,7 +103,7 @@ public class AddCommentActionTest {
new AddCommentAction(system2, userSession, dbClient, new IssueFinder(dbClient, userSession), issueUpdater, new IssueFieldsSetter(), responseWriter));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(system2.now()).thenReturn(NOW);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
index 3919c8fea27..08942433b09 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
@@ -265,13 +265,12 @@ public class AssignActionTest {
}
private IssueDto newIssue(String assignee) {
- IssueDto issue = db.issues().insertIssue(
+ return db.issues().insertIssue(
issueDto -> issueDto
.setAssigneeUuid(assignee)
.setCreatedAt(PAST).setIssueCreationTime(PAST)
.setUpdatedAt(PAST).setIssueUpdateTime(PAST)
.setType(CODE_SMELL));
- return issue;
}
private IssueDto newIssueWithBrowsePermission() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
index 158ff824d0f..6ce3f852583 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
@@ -72,7 +72,7 @@ public class ChangelogActionTest {
private WsActionTester tester = new WsActionTester(new ChangelogAction(db.getDbClient(), new IssueFinder(db.getDbClient(), userSession), new AvatarResolverImpl(), userSession));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
project = db.components().insertPrivateProject();
file = db.components().insertComponent(newFileDto(project));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
index 089552f1433..e0fb95d29b3 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java
@@ -64,7 +64,7 @@ public class MetricsActionTest {
private WsActionTester tester = new WsActionTester(underTest);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
defaultProject = insertDefaultProject();
userSession.logIn().addProjectPermission(UserRole.ADMIN, defaultProject);
}
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 c3b7eb46d78..b09e262be13 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
@@ -94,7 +94,7 @@ public class LiveMeasureComputerImplTest {
private EvaluatedQualityGate newQualityGate = mock(EvaluatedQualityGate.class);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
intMetric = db.measures().insertMetric(m -> m.setValueType(Metric.ValueType.INT.name()));
ratingMetric = db.measures().insertMetric(m -> m.setValueType(Metric.ValueType.RATING.name()));
alertStatusMetric = db.measures().insertMetric(m -> m.setKey(CoreMetrics.ALERT_STATUS_KEY));
@@ -452,7 +452,7 @@ public class LiveMeasureComputerImplTest {
Metric metric = new Metric.Builder(intMetric.getKey(), intMetric.getShortName(), Metric.ValueType.valueOf(intMetric.getValueType())).create();
AtomicInteger counter = new AtomicInteger();
return new IssueMetricFormula(metric, false, (ctx, issues) -> {
- ctx.setValue((double) counter.incrementAndGet());
+ ctx.setValue(counter.incrementAndGet());
});
}
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 0d82256257c..85836c997fe 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
@@ -395,7 +395,7 @@ public class ComponentActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
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 31103bb0667..a9b39764220 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
@@ -44,7 +44,6 @@ import org.sonarqube.ws.Measures.Measure;
import org.sonarqube.ws.Measures.SearchWsResponse;
import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Lists.transform;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
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 c06454e681d..a23ecc0f7d2 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
@@ -341,7 +341,7 @@ public class SearchHistoryActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java
index c93517fbb0f..c8554263d3e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/AddActionTest.java
@@ -327,7 +327,7 @@ public class AddActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java
index b08766bfbaa..215791d7db5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/RemoveActionTest.java
@@ -307,7 +307,7 @@ public class RemoveActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
index b6f9600af1a..367f07d328a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
@@ -61,7 +61,7 @@ public class GroupPermissionChangerTest {
private ComponentDto publicProject;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
org = db.organizations().insert();
group = db.users().insertGroup(org, "a-group");
privateProject = db.components().insertPrivateProject(org);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java
index 41d48efd496..877b0f1cb1e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java
@@ -68,7 +68,7 @@ public class UserPermissionChangerTest {
private ComponentDto publicProject;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
org1 = db.organizations().insert();
org2 = db.organizations().insert();
user1 = db.users().insertUser();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
index 51efdf27471..bdc01864e60 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
@@ -217,7 +217,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
}
@Test
- public void adding_a_project_permission_fails_if_project_is_not_set() throws Exception {
+ public void adding_a_project_permission_fails_if_project_is_not_set() {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
loginAsAdmin(db.getDefaultOrganization());
@@ -456,7 +456,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
GroupDto group = db.users().insertGroup(organization);
ComponentDto project = db.components().insertMainBranch(organization);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
index c18be504182..f94a4ed0598 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java
@@ -404,7 +404,7 @@ public class AddUserActionTest extends BasePermissionWsTest<AddUserAction> {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
addUserAsMemberOfOrganization(organization);
ComponentDto project = db.components().insertMainBranch(organization);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
index fd0cc81d2de..732fba0d30e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
@@ -157,7 +157,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
}
@Test
- public void fail_to_remove_last_admin_permission() throws Exception {
+ public void fail_to_remove_last_admin_permission() {
db.users().insertPermissionOnGroup(aGroup, ADMINISTER);
db.users().insertPermissionOnGroup(aGroup, PROVISION_PROJECTS);
loginAsAdmin(db.getDefaultOrganization());
@@ -183,7 +183,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
}
@Test
- public void fail_when_project_project_permission_without_project() throws Exception {
+ public void fail_when_project_project_permission_without_project() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
@@ -434,7 +434,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
GroupDto group = db.users().insertGroup(organization);
ComponentDto project = db.components().insertMainBranch(organization);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
index c6f011d6dfe..e0ea8ee5804 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java
@@ -353,7 +353,7 @@ public class RemoveUserActionTest extends BasePermissionWsTest<RemoveUserAction>
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
index 1f37a11b249..72907647f7c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
@@ -291,7 +291,7 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
ComponentDto branch = db.components().insertProjectBranch(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java
index 623d9dc8cb9..8623e569e66 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java
@@ -70,7 +70,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void add_user_to_template() throws Exception {
+ public void add_user_to_template() {
loginAsAdmin(db.getDefaultOrganization());
newRequest(user.getLogin(), permissionTemplate.getUuid(), CODEVIEWER);
@@ -109,7 +109,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void does_not_add_a_user_twice() throws Exception {
+ public void does_not_add_a_user_twice() {
loginAsAdmin(db.getDefaultOrganization());
newRequest(user.getLogin(), permissionTemplate.getUuid(), ISSUE_ADMIN);
@@ -119,7 +119,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_not_a_project_permission() throws Exception {
+ public void fail_if_not_a_project_permission() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(IllegalArgumentException.class);
@@ -128,7 +128,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_not_admin_of_default_organization() throws Exception {
+ public void fail_if_not_admin_of_default_organization() {
userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES, db.getDefaultOrganization());
expectedException.expect(ForbiddenException.class);
@@ -137,7 +137,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_user_missing() throws Exception {
+ public void fail_if_user_missing() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(IllegalArgumentException.class);
@@ -146,7 +146,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_permission_missing() throws Exception {
+ public void fail_if_permission_missing() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(IllegalArgumentException.class);
@@ -155,7 +155,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_template_uuid_and_name_are_missing() throws Exception {
+ public void fail_if_template_uuid_and_name_are_missing() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
@@ -164,7 +164,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_user_does_not_exist() throws Exception {
+ public void fail_if_user_does_not_exist() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
@@ -174,7 +174,7 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
}
@Test
- public void fail_if_template_key_does_not_exist() throws Exception {
+ public void fail_if_template_key_does_not_exist() {
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
@@ -195,7 +195,8 @@ public class AddUserToTemplateActionTest extends BasePermissionWsTest<AddUserToT
.setParam(PARAM_PERMISSION, CODEVIEWER)
.setParam(PARAM_TEMPLATE_NAME, permissionTemplate.getName().toUpperCase())
.setParam(PARAM_ORGANIZATION, "Unknown")
- .execute(); }
+ .execute();
+ }
@Test
public void fail_to_add_permission_when_user_is_not_member_of_given_organization() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
index 11f4c26b89f..d9c0e3f68b0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
@@ -80,7 +80,7 @@ public class DeleteTemplateActionTest {
private WsActionTester underTestWithViews;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
GroupWsSupport groupWsSupport = new GroupWsSupport(dbClient, TestDefaultOrganizationProvider.from(db), new DefaultGroupFinder(db.getDbClient()));
this.underTestWithoutViews = new WsActionTester(new DeleteTemplateAction(dbClient, userSession,
new PermissionWsSupport(dbClient, new ComponentFinder(dbClient, resourceTypes), groupWsSupport), defaultTemplatesResolver));
@@ -184,12 +184,12 @@ public class DeleteTemplateActionTest {
}
@Test
- public void fail_to_delete_by_uuid_if_template_is_default_template_for_project_without_views() throws Exception {
+ public void fail_to_delete_by_uuid_if_template_is_default_template_for_project_without_views() {
fail_to_delete_by_uuid_if_template_is_default_template_for_project(this.underTestWithoutViews);
}
@Test
- public void fail_to_delete_by_uuid_if_template_is_default_template_for_project_with_views() throws Exception {
+ public void fail_to_delete_by_uuid_if_template_is_default_template_for_project_with_views() {
fail_to_delete_by_uuid_if_template_is_default_template_for_project(this.underTestWithViews);
}
@@ -207,12 +207,12 @@ public class DeleteTemplateActionTest {
}
@Test
- public void fail_to_delete_by_name_if_template_is_default_template_for_project_without_views() throws Exception {
+ public void fail_to_delete_by_name_if_template_is_default_template_for_project_without_views() {
fail_to_delete_by_name_if_template_is_default_template_for_project(this.underTestWithoutViews);
}
@Test
- public void fail_to_delete_by_name_if_template_is_default_template_for_project_with_views() throws Exception {
+ public void fail_to_delete_by_name_if_template_is_default_template_for_project_with_views() {
fail_to_delete_by_name_if_template_is_default_template_for_project(this.underTestWithViews);
}
@@ -435,8 +435,7 @@ public class DeleteTemplateActionTest {
return request.execute();
}
- private TestResponse newRequestByName(WsActionTester actionTester, @Nullable OrganizationDto organizationDto, @Nullable PermissionTemplateDto permissionTemplateDto)
- throws Exception {
+ private TestResponse newRequestByName(WsActionTester actionTester, @Nullable OrganizationDto organizationDto, @Nullable PermissionTemplateDto permissionTemplateDto) {
return newRequestByName(
actionTester,
organizationDto == null ? null : organizationDto.getKey(),
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
index 86204efb938..3f35d799822 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
@@ -264,7 +264,7 @@ public class HealthActionTest {
assertThat(node.getHealth().name()).isEqualTo(nodeHealth.getStatus().name());
assertThat(node.getCausesList())
.extracting(System.Cause::getMessage)
- .containsOnly(nodeHealth.getCauses().stream().toArray(String[]::new));
+ .containsOnly(nodeHealth.getCauses().toArray(new String[0]));
assertThat(node.getName()).isEqualTo(nodeHealth.getDetails().getName());
assertThat(node.getHost()).isEqualTo(nodeHealth.getDetails().getHost());
assertThat(node.getPort()).isEqualTo(nodeHealth.getDetails().getPort());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
index 3a1cc765eec..e467ea9075c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.platform.ws;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.text.JsonWriter;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.platform.SystemInfoWriter;
import org.sonar.server.tester.UserSessionRule;
@@ -39,12 +38,7 @@ public class InfoActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private SystemInfoWriter jsonWriter = new SystemInfoWriter() {
- @Override
- public void write(JsonWriter json) {
- json.prop("key", "value");
- }
- };
+ private SystemInfoWriter jsonWriter = json -> json.prop("key", "value");
private InfoAction underTest = new InfoAction(userSessionRule, jsonWriter);
private WsActionTester ws = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java
index ff6f668236b..86a75a0a874 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/StatusActionTest.java
@@ -80,14 +80,14 @@ public class StatusActionTest {
}
@Test
- public void status_is_UP_if_platform_is_UP_and_restartFlag_is_false_whatever_databaseMigration_status_is() throws Exception {
+ public void status_is_UP_if_platform_is_UP_and_restartFlag_is_false_whatever_databaseMigration_status_is() {
for (DatabaseMigrationState.Status databaseMigrationStatus : DatabaseMigrationState.Status.values()) {
verifyStatus(Platform.Status.UP, databaseMigrationStatus, STATUS_UP);
}
}
@Test
- public void status_is_RESTARTING_if_platform_is_UP_and_restartFlag_is_true_whatever_databaseMigration_status_is() throws Exception {
+ public void status_is_RESTARTING_if_platform_is_UP_and_restartFlag_is_true_whatever_databaseMigration_status_is() {
restartFlagHolder.set();
for (DatabaseMigrationState.Status databaseMigrationStatus : DatabaseMigrationState.Status.values()) {
@@ -96,54 +96,54 @@ public class StatusActionTest {
}
@Test
- public void status_is_DOWN_if_platform_is_BOOTING_whatever_databaseMigration_status_is() throws Exception {
+ public void status_is_DOWN_if_platform_is_BOOTING_whatever_databaseMigration_status_is() {
for (DatabaseMigrationState.Status databaseMigrationStatus : DatabaseMigrationState.Status.values()) {
verifyStatus(Platform.Status.BOOTING, databaseMigrationStatus, STATUS_DOWN);
}
}
@Test
- public void status_is_DB_MIGRATION_NEEDED_if_platform_is_SAFEMODE_and_databaseMigration_is_NONE() throws Exception {
+ public void status_is_DB_MIGRATION_NEEDED_if_platform_is_SAFEMODE_and_databaseMigration_is_NONE() {
verifyStatus(Platform.Status.SAFEMODE, DatabaseMigrationState.Status.NONE, STATUS_MIGRATION_NEEDED);
}
@Test
- public void status_is_DB_MIGRATION_RUNNING_if_platform_is_SAFEMODE_and_databaseMigration_is_RUNNING() throws Exception {
+ public void status_is_DB_MIGRATION_RUNNING_if_platform_is_SAFEMODE_and_databaseMigration_is_RUNNING() {
verifyStatus(Platform.Status.SAFEMODE, DatabaseMigrationState.Status.RUNNING, STATUS_MIGRATION_RUNNING);
}
@Test
- public void status_is_STATUS_STARTING_if_platform_is_SAFEMODE_and_databaseMigration_is_SUCCEEDED() throws Exception {
+ public void status_is_STATUS_STARTING_if_platform_is_SAFEMODE_and_databaseMigration_is_SUCCEEDED() {
verifyStatus(Platform.Status.SAFEMODE, DatabaseMigrationState.Status.SUCCEEDED, STATUS_STARTING);
}
@Test
- public void status_is_DOWN_if_platform_is_SAFEMODE_and_databaseMigration_is_FAILED() throws Exception {
+ public void status_is_DOWN_if_platform_is_SAFEMODE_and_databaseMigration_is_FAILED() {
verifyStatus(Platform.Status.SAFEMODE, DatabaseMigrationState.Status.FAILED, STATUS_DOWN);
}
@Test
- public void status_is_STARTING_if_platform_is_STARTING_and_databaseMigration_is_NONE() throws Exception {
+ public void status_is_STARTING_if_platform_is_STARTING_and_databaseMigration_is_NONE() {
verifyStatus(Platform.Status.STARTING, DatabaseMigrationState.Status.NONE, STATUS_STARTING);
}
@Test
- public void status_is_DB_MIGRATION_RUNNING_if_platform_is_STARTING_and_databaseMigration_is_RUNNING() throws Exception {
+ public void status_is_DB_MIGRATION_RUNNING_if_platform_is_STARTING_and_databaseMigration_is_RUNNING() {
verifyStatus(Platform.Status.STARTING, DatabaseMigrationState.Status.RUNNING, STATUS_MIGRATION_RUNNING);
}
@Test
- public void status_is_STARTING_if_platform_is_STARTING_and_databaseMigration_is_SUCCEEDED() throws Exception {
+ public void status_is_STARTING_if_platform_is_STARTING_and_databaseMigration_is_SUCCEEDED() {
verifyStatus(Platform.Status.STARTING, DatabaseMigrationState.Status.SUCCEEDED, STATUS_STARTING);
}
@Test
- public void status_is_DOWN_if_platform_is_STARTING_and_databaseMigration_is_FAILED() throws Exception {
+ public void status_is_DOWN_if_platform_is_STARTING_and_databaseMigration_is_FAILED() {
verifyStatus(Platform.Status.STARTING, DatabaseMigrationState.Status.FAILED, STATUS_DOWN);
}
@Test
- public void safety_test_for_new_platform_status() throws Exception {
+ public void safety_test_for_new_platform_status() {
for (Platform.Status platformStatus : filter(asList(Platform.Status.values()), not(in(SUPPORTED_PLATFORM_STATUSES)))) {
for (DatabaseMigrationState.Status databaseMigrationStatus : DatabaseMigrationState.Status.values()) {
verifyStatus(platformStatus, databaseMigrationStatus, STATUS_DOWN);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java
index 8596f047fd4..37bf7d5ddb7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java
@@ -45,7 +45,6 @@ public class UpgradesActionTest {
private static final String JSON_EMPTY_UPGRADE_LIST = "{" +
" \"upgrades\":" + "[]" +
"}";
- private static Release release;
private UpdateCenterMatrixFactory updateCenterFactory = mock(UpdateCenterMatrixFactory.class);
private UpdateCenter updateCenter = mock(UpdateCenter.class);
@@ -75,7 +74,7 @@ public class UpgradesActionTest {
.setTermsConditionsUrl("http://dist.sonarsource.com/SonarSource_Terms_And_Conditions.pdf")
.setIssueTrackerUrl("http://jira.sonarsource.com/browse/VIEWS");
- release = new Release(new Sonar(), Version.create("5.1.0.5498"))
+ Release release = new Release(new Sonar(), Version.create("5.1.0.5498"))
.setDate(DateUtils.parseDate("2015-04-02"))
.setDescription("New overall layout, merge Issues Drilldown [...]")
.setDownloadUrl("http://dist.sonar.codehaus.org/sonarqube-5.1.zip")
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java
index 749d4b653eb..242f8c7cb29 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateKeyActionTest.java
@@ -124,7 +124,7 @@ public class UpdateKeyActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
ComponentDto project = db.components().insertMainBranch();
ComponentDto branch = db.components().insertProjectBranch(project);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
index 65df5995095..0393af7f7bc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
@@ -625,7 +625,7 @@ public class UpdateVisibilityActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
ComponentDto project = dbTester.components().insertMainBranch();
userSessionRule.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto branch = dbTester.components().insertProjectBranch(project);
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 3d34e71d317..db51a0473ee 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
@@ -33,7 +33,6 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
-import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.LogAndArguments;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
@@ -41,7 +40,6 @@ import org.sonar.api.web.UserRole;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
-import org.sonar.db.component.BranchDao;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
@@ -108,8 +106,7 @@ public class SearchActionTest {
private DbClient dbClient = db.getDbClient();
- private WsActionTester ws = new WsActionTester(new SearchAction(dbClient, TestComponentFinder.from(db),
- userSession, new BranchDao(System2.INSTANCE)));
+ private WsActionTester ws = new WsActionTester(new SearchAction(dbClient, TestComponentFinder.from(db), userSession));
private UuidFactoryFast uuidFactoryFast = UuidFactoryFast.getInstance();
@DataProvider
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
index 458f8ca0b14..d9170674af0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
@@ -220,7 +220,7 @@ public class CreateActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
index 834ca4b39a7..3ef67c10a6e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
@@ -238,7 +238,7 @@ public class SearchActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
index c0b71a0d85e..874ec379163 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
@@ -175,7 +175,7 @@ public class SetActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DestroyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DestroyActionTest.java
index f72cfde4739..a862dd0734f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DestroyActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/DestroyActionTest.java
@@ -169,7 +169,7 @@ public class DestroyActionTest {
expectedException.expectMessage(format("The 'id' parameter cannot be parsed as a long value: %s", invalidId));
ws.newRequest()
- .setParam(PARAM_ID, valueOf(invalidId))
+ .setParam(PARAM_ID, invalidId)
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute();
}
@@ -182,7 +182,7 @@ public class DestroyActionTest {
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_ID, valueOf(EMPTY))
+ .setParam(PARAM_ID, EMPTY)
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
index 7aaaaf3d22f..a4e53e8064d 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
@@ -243,7 +243,7 @@ public class GetByProjectActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
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 4dfcc43009a..53e2fbeff9b 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
@@ -411,7 +411,7 @@ public class ProjectStatusActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java
index 18ac6127aa4..72ae8797e01 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/SelectActionTest.java
@@ -304,7 +304,7 @@ public class SelectActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
QGateWithOrgDto qualityGate = db.qualityGates().insertQualityGate(organization);
ComponentDto project = db.components().insertMainBranch(organization);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
index 81ce2e33ef6..9f09440102c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
@@ -58,7 +58,6 @@ public class QProfileComparisonTest {
@Rule
public EsTester es = EsTester.create();
- private DbClient db;
private DbSession dbSession;
private QProfileRules qProfileRules;
private QProfileComparison comparison;
@@ -70,7 +69,7 @@ public class QProfileComparisonTest {
@Before
public void before() {
- db = dbTester.getDbClient();
+ DbClient db = dbTester.getDbClient();
dbSession = db.openSession(false);
RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE);
ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(db, es.client());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationTest.java
index d6a535e448f..5355dccf665 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationTest.java
@@ -138,7 +138,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(tuple(dbProfile.getName(), dbProfile.getLanguage()));
@@ -160,7 +160,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(tuple(dbProfile.getName(), dbProfile.getLanguage()));
@@ -190,7 +190,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(
@@ -218,7 +218,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(tuple(builtInQProfileDto.getName(), builtInQProfileDto.getLanguage()));
@@ -245,7 +245,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(tuple(builtInProfile.getName(), builtInProfile.getLanguage()));
@@ -275,7 +275,7 @@ public class RegisterQualityProfilesNotificationTest {
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
- Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.<Multimap<QProfileName, ActiveRuleChange>>getValue();
+ Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet())
.extracting(QProfileName::getName, QProfileName::getLanguage)
.containsExactlyInAnyOrder(tuple(builtInQProfileDto.getName(), builtInQProfileDto.getLanguage()));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
index 66b83cf7e62..cf37df75faf 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
@@ -45,7 +45,6 @@ import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.organization.OrganizationDto.Subscription.FREE;
import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class BackupActionTest {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
index dd7ca435cb5..3dac943de56 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
@@ -69,7 +69,6 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
index 074448c81f5..9cc130aa877 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
@@ -51,7 +51,6 @@ import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java
index 9beeeb2e4d3..57e712ac9ed 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java
@@ -37,7 +37,6 @@ import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
@@ -51,7 +50,6 @@ import org.sonar.server.ws.WsActionTester;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
index 3e054a4fe68..29e25f394d1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
@@ -67,7 +67,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
import static org.sonar.test.JsonAssert.assertJson;
import static org.sonarqube.ws.MediaTypes.PROTOBUF;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
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 8f6663eeb13..01670cd58ec 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
@@ -101,7 +101,7 @@ public class QProfilesWsMediumTest {
private WsActionTester wsActivateRules = new WsActionTester(new ActivateRulesAction(ruleQueryFactory, userSessionRule, qProfileRules, qProfileWsSupport, dbClient));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
organization = dbTester.organizations().insert();
}
@@ -273,7 +273,7 @@ public class QProfilesWsMediumTest {
}
@Test
- public void bulk_activate_rule() throws Exception {
+ public void bulk_activate_rule() {
QProfileDto profile = createProfile("java");
createRule(profile.getLanguage(), "toto");
createRule(profile.getLanguage(), "tata");
@@ -297,7 +297,7 @@ public class QProfilesWsMediumTest {
}
@Test
- public void bulk_activate_rule_not_all() throws Exception {
+ public void bulk_activate_rule_not_all() {
QProfileDto java = createProfile("java");
QProfileDto php = createProfile("php");
createRule(java.getLanguage(), "toto");
@@ -386,7 +386,7 @@ public class QProfilesWsMediumTest {
}
@Test
- public void does_not_return_warnings_when_bulk_activate_on_profile_and_rules_exist_on_another_language_than_profile() throws Exception {
+ public void does_not_return_warnings_when_bulk_activate_on_profile_and_rules_exist_on_another_language_than_profile() {
QProfileDto javaProfile = createProfile("java");
createRule(javaProfile.getLanguage(), "toto");
createRule(javaProfile.getLanguage(), "tata");
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
index 002c724d68e..253084602b7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
@@ -199,7 +199,7 @@ public class RemoveProjectActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
index 24567637699..0123ef11921 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
@@ -92,7 +92,7 @@ public class ListDefinitionsActionTest {
new ListDefinitionsAction(dbClient, TestComponentFinder.from(db), userSession, propertyDefinitions, support));
@Before
- public void setUp() throws Exception {
+ public void setUp() {
project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java
index 6043e4aa23e..8e084d7ae95 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SetActionTest.java
@@ -906,7 +906,7 @@ public class SetActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java
index 43a2a6cbff0..e28d7254179 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/SettingsUpdaterTest.java
@@ -65,7 +65,7 @@ public class SettingsUpdaterTest {
SettingsUpdater underTest= new SettingsUpdater(dbClient, definitions);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
index 5c17ab03bd6..a1c92fe3976 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
@@ -95,7 +95,7 @@ public class ValuesActionTest {
private ComponentDto project;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()));
}
@@ -747,7 +747,7 @@ public class ValuesActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn().addProjectPermission(UserRole.USER, project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/RawActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/RawActionTest.java
index 60e9e3d6424..7508b35186b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/RawActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/ws/RawActionTest.java
@@ -122,7 +122,7 @@ public class RawActionTest {
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
ComponentDto project = db.components().insertMainBranch();
userSession.addProjectPermission(UserRole.CODEVIEWER, project);
ComponentDto branch = db.components().insertProjectBranch(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
index 301ee897045..a81ca68c1b1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
@@ -25,15 +25,11 @@ import org.junit.rules.ExpectedException;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.System2;
-import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbTester;
import org.sonar.db.user.UserDto;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.OrganizationUpdater;
-import org.sonar.server.organization.OrganizationUpdaterImpl;
-import org.sonar.server.organization.OrganizationValidationImpl;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
@@ -59,13 +55,9 @@ public class UpdateLoginActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private OrganizationUpdater organizationUpdater = new OrganizationUpdaterImpl(db.getDbClient(), mock(System2.class), UuidFactoryFast.getInstance(),
- new OrganizationValidationImpl(), null, null, null, null);
-
private WsActionTester ws = new WsActionTester(new UpdateLoginAction(db.getDbClient(), userSession,
new UserUpdater(system2, mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()),
- null, null, null, null, null),
- organizationUpdater));
+ null, null, null, null, null)));
@Test
public void update_login_from_sonarqube_account_when_user_is_local() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
index 5050def00f0..c0bcade3e9a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
@@ -210,7 +210,7 @@ public class AddUserActionTest {
}
@Test
- public void fail_if_not_administrator() throws Exception {
+ public void fail_if_not_administrator() {
GroupDto group = db.users().insertGroup();
UserDto user = db.users().insertUser();
db.organizations().addMember(db.getDefaultOrganization(), user);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
index 7d96370e5cf..c5c4ad322e5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
@@ -259,7 +259,7 @@ public class DeleteActionTest {
}
@Test
- public void delete_admin_group_fails_if_no_admin_users_left() throws Exception {
+ public void delete_admin_group_fails_if_no_admin_users_left() {
// admin users are part of the group to be deleted
OrganizationDto org = db.organizations().insert();
db.users().insertDefaultGroup(org);
@@ -276,7 +276,7 @@ public class DeleteActionTest {
}
@Test
- public void delete_admin_group_succeeds_if_other_groups_have_administrators() throws Exception {
+ public void delete_admin_group_succeeds_if_other_groups_have_administrators() {
OrganizationDto org = db.organizations().insert();
db.users().insertDefaultGroup(org);
GroupDto adminGroup1 = db.users().insertGroup(org, "admins");
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 7558aee5679..3fade9563f8 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
@@ -152,7 +152,7 @@ public class DeleteActionTest {
}
@Test
- public void fail_if_not_logged_in() throws Exception {
+ public void fail_if_not_logged_in() {
OrganizationDto organization = organizationDbTester.insert();
WebhookDto dto = webhookDbTester.insertWebhook(organization);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ws/ws/ResponseExampleActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ws/ws/ResponseExampleActionTest.java
index a5a389280f9..81a764991d3 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ws/ws/ResponseExampleActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ws/ws/ResponseExampleActionTest.java
@@ -31,7 +31,7 @@ public class ResponseExampleActionTest {
private WebService.Action action;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
WebService.NewController newController = context.createController("api/ws");
underTest.define(newController);
newController.done();
diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java
index 07c11840a16..a55a8c2b1dc 100644
--- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java
+++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java
@@ -20,7 +20,6 @@
package org.sonar.server.ws;
import com.google.common.base.Throwables;
-import com.google.common.collect.Maps;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -28,6 +27,7 @@ import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import javax.annotation.CheckForNull;
import org.apache.commons.io.IOUtils;
@@ -41,7 +41,7 @@ public class DefaultLocalResponse implements Response, LocalConnector.LocalRespo
private final InMemoryStream stream = new InMemoryStream();
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
- private final Map<String, String> headers = Maps.newHashMap();
+ private final Map<String, String> headers = new HashMap<>();
@Override
public int getStatus() {
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java
index 262a8325845..e300f834aca 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java
@@ -36,7 +36,7 @@ public class RemovedWebServiceHandlerTest {
public ExpectedException expectedException = ExpectedException.none();
@Test
- public void throw_server_exception() throws Exception {
+ public void throw_server_exception() {
Request request = mock(Request.class);
when(request.getPath()).thenReturn("/api/resources/index");
diff --git a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java
index f7d2aeedd80..8ff41e5080a 100644
--- a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java
+++ b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java
@@ -20,7 +20,6 @@
package org.sonar.server.ws;
import com.google.common.base.Throwables;
-import com.google.common.collect.Maps;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -28,6 +27,7 @@ import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import javax.annotation.CheckForNull;
import org.apache.commons.io.IOUtils;
@@ -40,7 +40,7 @@ public class DumbResponse implements Response {
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
- private Map<String, String> headers = Maps.newHashMap();
+ private Map<String, String> headers = new HashMap<>();
public class InMemoryStream implements Response.Stream {
private String mediaType;
@@ -118,7 +118,7 @@ public class DumbResponse implements Response {
}
@CheckForNull
- public String getHeader(String name){
+ public String getHeader(String name) {
return headers.get(name);
}
diff --git a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java
index aea0e0d69bd..9992319c361 100644
--- a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java
+++ b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java
@@ -23,7 +23,6 @@ import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Maps;
import com.google.protobuf.GeneratedMessageV3;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -47,7 +46,7 @@ public class TestRequest extends ValidatingRequest {
private final ListMultimap<String, String> multiParams = ArrayListMultimap.create();
private final Map<String, String> params = new HashMap<>();
private final Map<String, String> headers = new HashMap<>();
- private final Map<String, Part> parts = Maps.newHashMap();
+ private final Map<String, Part> parts = new HashMap<>();
private String payload = "";
private boolean payloadConsumed = false;
private String method = "GET";
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java
index fc765edffee..973a5e0ad5c 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java
@@ -24,6 +24,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -122,7 +123,7 @@ public class MasterServletFilter implements Filter {
private static final class GodFilterChain implements FilterChain {
private FilterChain chain;
- private List<Filter> filters = Lists.newLinkedList();
+ private List<Filter> filters = new LinkedList<>();
private Iterator<Filter> iterator;
public GodFilterChain(FilterChain chain) {
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java
index b9a0c808d61..ab30626b1de 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java
@@ -61,7 +61,7 @@ public class TomcatContextsTest {
}
@Test
- public void configure_root_webapp() throws Exception {
+ public void configure_root_webapp() {
props.setProperty("foo", "bar");
StandardContext context = mock(StandardContext.class);
when(tomcat.addWebapp(anyString(), anyString())).thenReturn(context);
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
index e1b83207b63..f4a4cbf6577 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
@@ -129,7 +129,7 @@ public class MasterServletFilterTest {
}
@Test
- public void display_servlet_filter_patterns_in_INFO_log() throws Exception {
+ public void display_servlet_filter_patterns_in_INFO_log() {
ServletFilter filter = new PatternFilter(UrlPattern.builder().includes("/api/issues").excludes("/batch/projects").build());
FilterConfig config = mock(FilterConfig.class);
MasterServletFilter master = new MasterServletFilter();
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java
index 255e97509cc..9d39cc6f885 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java
@@ -44,7 +44,7 @@ public class RedirectFilterTest {
private RedirectFilter underTest = new RedirectFilter();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getContextPath()).thenReturn("/sonarqube");
}
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java
index 9cb937e245b..c605671fbd5 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java
@@ -220,7 +220,7 @@ public class UserSessionFilterTest {
}
@Test
- public void just_for_fun_and_coverage() throws ServletException {
+ public void just_for_fun_and_coverage() {
UserSessionFilter filter = new UserSessionFilter();
filter.init(mock(FilterConfig.class));
filter.destroy();
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
index d2949b6afc8..5b44991e0ce 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
@@ -53,7 +53,7 @@ public class WebPagesFilterTest {
private WebPagesFilter underTest = new WebPagesFilter(webPagesCache);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(servletContext.getContextPath()).thenReturn(TEST_CONTEXT);
}
@@ -85,7 +85,7 @@ public class WebPagesFilterTest {
verifyZeroInteractions(webPagesCache);
}
- class StringOutputStream extends ServletOutputStream {
+ static class StringOutputStream extends ServletOutputStream {
private final StringBuilder buf = new StringBuilder();
StringOutputStream() {
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java
index b10e67ea6fa..f85be9685a4 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java
@@ -19,9 +19,7 @@
*/
package org.sonar.server.platform.web;
-import java.io.IOException;
import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
@@ -53,7 +51,7 @@ public class WebServiceReroutingFilterTest {
private WebServiceReroutingFilter underTest = new WebServiceReroutingFilter(webServiceEngine);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(request.getContextPath()).thenReturn("/sonarqube");
}
@@ -65,7 +63,7 @@ public class WebServiceReroutingFilterTest {
}
@Test
- public void redirect_components_update_key() throws Exception {
+ public void redirect_components_update_key() {
when(request.getServletPath()).thenReturn("/api/components/update_key");
when(request.getMethod()).thenReturn("POST");
@@ -75,7 +73,7 @@ public class WebServiceReroutingFilterTest {
}
@Test
- public void redirect_components_bulk_update_key() throws IOException, ServletException {
+ public void redirect_components_bulk_update_key() {
when(request.getServletPath()).thenReturn("/api/components/bulk_update_key");
when(request.getMethod()).thenReturn("POST");