@@ -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); | |||
} |
@@ -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"); | |||
} |
@@ -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")), |
@@ -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; | |||
} |
@@ -69,7 +69,7 @@ public class CeWorkerImpl implements CeWorker { | |||
} | |||
@Override | |||
public Result call() throws Exception { | |||
public Result call() { | |||
return withCustomizedThreadName(this::findAndProcessTask); | |||
} | |||
@@ -82,7 +82,7 @@ public class EnabledCeWorkerControllerImpl implements EnabledCeWorkerController | |||
} | |||
@Override | |||
public void close() throws Exception { | |||
public void close() { | |||
map.put(ceWorker, Status.PAUSED); | |||
} | |||
} |
@@ -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); |
@@ -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(); | |||
} | |||
@@ -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()); | |||
@@ -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")); | |||
@@ -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:"); | |||
} |
@@ -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(); | |||
} | |||
@@ -77,7 +77,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerTest { | |||
notificationService, dbClient, serializer, system2); | |||
@Before | |||
public void setUp() throws Exception { | |||
public void setUp() { | |||
} | |||
@@ -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(); | |||
} |
@@ -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(); |
@@ -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(); |
@@ -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); |
@@ -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)); | |||
} | |||
@@ -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"); | |||
} | |||
} |
@@ -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); | |||
} | |||
@@ -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()); | |||
} | |||
@@ -47,7 +47,7 @@ public class CoreDbTester extends AbstractDbTester<CoreTestDb> { | |||
} | |||
@Override | |||
protected void before() throws Throwable { | |||
protected void before() { | |||
db.start(); | |||
db.truncateTables(); | |||
} |
@@ -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; | |||
} |
@@ -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); |
@@ -47,7 +47,7 @@ public class H2Test { | |||
} | |||
@Test | |||
public void testFetchSizeForScrolling() throws Exception { | |||
public void testFetchSizeForScrolling() { | |||
assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200); | |||
} | |||
@@ -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(); | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -52,7 +52,7 @@ public class PostgreSqlTest { | |||
} | |||
@Test | |||
public void testFetchSizeForScrolling() throws Exception { | |||
public void testFetchSizeForScrolling() { | |||
assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200); | |||
} | |||
@@ -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) { |
@@ -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); |
@@ -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"); | |||
} | |||
} |
@@ -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(); | |||
} | |||
@@ -319,7 +319,7 @@ public class DbTester extends AbstractDbTester<TestDb> { | |||
} | |||
@Override | |||
public Connection get() throws SQLException { | |||
public Connection get() { | |||
return dbSession.getConnection(); | |||
} | |||
@@ -47,7 +47,7 @@ public class MyBatisTest { | |||
private MyBatis underTest = new MyBatis(database); | |||
@After | |||
public void tearDown() throws Exception { | |||
public void tearDown() { | |||
underTest.stop(); | |||
} | |||
@@ -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"); | |||
@@ -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); |
@@ -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)); | |||
} |
@@ -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(); | |||
} |
@@ -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 |
@@ -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")); | |||
@@ -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); | |||
} | |||
} |
@@ -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) |
@@ -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) |
@@ -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); | |||
@@ -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"); |
@@ -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) |
@@ -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") |
@@ -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(); |
@@ -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"); |
@@ -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") |
@@ -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(); |
@@ -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); |
@@ -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); |
@@ -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"); |
@@ -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(); |
@@ -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); |
@@ -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) |
@@ -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") |
@@ -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"))) |
@@ -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); | |||
@@ -47,7 +47,7 @@ public class PurgeMapperTest { | |||
} | |||
@After | |||
public void tearDown() throws Exception { | |||
public void tearDown() { | |||
if (dbSession != null) { | |||
dbSession.close(); | |||
} |
@@ -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), |
@@ -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); |
@@ -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(); |
@@ -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())); |
@@ -310,7 +310,7 @@ public class RuleDaoTest { | |||
} | |||
@Test | |||
public void insert() throws Exception { | |||
public void insert() { | |||
RuleDefinitionDto newRule = new RuleDefinitionDto() | |||
.setRuleKey("NewRuleKey") | |||
.setRepositoryKey("plugin") |
@@ -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(); | |||
} | |||
} |
@@ -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); |
@@ -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) |
@@ -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); | |||
} |
@@ -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(); |
@@ -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"); | |||
@@ -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"); | |||
@@ -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"); | |||
@@ -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"); | |||
@@ -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'"); | |||
@@ -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"); | |||
@@ -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'"); | |||
@@ -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"); | |||
@@ -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"); | |||
@@ -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"); | |||
@@ -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); | |||
} |
@@ -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; | |||
} | |||
}); |
@@ -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); | |||
} | |||
}; |
@@ -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); | |||
} | |||
}; |
@@ -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; | |||
} | |||
} |
@@ -232,7 +232,6 @@ public class PopulateRulesMetadataTest { | |||
this.noteData = seed + "_noteData"; | |||
this.noteUserLogin = seed + "_noteUserLogin"; | |||
this.noteDates = new Dates(seed.hashCode()); | |||
; | |||
return this; | |||
} | |||
@@ -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); | |||
@@ -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(); | |||
@@ -96,7 +96,7 @@ public class SchedulerImplTest { | |||
} | |||
@After | |||
public void tearDown() throws Exception { | |||
public void tearDown() { | |||
processLauncher.close(); | |||
} | |||
@@ -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"); |
@@ -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"); | |||
@@ -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()); |
@@ -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(); | |||
} |
@@ -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") |
@@ -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") |
@@ -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()); | |||
@@ -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"); | |||