]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15142 remove dead code
authorPierre <pierre.guillot@sonarsource.com>
Wed, 11 Aug 2021 12:38:24 +0000 (14:38 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 19 Aug 2021 20:08:14 +0000 (20:08 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java

index 4d18a0194d8c6e0d01b9be3bfcb39f6a111ca255..d6a758b551f2ead740323000a84d72bfeb118d16 100644 (file)
@@ -383,13 +383,6 @@ public class ComponentDao implements Dao {
     mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
   }
 
-  public void delete(DbSession session, String componentUuid, String qualifier) {
-    if (auditPersister != null) {
-      auditPersister.deleteComponent(session, new ComponentNewValue(componentUuid, qualifier), qualifier);
-    }
-    mapper(session).delete(componentUuid);
-  }
-
   private static void checkThatNotTooManyComponents(ComponentQuery query) {
     checkThatNotTooManyConditions(query.getComponentKeys(), "Too many component keys in query");
     checkThatNotTooManyConditions(query.getComponentUuids(), "Too many component UUIDs in query");
index a6181b44d680801202ce4aa3848f2c23a6a320c1..7e4d2d2c5cd86165f0e9bab2355e8bcc0e38d8ee 100644 (file)
@@ -1311,18 +1311,6 @@ public class ComponentDaoTest {
         "from components where uuid='" + uuid + "'");
   }
 
-  @Test
-  public void delete() {
-    ComponentDto project1 = db.components().insertPrivateProject(t -> t.setDbKey("PROJECT_1"));
-    db.components().insertPrivateProject(t -> t.setDbKey("PROJECT_2"));
-
-    underTest.delete(dbSession, project1.uuid(), null);
-    dbSession.commit();
-
-    assertThat(underTest.selectByKey(dbSession, "PROJECT_1")).isEmpty();
-    assertThat(underTest.selectByKey(dbSession, "PROJECT_2")).isPresent();
-  }
-
   @Test
   public void selectByQuery_throws_IAE_if_too_many_component_keys() {
     Set<String> keys = IntStream.range(0, 1_010).mapToObj(String::valueOf).collect(toSet());
@@ -1893,14 +1881,6 @@ public class ComponentDaoTest {
     assertThat(result).isEmpty();
   }
 
-  @Test
-  public void delete_auditPersisterIsCalled() {
-    underTestWithAuditPersister.delete(dbSession, "anyUuid", APP);
-
-    verify(auditPersister, Mockito.times(1))
-      .deleteComponent(any(DbSession.class), any(ComponentNewValue.class), anyString());
-  }
-
   @Test
   public void setPrivateForRootComponentUuid_auditPersisterIsCalled() {
     underTestWithAuditPersister.setPrivateForRootComponentUuid(dbSession, "anyUuid", false, APP);
index c4bd1e54ab9778bab94474f35cc634eecc78ffdc..d973d4ecabc8481b118d2fb986d03f6b933b152e 100644 (file)
@@ -40,6 +40,7 @@ import static java.util.Collections.emptySet;
 import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
+import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME;
 import static org.sonar.server.component.index.ComponentIndexDefinition.TYPE_COMPONENT;
 import static org.sonar.server.es.ProjectIndexer.Cause.PROJECT_CREATION;
@@ -207,7 +208,7 @@ public class ComponentIndexerTest {
     indexProject(project, PROJECT_CREATION);
     assertThatIndexHasSize(1);
 
-    db.getDbClient().componentDao().delete(db.getSession(), project.uuid(), Qualifiers.PROJECT);
+    db.getDbClient().purgeDao().deleteProject(db.getSession(), project.uuid(), PROJECT);
     indexProject(project, PROJECT_DELETION);
 
     assertThatIndexHasSize(0);
index 77de29c71fd67ff3423f014d88895f8613cc913e..4c9eaacef72db1895c05e939c197d59df33e230a 100644 (file)
@@ -40,6 +40,7 @@ import org.sonar.server.tester.UserSessionRule;
 import static java.util.Arrays.asList;
 import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.web.UserRole.ADMIN;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.server.es.ProjectIndexer.Cause.PERMISSION_CHANGE;
@@ -89,26 +90,6 @@ public class PermissionIndexerTest {
     verifyAuthorized(project, user2);
   }
 
-  @Test
-  public void deletion_resilience_will_deindex_projects() {
-    ComponentDto project1 = createUnindexedPublicProject();
-    ComponentDto project2 = createUnindexedPublicProject();
-    // UserDto user1 = db.users().insertUser();
-    indexOnStartup();
-    assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(2);
-
-    // Simulate a indexation issue
-    db.getDbClient().componentDao().delete(db.getSession(), project1.uuid(), Qualifiers.PROJECT);
-    underTest.prepareForRecovery(db.getSession(), asList(project1.uuid()), ProjectIndexer.Cause.PROJECT_DELETION);
-    assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isEqualTo(1);
-    Collection<EsQueueDto> esQueueDtos = db.getDbClient().esQueueDao().selectForRecovery(db.getSession(), Long.MAX_VALUE, 2);
-
-    underTest.index(db.getSession(), esQueueDtos);
-
-    assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isZero();
-    assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(1);
-  }
-
   @Test
   public void indexOnStartup_grants_access_to_user() {
     ComponentDto project = createAndIndexPrivateProject();
@@ -314,7 +295,7 @@ public class PermissionIndexerTest {
     indexPermissions(project, ProjectIndexer.Cause.PROJECT_CREATION);
     verifyAuthorized(project, user);
 
-    db.getDbClient().componentDao().delete(db.getSession(), project.uuid(), Qualifiers.PROJECT);
+    db.getDbClient().purgeDao().deleteProject(db.getSession(), project.uuid(), PROJECT);
     indexPermissions(project, ProjectIndexer.Cause.PROJECT_DELETION);
 
     verifyNotAuthorized(project, user);
index 5b266605e84b51b21b9130555bf6f6b37b487ca8..740a89af63e01d2c11cd543ccf661f426c15c716 100644 (file)
@@ -394,7 +394,7 @@ public class SuggestionsActionTest {
     componentIndexer.indexAll();
     authorizationIndexerTester.allowOnlyAnyone(project);
 
-    db.getDbClient().componentDao().delete(db.getSession(), project.uuid(), PROJECT);
+    db.getDbClient().purgeDao().deleteProject(db.getSession(), project.uuid(), PROJECT);
     db.commit();
 
     SuggestionsWsResponse response = ws.newRequest()