Browse Source

Cleanup code based on Intellij inspections

tags/7.0-RC1
Simon Brandhof 6 years ago
parent
commit
d55f047c44
100 changed files with 237 additions and 243 deletions
  1. 2
    2
      plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java
  2. 2
    2
      plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java
  3. 1
    1
      plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
  4. 2
    2
      server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java
  5. 1
    1
      server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerImpl.java
  6. 1
    1
      server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/EnabledCeWorkerControllerImpl.java
  7. 5
    5
      server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java
  8. 5
    5
      server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java
  9. 2
    2
      server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java
  10. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java
  11. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/httpd/CeHttpServerTest.java
  12. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java
  13. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java
  14. 2
    2
      server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueCleanerTest.java
  15. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueInitializerTest.java
  16. 8
    8
      server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
  17. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/queue/PurgeCeActivitiesTest.java
  18. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/systeminfo/SystemInfoHttpActionTest.java
  19. 9
    9
      server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
  20. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java
  21. 1
    2
      server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfiledDataSource.java
  22. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/CoreDbTester.java
  23. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/DatabaseCommands.java
  24. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/DdlUtilsTest.java
  25. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
  26. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java
  27. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java
  28. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java
  29. 1
    1
      server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
  30. 1
    1
      server/sonar-db-dao/src/main/java/org/sonar/db/ce/LogsIteratorInputStream.java
  31. 4
    8
      server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java
  32. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java
  33. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java
  34. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/DbTester.java
  35. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/MyBatisTest.java
  36. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
  37. 5
    5
      server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
  38. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java
  39. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskQueryTest.java
  40. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java
  41. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
  42. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentLinkDtoTest.java
  43. 3
    3
      server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentQueryTest.java
  44. 5
    5
      server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java
  45. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
  46. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java
  47. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java
  48. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDtoTest.java
  49. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/favorite/FavoriteDbTester.java
  50. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
  51. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java
  52. 7
    7
      server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java
  53. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java
  54. 12
    12
      server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
  55. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java
  56. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java
  57. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java
  58. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java
  59. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
  60. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest.java
  61. 4
    4
      server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
  62. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java
  63. 2
    2
      server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java
  64. 5
    5
      server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateConditionDaoTest.java
  65. 4
    4
      server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateConditionDtoTest.java
  66. 3
    3
      server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
  67. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java
  68. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
  69. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java
  70. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipQueryTest.java
  71. 4
    4
      server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDtoTest.java
  72. 1
    1
      server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java
  73. 6
    6
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/DatabaseCharsetCheckerTest.java
  74. 5
    5
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/BigIntegerColumnDefTest.java
  75. 5
    5
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/BooleanColumnDefTest.java
  76. 9
    9
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/ClobColumnDefTest.java
  77. 8
    8
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/DecimalColumnDefTest.java
  78. 5
    5
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/TimestampColumnDefTest.java
  79. 3
    3
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/TinyIntColumnDefTest.java
  80. 2
    2
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/ValidationsTest.java
  81. 7
    7
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java
  82. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java
  83. 2
    2
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropTableBuilderTest.java
  84. 6
    6
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
  85. 2
    2
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java
  86. 2
    2
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java
  87. 2
    2
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/TestDefaultOrganizationUuidProvider.java
  88. 0
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java
  89. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java
  90. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java
  91. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java
  92. 4
    4
      server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
  93. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java
  94. 2
    2
      server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java
  95. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java
  96. 3
    3
      server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java
  97. 2
    2
      server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java
  98. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java
  99. 1
    1
      server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java
  100. 0
    0
      server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java

+ 2
- 2
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java View File

@@ -94,7 +94,7 @@ public class MultilineIssuesSensor implements Sensor {
Integer issueFlowNum = Integer.parseInt(m.group(3));
TextPointer newPointer = file.newPointer(currentLine, m.end());
if (!startFlowsPositions.containsKey(issueId)) {
startFlowsPositions.put(issueId, HashBasedTable.<Integer, Integer, TextPointer>create());
startFlowsPositions.put(issueId, HashBasedTable.create());
}
startFlowsPositions.get(issueId).row(issueFlowId).put(issueFlowNum, newPointer);
}
@@ -106,7 +106,7 @@ public class MultilineIssuesSensor implements Sensor {
Integer issueFlowNum = Integer.parseInt(m.group(3));
TextPointer newPointer = file.newPointer(currentLine, m.start());
if (!endFlowsPositions.containsKey(issueId)) {
endFlowsPositions.put(issueId, HashBasedTable.<Integer, Integer, TextPointer>create());
endFlowsPositions.put(issueId, HashBasedTable.create());
}
endFlowsPositions.get(issueId).row(issueFlowId).put(issueFlowNum, newPointer);
}

+ 2
- 2
plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java View File

