From: Pierre Date: Wed, 11 Aug 2021 12:38:24 +0000 (+0200) Subject: SONAR-15142 remove dead code X-Git-Tag: 9.1.0.47736~139 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f660a790f6d88b5d68bf1f1677cd2bc0ae657309;p=sonarqube.git SONAR-15142 remove dead code --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index 4d18a0194d8..d6a758b551f 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -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"); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index a6181b44d68..7e4d2d2c5cd 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -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 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); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java index c4bd1e54ab9..d973d4ecabc 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java @@ -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); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java index 77de29c71fd..4c9eaacef72 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java @@ -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 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); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java index 5b266605e84..740a89af63e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java @@ -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()