]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless method
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 21 Sep 2015 13:07:38 +0000 (15:07 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 22 Sep 2015 15:05:11 +0000 (17:05 +0200)
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java
sonar-db/src/main/java/org/sonar/db/source/FileSourceDao.java
sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java

index 302cc4ed8b537355eca657fc0a5292d52a9a0428..ad860e1a4ad223683abb19ba40eab9baf5af216a 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.api.utils.System2;
 import org.sonar.batch.protocol.Constants;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.protobuf.DbFileSources;
 import org.sonar.db.source.FileSourceDto;
@@ -69,6 +70,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
   public BatchReportReaderRule reportReader = new BatchReportReaderRule();
 
   DbClient dbClient = dbTester.getDbClient();
+  DbSession session = dbTester.getSession();
+
   PersistFileSourcesStep underTest;
 
   long now = 123456789L;
@@ -92,7 +95,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     assertThat(fileSourceDto.getProjectUuid()).isEqualTo(PROJECT_UUID);
     assertThat(fileSourceDto.getFileUuid()).isEqualTo(FILE_UUID);
     assertThat(fileSourceDto.getBinaryData()).isNotEmpty();
@@ -131,7 +134,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
     assertThat(data.getLinesCount()).isEqualTo(3);
     assertThat(data.getLines(2).getLine()).isEqualTo(3);
@@ -145,7 +148,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource("FILE");
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, "FILE");
     assertThat(fileSourceDto.getLineHashes()).isEqualTo("137f72c3708c6bd0de00a0e5a69c699b\ne6251bcf1a7dc3ba5e7933e325bbe605");
     assertThat(fileSourceDto.getSrcHash()).isEqualTo("ee5a58024a155466b43bc559d953e018");
   }
@@ -167,7 +170,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
 
     assertThat(data.getLinesList()).hasSize(1);
@@ -200,7 +203,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
 
     assertThat(data.getLinesList()).hasSize(1);
@@ -225,7 +228,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
 
     assertThat(data.getLinesList()).hasSize(1);
@@ -250,7 +253,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
 
     assertThat(data.getLinesList()).hasSize(3);
@@ -281,7 +284,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     DbFileSources.Data data = FileSourceDto.decodeSourceData(fileSourceDto.getBinaryData());
 
     assertThat(data.getLinesList()).hasSize(1);
@@ -319,7 +322,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     assertThat(fileSourceDto.getSrcHash()).isEqualTo(srcHash);
     assertThat(fileSourceDto.getLineHashes()).isEqualTo(lineHashes);
     assertThat(fileSourceDto.getDataHash()).isEqualTo(dataHash);
@@ -353,7 +356,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past);
     assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now);
   }
@@ -384,7 +387,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     underTest.execute();
 
     assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
-    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSource(FILE_UUID);
+    FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
     assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past);
     // Updated at is not updated to not reindex the file source in E/S as the src hash is not indexed
     assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(past);
index f1448a545bffac609a687cab76dfffa2ba93d101..92d1e0b6762e844327d23d88168efcc76d7640ec 100644 (file)
@@ -45,16 +45,6 @@ public class FileSourceDao implements Dao {
     this.mybatis = myBatis;
   }
 
-  @CheckForNull
-  public FileSourceDto selectSource(String fileUuid) {
-    DbSession session = mybatis.openSession(false);
-    try {
-      return mapper(session).select(fileUuid, Type.SOURCE);
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
   @CheckForNull
   public FileSourceDto selectSourceByFileUuid(DbSession session, String fileUuid) {
     return mapper(session).select(fileUuid, Type.SOURCE);
index 6971a700aeca40d99cc10398efc81992309d7d4b..393a5fcd42c3b88fb840037a6e471f3eb473773e 100644 (file)
@@ -28,6 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.sonar.api.utils.System2;
+import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.source.FileSourceDto.Type;
 import org.sonar.test.DbTests;
@@ -40,13 +41,15 @@ public class FileSourceDaoTest {
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
 
+  DbSession session = dbTester.getSession();
+
   FileSourceDao underTest = dbTester.getDbClient().fileSourceDao();
 
   @Test
   public void select() {
     dbTester.prepareDbUnit(getClass(), "shared.xml");
 
-    FileSourceDto fileSourceDto = underTest.selectSource("FILE1_UUID");
+    FileSourceDto fileSourceDto = underTest.selectSourceByFileUuid(session, "FILE1_UUID");
 
     assertThat(fileSourceDto.getBinaryData()).isNotEmpty();
     assertThat(fileSourceDto.getDataHash()).isEqualTo("hash");