@@ -41,8 +41,8 @@ public class XooPostJobTest {
public void increaseCoverage() {
new XooPostJob().describe(new DefaultPostJobDescriptor());
PostJobContext context = mock(PostJobContext.class);
when(context.issues()).thenReturn(Arrays.<PostJobIssue>asList());
when(context.resolvedIssues()).thenReturn(Arrays.<PostJobIssue>asList());
when(context.issues()).thenReturn(Arrays.asList());
when(context.resolvedIssues()).thenReturn(Arrays.asList());
new XooPostJob().execute(context);
assertThat(logTester.logs()).contains("Resolved issues: 0", "Open issues: 0");
}

+ 1
- 1
plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java View File

@@ -76,7 +76,7 @@ public class XooBlameCommandTest {
fs.add(inputFile);

BlameOutput result = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
when(input.filesToBlame()).thenReturn(Arrays.asList(inputFile));
new XooBlameCommand().blame(input, result);
verify(result).blameResult(inputFile, Arrays.asList(
new BlameLine().revision("123").author("julien").date(DateUtils.parseDate("2014-12-12")),

+ 2
- 2
server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java View File

@@ -67,7 +67,7 @@ public class StandaloneCeDistributedInformation implements CeDistributedInformat
}

@Override
public void lockInterruptibly() throws InterruptedException {
public void lockInterruptibly() {
// return immediately and never block
}

@@ -78,7 +78,7 @@ public class StandaloneCeDistributedInformation implements CeDistributedInformat
}

@Override
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
public boolean tryLock(long time, TimeUnit unit) {
// always succeed
return true;
}

+ 1
- 1
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerImpl.java View File

@@ -69,7 +69,7 @@ public class CeWorkerImpl implements CeWorker {
}

@Override
public Result call() throws Exception {
public Result call() {
return withCustomizedThreadName(this::findAndProcessTask);
}


+ 1
- 1
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/EnabledCeWorkerControllerImpl.java View File

@@ -82,7 +82,7 @@ public class EnabledCeWorkerControllerImpl implements EnabledCeWorkerController
}

@Override
public void close() throws Exception {
public void close() {
map.put(ceWorker, Status.PAUSED);
}
}

+ 5
- 5
server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java View File

@@ -104,7 +104,7 @@ public class CeServerTest {
}

@Test
public void getStatus_does_not_return_OPERATIONAL_until_ComputeEngine_startup_returns() throws InterruptedException, IOException {
public void getStatus_does_not_return_OPERATIONAL_until_ComputeEngine_startup_returns() throws IOException {
BlockingStartupComputeEngine computeEngine = new BlockingStartupComputeEngine(null);
CeServer ceServer = newCeServer(computeEngine);

@@ -122,7 +122,7 @@ public class CeServerTest {
}

@Test
public void getStatus_returns_OPERATIONAL_when_ComputeEngine_startup_throws_any_Exception_or_Error() throws InterruptedException, IOException {
public void getStatus_returns_OPERATIONAL_when_ComputeEngine_startup_throws_any_Exception_or_Error() throws IOException {
Throwable startupException = new Throwable("Faking failing ComputeEngine#startup()");

BlockingStartupComputeEngine computeEngine = new BlockingStartupComputeEngine(startupException);
@@ -152,7 +152,7 @@ public class CeServerTest {
}

@Test
public void awaitStop_throws_ISE_if_called_twice() throws InterruptedException, IOException {
public void awaitStop_throws_ISE_if_called_twice() throws IOException {
final CeServer ceServer = newCeServer();
ExceptionCatcherWaitingThread waitingThread1 = new ExceptionCatcherWaitingThread(ceServer);
ExceptionCatcherWaitingThread waitingThread2 = new ExceptionCatcherWaitingThread(ceServer);
@@ -197,7 +197,7 @@ public class CeServerTest {
}

@Test
public void awaitStop_unblocks_when_waiting_for_ComputeEngine_startup_fails() throws InterruptedException, IOException {
public void awaitStop_unblocks_when_waiting_for_ComputeEngine_startup_fails() throws IOException {
CeServer ceServer = newCeServer(new ComputeEngine() {
@Override
public void startup() {
@@ -242,7 +242,7 @@ public class CeServerTest {
return newCeServer(DoNothingComputeEngine.INSTANCE);
}

private CeServer newCeServer(ComputeEngine computeEngine) throws IOException {
private CeServer newCeServer(ComputeEngine computeEngine) {
checkState(this.underTest == null, "Only one CeServer can be created per test method");
this.underTest = new CeServer(
computeEngine, minimumViableSystem);

+ 5
- 5
server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java View File

@@ -237,7 +237,7 @@ public class CeCleaningSchedulerImplTest {
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
public boolean awaitTermination(long timeout, TimeUnit unit) {
throw createUnsupportedOperationException();
}

@@ -257,22 +257,22 @@ public class CeCleaningSchedulerImplTest {
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
throw createUnsupportedOperationException();
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
throw createUnsupportedOperationException();
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) {
throw createUnsupportedOperationException();
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
throw createUnsupportedOperationException();
}


+ 2
- 2
server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java View File

@@ -40,7 +40,7 @@ public class CePluginJarExploderTest {
CePluginJarExploder underTest = new CePluginJarExploder(fs);

@Test
public void explode_jar_to_temp_directory() throws Exception {
public void explode_jar_to_temp_directory() {
PluginInfo info = PluginInfo.create(plugin1Jar());

ExplodedPlugin exploded = underTest.explode(info);
@@ -55,7 +55,7 @@ public class CePluginJarExploderTest {
}

@Test
public void plugins_do_not_overlap() throws Exception {
public void plugins_do_not_overlap() {
PluginInfo info1 = PluginInfo.create(plugin1Jar());
PluginInfo info2 = PluginInfo.create(plugin2Jar());


+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java View File

@@ -67,7 +67,7 @@ public class CePluginRepositoryTest {
}

@Test
public void load_plugins() throws Exception {
public void load_plugins() {
String pluginKey = "test";
when(fs.getInstalledPluginsDir()).thenReturn(new File("src/test/plugins/sonar-test-plugin/target"));


+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/httpd/CeHttpServerTest.java View File

@@ -68,7 +68,7 @@ public class CeHttpServerTest {
}

@Test
public void start_publishes_URL_in_IPC() throws Exception {
public void start_publishes_URL_in_IPC() {
try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(this.sharedDir, 1)) {
assertThat(commands.getHttpUrl()).startsWith("http://127.0.0.1:");
}

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java View File

@@ -45,7 +45,7 @@ public class CEQueueStatusImplConcurrentTest {
private CEQueueStatusImpl underTest = new CEQueueStatusImpl(mock(DbClient.class));

@After
public void tearDown() throws Exception {
public void tearDown() {
executorService.shutdownNow();
}


+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java View File

@@ -77,7 +77,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerTest {
notificationService, dbClient, serializer, system2);

@Before
public void setUp() throws Exception {
public void setUp() {

}


+ 2
- 2
server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueCleanerTest.java View File

@@ -83,7 +83,7 @@ public class CeQueueCleanerTest {
assertThat(dataDao.selectData(dbTester.getSession(), "TASK_2")).isNotPresent();
}

private CeQueueDto insertInQueue(String taskUuid, CeQueueDto.Status status) throws IOException {
private CeQueueDto insertInQueue(String taskUuid, CeQueueDto.Status status) {
CeQueueDto dto = new CeQueueDto();
dto.setTaskType(CeTaskTypes.REPORT);
dto.setComponentUuid("PROJECT_1");
@@ -94,7 +94,7 @@ public class CeQueueCleanerTest {
return dto;
}

private void insertTaskData(String taskUuid) throws IOException {
private void insertTaskData(String taskUuid) {
dbTester.getDbClient().ceTaskInputDao().insert(dbTester.getSession(), taskUuid, IOUtils.toInputStream("{binary}"));
dbTester.getSession().commit();
}

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueInitializerTest.java View File

@@ -39,7 +39,7 @@ public class CeQueueInitializerTest {
private CeQueueInitializer underTest = new CeQueueInitializer(processingScheduler, cleaningScheduler, mock(CeDistributedInformation.class));

@Test
public void clean_queue_then_start_scheduler_of_workers() throws IOException {
public void clean_queue_then_start_scheduler_of_workers() {
underTest.onServerStart(server);

verify(processingScheduler).startScheduling();

+ 8
- 8
server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java View File

@@ -79,7 +79,7 @@ public class InternalCeQueueImplTest {
private InternalCeQueue underTest = new InternalCeQueueImpl(system2, db.getDbClient(), uuidFactory, queueStatus, defaultOrganizationProvider, computeEngineStatus);

@Before
public void setUp() throws Exception {
public void setUp() {
OrganizationDto defaultOrganization = db.getDefaultOrganization();
when(defaultOrganizationProvider.get()).thenReturn(DefaultOrganization.newBuilder()
.setUuid(defaultOrganization.getUuid())
@@ -289,7 +289,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void fail_to_remove_if_not_in_queue() throws Exception {
public void fail_to_remove_if_not_in_queue() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
underTest.remove(task, CeActivityDto.Status.SUCCESS, null, null);

@@ -299,7 +299,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void test_peek() throws Exception {
public void test_peek() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");

Optional<CeTask> peek = underTest.peek(WORKER_UUID_1);
@@ -329,7 +329,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void peek_nothing_if_application_status_stopping() throws Exception {
public void peek_nothing_if_application_status_stopping() {
submit(CeTaskTypes.REPORT, "PROJECT_1");
when(computeEngineStatus.getStatus()).thenReturn(STOPPING);

@@ -492,7 +492,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void cancel_pending() throws Exception {
public void cancel_pending() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
CeQueueDto queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();

@@ -521,7 +521,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void fail_to_cancel_if_in_progress() throws Exception {
public void fail_to_cancel_if_in_progress() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
underTest.peek(WORKER_UUID_2);
CeQueueDto queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();
@@ -533,7 +533,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void cancelAll_pendings_but_not_in_progress() throws Exception {
public void cancelAll_pendings_but_not_in_progress() {
CeTask inProgressTask = submit(CeTaskTypes.REPORT, "PROJECT_1");
CeTask pendingTask1 = submit(CeTaskTypes.REPORT, "PROJECT_2");
CeTask pendingTask2 = submit(CeTaskTypes.REPORT, "PROJECT_3");
@@ -698,7 +698,7 @@ public class InternalCeQueueImplTest {
}

@Test
public void pause_and_resume_submits() throws Exception {
public void pause_and_resume_submits() {
assertThat(underTest.isSubmitPaused()).isFalse();
underTest.pauseSubmit();
assertThat(underTest.isSubmitPaused()).isTrue();

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/queue/PurgeCeActivitiesTest.java View File

@@ -41,7 +41,7 @@ public class PurgeCeActivitiesTest {
private PurgeCeActivities underTest = new PurgeCeActivities(dbTester.getDbClient(), system2);

@Test
public void delete_older_than_6_months() throws Exception {
public void delete_older_than_6_months() {
insertWithDate("VERY_OLD", 1_000_000_000_000L);
insertWithDate("RECENT", 1_500_000_000_000L);
when(system2.now()).thenReturn(1_500_000_000_100L);

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/systeminfo/SystemInfoHttpActionTest.java View File

@@ -49,7 +49,7 @@ public class SystemInfoHttpActionTest {
private SystemInfoHttpAction underTest;

@Before
public void setUp() throws Exception {
public void setUp() {
underTest = new SystemInfoHttpAction(Arrays.asList(stateProvider1, stateProvider2));
}


+ 9
- 9
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java View File

@@ -391,7 +391,7 @@ public class CeProcessingSchedulerImplTest {
public ScheduledFuture<?> schedule(final Runnable command, long delay, TimeUnit unit) {
ScheduledFuture<Void> res = new AbstractPartiallyImplementedScheduledFuture<Void>() {
@Override
public Void get() throws InterruptedException, ExecutionException {
public Void get() {
command.run();
return null;
}
@@ -405,7 +405,7 @@ public class CeProcessingSchedulerImplTest {
ScheduledFuture<V> res = new AbstractPartiallyImplementedScheduledFuture<V>() {

@Override
public V get() throws InterruptedException, ExecutionException {
public V get() throws ExecutionException {
try {
return callable.call();
} catch (Exception e) {
@@ -422,7 +422,7 @@ public class CeProcessingSchedulerImplTest {
Future<T> res = new AbstractPartiallyImplementedFuture<T>() {

@Override
public T get() throws InterruptedException, ExecutionException {
public T get() throws ExecutionException {
try {
return task.call();
} catch (Exception e) {
@@ -473,7 +473,7 @@ public class CeProcessingSchedulerImplTest {
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
public boolean awaitTermination(long timeout, TimeUnit unit) {
throw new UnsupportedOperationException("awaitTermination(long timeout, TimeUnit unit) not implemented");
}

@@ -488,22 +488,22 @@ public class CeProcessingSchedulerImplTest {
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) {
throw new UnsupportedOperationException("invokeAll(Collection<? extends Callable<T>> tasks) not implemented");
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
throw new UnsupportedOperationException("invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) not implemented");
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) {
throw new UnsupportedOperationException("invokeAny(Collection<? extends Callable<T>> tasks) not implemented");
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) {
throw new UnsupportedOperationException("invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) not implemented");
}
}
@@ -542,7 +542,7 @@ public class CeProcessingSchedulerImplTest {
}

@Override
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public T get(long timeout, TimeUnit unit) {
throw new UnsupportedOperationException("get(long timeout, TimeUnit unit) not implemented");
}
}

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java View File

@@ -77,7 +77,7 @@ public class CeWorkerImplTest {
private InOrder inOrder = Mockito.inOrder(taskProcessor, queue, executionListener1, executionListener2);

@Before
public void setUp() throws Exception {
public void setUp() {
when(enabledCeWorkerController.isEnabled(any(CeWorker.class))).thenReturn(true);
}


+ 1
- 2
server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfiledDataSource.java View File

@@ -22,7 +22,6 @@ package org.sonar.db.profiling;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Collection;
import org.apache.commons.dbcp.BasicDataSource;
import org.sonar.api.utils.log.Logger;
@@ -334,7 +333,7 @@ public class ProfiledDataSource extends BasicDataSource {
}

@Override
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
public java.util.logging.Logger getParentLogger() {
return java.util.logging.Logger.getLogger(getClass().getName());
}


+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/CoreDbTester.java View File

@@ -47,7 +47,7 @@ public class CoreDbTester extends AbstractDbTester<CoreTestDb> {
}

@Override
protected void before() throws Throwable {
protected void before() {
db.start();
db.truncateTables();
}

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/DatabaseCommands.java View File

@@ -126,7 +126,7 @@ public abstract class DatabaseCommands {
}

@Override
protected boolean shouldTruncate(Connection connection, String table) throws SQLException {
protected boolean shouldTruncate(Connection connection, String table) {
// truncate all tables on mssql, else unexpected errors in some tests
return true;
}

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/DdlUtilsTest.java View File

@@ -47,7 +47,7 @@ public class DdlUtilsTest {
@Test
public void shouldCreateSchema_with_schema_migrations() throws SQLException {
DriverManager.registerDriver(new Driver());
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:sonar_test");) {
try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:sonar_test")) {
DdlUtils.createSchema(connection, "h2", true);

int tableCount = countTables(connection);

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java View File

@@ -47,7 +47,7 @@ public class H2Test {
}

@Test
public void testFetchSizeForScrolling() throws Exception {
public void testFetchSizeForScrolling() {
assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200);
}


+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java View File

@@ -49,7 +49,7 @@ public class MsSqlTest {
}

@Test
public void do_not_support_jtds_since_5_2() throws Exception {
public void do_not_support_jtds_since_5_2() {
assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isFalse();

}

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java View File

@@ -50,7 +50,7 @@ public class MySqlTest {
}

@Test
public void testFetchSizeForScrolling() throws Exception {
public void testFetchSizeForScrolling() {
assertThat(mySql.getScrollDefaultFetchSize()).isEqualTo(Integer.MIN_VALUE);
assertThat(mySql.getScrollSingleRowFetchSize()).isEqualTo(Integer.MIN_VALUE);
}

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java View File

@@ -47,7 +47,7 @@ public class OracleTest {
}

@Test
public void testFetchSizeForScrolling() throws Exception {
public void testFetchSizeForScrolling() {
assertThat(underTest.getScrollDefaultFetchSize()).isEqualTo(200);
assertThat(underTest.getScrollSingleRowFetchSize()).isEqualTo(1);
}

+ 1
- 1
server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java View File

@@ -52,7 +52,7 @@ public class PostgreSqlTest {
}

@Test
public void testFetchSizeForScrolling() throws Exception {
public void testFetchSizeForScrolling() {
assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200);
}


+ 1
- 1
server/sonar-db-dao/src/main/java/org/sonar/db/ce/LogsIteratorInputStream.java View File

@@ -48,7 +48,7 @@ final class LogsIteratorInputStream extends InputStream {
}

@Override
public int read() throws IOException {
public int read() {
if (nextChar == UNSET || nextChar >= buf.length) {
fill();
if (nextChar == UNSET) {

+ 4
- 8
server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java View File

@@ -97,13 +97,9 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
}

public static ProjectMeasuresIndexerIterator create(DbSession session, @Nullable String projectUuid) {
try {
List<Project> projects = selectProjects(session, projectUuid);
PreparedStatement projectsStatement = createMeasuresStatement(session);
return new ProjectMeasuresIndexerIterator(projectsStatement, projects);
} catch (SQLException e) {
throw new IllegalStateException("Fail to execute request to select all project measures", e);
}
List<Project> projects = selectProjects(session, projectUuid);
PreparedStatement projectsStatement = createMeasuresStatement(session);
return new ProjectMeasuresIndexerIterator(projectsStatement, projects);
}

private static List<Project> selectProjects(DbSession session, @Nullable String projectUuid) {
@@ -146,7 +142,7 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
}
}

private static PreparedStatement createMeasuresStatement(DbSession session) throws SQLException {
private static PreparedStatement createMeasuresStatement(DbSession session) {
try {
String metricNameQuestionMarks = METRIC_KEYS.stream().map(x -> "?").collect(Collectors.joining(","));
String sql = StringUtils.replace(SQL_MEASURES, "{metricNames}", metricNameQuestionMarks);

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java View File

@@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ProjectPermissionsTest {

@Test
public void all_permissions() throws Exception {
public void all_permissions() {
assertThat(ProjectPermissions.ALL).containsExactly(UserRole.ADMIN, UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN, GlobalPermissions.SCAN_EXECUTION, UserRole.USER);
}

@Test
public void all_permissions_as_string() throws Exception {
public void all_permissions_as_string() {
assertThat(ProjectPermissions.ALL_ON_ONE_LINE).isEqualTo("admin, codeviewer, issueadmin, scan, user");
}
}

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java View File

@@ -62,7 +62,7 @@ public class DBSessionsImplTest {
private final DBSessionsImpl underTest = new DBSessionsImpl(myBatis);

@After
public void tearDown() throws Exception {
public void tearDown() {
underTest.disableCaching();
}


+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/DbTester.java View File

@@ -319,7 +319,7 @@ public class DbTester extends AbstractDbTester<TestDb> {
}

@Override
public Connection get() throws SQLException {
public Connection get() {
return dbSession.getConnection();
}


+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/MyBatisTest.java View File

@@ -47,7 +47,7 @@ public class MyBatisTest {
private MyBatis underTest = new MyBatis(database);

@After
public void tearDown() throws Exception {
public void tearDown() {
underTest.stop();
}


+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java View File

@@ -158,7 +158,7 @@ public class CeActivityDaoTest {
insert("TASK_4", "views", null, CeActivityDto.Status.SUCCESS);

// no filters
CeTaskQuery query = new CeTaskQuery().setStatuses(Collections.<String>emptyList());
CeTaskQuery query = new CeTaskQuery().setStatuses(Collections.emptyList());
List<CeActivityDto> dtos = underTest.selectByQuery(db.getSession(), query, forPage(1).andSize(10));
assertThat(dtos).extracting("uuid").containsExactly("TASK_4", "TASK_3", "TASK_2", "TASK_1");


+ 5
- 5
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java View File

@@ -201,7 +201,7 @@ public class CeQueueDaoTest {
}

@Test
public void test_resetAllToPendingStatus() throws Exception {
public void test_resetAllToPendingStatus() {
insert(TASK_UUID_1, COMPONENT_UUID_1, PENDING);
insert(TASK_UUID_2, COMPONENT_UUID_1, IN_PROGRESS);
insert(TASK_UUID_3, COMPONENT_UUID_1, IN_PROGRESS);
@@ -361,7 +361,7 @@ public class CeQueueDaoTest {
}

@Test
public void peek_none_if_no_pendings() throws Exception {
public void peek_none_if_no_pendings() {
assertThat(underTest.peek(db.getSession(), WORKER_UUID_1, MAX_EXECUTION_COUNT).isPresent()).isFalse();

// not pending, but in progress
@@ -370,7 +370,7 @@ public class CeQueueDaoTest {
}

@Test
public void peek_oldest_pending() throws Exception {
public void peek_oldest_pending() {
insert(TASK_UUID_1, COMPONENT_UUID_1, PENDING);
system2.setNow(INIT_TIME + 3_000_000);
insert(TASK_UUID_2, COMPONENT_UUID_2, PENDING);
@@ -401,7 +401,7 @@ public class CeQueueDaoTest {
}

@Test
public void do_not_peek_multiple_tasks_on_same_project_at_the_same_time() throws Exception {
public void do_not_peek_multiple_tasks_on_same_project_at_the_same_time() {
// two pending tasks on the same project
insert(TASK_UUID_1, COMPONENT_UUID_1, PENDING);
system2.setNow(INIT_TIME + 3_000_000);
@@ -563,7 +563,7 @@ public class CeQueueDaoTest {
.setTaskType(CeTaskTypes.REPORT)
.setCreatedAt(100_000L));

CeTaskQuery query = new CeTaskQuery().setComponentUuids(Collections.<String>emptyList());
CeTaskQuery query = new CeTaskQuery().setComponentUuids(Collections.emptyList());

List<CeQueueDto> result = underTest.selectByQueryInDescOrder(db.getSession(), query, 1_000);
int total = underTest.countByQuery(db.getSession(), query);

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java View File

@@ -66,7 +66,7 @@ public class CeTaskInputDaoTest {
}

@Test
public void fail_to_insert_invalid_row() throws Exception {
public void fail_to_insert_invalid_row() {
expectedException.expectMessage("Fail to insert data of CE task null");
underTest.insert(dbTester.getSession(), null, IOUtils.toInputStream(SOME_DATA));
}

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskQueryTest.java View File

@@ -57,7 +57,7 @@ public class CeTaskQueryTest {
*/
@Test
public void short_circuited_if_empty_component_uuid_filter() {
underTest.setComponentUuids(Collections.<String>emptyList());
underTest.setComponentUuids(Collections.emptyList());
assertThat(underTest.getComponentUuids()).isEmpty();
assertThat(underTest.isShortCircuitedByComponentUuids()).isTrue();
}

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java View File

@@ -56,7 +56,7 @@ public class LogsIteratorInputStreamTest {
}

@Test
public void constructor_throws_IAE_when_ClosableIterator_is_empty() throws IOException {
public void constructor_throws_IAE_when_ClosableIterator_is_empty() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("LogsIterator can't be empty or already read");

@@ -64,7 +64,7 @@ public class LogsIteratorInputStreamTest {
}

@Test
public void constructor_throws_IAE_when_ClosableIterator_has_already_been_read() throws IOException {
public void constructor_throws_IAE_when_ClosableIterator_has_already_been_read() {
CloseableIterator<String> iterator = CloseableIterator.from(Arrays.asList("line1").iterator());

// read iterator to the end

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java View File

@@ -375,7 +375,7 @@ public class ComponentDaoTest {
}

@Test
public void fail_with_IAE_select_component_keys_by_qualifiers_on_empty_qualifier() throws Exception {
public void fail_with_IAE_select_component_keys_by_qualifiers_on_empty_qualifier() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Qualifiers cannot be empty");

@@ -987,7 +987,7 @@ public class ComponentDaoTest {
}

@Test
public void delete() throws Exception {
public void delete() {
ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setDbKey("PROJECT_1"));
db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setDbKey("PROJECT_2"));


+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentLinkDtoTest.java View File

@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ComponentLinkDtoTest {

@Test
public void test_getters_and_setters() throws Exception {
public void test_getters_and_setters() {
ComponentLinkDto dto = new ComponentLinkDto()
.setId(1L)
.setComponentUuid("ABCD")
@@ -42,7 +42,7 @@ public class ComponentLinkDtoTest {
}

@Test
public void test_provided_types() throws Exception {
public void test_provided_types() {
assertThat(ComponentLinkDto.PROVIDED_TYPES).hasSize(5);
}
}

+ 3
- 3
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentQueryTest.java View File

@@ -35,7 +35,7 @@ public class ComponentQueryTest {
public ExpectedException expectedException = ExpectedException.none();

@Test
public void build_query() throws Exception {
public void build_query() {
ComponentQuery underTest = ComponentQuery.builder()
.setNameOrKeyQuery("key")
.setLanguage("java")
@@ -53,7 +53,7 @@ public class ComponentQueryTest {
}

@Test
public void build_query_minimal_properties() throws Exception {
public void build_query_minimal_properties() {
ComponentQuery underTest = ComponentQuery.builder()
.setQualifiers(PROJECT)
.build();
@@ -64,7 +64,7 @@ public class ComponentQueryTest {
}

@Test
public void test_getNameOrKeyUpperLikeQuery() throws Exception {
public void test_getNameOrKeyUpperLikeQuery() {
ComponentQuery underTest = ComponentQuery.builder()
.setNameOrKeyQuery("NAME/key")
.setQualifiers(PROJECT)

+ 5
- 5
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java View File

@@ -38,7 +38,7 @@ public class ComponentTreeQueryTest {
public ExpectedException expectedException = ExpectedException.none();

@Test
public void create_query() throws Exception {
public void create_query() {
ComponentTreeQuery query = ComponentTreeQuery.builder()
.setBaseUuid(BASE_UUID)
.setStrategy(CHILDREN)
@@ -54,7 +54,7 @@ public class ComponentTreeQueryTest {
}

@Test
public void create_minimal_query() throws Exception {
public void create_minimal_query() {
ComponentTreeQuery query = ComponentTreeQuery.builder()
.setBaseUuid(BASE_UUID)
.setStrategy(CHILDREN)
@@ -68,7 +68,7 @@ public class ComponentTreeQueryTest {
}

@Test
public void test_getUuidPath() throws Exception {
public void test_getUuidPath() {
assertThat(ComponentTreeQuery.builder().setBaseUuid(BASE_UUID).setStrategy(CHILDREN)
.build().getUuidPath(newPrivateProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");

@@ -77,7 +77,7 @@ public class ComponentTreeQueryTest {
}

@Test
public void fail_when_no_base_uuid() throws Exception {
public void fail_when_no_base_uuid() {
expectedException.expect(NullPointerException.class);
ComponentTreeQuery.builder()
.setStrategy(CHILDREN)
@@ -85,7 +85,7 @@ public class ComponentTreeQueryTest {
}

@Test
public void fail_when_no_strategy() throws Exception {
public void fail_when_no_strategy() {
expectedException.expect(NullPointerException.class);
ComponentTreeQuery.builder()
.setBaseUuid(BASE_UUID)

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java View File

@@ -190,7 +190,7 @@ public class SnapshotDaoTest {
}

@Test
public void select_first_snapshots() throws Exception {
public void select_first_snapshots() {
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization());
db.getDbClient().componentDao().insert(dbSession, project);


+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java View File

@@ -33,7 +33,7 @@ public class SnapshotDtoTest {
public ExpectedException expectedException = ExpectedException.none();

@Test
public void test_getter_and_setter() throws Exception {
public void test_getter_and_setter() {
SnapshotDto snapshotDto = new SnapshotDto()
.setId(10L)
.setBuildDate(parseDate("2014-07-02").getTime())
@@ -55,7 +55,7 @@ public class SnapshotDtoTest {
}

@Test
public void fail_if_version_name_is_longer_then_100_characters() throws Exception {
public void fail_if_version_name_is_longer_then_100_characters() {
SnapshotDto snapshotDto = new SnapshotDto();
snapshotDto.setVersion(null);
snapshotDto.setVersion("1.0");

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java View File

@@ -28,7 +28,7 @@ import static org.sonar.db.component.SnapshotQuery.SORT_ORDER.ASC;
public class SnapshotQueryTest {

@Test
public void test_setters_and_getters() throws Exception {
public void test_setters_and_getters() {
SnapshotQuery query = new SnapshotQuery()
.setComponentUuid("abcd")
.setIsLast(true)

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/event/EventDtoTest.java View File

@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class EventDtoTest {

@Test
public void test_getters_and_setters() throws Exception {
public void test_getters_and_setters() {
EventDto dto = new EventDto()
.setId(1L)
.setAnalysisUuid("uuid_1")

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/favorite/FavoriteDbTester.java View File

@@ -50,7 +50,7 @@ public class FavoriteDbTester {
List<PropertyDto> result = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
.setKey(PROP_FAVORITE_KEY)
.setComponentId(componentDto.getId())
.setUserId((int) userId)
.setUserId(userId)
.build(), dbSession);

return !result.isEmpty();

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java View File

@@ -136,7 +136,7 @@ public class IssueDtoTest {
assertThat(dto.getTags()).containsOnly("tag1", "tag2", "tag3");
assertThat(dto.getTagsString()).isEqualTo("tag1,tag2,tag3");

dto.setTags(Arrays.<String>asList());
dto.setTags(Arrays.asList());
assertThat(dto.getTags()).isEmpty();

dto.setTagsString("tag1, tag2 ,,tag3");

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java View File

@@ -29,7 +29,7 @@ public class MeasureDtoTest {
MeasureDto underTest = new MeasureDto();

@Test
public void test_getter_and_setter() throws Exception {
public void test_getter_and_setter() {
underTest
.setValue(2d)
.setData("text value")

+ 7
- 7
server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java View File

@@ -37,7 +37,7 @@ public class MeasureTreeQueryTest {
public ExpectedException expectedException = ExpectedException.none();

@Test
public void create_query() throws Exception {
public void create_query() {
MeasureTreeQuery query = MeasureTreeQuery.builder()
.setStrategy(CHILDREN)
.setQualifiers(asList("FIL", "DIR"))
@@ -52,7 +52,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void create_minimal_query() throws Exception {
public void create_minimal_query() {
MeasureTreeQuery query = MeasureTreeQuery.builder()
.setStrategy(CHILDREN)
.build();
@@ -64,7 +64,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void test_getNameOrKeyUpperLikeQuery() throws Exception {
public void test_getNameOrKeyUpperLikeQuery() {
assertThat(MeasureTreeQuery.builder()
.setNameOrKeyQuery("like-\\_%/-value")
.setStrategy(CHILDREN)
@@ -76,7 +76,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void test_getUuidPath() throws Exception {
public void test_getUuidPath() {
assertThat(MeasureTreeQuery.builder().setStrategy(CHILDREN)
.build().getUuidPath(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID.");

@@ -85,7 +85,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void return_empty_when_metrics_is_empty() throws Exception {
public void return_empty_when_metrics_is_empty() {
assertThat(MeasureTreeQuery.builder()
.setStrategy(CHILDREN)
.setMetricIds(Collections.emptyList())
@@ -98,7 +98,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void return_empty_when_qualifiers_is_empty() throws Exception {
public void return_empty_when_qualifiers_is_empty() {
assertThat(MeasureTreeQuery.builder()
.setStrategy(CHILDREN)
.setQualifiers(Collections.emptyList())
@@ -111,7 +111,7 @@ public class MeasureTreeQueryTest {
}

@Test
public void fail_when_no_strategy() throws Exception {
public void fail_when_no_strategy() {
expectedException.expect(NullPointerException.class);
MeasureTreeQuery.builder()
.build();

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java View File

@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PastMeasureDtoTest {

@Test
public void test_getter_and_setter() throws Exception {
public void test_getter_and_setter() {
PastMeasureDto dto = new PastMeasureDto()
.setValue(1d)
.setMetricId(2);
@@ -37,7 +37,7 @@ public class PastMeasureDtoTest {
}

@Test
public void test_has_value() throws Exception {
public void test_has_value() {
PastMeasureDto measureWithValue = new PastMeasureDto()
.setValue(1d)
.setMetricId(2);

+ 12
- 12
server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java View File

@@ -83,7 +83,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_project_measure_having_leak() throws Exception {
public void return_project_measure_having_leak() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization, p -> p.setDbKey("Project-Key").setName("Project Name").setTagsString("platform,java"));
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("new_lines"));
@@ -95,7 +95,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_quality_gate_status_measure() throws Exception {
public void return_quality_gate_status_measure() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project1 = dbTester.components().insertPrivateProject(organization);
ComponentDto project2 = dbTester.components().insertPrivateProject(organization);
@@ -113,7 +113,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void does_not_fail_when_quality_gate_has_no_value() throws Exception {
public void does_not_fail_when_quality_gate_has_no_value() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(LEVEL.name()).setKey("alert_status"));
@@ -125,7 +125,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_language_distribution_measure() throws Exception {
public void return_language_distribution_measure() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(DATA.name()).setKey("ncloc_language_distribution"));
@@ -138,7 +138,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void does_not_return_none_numeric_metrics() throws Exception {
public void does_not_return_none_numeric_metrics() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
MetricDto dataMetric = dbTester.measures().insertMetric(m -> m.setValueType(DATA.name()).setKey("data"));
@@ -154,7 +154,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void does_not_return_disabled_metrics() throws Exception {
public void does_not_return_disabled_metrics() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
MetricDto disabledMetric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setEnabled(false).setHidden(false).setKey("disabled"));
@@ -166,7 +166,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void ignore_measure_that_does_not_have_value() throws Exception {
public void ignore_measure_that_does_not_have_value() {
OrganizationDto organization = dbTester.organizations().insert();
MetricDto metric1 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("coverage"));
MetricDto metric2 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
@@ -182,7 +182,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void ignore_numeric_measure_that_has_text_value_but_not_numeric_value() throws Exception {
public void ignore_numeric_measure_that_has_text_value_but_not_numeric_value() {
OrganizationDto organization = dbTester.organizations().insert();
MetricDto metric1 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("coverage"));
MetricDto metric2 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
@@ -208,7 +208,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_project_without_analysis() throws Exception {
public void return_project_without_analysis() {
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setLast(false));
dbSession.commit();
@@ -221,7 +221,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void does_not_return_non_active_projects() throws Exception {
public void does_not_return_non_active_projects() {
OrganizationDto organization = dbTester.organizations().insert();
// Disabled project
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false));
@@ -238,7 +238,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_only_docs_from_given_project() throws Exception {
public void return_only_docs_from_given_project() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project1 = dbTester.components().insertPrivateProject(organization);
ComponentDto project2 = dbTester.components().insertPrivateProject(organization);
@@ -259,7 +259,7 @@ public class ProjectMeasuresIndexerIteratorTest {
}

@Test
public void return_nothing_on_unknown_project() throws Exception {
public void return_nothing_on_unknown_project() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
dbTester.components().insertSnapshot(project);

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java View File

@@ -154,7 +154,7 @@ public class CustomMeasureDaoTest {
}

@Test
public void select_by_metric_key_and_text_value() throws Exception {
public void select_by_metric_key_and_text_value() {
db.prepareDbUnit(getClass(), "select_by_metric_key_and_text_value.xml");

List<CustomMeasureDto> result = underTest.selectByMetricKeyAndTextValue(session, "customKey", "value1");

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java View File

@@ -72,7 +72,7 @@ public class MetricDtoTest {
}

@Test
public void is_data_type() throws Exception {
public void is_data_type() {
assertThat(MetricTesting.newMetricDto().setValueType(INT.name()).isDataType()).isFalse();

assertThat(MetricTesting.newMetricDto().setValueType(DATA.name()).isDataType()).isTrue();

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java View File

@@ -447,7 +447,7 @@ public class GroupPermissionDaoTest {
}

@Test
public void selectAllPermissionsByGroupId_on_public_project() throws Exception {
public void selectAllPermissionsByGroupId_on_public_project() {
OrganizationDto org1 = db.organizations().insert();
GroupDto group1 = db.users().insertGroup(org1, "group1");
ComponentDto project1 = db.components().insertPublicProject(org1);
@@ -467,7 +467,7 @@ public class GroupPermissionDaoTest {
}

@Test
public void selectAllPermissionsByGroupId_on_private_project() throws Exception {
public void selectAllPermissionsByGroupId_on_private_project() {
OrganizationDto org1 = db.organizations().insert();
GroupDto group1 = db.users().insertGroup(org1, "group1");
ComponentDto project1 = db.components().insertPrivateProject(org1);

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java View File

@@ -180,7 +180,7 @@ public class PermissionTemplateCharacteristicDaoTest {
}

@Test
public void delete_by_permission_template_id() throws Exception {
public void delete_by_permission_template_id() {
underTest.insert(dbSession, new PermissionTemplateCharacteristicDto()
.setPermission(UserRole.USER)
.setTemplateId(1L)

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java View File

@@ -71,7 +71,7 @@ public class PermissionTemplateDaoTest {
}

@Test
public void should_create_permission_template() throws ParseException {
public void should_create_permission_template() {
PermissionTemplateDto permissionTemplate = underTest.insert(db.getSession(), newPermissionTemplateDto()
.setUuid("ABCD")
.setName("my template")

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest.java View File

@@ -115,7 +115,7 @@ public class UserWithPermissionTemplateDaoTest {
}

@Test
public void count_users() throws Exception {
public void count_users() {
dbTester.prepareDbUnit(getClass(), "users_with_permissions.xml");

assertThat(underTest.countUserLoginsByQueryAndTemplate(dbSession, newQuery().build(), TEMPLATE_ID)).isEqualTo(3);
@@ -123,7 +123,7 @@ public class UserWithPermissionTemplateDaoTest {
}

@Test
public void select_user_permission_templates_by_template_and_logins() throws Exception {
public void select_user_permission_templates_by_template_and_logins() {
dbTester.prepareDbUnit(getClass(), "users_with_permissions.xml");

assertThat(underTest.selectUserPermissionsByTemplateIdAndUserLogins(dbSession, 50L, singletonList("user1")))

+ 4
- 4
server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java View File

@@ -375,7 +375,7 @@ public class PropertiesDaoTest {
}

@Test
public void select_component_properties_by_ids() throws Exception {
public void select_component_properties_by_ids() {
ComponentDto project = dbTester.components().insertPrivateProject();
ComponentDto project2 = dbTester.components().insertPrivateProject();

@@ -403,7 +403,7 @@ public class PropertiesDaoTest {
}

@Test
public void select_properties_by_keys_and_component_ids() throws Exception {
public void select_properties_by_keys_and_component_ids() {
ComponentDto project = dbTester.components().insertPrivateProject();
ComponentDto project2 = dbTester.components().insertPrivateProject();

@@ -1008,10 +1008,10 @@ public class PropertiesDaoTest {
return insertProperty(key, value, resourceId, userId);
}

private long insertProperty(String key, @Nullable String value, @Nullable Long resourceId, @Nullable Integer userId) throws SQLException {
private long insertProperty(String key, @Nullable String value, @Nullable Long resourceId, @Nullable Integer userId) {
PropertyDto dto = new PropertyDto().setKey(key)
.setResourceId(resourceId)
.setUserId(userId == null ? null : userId)
.setUserId(userId)
.setValue(value);
dbTester.properties().insertProperty(dto);


+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeMapperTest.java View File

@@ -47,7 +47,7 @@ public class PurgeMapperTest {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
if (dbSession != null) {
dbSession.close();
}

+ 2
- 2
server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java View File

@@ -40,7 +40,7 @@ public class KeepOneFilterTest {
public void shouldOnlyOneSnapshotPerInterval() {
Filter filter = new KeepOneFilter(DateUtils.parseDate("2011-03-25"), DateUtils.parseDate("2011-08-25"), Calendar.MONTH, "month");

List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.<PurgeableAnalysisDto>asList(
List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.asList(
DbCleanerTestUtils.createAnalysisWithDate("u1", "2010-01-01"), // out of scope -> keep
DbCleanerTestUtils.createAnalysisWithDate("u2", "2011-05-01"), // may -> keep
DbCleanerTestUtils.createAnalysisWithDate("u3", "2011-05-02"), // may -> to be deleted
@@ -58,7 +58,7 @@ public class KeepOneFilterTest {
public void shouldKeepNonDeletableSnapshots() {
Filter filter = new KeepOneFilter(DateUtils.parseDate("2011-03-25"), DateUtils.parseDate("2011-08-25"), Calendar.MONTH, "month");

List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.<PurgeableAnalysisDto>asList(
List<PurgeableAnalysisDto> toDelete = filter.filter(Arrays.asList(
DbCleanerTestUtils.createAnalysisWithDate("u1", "2011-05-01"), // to be deleted
DbCleanerTestUtils.createAnalysisWithDate("u2", "2011-05-02").setLast(true),
DbCleanerTestUtils.createAnalysisWithDate("u3", "2011-05-19").setHasEvents(true).setLast(false),

+ 5
- 5
server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateConditionDaoTest.java View File

@@ -40,7 +40,7 @@ public class QualityGateConditionDaoTest {
private QualityGateConditionDao underTest = dbTester.getDbClient().gateConditionDao();

@Test
public void testInsert() throws Exception {
public void testInsert() {
dbTester.prepareDbUnit(getClass(), "insert.xml");
QualityGateConditionDto newCondition = new QualityGateConditionDto()
.setQualityGateId(1L).setMetricId(2L).setOperator("GT").setWarningThreshold("10").setErrorThreshold("20").setPeriod(3);
@@ -53,14 +53,14 @@ public class QualityGateConditionDaoTest {
}

@Test
public void testSelectForQualityGate() throws Exception {
public void testSelectForQualityGate() {
dbTester.prepareDbUnit(getClass(), "selectForQualityGate.xml");
assertThat(underTest.selectForQualityGate(dbSession, 1L)).hasSize(3);
assertThat(underTest.selectForQualityGate(dbSession, 2L)).hasSize(2);
}

@Test
public void testSelectById() throws Exception {
public void testSelectById() {
dbTester.prepareDbUnit(getClass(), "selectForQualityGate.xml");
QualityGateConditionDto selectById = underTest.selectById(1L, dbSession);
assertThat(selectById).isNotNull();
@@ -75,7 +75,7 @@ public class QualityGateConditionDaoTest {
}

@Test
public void testDelete() throws Exception {
public void testDelete() {
dbTester.prepareDbUnit(getClass(), "selectForQualityGate.xml");

underTest.delete(new QualityGateConditionDto().setId(1L), dbSession);
@@ -85,7 +85,7 @@ public class QualityGateConditionDaoTest {
}

@Test
public void testUpdate() throws Exception {
public void testUpdate() {
dbTester.prepareDbUnit(getClass(), "selectForQualityGate.xml");

underTest.update(new QualityGateConditionDto().setId(1L).setMetricId(7L).setOperator(">").setPeriod(1).setWarningThreshold("50").setErrorThreshold("80"), dbSession);

+ 4
- 4
server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateConditionDtoTest.java View File

@@ -43,7 +43,7 @@ public class QualityGateConditionDtoTest {
}

@Test
public void validate_operators_for_BOOL() throws Exception {
public void validate_operators_for_BOOL() {
assertThat(isOperatorAllowed("EQ", BOOL)).isTrue();
assertThat(isOperatorAllowed("NE", BOOL)).isFalse();
assertThat(isOperatorAllowed("LT", BOOL)).isFalse();
@@ -51,7 +51,7 @@ public class QualityGateConditionDtoTest {
}

@Test
public void validate_operators_for_LEVEL() throws Exception {
public void validate_operators_for_LEVEL() {
assertThat(isOperatorAllowed("EQ", LEVEL)).isTrue();
assertThat(isOperatorAllowed("NE", LEVEL)).isTrue();
assertThat(isOperatorAllowed("LT", LEVEL)).isFalse();
@@ -59,7 +59,7 @@ public class QualityGateConditionDtoTest {
}

@Test
public void validate_operators_for_RATING() throws Exception {
public void validate_operators_for_RATING() {
assertThat(isOperatorAllowed("EQ", RATING)).isFalse();
assertThat(isOperatorAllowed("NE", RATING)).isFalse();
assertThat(isOperatorAllowed("LT", RATING)).isFalse();
@@ -67,7 +67,7 @@ public class QualityGateConditionDtoTest {
}

@Test
public void validate_operators_for_other_types() throws Exception {
public void validate_operators_for_other_types() {
Arrays.stream(new ValueType[] {STRING, INT, FLOAT, PERCENT, MILLISEC}).forEach(type -> {
assertThat(isOperatorAllowed("EQ", type)).isTrue();
assertThat(isOperatorAllowed("NE", type)).isTrue();

+ 3
- 3
server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java View File

@@ -575,7 +575,7 @@ public class QualityProfileDaoTest {
}

@Test
public void select_selected_projects() throws Exception {
public void select_selected_projects() {
ComponentDto project1 = db.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project2 = db.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project3 = db.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
@@ -604,7 +604,7 @@ public class QualityProfileDaoTest {
}

@Test
public void select_deselected_projects() throws Exception {
public void select_deselected_projects() {
ComponentDto project1 = db.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project2 = db.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project3 = db.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));
@@ -632,7 +632,7 @@ public class QualityProfileDaoTest {
}

@Test
public void select_project_associations() throws Exception {
public void select_project_associations() {
ComponentDto project1 = db.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project2 = db.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid()));
ComponentDto project3 = db.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid()));

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java View File

@@ -310,7 +310,7 @@ public class RuleDaoTest {
}

@Test
public void insert() throws Exception {
public void insert() {
RuleDefinitionDto newRule = new RuleDefinitionDto()
.setRuleKey("NewRuleKey")
.setRepositoryKey("plugin")

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java View File

@@ -61,7 +61,7 @@ public class RuleDtoTest {

@Test
public void tags_are_optional() {
RuleDto dto = new RuleDto().setTags(Collections.<String>emptySet());
RuleDto dto = new RuleDto().setTags(Collections.emptySet());
assertThat(dto.getTags()).isEmpty();
}
}

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java View File

@@ -87,7 +87,7 @@ public class GroupMembershipDaoTest {
}

@Test
public void count_groups_only_from_given_organization() throws Exception {
public void count_groups_only_from_given_organization() {
OrganizationDto otherOrganization = db.organizations().insert();
GroupDto otherGroup = db.users().insertGroup(otherOrganization, "sonar-administrators-other_orga");
db.users().insertMember(group1, user1);

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipQueryTest.java View File

@@ -31,7 +31,7 @@ public class GroupMembershipQueryTest {
public ExpectedException expectedException = ExpectedException.none();

@Test
public void create_query() throws Exception {
public void create_query() {
GroupMembershipQuery underTest = GroupMembershipQuery.builder()
.groupSearch("sonar-users")
.membership(GroupMembershipQuery.IN)

+ 4
- 4
server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDtoTest.java View File

@@ -35,7 +35,7 @@ public class UserDtoTest {
@Test
public void encode_scm_accounts() {
assertThat(UserDto.encodeScmAccounts(null)).isNull();
assertThat(UserDto.encodeScmAccounts(Collections.<String>emptyList())).isNull();
assertThat(UserDto.encodeScmAccounts(Collections.emptyList())).isNull();
assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo"))).isEqualTo("\nfoo\n");
assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo", "bar"))).isEqualTo("\nfoo\nbar\n");
}
@@ -48,18 +48,18 @@ public class UserDtoTest {
}

@Test
public void encrypt_password() throws Exception {
public void encrypt_password() {
assertThat(UserDto.encryptPassword("PASSWORD", "0242b0b4c0a93ddfe09dd886de50bc25ba000b51")).isEqualTo("540e4fc4be4e047db995bc76d18374a5b5db08cc");
}

@Test
public void fail_to_encrypt_password_when_password_is_null() throws Exception {
public void fail_to_encrypt_password_when_password_is_null() {
expectedException.expect(NullPointerException.class);
UserDto.encryptPassword(null, "salt");
}

@Test
public void fail_to_encrypt_password_when_salt_is_null() throws Exception {
public void fail_to_encrypt_password_when_salt_is_null() {
expectedException.expect(NullPointerException.class);
UserDto.encryptPassword("password", null);
}

+ 1
- 1
server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java View File

@@ -88,7 +88,7 @@ public class UserGroupDaoTest {
}

@Test
public void delete_by_user() throws Exception {
public void delete_by_user() {
UserDto user1 = dbTester.users().insertUser();
UserDto user2 = dbTester.users().insertUser();
GroupDto group1 = dbTester.users().insertGroup();

+ 6
- 6
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/DatabaseCharsetCheckerTest.java View File

@@ -74,32 +74,32 @@ public class DatabaseCharsetCheckerTest {
}

@Test
public void does_nothing_if_h2() throws Exception {
public void does_nothing_if_h2() {
assertThat(underTest.getHandler(new H2())).isNull();
}

@Test
public void getHandler_returns_MysqlCharsetHandler_if_mysql() throws Exception {
public void getHandler_returns_MysqlCharsetHandler_if_mysql() {
assertThat(underTest.getHandler(new MySql())).isInstanceOf(MysqlCharsetHandler.class);
}

@Test
public void getHandler_returns_MssqlCharsetHandler_if_mssql() throws Exception {
public void getHandler_returns_MssqlCharsetHandler_if_mssql() {
assertThat(underTest.getHandler(new MsSql())).isInstanceOf(MssqlCharsetHandler.class);
}

@Test
public void getHandler_returns_OracleCharsetHandler_if_oracle() throws Exception {
public void getHandler_returns_OracleCharsetHandler_if_oracle() {
assertThat(underTest.getHandler(new Oracle())).isInstanceOf(OracleCharsetHandler.class);
}

@Test
public void getHandler_returns_PostgresCharsetHandler_if_postgres() throws Exception {
public void getHandler_returns_PostgresCharsetHandler_if_postgres() {
assertThat(underTest.getHandler(new PostgreSql())).isInstanceOf(PostgresCharsetHandler.class);
}

@Test
public void getHandler_throws_IAE_if_unsupported_db() throws Exception {
public void getHandler_throws_IAE_if_unsupported_db() {
Dialect unsupportedDialect = mock(Dialect.class);
when(unsupportedDialect.getId()).thenReturn("foo");


+ 5
- 5
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/BigIntegerColumnDefTest.java View File

@@ -36,7 +36,7 @@ public class BigIntegerColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_string_column_def() throws Exception {
public void build_string_column_def() {
BigIntegerColumnDef def = new BigIntegerColumnDef.Builder()
.setColumnName("issues")
.setIsNullable(true)
@@ -47,7 +47,7 @@ public class BigIntegerColumnDefTest {
}

@Test
public void build_string_column_def_with_default_values() throws Exception {
public void build_string_column_def_with_default_values() {
BigIntegerColumnDef def = new BigIntegerColumnDef.Builder()
.setColumnName("issues")
.build();
@@ -57,7 +57,7 @@ public class BigIntegerColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
BigIntegerColumnDef def = new BigIntegerColumnDef.Builder()
.setColumnName("issues")
.setIsNullable(true)
@@ -71,7 +71,7 @@ public class BigIntegerColumnDefTest {
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -80,7 +80,7 @@ public class BigIntegerColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");


+ 5
- 5
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/BooleanColumnDefTest.java View File

@@ -37,7 +37,7 @@ public class BooleanColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_column_def() throws Exception {
public void build_column_def() {
BooleanColumnDef def = new BooleanColumnDef.Builder()
.setColumnName("enabled")
.setIsNullable(false)
@@ -50,7 +50,7 @@ public class BooleanColumnDefTest {
}

@Test
public void build_column_def_with_only_required_attributes() throws Exception {
public void build_column_def_with_only_required_attributes() {
BooleanColumnDef def = new BooleanColumnDef.Builder()
.setColumnName("enabled")
.build();
@@ -61,7 +61,7 @@ public class BooleanColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
BooleanColumnDef def = new BooleanColumnDef.Builder()
.setColumnName("enabled")
.setIsNullable(true)
@@ -75,7 +75,7 @@ public class BooleanColumnDefTest {
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -83,7 +83,7 @@ public class BooleanColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");


+ 9
- 9
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/ClobColumnDefTest.java View File

@@ -40,14 +40,14 @@ public class ClobColumnDefTest {
.build();

@Test
public void build_string_column_def() throws Exception {
public void build_string_column_def() {
assertThat(underTest.getName()).isEqualTo("issues");
assertThat(underTest.isNullable()).isTrue();
assertThat(underTest.getDefaultValue()).isNull();
}

@Test
public void build_string_column_def_with_only_required_attributes() throws Exception {
public void build_string_column_def_with_only_required_attributes() {
ClobColumnDef def = new ClobColumnDef.Builder()
.setColumnName("issues")
.build();
@@ -58,32 +58,32 @@ public class ClobColumnDefTest {
}

@Test
public void generate_sql_type_on_mssql() throws Exception {
public void generate_sql_type_on_mssql() {
assertThat(underTest.generateSqlType(new MsSql())).isEqualTo("NVARCHAR (MAX)");
}

@Test
public void generate_sql_type_on_h2() throws Exception {
public void generate_sql_type_on_h2() {
assertThat(underTest.generateSqlType(new H2())).isEqualTo("CLOB(2147483647)");
}

@Test
public void generate_sql_type_on_mysql() throws Exception {
public void generate_sql_type_on_mysql() {
assertThat(underTest.generateSqlType(new MySql())).isEqualTo("LONGTEXT");
}

@Test
public void generate_sql_type_on_oracle() throws Exception {
public void generate_sql_type_on_oracle() {
assertThat(underTest.generateSqlType(new Oracle())).isEqualTo("CLOB");
}

@Test
public void generate_sql_type_on_postgre() throws Exception {
public void generate_sql_type_on_postgre() {
assertThat(underTest.generateSqlType(new PostgreSql())).isEqualTo("TEXT");
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -92,7 +92,7 @@ public class ClobColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");


+ 8
- 8
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/DecimalColumnDefTest.java View File

@@ -39,7 +39,7 @@ public class DecimalColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_string_column_def() throws Exception {
public void build_string_column_def() {
DecimalColumnDef def = new DecimalColumnDef.Builder()
.setColumnName("issues")
.setPrecision(30)
@@ -55,7 +55,7 @@ public class DecimalColumnDefTest {
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -64,7 +64,7 @@ public class DecimalColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -73,7 +73,7 @@ public class DecimalColumnDefTest {
}

@Test
public void default_precision_is_38() throws Exception {
public void default_precision_is_38() {
DecimalColumnDef def = new DecimalColumnDef.Builder()
.setColumnName("issues")
.setScale(20)
@@ -84,7 +84,7 @@ public class DecimalColumnDefTest {
}

@Test
public void default_precision_is_20() throws Exception {
public void default_precision_is_20() {
DecimalColumnDef def = new DecimalColumnDef.Builder()
.setColumnName("issues")
.setPrecision(30)
@@ -95,7 +95,7 @@ public class DecimalColumnDefTest {
}

@Test
public void create_builder_with_only_required_attributes() throws Exception {
public void create_builder_with_only_required_attributes() {
DecimalColumnDef def = new DecimalColumnDef.Builder()
.setColumnName("issues")
.build();
@@ -107,7 +107,7 @@ public class DecimalColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
DecimalColumnDef def = new DecimalColumnDef.Builder()
.setColumnName("issues")
.setPrecision(30)
@@ -123,7 +123,7 @@ public class DecimalColumnDefTest {
}

@Test
public void fail_with_UOE_to_generate_sql_type_when_unknown_dialect() throws Exception {
public void fail_with_UOE_to_generate_sql_type_when_unknown_dialect() {
thrown.expect(UnsupportedOperationException.class);
thrown.expectMessage("Unknown dialect 'unknown'");


+ 5
- 5
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/TimestampColumnDefTest.java View File

@@ -37,7 +37,7 @@ public class TimestampColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_column_def() throws Exception {
public void build_column_def() {
TimestampColumnDef def = newTimestampColumnDefBuilder()
.setColumnName("created_at")
.setIsNullable(false)
@@ -49,7 +49,7 @@ public class TimestampColumnDefTest {
}

@Test
public void build_column_def_with_only_required_attributes() throws Exception {
public void build_column_def_with_only_required_attributes() {
TimestampColumnDef def = newTimestampColumnDefBuilder()
.setColumnName("created_at")
.build();
@@ -60,7 +60,7 @@ public class TimestampColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
TimestampColumnDef def = newTimestampColumnDefBuilder()
.setColumnName("created_at")
.build();
@@ -73,7 +73,7 @@ public class TimestampColumnDefTest {
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -81,7 +81,7 @@ public class TimestampColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");


+ 3
- 3
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/TinyIntColumnDefTest.java View File

@@ -39,7 +39,7 @@ public class TinyIntColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_string_column_def() throws Exception {
public void build_string_column_def() {
TinyIntColumnDef def = new TinyIntColumnDef.Builder()
.setColumnName("foo")
.setIsNullable(true)
@@ -51,7 +51,7 @@ public class TinyIntColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
TinyIntColumnDef def = new TinyIntColumnDef.Builder()
.setColumnName("foo")
.setIsNullable(true)
@@ -65,7 +65,7 @@ public class TinyIntColumnDefTest {
}

@Test
public void fail_with_UOE_to_generate_sql_type_when_unknown_dialect() throws Exception {
public void fail_with_UOE_to_generate_sql_type_when_unknown_dialect() {
thrown.expect(UnsupportedOperationException.class);
thrown.expectMessage("Unknown dialect 'unknown'");


+ 2
- 2
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/ValidationsTest.java View File

@@ -33,13 +33,13 @@ public class ValidationsTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void accept_valid_table_name() throws Exception {
public void accept_valid_table_name() {
validateColumnName("date_in_ms");
validateColumnName("date_in_ms_1");
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");


+ 7
- 7
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java View File

@@ -36,7 +36,7 @@ public class VarcharColumnDefTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void build_string_column_def() throws Exception {
public void build_string_column_def() {
VarcharColumnDef def = new VarcharColumnDef.Builder()
.setColumnName("issues")
.setLimit(10)
@@ -51,7 +51,7 @@ public class VarcharColumnDefTest {
}

@Test
public void build_string_column_def_with_only_required_attributes() throws Exception {
public void build_string_column_def_with_only_required_attributes() {
VarcharColumnDef def = new VarcharColumnDef.Builder()
.setColumnName("issues")
.setLimit(10)
@@ -64,7 +64,7 @@ public class VarcharColumnDefTest {
}

@Test
public void generate_sql_type() throws Exception {
public void generate_sql_type() {
VarcharColumnDef def = new VarcharColumnDef.Builder()
.setColumnName("issues")
.setLimit(10)
@@ -79,7 +79,7 @@ public class VarcharColumnDefTest {
}

@Test
public void generateSqlType_does_not_set_unit_on_oracle_if_legacy_mode() throws Exception {
public void generateSqlType_does_not_set_unit_on_oracle_if_legacy_mode() {
VarcharColumnDef def = new VarcharColumnDef.Builder()
.setColumnName("issues")
.setLimit(10)
@@ -91,7 +91,7 @@ public class VarcharColumnDefTest {
}

@Test
public void fail_with_NPE_if_name_is_null() throws Exception {
public void fail_with_NPE_if_name_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -100,7 +100,7 @@ public class VarcharColumnDefTest {
}

@Test
public void fail_with_NPE_if_no_name() throws Exception {
public void fail_with_NPE_if_no_name() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Column name cannot be null");

@@ -109,7 +109,7 @@ public class VarcharColumnDefTest {
}

@Test
public void fail_with_NPE_if_size_is_null() throws Exception {
public void fail_with_NPE_if_size_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Limit cannot be null");


+ 1
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java View File

@@ -34,7 +34,7 @@ public class NoTableMigrationHistoryImplTest {
private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database());

@Test
public void start_fails_with_ISE_if_table_history_does_not_exist() throws SQLException {
public void start_fails_with_ISE_if_table_history_does_not_exist() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Migration history table is missing");


+ 2
- 2
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropTableBuilderTest.java View File

@@ -83,13 +83,13 @@ public class DropTableBuilderTest {
}

@Test
public void fail_when_dialect_is_null() throws Exception {
public void fail_when_dialect_is_null() {
expectedException.expect(NullPointerException.class);
new DropTableBuilder(null, "issues");
}

@Test
public void fail_when_table_is_null() throws Exception {
public void fail_when_table_is_null() {
expectedException.expect(NullPointerException.class);
new DropTableBuilder(new PostgreSql(), null);
}

+ 6
- 6
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java View File

@@ -117,7 +117,7 @@ public class DataChangeTest {
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) throws SQLException {
public Long read(Row row) {
throw new IllegalStateException("Unexpected error");
}
});
@@ -138,7 +138,7 @@ public class DataChangeTest {
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) throws SQLException {
public Long read(Row row) {
throw new IllegalStateException("Unexpected error");
}
});
@@ -319,7 +319,7 @@ public class DataChangeTest {
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) throws SQLException {
public void handle(Row row) {
throw new IllegalStateException("Unexpected error");
}
});
@@ -370,7 +370,7 @@ public class DataChangeTest {
massUpdate.update("update persons set login=?, age=? where id=?");
massUpdate.execute(new MassUpdate.Handler() {
@Override
public boolean handle(Row row, SqlStatement update) throws SQLException {
public boolean handle(Row row, SqlStatement update) {
throw new IllegalStateException("Unexpected error");
}
});
@@ -390,7 +390,7 @@ public class DataChangeTest {
massUpdate.update("update persons set login=?, age=? where id=?");
massUpdate.execute(new MassUpdate.Handler() {
@Override
public boolean handle(Row row, SqlStatement update) throws SQLException {
public boolean handle(Row row, SqlStatement update) {
return false;
}
});
@@ -412,7 +412,7 @@ public class DataChangeTest {
// update is not set
massUpdate.execute(new MassUpdate.Handler() {
@Override
public boolean handle(Row row, SqlStatement update) throws SQLException {
public boolean handle(Row row, SqlStatement update) {
return false;
}
});

+ 2
- 2
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java View File

@@ -45,13 +45,13 @@ public class Migration1223Test {

private FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects = new FixProjectUuidOfDeveloperProjects(database) {
@Override
public void execute(Context context) throws SQLException {
public void execute(Context context) {
calls.add(Call.CALL_1);
}
};
private CleanUsurperRootComponents cleanUsurperRootComponents = new CleanUsurperRootComponents(database) {
@Override
public void execute(Context context) throws SQLException {
public void execute(Context context) {
calls.add(Call.CALL_2);
}
};

+ 2
- 2
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/Migration1304Test.java View File

@@ -46,13 +46,13 @@ public class Migration1304Test {

private ShrinkModuleUuidPathOfProjects shrinkModuleUuidPathOfProjects = new ShrinkModuleUuidPathOfProjects(database) {
@Override
public void execute(Context context) throws SQLException {
public void execute(Context context) {
calls.add(Call.CALL_1);
}
};
private AddBUuidPathToProjects addBUuidPathToProjects = new AddBUuidPathToProjects(database) {
@Override
public void execute(Context context) throws SQLException {
public void execute(Context context) {
calls.add(Call.CALL_2);
}
};

+ 2
- 2
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/TestDefaultOrganizationUuidProvider.java View File

@@ -35,12 +35,12 @@ public class TestDefaultOrganizationUuidProvider implements DefaultOrganizationU
}

@Override
public String get(DataChange.Context context) throws SQLException {
public String get(DataChange.Context context) {
return organizationUuid;
}

@Override
public String getAndCheck(DataChange.Context context) throws SQLException {
public String getAndCheck(DataChange.Context context) {
return organizationUuid;
}
}

+ 0
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateRulesMetadataTest.java View File

@@ -232,7 +232,6 @@ public class PopulateRulesMetadataTest {
this.noteData = seed + "_noteData";
this.noteUserLogin = seed + "_noteUserLogin";
this.noteDates = new Dates(seed.hashCode());
;
return this;
}


+ 1
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/RenameOldSonarQubeWayQualityGateTest.java View File

@@ -84,7 +84,7 @@ public class RenameOldSonarQubeWayQualityGateTest {
}

@Test
public void should_log_a_meaningful_info_if_outdated_copy_exists() throws SQLException {
public void should_log_a_meaningful_info_if_outdated_copy_exists() {
insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false);
insertQualityGate(SONAR_WAY_OUTDATED_QUALITY_GATE, false);


+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java View File

@@ -248,7 +248,7 @@ public class AppLoggingTest {
}

@Test
public void no_info_log_from_hazelcast() throws IOException {
public void no_info_log_from_hazelcast() {
settings.getProps().set(CLUSTER_ENABLED, "true");
underTest.configure();


+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java View File

@@ -96,7 +96,7 @@ public class SchedulerImplTest {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
processLauncher.close();
}


+ 4
- 4
server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java View File

@@ -51,7 +51,7 @@ public class ClusterAppStateImplTest {
public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));

@Test
public void tryToLockWebLeader_returns_true_only_for_the_first_call() throws Exception {
public void tryToLockWebLeader_returns_true_only_for_the_first_call() {
try (ClusterAppStateImpl underTest = new ClusterAppStateImpl(new TestAppSettings(), newHzMember())) {
assertThat(underTest.tryToLockWebLeader()).isEqualTo(true);
assertThat(underTest.tryToLockWebLeader()).isEqualTo(false);
@@ -59,7 +59,7 @@ public class ClusterAppStateImplTest {
}

@Test
public void test_listeners() throws InterruptedException {
public void test_listeners() {
AppStateListener listener = mock(AppStateListener.class);
try (ClusterAppStateImpl underTest = new ClusterAppStateImpl(new TestAppSettings(), newHzMember())) {
underTest.addListener(listener);
@@ -106,7 +106,7 @@ public class ClusterAppStateImplTest {
}

@Test
public void registerSonarQubeVersion_throws_ISE_if_initial_version_is_different() throws Exception {
public void registerSonarQubeVersion_throws_ISE_if_initial_version_is_different() {
// Now launch an instance that try to be part of the hzInstance cluster
try (ClusterAppStateImpl underTest = new ClusterAppStateImpl(new TestAppSettings(), newHzMember())) {
// Register first version
@@ -121,7 +121,7 @@ public class ClusterAppStateImplTest {
}

@Test
public void registerClusterName_throws_MessageException_if_clusterName_is_different() throws Exception {
public void registerClusterName_throws_MessageException_if_clusterName_is_different() {
try (ClusterAppStateImpl underTest = new ClusterAppStateImpl(new TestAppSettings(), newHzMember())) {
// Register first version
underTest.getHazelcastMember().getAtomicReference(CLUSTER_NAME).set("goodClusterName");

+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/command/AbstractCommandTest.java View File

@@ -57,7 +57,7 @@ public class AbstractCommandTest {
}

@Test
public void constructor_throws_NPE_of_workDir_is_null() throws IOException {
public void constructor_throws_NPE_of_workDir_is_null() {
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("workDir can't be null");


+ 2
- 2
server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java View File

@@ -63,7 +63,7 @@ public class CommandFactoryImplTest {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
if (listAppender != null) {
ListAppender.detachMemoryAppenderToLoggerOf(CommandFactoryImpl.class, listAppender);
}
@@ -287,7 +287,7 @@ public class CommandFactoryImplTest {
return newFactory(userProps, System2.INSTANCE);
}

private CommandFactoryImpl newFactory(Properties userProps, System2 system2) throws IOException {
private CommandFactoryImpl newFactory(Properties userProps, System2 system2) {
Properties p = new Properties();
p.setProperty("sonar.path.home", homeDir.getAbsolutePath());
p.setProperty("sonar.path.temp", tempDir.getAbsolutePath());

+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsLoaderImplTest.java View File

@@ -97,7 +97,7 @@ public class AppSettingsLoaderImplTest {
}

@Test
public void detectHomeDir_returns_existing_dir() throws Exception {
public void detectHomeDir_returns_existing_dir() {
assertThat(new AppSettingsLoaderImpl(new String[0]).getHomeDir()).exists().isDirectory();

}

+ 3
- 3
server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java View File

@@ -52,7 +52,7 @@ public class ClusterSettingsLoopbackTest {
private NetworkUtils network = spy(NetworkUtilsImpl.INSTANCE);

@Before
public void setUp() throws Exception {
public void setUp() {
Optional<InetAddress> opt = network.getLocalNonLoopbackIpv4Address();
assumeThat(opt.isPresent(), CoreMatchers.is(true));

@@ -93,7 +93,7 @@ public class ClusterSettingsLoopbackTest {
new ClusterSettings(network).accept(settings.getProps());
}

private TestAppSettings newSettingsForAppNode() throws SocketException {
private TestAppSettings newSettingsForAppNode() {
return new TestAppSettings()
.set(CLUSTER_ENABLED, "true")
.set(CLUSTER_NODE_TYPE, "application")
@@ -104,7 +104,7 @@ public class ClusterSettingsLoopbackTest {
.set(JDBC_URL, "jdbc:mysql://localhost:3306/sonar");
}

private TestAppSettings newSettingsForSearchNode() throws SocketException {
private TestAppSettings newSettingsForSearchNode() {
return new TestAppSettings()
.set(CLUSTER_ENABLED, "true")
.set(CLUSTER_NODE_TYPE, "search")

+ 2
- 2
server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java View File

@@ -231,7 +231,7 @@ public class ClusterSettingsTest {
new ClusterSettings(network).accept(settings.getProps());
}

private TestAppSettings newSettingsForAppNode() throws SocketException {
private TestAppSettings newSettingsForAppNode() {
return new TestAppSettings()
.set(CLUSTER_ENABLED, "true")
.set(CLUSTER_NODE_TYPE, "application")
@@ -242,7 +242,7 @@ public class ClusterSettingsTest {
.set(JDBC_URL, "jdbc:mysql://localhost:3306/sonar");
}

private TestAppSettings newSettingsForSearchNode() throws SocketException {
private TestAppSettings newSettingsForSearchNode() {
return new TestAppSettings()
.set(CLUSTER_ENABLED, "true")
.set(CLUSTER_NODE_TYPE, "search")

+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/config/FileSystemSettingsTest.java View File

@@ -52,7 +52,7 @@ public class FileSystemSettingsTest {
}

@Test
public void relative_paths_are_converted_to_absolute_paths() throws Exception {
public void relative_paths_are_converted_to_absolute_paths() {
Props props = new Props(new Properties());
props.set(PATH_HOME, homeDir.getAbsolutePath());


+ 1
- 1
server/sonar-main/src/test/java/org/sonar/application/config/JdbcSettingsTest.java View File

@@ -181,7 +181,7 @@ public class JdbcSettingsTest {
}

@Test
public void driver_dir_does_not_exist() throws Exception {
public void driver_dir_does_not_exist() {
expectedException.expect(MessageException.class);
expectedException.expectMessage("Directory does not exist: extensions/jdbc-driver/oracle");


+ 0
- 0
server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save