aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-26 20:36:12 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-29 13:26:54 +0100
commit2a387b3eb1c18708800e5c546cee98dd68d513c7 (patch)
tree5e9a3ac0ef573b1c50f7fa635a18e18970fe81c0 /sonar-db
parent5b6b5bd5e02efb1232e5dd318e4284c210173492 (diff)
downloadsonarqube-2a387b3eb1c18708800e5c546cee98dd68d513c7.tar.gz
sonarqube-2a387b3eb1c18708800e5c546cee98dd68d513c7.zip
SONAR-7330 Remove DAOv2 base classes
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java5
-rw-r--r--sonar-db/src/main/java/org/sonar/db/BatchSession.java16
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DbSession.java27
-rw-r--r--sonar-db/src/main/java/org/sonar/db/MyBatis.java9
-rw-r--r--sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java28
-rw-r--r--sonar-db/src/main/java/org/sonar/db/deprecated/NullQueue.java30
-rw-r--r--sonar-db/src/main/java/org/sonar/db/deprecated/WorkQueue.java29
-rw-r--r--sonar-db/src/test/java/org/sonar/db/BatchSessionTest.java22
-rw-r--r--sonar-db/src/test/java/org/sonar/db/MyBatisTest.java7
-rw-r--r--sonar-db/src/test/java/org/sonar/db/TestDb.java3
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java11
-rw-r--r--sonar-db/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/permission/GroupWithPermissionDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java2
21 files changed, 34 insertions, 177 deletions
diff --git a/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java
index 5d66a44b676..c72e0e5ec7e 100644
--- a/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-db/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -20,7 +20,6 @@
package org.sonar.core.persistence;
import org.sonar.db.Database;
-import org.sonar.db.deprecated.WorkQueue;
/**
* Kept for backward compatibility of plugins/libs (like sonar-license) that are directly calling classes from the core
@@ -30,8 +29,8 @@ import org.sonar.db.deprecated.WorkQueue;
@Deprecated
public class MyBatis extends org.sonar.db.MyBatis {
- public MyBatis(Database database, WorkQueue<?> queue) {
- super(database, queue);
+ public MyBatis(Database database) {
+ super(database);
}
}
diff --git a/sonar-db/src/main/java/org/sonar/db/BatchSession.java b/sonar-db/src/main/java/org/sonar/db/BatchSession.java
index 93cc0540b58..9e98d66e622 100644
--- a/sonar-db/src/main/java/org/sonar/db/BatchSession.java
+++ b/sonar-db/src/main/java/org/sonar/db/BatchSession.java
@@ -29,8 +29,6 @@ import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.sonar.db.deprecated.ClusterAction;
-import org.sonar.db.deprecated.WorkQueue;
public class BatchSession extends DbSession {
@@ -39,22 +37,16 @@ public class BatchSession extends DbSession {
private final int batchSize;
private int count = 0;
- public BatchSession(WorkQueue<?> queue, SqlSession session) {
- this(queue, session, MAX_BATCH_SIZE);
+ public BatchSession(SqlSession session) {
+ this(session, MAX_BATCH_SIZE);
}
- BatchSession(WorkQueue<?> queue, SqlSession session, int batchSize) {
- super(queue, session);
+ BatchSession(SqlSession session, int batchSize) {
+ super(session);
this.batchSize = batchSize;
}
@Override
- public void enqueue(ClusterAction action) {
- increment();
- super.enqueue(action);
- }
-
- @Override
public void select(String statement, Object parameter, ResultHandler handler) {
reset();
super.select(statement, parameter, handler);
diff --git a/sonar-db/src/main/java/org/sonar/db/DbSession.java b/sonar-db/src/main/java/org/sonar/db/DbSession.java
index 08e2b4ba04d..845dc679c64 100644
--- a/sonar-db/src/main/java/org/sonar/db/DbSession.java
+++ b/sonar-db/src/main/java/org/sonar/db/DbSession.java
@@ -20,7 +20,6 @@
package org.sonar.db;
import java.sql.Connection;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.executor.BatchResult;
@@ -28,49 +27,25 @@ import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.sonar.db.deprecated.ClusterAction;
-import org.sonar.db.deprecated.WorkQueue;
public class DbSession implements SqlSession {
- private List<ClusterAction> actions;
-
private SqlSession session;
private int actionCount;
- public DbSession(WorkQueue queue, SqlSession session) {
+ public DbSession(SqlSession session) {
this.actionCount = 0;
this.session = session;
- this.actions = new ArrayList<>();
- }
-
- /**
- * @deprecated since 5.5, not used anymore
- */
- @Deprecated
- public void enqueue(ClusterAction action) {
- actionCount++;
- this.actions.add(action);
- }
-
- /**
- * @deprecated since 5.5, not used anymore
- */
- @Deprecated
- public int getActionCount() {
- return actionCount;
}
@Override
public void commit() {
session.commit();
- actions.clear();
}
@Override
public void commit(boolean force) {
session.commit(force);
- actions.clear();
}
/**
diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java
index 5076f23dc21..b7517208fc8 100644
--- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java
+++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java
@@ -57,7 +57,6 @@ import org.sonar.db.dashboard.WidgetMapper;
import org.sonar.db.dashboard.WidgetPropertyDto;
import org.sonar.db.dashboard.WidgetPropertyMapper;
import org.sonar.db.debt.RequirementMigrationDto;
-import org.sonar.db.deprecated.WorkQueue;
import org.sonar.db.duplication.DuplicationMapper;
import org.sonar.db.duplication.DuplicationUnitDto;
import org.sonar.db.event.EventDto;
@@ -139,11 +138,9 @@ public class MyBatis {
private final Database database;
private SqlSessionFactory sessionFactory;
- private WorkQueue<?> queue;
- public MyBatis(Database database, WorkQueue<?> queue) {
+ public MyBatis(Database database) {
this.database = database;
- this.queue = queue;
}
// FIXME should be visible only to DAOs -> to be moved to AbstractDao
@@ -265,10 +262,10 @@ public class MyBatis {
public DbSession openSession(boolean batch) {
if (batch) {
SqlSession session = sessionFactory.openSession(ExecutorType.BATCH);
- return new BatchSession(queue, session);
+ return new BatchSession(session);
}
SqlSession session = sessionFactory.openSession(ExecutorType.REUSE);
- return new DbSession(queue, session);
+ return new DbSession(session);
}
/**
diff --git a/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java b/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java
deleted file mode 100644
index 55512295d6e..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/deprecated/ClusterAction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.deprecated;
-
-import java.util.concurrent.Callable;
-
-public interface ClusterAction<K> extends Callable<K> {
-
- @Override
- K call() throws Exception;
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/deprecated/NullQueue.java b/sonar-db/src/main/java/org/sonar/db/deprecated/NullQueue.java
deleted file mode 100644
index 9fa09f9c0cb..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/deprecated/NullQueue.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.deprecated;
-
-import java.util.List;
-
-public class NullQueue implements WorkQueue<ClusterAction> {
-
- @Override
- public void enqueue(List<ClusterAction> actions) {
- // do nothing
- }
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/deprecated/WorkQueue.java b/sonar-db/src/main/java/org/sonar/db/deprecated/WorkQueue.java
deleted file mode 100644
index d6466da6d28..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/deprecated/WorkQueue.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.deprecated;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-
-public interface WorkQueue<K extends Callable> {
-
- void enqueue(List<K> actions);
-
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/BatchSessionTest.java b/sonar-db/src/test/java/org/sonar/db/BatchSessionTest.java
index e1f02e93ca0..40fe0541f6f 100644
--- a/sonar-db/src/test/java/org/sonar/db/BatchSessionTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/BatchSessionTest.java
@@ -21,8 +21,6 @@ package org.sonar.db;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
-import org.sonar.db.deprecated.ClusterAction;
-import org.sonar.db.deprecated.WorkQueue;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.mock;
@@ -34,8 +32,7 @@ public class BatchSessionTest {
@Test
public void shouldCommitWhenReachingBatchSize() {
SqlSession mybatisSession = mock(SqlSession.class);
- WorkQueue<?> queue = mock(WorkQueue.class);
- BatchSession session = new BatchSession(queue, mybatisSession, 10);
+ BatchSession session = new BatchSession(mybatisSession, 10);
for (int i = 0; i < 9; i++) {
session.insert("id" + i);
@@ -51,22 +48,14 @@ public class BatchSessionTest {
@Test
public void shouldCommitWhenReachingBatchSizeWithoutCommits() {
SqlSession mybatisSession = mock(SqlSession.class);
- WorkQueue<?> queue = mock(WorkQueue.class);
- BatchSession session = new BatchSession(queue, mybatisSession, 10);
-
- ClusterAction action = new ClusterAction() {
- @Override
- public Object call() throws Exception {
- return null;
- }
- };
+ BatchSession session = new BatchSession(mybatisSession, 10);
for (int i = 0; i < 9; i++) {
- session.enqueue(action);
+ session.delete("delete something");
verify(mybatisSession, never()).commit();
verify(mybatisSession, never()).commit(anyBoolean());
}
- session.enqueue(action);
+ session.delete("delete something");
verify(mybatisSession).commit();
session.close();
}
@@ -74,8 +63,7 @@ public class BatchSessionTest {
@Test
public void shouldResetCounterAfterCommit() {
SqlSession mybatisSession = mock(SqlSession.class);
- WorkQueue<?> queue = mock(WorkQueue.class);
- BatchSession session = new BatchSession(queue, mybatisSession, 10);
+ BatchSession session = new BatchSession(mybatisSession, 10);
for (int i = 0; i < 35; i++) {
session.insert("id" + i);
diff --git a/sonar-db/src/test/java/org/sonar/db/MyBatisTest.java b/sonar-db/src/test/java/org/sonar/db/MyBatisTest.java
index b3023a4af63..9368138569d 100644
--- a/sonar-db/src/test/java/org/sonar/db/MyBatisTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/MyBatisTest.java
@@ -25,16 +25,13 @@ import org.hamcrest.core.Is;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.sonar.db.deprecated.WorkQueue;
import org.sonar.db.rule.RuleMapper;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
public class MyBatisTest {
private static H2Database database;
- private WorkQueue<?> queue = mock(WorkQueue.class);
@BeforeClass
public static void start() {
@@ -49,7 +46,7 @@ public class MyBatisTest {
@Test
public void shouldConfigureMyBatis() {
- MyBatis myBatis = new MyBatis(database, queue);
+ MyBatis myBatis = new MyBatis(database);
myBatis.start();
Configuration conf = myBatis.getSessionFactory().getConfiguration();
@@ -60,7 +57,7 @@ public class MyBatisTest {
@Test
public void shouldOpenBatchSession() {
- MyBatis myBatis = new MyBatis(database, queue);
+ MyBatis myBatis = new MyBatis(database);
myBatis.start();
SqlSession session = myBatis.openSession(false);
diff --git a/sonar-db/src/test/java/org/sonar/db/TestDb.java b/sonar-db/src/test/java/org/sonar/db/TestDb.java
index 8ab3dc5a611..e4d2fd0aa0a 100644
--- a/sonar-db/src/test/java/org/sonar/db/TestDb.java
+++ b/sonar-db/src/test/java/org/sonar/db/TestDb.java
@@ -40,7 +40,6 @@ import org.junit.AssumptionViolatedException;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.deprecated.NullQueue;
import org.sonar.db.dialect.H2;
/**
@@ -105,7 +104,7 @@ class TestDb {
commands = DatabaseCommands.forDialect(db.getDialect());
tester = new DataSourceDatabaseTester(db.getDataSource(), commands.useLoginAsSchema() ? login : null);
- myBatis = new MyBatis(db, new NullQueue());
+ myBatis = new MyBatis(db);
myBatis.start();
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index e739cba9096..dd5c13782ca 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -58,7 +58,7 @@ public class ComponentDaoTest {
public DbTester db = DbTester.create(System2.INSTANCE);
ComponentDbTester componentDb = new ComponentDbTester(db);
- DbSession dbSession = db.getSession();
+ final DbSession dbSession = db.getSession();
ComponentDao underTest = new ComponentDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
index 10f6c501cd7..122c108ed03 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
@@ -44,7 +44,7 @@ public class ComponentDaoWithDuplicatedKeysTest {
DbClient dbClient = db.getDbClient();
- DbSession dbSession = db.getSession();
+ final DbSession dbSession = db.getSession();
ComponentDao underTest = new ComponentDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
index e4ee5ac915c..59bbea74db0 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
@@ -29,7 +29,6 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.test.DbTests;
@@ -51,8 +50,7 @@ public class SnapshotDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
ComponentDbTester componentDb = new ComponentDbTester(db);
- DbClient dbClient = db.getDbClient();
- DbSession dbSession = db.getSession();
+ final DbSession dbSession = db.getSession();
SnapshotDao underTest = db.getDbClient().snapshotDao();
@@ -178,7 +176,8 @@ public class SnapshotDaoTest {
assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L);
assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setScope(Scopes.PROJECT).setQualifier(Qualifiers.PACKAGE))).extracting("id").containsOnly(1L);
- assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setScope(Scopes.DIRECTORY).setQualifier(Qualifiers.PACKAGE))).extracting("id").containsOnly(2L, 3L, 4L, 5L, 6L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setScope(Scopes.DIRECTORY).setQualifier(Qualifiers.PACKAGE))).extracting("id").containsOnly(
+ 2L, 3L, 4L, 5L, 6L);
assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentUuid("ABCD"))).hasSize(3);
assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentUuid("UNKOWN"))).isEmpty();
@@ -227,7 +226,7 @@ public class SnapshotDaoTest {
newSnapshotForProject(project).setCreatedAt(5L),
newSnapshotForProject(project).setCreatedAt(2L),
newSnapshotForProject(project).setCreatedAt(1L)
- );
+ );
dbSession.commit();
SnapshotDto dto = underTest.selectOldestSnapshot(dbSession, project.getId());
@@ -247,7 +246,7 @@ public class SnapshotDaoTest {
db.getSession().commit();
assertThat(dto.getId()).isNotNull();
- db.assertDbUnit(getClass(), "insert-result.xml", new String[]{"id"}, "snapshots");
+ db.assertDbUnit(getClass(), "insert-result.xml", new String[] {"id"}, "snapshots");
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java b/sonar-db/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java
index c31b3e6938e..b9cd5e367dc 100644
--- a/sonar-db/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java
@@ -37,7 +37,7 @@ public class DuplicationDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- DbSession dbSession = db.getSession();
+ final DbSession dbSession = db.getSession();
DuplicationDao dao = db.getDbClient().duplicationDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
index 37c53d4bde0..fa2985530b7 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
@@ -58,8 +58,8 @@ public class MeasureDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- private DbClient dbClient = db.getDbClient();
- private DbSession dbSession = db.getSession();
+ final DbClient dbClient = db.getDbClient();
+ final DbSession dbSession = db.getSession();
MeasureDao underTest = dbClient.measureDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java
index f9bfd12ba0c..369f2368065 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java
@@ -33,7 +33,7 @@ public class MeasureFilterDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- DbSession session = db.getSession();
+ final DbSession session = db.getSession();
MeasureFilterDao underTest = db.getDbClient().measureFilterDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java
index 41402810c3a..d2c94c30768 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java
@@ -33,7 +33,7 @@ public class MeasureFilterFavouriteDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- DbSession session = db.getSession();
+ final DbSession session = db.getSession();
MeasureFilterFavouriteDao underTest = db.getDbClient().measureFilterFavouriteDao();
diff --git a/sonar-db/src/test/java/org/sonar/db/permission/GroupWithPermissionDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/GroupWithPermissionDaoTest.java
index 778cb24ec5e..ddb3b5b9923 100644
--- a/sonar-db/src/test/java/org/sonar/db/permission/GroupWithPermissionDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/permission/GroupWithPermissionDaoTest.java
@@ -48,7 +48,7 @@ public class GroupWithPermissionDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- DbSession session = db.getSession();
+ final DbSession session = db.getSession();
PermissionDao underTest = new PermissionDao(db.myBatis());
diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
index 4853cac312f..a6a2696806b 100644
--- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
@@ -61,7 +61,7 @@ public class PermissionTemplateDaoTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- DbSession session = db.getSession();
+ final DbSession session = db.getSession();
DbClient dbClient = db.getDbClient();
PermissionTemplateDao underTest = new PermissionTemplateDao(db.myBatis(), system);
diff --git a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
index 3fba65b42ef..efd1887a503 100644
--- a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.test.DbTests;
@@ -41,8 +40,7 @@ public class GroupDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- DbSession dbSession = db.getSession();
- DbClient dbClient = db.getDbClient();
+ final DbSession dbSession = db.getSession();
System2 system2 = mock(System2.class);
GroupDao underTest = new GroupDao(system2);
diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
index a090b59b03b..55d413370f2 100644
--- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
@@ -70,7 +70,7 @@ public class UserDaoTest {
DbClient dbClient = db.getDbClient();
UserDao underTest = db.getDbClient().userDao();
- DbSession session = db.getSession();
+ final DbSession session = db.getSession();
@Before
public void setUp() throws Exception {