From d20ca1857a018a6b255a6eae7e5eeb71b31c22ab Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 22 Jun 2016 16:37:21 +0200 Subject: [PATCH] SONAR-7800 add column PROJECTS.UUID_PATH --- .../java/it/sourceCode/ProjectCodeTest.java | 4 +- .../server/component/ComponentService.java | 3 +- .../sonar/server/component/ws/ShowAction.java | 23 +- .../sonar/server/component/ws/ShowData.java | 104 ---- .../sonar/server/component/ws/TreeAction.java | 44 +- .../filemove/FileMoveDetectionStep.java | 11 +- .../step/PersistComponentsStep.java | 13 +- .../server/measure/ws/ComponentTreeData.java | 9 +- .../measure/ws/ComponentTreeDataLoader.java | 81 +-- .../server/measure/ws/ComponentTreeSort.java | 78 +-- .../sonar/server/measure/ws/HasMeasure.java | 42 +- .../org/sonar/ce/queue/CeQueueImplTest.java | 9 +- .../server/batch/ProjectDataLoaderTest.java | 8 +- .../sonar/server/ce/ws/TaskFormatterTest.java | 7 +- .../component/ComponentServiceTest.java | 28 +- .../server/component/ws/ShowDataTest.java | 81 --- .../server/component/ws/TreeActionTest.java | 91 +-- .../filemove/FileMoveDetectionStepTest.java | 57 +- .../queue/InternalCeQueueImplTest.java | 3 +- .../step/PersistMeasuresStepTest.java | 6 +- .../measure/ws/ComponentActionTest.java | 14 +- .../measure/ws/ComponentTreeActionTest.java | 121 ++-- .../measure/ws/ComponentTreeSortTest.java | 38 +- .../measure/ws/MeasureDtoToWsMeasureTest.java | 3 +- .../ws/SearchMyProjectsActionTest.java | 4 +- .../ws/ProjectStatusActionTest.java | 6 +- .../QProfileFactoryMediumTest.java | 12 +- .../QProfileProjectOperationsMediumTest.java | 28 +- .../ws/QProfilesWsMediumTest.java | 56 +- .../sonar/server/test/ws/ListActionTest.java | 14 +- ...urn_only_authorized_projects_from_view.xml | 111 +++- .../SearchViewComponentsActionTest/shared.xml | 132 +++- .../activity/ActivityManagerTest/shared.xml | 47 +- .../MeasureRepositoryImplTest/shared.xml | 21 +- .../shared.xml | 124 +++- .../step/LoadPeriodsStepTest/empty.xml | 6 +- .../no_previous_version.xml | 180 +++++- .../previous_version_deleted.xml | 1 + .../previous_version_is_last_one.xml | 44 +- .../step/LoadPeriodsStepTest/shared.xml | 1 + .../unprocessed_snapshots.xml | 53 +- .../load_component_id_from_db.xml | 26 +- .../load_project_id_from_db.xml | 24 +- .../should_insert_new_issues.xml | 26 +- .../should_update_issues.xml | 28 +- .../no_authorization.xml | 41 +- .../IssueAuthorizationDaoTest/shared.xml | 109 +++- .../IssueAuthorizationIndexerTest/index.xml | 66 +- .../issue/index/IssueIndexerTest/index.xml | 38 +- .../index/IssueIndexerTest/index_project.xml | 63 +- .../extract_directory_path.xml | 269 +++++---- .../extract_file_path.xml | 269 +++++---- .../many_projects.xml | 63 +- .../IssueResultSetIteratorTest/one_issue.xml | 107 +++- .../IssueResultSetIteratorTest/shared.xml | 59 +- ...e_when_filter_by_component_name_or_key.xml | 247 ++++++-- .../ignore_person_measures.xml | 109 +++- .../ignore_quality_model_measures.xml | 85 ++- .../MeasureFilterExecutorTest/shared.xml | 563 ++++++++++++++---- .../sort_by_alert.xml | 224 +++++-- .../BackendCleanupMediumTest/shared.xml | 72 ++- .../source/ws/HashActionTest/no_source.xml | 25 +- .../source/ws/HashActionTest/shared.xml | 36 +- .../show_hashes_on_test_file.xml | 47 +- .../view/index/ViewIndexerTest/index.xml | 308 ++++++++-- .../1255_add_uuid_path_column_to_projects.rb | 29 + ...6_populate_uuid_path_column_on_projects.rb | 29 + ...e_uuid_path_column_not_null_on_projects.rb | 29 + .../org/sonar/db/component/ComponentDao.java | 101 +++- .../org/sonar/db/component/ComponentDto.java | 107 +++- .../sonar/db/component/ComponentMapper.java | 17 +- .../db/component/ComponentTreeQuery.java | 46 +- .../java/org/sonar/db/measure/MeasureDao.java | 14 + .../org/sonar/db/measure/MeasureMapper.java | 3 +- .../org/sonar/db/measure/MeasureQuery.java | 95 +++ .../org/sonar/db/version/DatabaseVersion.java | 5 +- .../sonar/db/version/MigrationStepModule.java | 10 +- .../java/org/sonar/db/version/Select.java | 2 + .../sonar/db/version/VarcharColumnDef.java | 1 + .../v60/AddUuidPathColumnToProjects.java | 45 ++ .../MakeUuidPathColumnNotNullOnProjects.java | 45 ++ .../v60/PopulateUuidPathColumnOnProjects.java | 156 +++++ .../sonar/db/component/ComponentMapper.xml | 170 ++++-- .../org/sonar/db/measure/MeasureMapper.xml | 43 ++ .../org/sonar/db/version/rows-h2.sql | 3 + .../org/sonar/db/version/schema-h2.ddl | 5 +- .../sonar/db/component/ComponentDaoTest.java | 407 +++++++------ .../sonar/db/component/ComponentDtoTest.java | 29 +- .../sonar/db/component/ComponentTesting.java | 43 +- .../db/component/ComponentTreeQueryTest.java | 8 +- .../db/component/ResourceIndexDaoTest.java | 9 +- .../org/sonar/db/measure/MeasureDaoTest.java | 14 +- .../org/sonar/db/measure/MeasureTesting.java | 14 +- .../db/version/MigrationStepModuleTest.java | 2 +- .../PopulateUuidPathColumnOnProjectsTest.java | 157 +++++ .../ComponentDaoTest/delete-result.xml | 66 +- .../db/component/ComponentDaoTest/delete.xml | 90 ++- .../ComponentDaoTest/insert-result.xml | 29 +- .../insert_disabled_component-result.xml | 28 +- .../ComponentDaoTest/multi-modules.xml | 181 +++++- .../select_ghost_projects.xml | 217 +++++-- .../select_module_files_tree.xml | 155 ++++- .../select_provisioned_projects.xml | 332 ++++++++--- .../db/component/ComponentDaoTest/shared.xml | 309 ++++++++-- .../ComponentDaoTest/shared_views.xml | 146 ++++- .../ComponentDaoTest/update-result.xml | 29 +- .../db/component/ComponentDaoTest/update.xml | 29 +- .../schema.sql | 1 + ...g-ghost-projects-and-technical-project.xml | 466 +++++++++++---- .../db/component/ResourceDaoTest/fixture.xml | 245 ++++++-- .../get_last_snapshot_by_component_uuid.xml | 277 +++++++-- .../update_authorization_date-result.xml | 23 +- .../update_authorization_date.xml | 23 +- ...s_from_query_and_view_or_sub_view_uuid.xml | 196 +++++- .../shouldIndexMultiModulesProject-result.xml | 265 +++++++-- .../shouldIndexMultiModulesProject.xml | 83 ++- .../shouldIndexProjects-result.xml | 183 +++++- .../shouldIndexProjects.xml | 77 ++- .../shouldNotIndexPackages.xml | 65 +- ...shouldReIndexNewTwoLettersLongResource.xml | 53 +- .../shouldReIndexTwoLettersLongResource.xml | 29 +- ...ouldReindexProjectAfterRenaming-result.xml | 103 +++- .../shouldReindexProjectAfterRenaming.xml | 53 +- .../ResourceKeyUpdaterDaoTest/shared.xml | 176 ++++-- .../shouldBulkUpdateKey-result.xml | 189 ++++-- ...BulkUpdateKeyOnOnlyOneSubmodule-result.xml | 190 ++++-- .../shouldNotUpdateAllSubmodules-result.xml | 150 ++++- .../shouldNotUpdateAllSubmodules.xml | 149 ++++- .../shouldUpdateKey-result.xml | 174 ++++-- .../has_last_snapshot_by_component_uuid.xml | 80 ++- .../select_previous_version_snapshots.xml | 1 + .../select_snapshots_by_query.xml | 310 +++++++--- .../DuplicationDaoTest/insert-result.xml | 8 +- .../duplication/DuplicationDaoTest/insert.xml | 9 +- .../DuplicationDaoTest/select_candidates.xml | 6 + .../sonar/db/issue/IssueDaoTest/shared.xml | 101 +++- .../measure/MeasureDaoTest/past_measures.xml | 192 ++++-- .../past_measures_with_person_id.xml | 60 +- .../select_by_snapshot_and_metric_keys.xml | 71 ++- .../db/measure/MeasureDaoTest/shared.xml | 60 +- .../with_some_measures_for_developer.xml | 140 ++++- .../apply_default_permission_template.xml | 118 +++- ...lt_permission_template_by_component_id.xml | 100 +++- .../should_add_user_permission.xml | 31 +- .../should_apply_permission_template.xml | 86 ++- .../should_delete_group_permission-result.xml | 28 +- .../should_delete_group_permission.xml | 33 +- .../should_delete_user_permission-result.xml | 31 +- .../should_delete_user_permission.xml | 36 +- ..._insert_anyone_group_permission-result.xml | 33 +- .../should_insert_anyone_group_permission.xml | 28 +- .../should_insert_group_permission-result.xml | 33 +- .../should_insert_group_permission.xml | 28 +- .../delete_project_property-result.xml | 51 +- .../delete_project_property.xml | 60 +- .../findNotificationSubscribers.xml | 10 +- .../selectProjectProperties.xml | 60 +- .../selectProjectPropertiesByResourceId.xml | 57 +- .../select_module_properties_tree.xml | 165 +++-- .../shouldFindUsersForNotification.xml | 12 +- .../shouldDeleteResource.xml | 1 + ...ete_file_sources_of_disabled_resources.xml | 311 +++++++--- ...t_in_ce_activity_when_deleting_project.xml | 23 +- ...resources_without_last_snapshot-result.xml | 299 ++++++++-- ...isable_resources_without_last_snapshot.xml | 294 +++++++-- .../shouldDeleteAbortedBuilds-result.xml | 97 ++- .../shouldDeleteAbortedBuilds.xml | 135 ++++- ...oricalDataOfDirectoriesAndFiles-result.xml | 228 +++++-- ...eteHistoricalDataOfDirectoriesAndFiles.xml | 304 +++++++--- .../PurgeDaoTest/shouldDeleteProject.xml | 289 +++++++-- .../shouldPurgeProject-result.xml | 139 ++++- .../purge/PurgeDaoTest/shouldPurgeProject.xml | 139 ++++- ...should_delete_all_closed_issues-result.xml | 138 ++++- .../should_delete_all_closed_issues.xml | 243 ++++++-- ...should_delete_old_closed_issues-result.xml | 178 ++++-- .../should_delete_old_closed_issues.xml | 243 ++++++-- .../view_sub_view_and_tech_project.xml | 92 ++- .../ProjectQgateAssociationDaoTest/shared.xml | 216 ++++++- .../QualityProfileDaoTest/projects.xml | 66 +- .../add_missing_module_uuid_path-result.xml | 30 +- .../shouldInsertAuthorAndDeveloper-result.xml | 15 +- ...AuthorsAndDevelopersDuplication-result.xml | 15 +- ...PreventAuthorsAndDevelopersDuplication.xml | 15 +- .../anonymous_should_be_authorized.xml | 53 +- .../group_should_be_authorized.xml | 53 +- ...ed_component_key_for_global_permission.xml | 46 +- ...p_authorized_project_ids_for_anonymous.xml | 29 +- .../keep_authorized_project_ids_for_group.xml | 29 +- .../keep_authorized_project_ids_for_user.xml | 26 +- ...ers_for_role_and_project_for_anonymous.xml | 48 +- ...d_users_for_role_and_project_for_group.xml | 48 +- ...ed_users_for_role_and_project_for_user.xml | 42 +- ...return_root_project_keys_for_anonymous.xml | 50 +- ...uld_return_root_project_keys_for_group.xml | 50 +- ...ould_return_root_project_keys_for_user.xml | 50 +- .../user_should_be_authorized.xml | 32 +- .../in_progress_projects_and_snapshots.sql | 58 ++ .../measure/ComponentTreeWsRequest.java | 3 +- 198 files changed, 13201 insertions(+), 4005 deletions(-) delete mode 100644 server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowData.java delete mode 100644 server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowDataTest.java create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1255_add_uuid_path_column_to_projects.rb create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1256_populate_uuid_path_column_on_projects.rb create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1257_make_uuid_path_column_not_null_on_projects.rb create mode 100644 sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java create mode 100644 sonar-db/src/main/java/org/sonar/db/version/v60/AddUuidPathColumnToProjects.java create mode 100644 sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidPathColumnNotNullOnProjects.java create mode 100644 sonar-db/src/main/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjects.java create mode 100644 sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java create mode 100644 sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql diff --git a/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java b/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java index c48b11d6380..7135aa77f30 100644 --- a/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java +++ b/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java @@ -20,7 +20,7 @@ package it.sourceCode; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.ClassRule; @@ -58,7 +58,7 @@ public class ProjectCodeTest { private void executeBuild(String projectLocation, String projectKey, String projectName) { orchestrator.executeBuild( - SonarRunner.create(projectDir(projectLocation)) + SonarScanner.create(projectDir(projectLocation)) .setProjectKey(projectKey) .setProjectName(projectName) ); diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java index 5af8eddb220..a6099d8d04c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java @@ -185,9 +185,10 @@ public class ComponentService { String uuid = Uuids.create(); ComponentDto component = new ComponentDto() .setUuid(uuid) + .setUuidPath(ComponentDto.UUID_PATH_OF_ROOT) .setRootUuid(uuid) .setModuleUuid(null) - .setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP + uuid + ComponentDto.MODULE_UUID_PATH_SEP) + .setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + uuid + ComponentDto.UUID_PATH_SEPARATOR) .setProjectUuid(uuid) .setKey(keyWithBranch) .setDeprecatedKey(keyWithBranch) diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java index 6e8c9c09506..0aa142e7fbe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java @@ -28,7 +28,6 @@ import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.SnapshotDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.component.ComponentFinder.ParamNames; import org.sonar.server.user.UserSession; @@ -37,7 +36,6 @@ import org.sonarqube.ws.client.component.ShowWsRequest; import static com.google.common.base.MoreObjects.firstNonNull; import static java.lang.String.format; -import static java.util.Collections.emptyList; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.server.component.ws.ComponentDtoToWsComponent.componentDtoToWsComponent; import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; @@ -96,28 +94,21 @@ public class ShowAction implements ComponentsWsAction { DbSession dbSession = dbClient.openSession(false); try { ComponentDto component = getComponentByUuidOrKey(dbSession, request); - SnapshotDto lastSnapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, component.uuid()); - List orderedAncestors = emptyList(); - if (lastSnapshot != null) { - ShowData.Builder showDataBuilder = ShowData.builder(lastSnapshot); - List ancestorsSnapshots = dbClient.snapshotDao().selectByIds(dbSession, showDataBuilder.getOrderedSnapshotIds()); - showDataBuilder.withAncestorsSnapshots(ancestorsSnapshots); - List ancestorComponents = dbClient.componentDao().selectByUuids(dbSession, showDataBuilder.getOrderedComponentUuids()); - ShowData showData = showDataBuilder.andAncestorComponents(ancestorComponents); - orderedAncestors = showData.getComponents(); - } - - return buildResponse(component, orderedAncestors); + List ancestors = dbClient.componentDao().selectAncestors(dbSession, component); + return buildResponse(component, ancestors); } finally { dbClient.closeSession(dbSession); } } - private static ShowWsResponse buildResponse(ComponentDto component, List orderedAncestorComponents) { + private static ShowWsResponse buildResponse(ComponentDto component, List orderedAncestors) { ShowWsResponse.Builder response = ShowWsResponse.newBuilder(); response.setComponent(componentDtoToWsComponent(component)); - for (ComponentDto ancestor : orderedAncestorComponents) { + // ancestors are ordered from root to leaf, whereas it's the opposite + // in WS response + for (int i = orderedAncestors.size() - 1; i >= 0; i--) { + ComponentDto ancestor = orderedAncestors.get(i); response.addAncestors(componentDtoToWsComponent(ancestor)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowData.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowData.java deleted file mode 100644 index 9b090941d4a..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowData.java +++ /dev/null @@ -1,104 +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.server.component.ws; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import java.util.Collections; -import java.util.List; -import javax.annotation.Nonnull; -import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ComponentDtoFunctions; -import org.sonar.db.component.SnapshotDto; -import org.sonar.db.component.SnapshotDtoFunctions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -class ShowData { - private final List components; - - private ShowData(List components) { - this.components = components; - } - - static Builder builder(SnapshotDto snapshot) { - return new Builder(snapshot); - } - - List getComponents() { - return components; - } - - static class Builder { - private Ordering snapshotOrdering; - private List orderedSnapshotIds; - private List orderedComponentUuids; - - private Builder(SnapshotDto snapshot) { - List orderedSnapshotIdsAsString = snapshot.getPath() == null ? Collections.emptyList() : Splitter.on(".").omitEmptyStrings().splitToList(snapshot.getPath()); - orderedSnapshotIds = Lists.transform(orderedSnapshotIdsAsString, StringToLongFunction.INSTANCE); - snapshotOrdering = Ordering - .explicit(orderedSnapshotIds) - .onResultOf(SnapshotDtoFunctions.toId()) - .reverse(); - } - - Builder withAncestorsSnapshots(List ancestorsSnapshots) { - checkNotNull(snapshotOrdering, "Snapshot must be set before the ancestors"); - checkState(orderedSnapshotIds.size() == ancestorsSnapshots.size(), "Missing ancestor"); - - orderedComponentUuids = Lists.transform( - snapshotOrdering.immutableSortedCopy(ancestorsSnapshots), - SnapshotDtoFunctions.toComponentUuid()); - - return this; - } - - ShowData andAncestorComponents(List ancestorComponents) { - checkNotNull(orderedComponentUuids, "Snapshot ancestors must be set before the component ancestors"); - checkState(orderedComponentUuids.size() == ancestorComponents.size(), "Missing ancestor"); - - return new ShowData(Ordering - .explicit(orderedComponentUuids) - .onResultOf(ComponentDtoFunctions.toUuid()) - .immutableSortedCopy(ancestorComponents)); - } - - List getOrderedSnapshotIds() { - return orderedSnapshotIds; - } - - List getOrderedComponentUuids() { - return orderedComponentUuids; - } - } - - private enum StringToLongFunction implements Function { - INSTANCE; - - @Override - public Long apply(@Nonnull String input) { - return Long.parseLong(input); - } - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java index 41225d4d5c2..7e46b87b2b4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -23,7 +23,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -40,9 +39,7 @@ import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ComponentDtoWithSnapshotId; import org.sonar.db.component.ComponentTreeQuery; -import org.sonar.db.component.SnapshotDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.user.UserSession; import org.sonarqube.ws.WsComponents.TreeWsResponse; @@ -155,28 +152,24 @@ public class TreeAction implements ComponentsWsAction { try { ComponentDto baseComponent = componentFinder.getByUuidOrKey(dbSession, treeWsRequest.getBaseComponentId(), treeWsRequest.getBaseComponentKey(), BASE_COMPONENT_ID_AND_KEY); checkPermissions(baseComponent); - SnapshotDto baseSnapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, baseComponent.uuid()); - if (baseSnapshot == null) { - return emptyResponse(baseComponent, treeWsRequest); - } - ComponentTreeQuery query = toComponentTreeQuery(treeWsRequest, baseSnapshot); - List components; + ComponentTreeQuery query = toComponentTreeQuery(treeWsRequest, baseComponent); + List components; int total; switch (treeWsRequest.getStrategy()) { case CHILDREN_STRATEGY: - components = dbClient.componentDao().selectDirectChildren(dbSession, query); - total = dbClient.componentDao().countDirectChildren(dbSession, query); + components = dbClient.componentDao().selectChildren(dbSession, query); + total = dbClient.componentDao().countChildren(dbSession, query); break; case LEAVES_STRATEGY: case ALL_STRATEGY: - components = dbClient.componentDao().selectAllChildren(dbSession, query); - total = dbClient.componentDao().countAllChildren(dbSession, query); + components = dbClient.componentDao().selectDescendants(dbSession, query); + total = dbClient.componentDao().countDescendants(dbSession, query); break; default: throw new IllegalStateException("Unknown component tree strategy"); } - Map referenceComponentsByUuid = searchreferenceComponentsByUuid(dbSession, components); + Map referenceComponentsByUuid = searchReferenceComponentsByUuid(dbSession, components); return buildResponse(baseComponent, components, referenceComponentsByUuid, Paging.forPageIndex(query.getPage()).withPageSize(query.getPageSize()).andTotal(total)); @@ -185,10 +178,10 @@ public class TreeAction implements ComponentsWsAction { } } - private Map searchreferenceComponentsByUuid(DbSession dbSession, List components) { + private Map searchReferenceComponentsByUuid(DbSession dbSession, List components) { List referenceComponentIds = from(components) .transform(ComponentDto::getCopyResourceUuid) - .filter(Predicates.notNull()) + .filter(Predicates.notNull()) .toList(); if (referenceComponentIds.isEmpty()) { return emptyMap(); @@ -207,7 +200,7 @@ public class TreeAction implements ComponentsWsAction { } } - private static TreeWsResponse buildResponse(ComponentDto baseComponent, List components, + private static TreeWsResponse buildResponse(ComponentDto baseComponent, List components, Map referenceComponentsByUuid, Paging paging) { TreeWsResponse.Builder response = TreeWsResponse.newBuilder(); response.getPagingBuilder() @@ -224,22 +217,11 @@ public class TreeAction implements ComponentsWsAction { return response.build(); } - private static TreeWsResponse emptyResponse(ComponentDto baseComponent, TreeWsRequest request) { - TreeWsResponse.Builder response = TreeWsResponse.newBuilder(); - response.getPagingBuilder() - .setTotal(0) - .setPageIndex(request.getPage()) - .setPageSize(request.getPageSize()); - response.setBaseComponent(componentDtoToWsComponent(baseComponent, Collections.emptyMap())); - - return response.build(); - } - - private ComponentTreeQuery toComponentTreeQuery(TreeWsRequest request, SnapshotDto baseSnapshot) { - List childrenQualifiers = childrenQualifiers(request, baseSnapshot.getQualifier()); + private ComponentTreeQuery toComponentTreeQuery(TreeWsRequest request, ComponentDto baseComponent) { + List childrenQualifiers = childrenQualifiers(request, baseComponent.qualifier()); ComponentTreeQuery.Builder query = ComponentTreeQuery.builder() - .setBaseSnapshot(baseSnapshot) + .setBaseUuid(baseComponent.uuid()) .setPage(request.getPage()) .setPageSize(request.getPageSize()) .setSortFields(request.getSort()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java index d0750fd8814..cafbab7ced6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/filemove/FileMoveDetectionStep.java @@ -44,7 +44,6 @@ import org.sonar.core.util.CloseableIterator; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentTreeQuery; -import org.sonar.db.component.SnapshotDto; import org.sonar.db.source.FileSourceDto; import org.sonar.server.computation.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.component.Component; @@ -101,7 +100,7 @@ public class FileMoveDetectionStep implements ComputationStep { return; } - Map dbFilesByKey = getDbFilesByKey(baseProjectSnapshot); + Map dbFilesByKey = getDbFilesByKey(); if (dbFilesByKey.isEmpty()) { LOG.debug("Previous snapshot has no file. Do nothing."); return; @@ -151,15 +150,13 @@ public class FileMoveDetectionStep implements ComputationStep { } } - private Map getDbFilesByKey(Snapshot baseProjectSnapshot) { + private Map getDbFilesByKey() { try (DbSession dbSession = dbClient.openSession(false)) { // FIXME no need to use such a complex query, joining on SNAPSHOTS and retrieving all column of table PROJECTS, replace with dedicated mapper method - return from(dbClient.componentDao().selectAllChildren( + return from(dbClient.componentDao().selectDescendants( dbSession, ComponentTreeQuery.builder() - .setBaseSnapshot(new SnapshotDto() - .setId(baseProjectSnapshot.getId()) - .setRootId(baseProjectSnapshot.getId())) + .setBaseUuid(rootHolder.getRoot().getUuid()) .setQualifiers(FILE_QUALIFIERS) .setSortFields(SORT_FIELDS) .setPageSize(Integer.MAX_VALUE) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java index 823361a13a8..5ea98a188db 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java @@ -42,7 +42,8 @@ import org.sonar.server.computation.component.PathAwareVisitorAdapter; import org.sonar.server.computation.component.TreeRootHolder; import static com.google.common.collect.FluentIterable.from; -import static org.sonar.db.component.ComponentDto.MODULE_UUID_PATH_SEP; +import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR; +import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent; import static org.sonar.db.component.ComponentDtoFunctions.toKey; import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER; @@ -193,7 +194,8 @@ public class PersistComponentsStep implements ComputationStep { res.setDescription(project.getDescription()); res.setProjectUuid(res.uuid()); res.setRootUuid(res.uuid()); - res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); + res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT); + res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR); return res; } @@ -252,7 +254,8 @@ public class PersistComponentsStep implements ComputationStep { res.setLongName(res.name()); res.setProjectUuid(res.uuid()); res.setRootUuid(res.uuid()); - res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); + res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT); + res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR); return res; } @@ -307,8 +310,9 @@ public class PersistComponentsStep implements ComputationStep { res.setProjectUuid(projectDto.uuid()); ComponentDto parentModule = path.parent().getDto(); + res.setUuidPath(formatUuidPathFromParent(parentModule)); res.setModuleUuid(parentModule.uuid()); - res.setModuleUuidPath(parentModule.moduleUuidPath() + res.uuid() + MODULE_UUID_PATH_SEP); + res.setModuleUuidPath(parentModule.moduleUuidPath() + res.uuid() + UUID_PATH_SEPARATOR); } /** @@ -320,6 +324,7 @@ public class PersistComponentsStep implements ComputationStep { .first() .get() .getElement().getDto(); + componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto())); componentDto.setRootUuid(parentModule.uuid()); componentDto.setProjectUuid(parentModule.projectUuid()); componentDto.setModuleUuid(parentModule.uuid()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeData.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeData.java index 78e779e4ff3..7c88b41a155 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeData.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import javax.annotation.CheckForNull; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ComponentDtoWithSnapshotId; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; import org.sonarqube.ws.WsMeasures; @@ -33,7 +32,7 @@ import static java.util.Objects.requireNonNull; class ComponentTreeData { private final ComponentDto baseComponent; - private final List components; + private final List components; private final int componentCount; private final Map referenceComponentsByUuid; private final List metrics; @@ -55,7 +54,7 @@ class ComponentTreeData { } @CheckForNull - List getComponents() { + List getComponents() { return components; } @@ -90,7 +89,7 @@ class ComponentTreeData { static class Builder { private ComponentDto baseComponent; - private List componentsFromDb; + private List componentsFromDb; private Map referenceComponentsByUuid; private int componentCount; private List metrics; @@ -106,7 +105,7 @@ class ComponentTreeData { return this; } - public Builder setComponentsFromDb(List componentsFromDbQuery) { + public Builder setComponentsFromDb(List componentsFromDbQuery) { this.componentsFromDb = componentsFromDbQuery; return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java index 4063539a8d3..cfaa7c25271 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java @@ -33,12 +33,12 @@ import com.google.common.collect.Sets; import com.google.common.collect.Table; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -48,10 +48,10 @@ import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ComponentDtoWithSnapshotId; import org.sonar.db.component.ComponentTreeQuery; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.MeasureDto; +import org.sonar.db.measure.MeasureQuery; import org.sonar.db.metric.MetricDto; import org.sonar.db.metric.MetricDtoFunctions; import org.sonar.server.component.ComponentFinder; @@ -102,7 +102,7 @@ public class ComponentTreeDataLoader { try { ComponentDto baseComponent = componentFinder.getByUuidOrKey(dbSession, wsRequest.getBaseComponentId(), wsRequest.getBaseComponentKey(), BASE_COMPONENT_ID_AND_KEY); checkPermissions(baseComponent); - SnapshotDto baseSnapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, baseComponent.uuid()); + SnapshotDto baseSnapshot = dbClient.snapshotDao().selectLastSnapshotByComponentUuid(dbSession, baseComponent.projectUuid()); if (baseSnapshot == null) { return ComponentTreeData.builder() .setBaseComponent(baseComponent) @@ -110,12 +110,12 @@ public class ComponentTreeDataLoader { } Long developerId = searchDeveloperId(dbSession, wsRequest); - ComponentTreeQuery dbQuery = toComponentTreeQuery(wsRequest, baseSnapshot); + ComponentTreeQuery dbQuery = toComponentTreeQuery(wsRequest, baseComponent); ComponentDtosAndTotal componentDtosAndTotal = searchComponents(dbSession, dbQuery, wsRequest); - List components = componentDtosAndTotal.componentDtos; + List components = componentDtosAndTotal.componentDtos; List metrics = searchMetrics(dbSession, wsRequest); List periods = snapshotToWsPeriods(baseSnapshot); - Table measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, baseSnapshot, components, metrics, + Table measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, components, metrics, periods, developerId); components = filterComponents(components, measuresByComponentUuidAndMetric, metrics, wsRequest); @@ -138,7 +138,7 @@ public class ComponentTreeDataLoader { } } - private static int computeComponentCount(int dbComponentCount, List components, boolean returnOnlyComponentsWithMeasures) { + private static int computeComponentCount(int dbComponentCount, List components, boolean returnOnlyComponentsWithMeasures) { return returnOnlyComponentsWithMeasures ? components.size() : dbComponentCount; } @@ -151,7 +151,7 @@ public class ComponentTreeDataLoader { return componentFinder.getByUuidOrKey(dbSession, wsRequest.getDeveloperId(), wsRequest.getDeveloperKey(), DEVELOPER_ID_AND_KEY).getId(); } - private Map searchReferenceComponentsById(DbSession dbSession, List components) { + private Map searchReferenceComponentsById(DbSession dbSession, List components) { List referenceComponentUUids = from(components) .transform(ComponentDto::getCopyResourceUuid) .filter(Predicates.notNull()) @@ -166,19 +166,19 @@ public class ComponentTreeDataLoader { private ComponentDtosAndTotal searchComponents(DbSession dbSession, ComponentTreeQuery dbQuery, ComponentTreeWsRequest wsRequest) { if (dbQuery.getQualifiers() != null && dbQuery.getQualifiers().isEmpty()) { - return new ComponentDtosAndTotal(Collections.emptyList(), 0); + return new ComponentDtosAndTotal(Collections.emptyList(), 0); } String strategy = requireNonNull(wsRequest.getStrategy()); switch (strategy) { case CHILDREN_STRATEGY: return new ComponentDtosAndTotal( - dbClient.componentDao().selectDirectChildren(dbSession, dbQuery), - dbClient.componentDao().countDirectChildren(dbSession, dbQuery)); + dbClient.componentDao().selectChildren(dbSession, dbQuery), + dbClient.componentDao().countChildren(dbSession, dbQuery)); case LEAVES_STRATEGY: case ALL_STRATEGY: return new ComponentDtosAndTotal( - dbClient.componentDao().selectAllChildren(dbSession, dbQuery), - dbClient.componentDao().countAllChildren(dbSession, dbQuery)); + dbClient.componentDao().selectDescendants(dbSession, dbQuery), + dbClient.componentDao().countDescendants(dbSession, dbQuery)); default: throw new IllegalStateException("Unknown component tree strategy"); } @@ -199,25 +199,25 @@ public class ComponentTreeDataLoader { return metrics; } - private Table searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent, SnapshotDto baseSnapshot, - List components, List metrics, + private Table searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent, + List components, List metrics, List periods, @Nullable Long developerId) { - Map componentsBySnapshotId = new HashMap<>(); - componentsBySnapshotId.put(baseSnapshot.getId(), baseComponent); - for (ComponentDtoWithSnapshotId component : components) { - componentsBySnapshotId.put(component.getSnapshotId(), component); - } + List componentUuids = new ArrayList<>(); + componentUuids.add(baseComponent.uuid()); + components.stream().forEach(c -> componentUuids.add(c.uuid())); Map metricsById = Maps.uniqueIndex(metrics, MetricDtoFunctions.toId()); - List measureDtos = dbClient.measureDao().selectByDeveloperAndSnapshotIdsAndMetricIds(dbSession, - developerId, - new ArrayList<>(componentsBySnapshotId.keySet()), - new ArrayList<>(metricsById.keySet())); + MeasureQuery measureQuery = new MeasureQuery.Builder() + .setPersonId(developerId) + .setComponentUuids(componentUuids) + .setMetricIds(metricsById.keySet()) + .build(); + List measureDtos = dbClient.measureDao().selectByQuery(dbSession, measureQuery); Table measuresByComponentUuidAndMetric = HashBasedTable.create(components.size(), metrics.size()); for (MeasureDto measureDto : measureDtos) { measuresByComponentUuidAndMetric.put( - componentsBySnapshotId.get(measureDto.getSnapshotId()).uuid(), + measureDto.getComponentUuid(), metricsById.get(measureDto.getMetricId()), measureDto); } @@ -234,7 +234,7 @@ public class ComponentTreeDataLoader { *
  • metric is optimized for best value
  • * */ - private static void addBestValuesToMeasures(Table measuresByComponentUuidAndMetric, List components, + private static void addBestValuesToMeasures(Table measuresByComponentUuidAndMetric, List components, List metrics, List periods) { List metricDtosWithBestValueMeasure = from(metrics) .filter(MetricDtoFunctions.isOptimizedForBestValue()) @@ -244,8 +244,8 @@ public class ComponentTreeDataLoader { return; } - List componentsEligibleForBestValue = from(components).filter(IsFileComponent.INSTANCE).toList(); - for (ComponentDtoWithSnapshotId component : componentsEligibleForBestValue) { + List componentsEligibleForBestValue = from(components).filter(IsFileComponent.INSTANCE).toList(); + for (ComponentDto component : componentsEligibleForBestValue) { for (MetricDtoWithBestValue metricWithBestValue : metricDtosWithBestValueMeasure) { if (measuresByComponentUuidAndMetric.get(component.uuid(), metricWithBestValue.getMetric()) == null) { measuresByComponentUuidAndMetric.put(component.uuid(), metricWithBestValue.getMetric(), metricWithBestValue.getBestValue()); @@ -254,7 +254,7 @@ public class ComponentTreeDataLoader { } } - private static List filterComponents(List components, + private static List filterComponents(List components, Table measuresByComponentUuidAndMetric, List metrics, ComponentTreeWsRequest wsRequest) { if (!componentWithMeasuresOnly(wsRequest)) { return components; @@ -264,16 +264,17 @@ public class ComponentTreeDataLoader { Optional metricToSort = from(metrics).firstMatch(new MatchMetricKey(metricKeyToSort)); checkState(metricToSort.isPresent(), "Metric '%s' not found", metricKeyToSort, wsRequest.getMetricKeys()); - return from(components) + return components + .stream() .filter(new HasMeasure(measuresByComponentUuidAndMetric, metricToSort.get(), wsRequest)) - .toList(); + .collect(Collectors.toList()); } private static boolean componentWithMeasuresOnly(ComponentTreeWsRequest wsRequest) { return WITH_MEASURES_ONLY_METRIC_SORT_FILTER.equals(wsRequest.getMetricSortFilter()); } - private static List sortComponents(List components, ComponentTreeWsRequest wsRequest, List metrics, + private static List sortComponents(List components, ComponentTreeWsRequest wsRequest, List metrics, Table measuresByComponentUuidAndMetric) { if (!isSortByMetric(wsRequest)) { return components; @@ -282,7 +283,7 @@ public class ComponentTreeDataLoader { return ComponentTreeSort.sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric); } - private static List paginateComponents(List components, ComponentTreeWsRequest wsRequest) { + private static List paginateComponents(List components, ComponentTreeWsRequest wsRequest) { if (!isSortByMetric(wsRequest)) { return components; } @@ -319,14 +320,14 @@ public class ComponentTreeDataLoader { return new ArrayList<>(qualifiersIntersection); } - private ComponentTreeQuery toComponentTreeQuery(ComponentTreeWsRequest wsRequest, SnapshotDto baseSnapshot) { - List childrenQualifiers = childrenQualifiers(wsRequest, baseSnapshot.getQualifier()); + private ComponentTreeQuery toComponentTreeQuery(ComponentTreeWsRequest wsRequest, ComponentDto baseComponent) { + List childrenQualifiers = childrenQualifiers(wsRequest, baseComponent.qualifier()); List sortsWithoutMetricSort = newArrayList(Iterables.filter(wsRequest.getSort(), IsNotMetricSort.INSTANCE)); sortsWithoutMetricSort = sortsWithoutMetricSort.isEmpty() ? singletonList(NAME_SORT) : sortsWithoutMetricSort; ComponentTreeQuery.Builder dbQuery = ComponentTreeQuery.builder() - .setBaseSnapshot(baseSnapshot) + .setBaseUuid(baseComponent.uuid()) .setPage(wsRequest.getPage()) .setPageSize(wsRequest.getPageSize()) .setSortFields(sortsWithoutMetricSort) @@ -356,20 +357,20 @@ public class ComponentTreeDataLoader { } private static class ComponentDtosAndTotal { - private final List componentDtos; + private final List componentDtos; private final int total; - private ComponentDtosAndTotal(List componentDtos, int total) { + private ComponentDtosAndTotal(List componentDtos, int total) { this.componentDtos = componentDtos; this.total = total; } } - private enum IsFileComponent implements Predicate { + private enum IsFileComponent implements Predicate { INSTANCE; @Override - public boolean apply(@Nonnull ComponentDtoWithSnapshotId input) { + public boolean apply(@Nonnull ComponentDto input) { return QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE.contains(input.qualifier()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java index 8b2d4c831fe..a833af62fed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeSort.java @@ -32,7 +32,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.sonar.api.measures.Metric; import org.sonar.api.measures.Metric.ValueType; -import org.sonar.db.component.ComponentDtoWithSnapshotId; +import org.sonar.db.component.ComponentDto; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; import org.sonar.db.metric.MetricDtoFunctions; @@ -66,14 +66,14 @@ class ComponentTreeSort { // static method only } - static List sortComponents(List components, ComponentTreeWsRequest wsRequest, List metrics, + static List sortComponents(List components, ComponentTreeWsRequest wsRequest, List metrics, Table measuresByComponentUuidAndMetric) { List sortParameters = wsRequest.getSort(); if (sortParameters == null || sortParameters.isEmpty()) { return components; } boolean isAscending = wsRequest.getAsc(); - Map> orderingsBySortField = ImmutableMap.>builder() + Map> orderingsBySortField = ImmutableMap.>builder() .put(NAME_SORT, componentNameOrdering(isAscending)) .put(QUALIFIER_SORT, componentQualifierOrdering(isAscending)) .put(PATH_SORT, componentPathOrdering(isAscending)) @@ -82,11 +82,11 @@ class ComponentTreeSort { .build(); String firstSortParameter = sortParameters.get(0); - Ordering primaryOrdering = orderingsBySortField.get(firstSortParameter); + Ordering primaryOrdering = orderingsBySortField.get(firstSortParameter); if (sortParameters.size() > 1) { for (int i = 1; i < sortParameters.size(); i++) { String secondarySortParameter = sortParameters.get(i); - Ordering secondaryOrdering = orderingsBySortField.get(secondarySortParameter); + Ordering secondaryOrdering = orderingsBySortField.get(secondarySortParameter); primaryOrdering = primaryOrdering.compound(secondaryOrdering); } } @@ -94,19 +94,19 @@ class ComponentTreeSort { return primaryOrdering.immutableSortedCopy(components); } - private static Ordering componentNameOrdering(boolean isAscending) { - return stringOrdering(isAscending, ComponentDtoWithSnapshotIdToName.INSTANCE); + private static Ordering componentNameOrdering(boolean isAscending) { + return stringOrdering(isAscending, ComponentDtoToName.INSTANCE); } - private static Ordering componentQualifierOrdering(boolean isAscending) { - return stringOrdering(isAscending, ComponentDtoWithSnapshotIdToQualifier.INSTANCE); + private static Ordering componentQualifierOrdering(boolean isAscending) { + return stringOrdering(isAscending, ComponentDtoToQualifier.INSTANCE); } - private static Ordering componentPathOrdering(boolean isAscending) { - return stringOrdering(isAscending, ComponentDtoWithSnapshotIdToPath.INSTANCE); + private static Ordering componentPathOrdering(boolean isAscending) { + return stringOrdering(isAscending, ComponentDtoToPath.INSTANCE); } - private static Ordering stringOrdering(boolean isAscending, Function function) { + private static Ordering stringOrdering(boolean isAscending, Function function) { Ordering ordering = Ordering.from(CASE_INSENSITIVE_ORDER); if (!isAscending) { ordering = ordering.reverse(); @@ -115,7 +115,7 @@ class ComponentTreeSort { return ordering.nullsLast().onResultOf(function); } - private static Ordering metricValueOrdering(ComponentTreeWsRequest wsRequest, List metrics, + private static Ordering metricValueOrdering(ComponentTreeWsRequest wsRequest, List metrics, Table measuresByComponentUuidAndMetric) { if (wsRequest.getMetricSort() == null) { return componentNameOrdering(wsRequest.getAsc()); @@ -128,7 +128,7 @@ class ComponentTreeSort { if (NUMERIC_VALUE_TYPES.contains(metricValueType)) { return numericalMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } else if (TEXTUAL_VALUE_TYPES.contains(metricValueType)) { - return stringOrdering(isAscending, new ComponentDtoWithSnapshotIdToTextualMeasureValue(metric, measuresByComponentUuidAndMetric)); + return stringOrdering(isAscending, new ComponentDtoToTextualMeasureValue(metric, measuresByComponentUuidAndMetric)); } else if (ValueType.LEVEL.equals(ValueType.valueOf(metric.getValueType()))) { return levelMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } @@ -136,7 +136,7 @@ class ComponentTreeSort { throw new IllegalStateException("Unrecognized metric value type: " + metric.getValueType()); } - private static Ordering metricPeriodOrdering(ComponentTreeWsRequest wsRequest, List metrics, + private static Ordering metricPeriodOrdering(ComponentTreeWsRequest wsRequest, List metrics, Table measuresByComponentUuidAndMetric) { if (wsRequest.getMetricSort() == null || wsRequest.getMetricPeriodSort() == null) { return componentNameOrdering(wsRequest.getAsc()); @@ -152,7 +152,7 @@ class ComponentTreeSort { throw new BadRequestException(format("Impossible to sort metric '%s' by measure period.", metric.getKey())); } - private static Ordering numericalMetricOrdering(boolean isAscending, @Nullable MetricDto metric, + private static Ordering numericalMetricOrdering(boolean isAscending, @Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { Ordering ordering = Ordering.natural(); @@ -160,10 +160,10 @@ class ComponentTreeSort { ordering = ordering.reverse(); } - return ordering.nullsLast().onResultOf(new ComponentDtoWithSnapshotIdToNumericalMeasureValue(metric, measuresByComponentUuidAndMetric)); + return ordering.nullsLast().onResultOf(new ComponentDtoToNumericalMeasureValue(metric, measuresByComponentUuidAndMetric)); } - private static Ordering numericalMetricPeriodOrdering(ComponentTreeWsRequest request, @Nullable MetricDto metric, + private static Ordering numericalMetricPeriodOrdering(ComponentTreeWsRequest request, @Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { Ordering ordering = Ordering.natural(); @@ -171,10 +171,10 @@ class ComponentTreeSort { ordering = ordering.reverse(); } - return ordering.nullsLast().onResultOf(new ComponentDtoWithSnapshotIdToMeasureVariationValue(metric, measuresByComponentUuidAndMetric, request.getMetricPeriodSort())); + return ordering.nullsLast().onResultOf(new ComponentDtoToMeasureVariationValue(metric, measuresByComponentUuidAndMetric, request.getMetricPeriodSort())); } - private static Ordering levelMetricOrdering(boolean isAscending, @Nullable MetricDto metric, + private static Ordering levelMetricOrdering(boolean isAscending, @Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { Ordering ordering = Ordering.natural(); @@ -183,21 +183,21 @@ class ComponentTreeSort { ordering = ordering.reverse(); } - return ordering.nullsLast().onResultOf(new ComponentDtoWithSnapshotIdToLevelIndex(metric, measuresByComponentUuidAndMetric)); + return ordering.nullsLast().onResultOf(new ComponentDtoToLevelIndex(metric, measuresByComponentUuidAndMetric)); } - private static class ComponentDtoWithSnapshotIdToNumericalMeasureValue implements Function { + private static class ComponentDtoToNumericalMeasureValue implements Function { private final MetricDto metric; private final Table measuresByComponentUuidAndMetric; - private ComponentDtoWithSnapshotIdToNumericalMeasureValue(@Nullable MetricDto metric, + private ComponentDtoToNumericalMeasureValue(@Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { this.metric = metric; this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; } @Override - public Double apply(@Nonnull ComponentDtoWithSnapshotId input) { + public Double apply(@Nonnull ComponentDto input) { MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); if (measure == null || measure.getValue() == null) { return null; @@ -207,18 +207,18 @@ class ComponentTreeSort { } } - private static class ComponentDtoWithSnapshotIdToLevelIndex implements Function { + private static class ComponentDtoToLevelIndex implements Function { private final MetricDto metric; private final Table measuresByComponentUuidAndMetric; - private ComponentDtoWithSnapshotIdToLevelIndex(@Nullable MetricDto metric, + private ComponentDtoToLevelIndex(@Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { this.metric = metric; this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; } @Override - public Integer apply(@Nonnull ComponentDtoWithSnapshotId input) { + public Integer apply(@Nonnull ComponentDto input) { MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); if (measure == null || measure.getData() == null) { return null; @@ -228,12 +228,12 @@ class ComponentTreeSort { } } - private static class ComponentDtoWithSnapshotIdToMeasureVariationValue implements Function { + private static class ComponentDtoToMeasureVariationValue implements Function { private final MetricDto metric; private final Table measuresByComponentUuidAndMetric; private final int variationIndex; - private ComponentDtoWithSnapshotIdToMeasureVariationValue(@Nullable MetricDto metric, + private ComponentDtoToMeasureVariationValue(@Nullable MetricDto metric, Table measuresByComponentUuidAndMetric, int variationIndex) { this.metric = metric; this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; @@ -241,7 +241,7 @@ class ComponentTreeSort { } @Override - public Double apply(@Nonnull ComponentDtoWithSnapshotId input) { + public Double apply(@Nonnull ComponentDto input) { MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); if (measure == null || measure.getVariation(variationIndex) == null) { return null; @@ -251,18 +251,18 @@ class ComponentTreeSort { } } - private static class ComponentDtoWithSnapshotIdToTextualMeasureValue implements Function { + private static class ComponentDtoToTextualMeasureValue implements Function { private final MetricDto metric; private final Table measuresByComponentUuidAndMetric; - private ComponentDtoWithSnapshotIdToTextualMeasureValue(@Nullable MetricDto metric, + private ComponentDtoToTextualMeasureValue(@Nullable MetricDto metric, Table measuresByComponentUuidAndMetric) { this.metric = metric; this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; } @Override - public String apply(@Nonnull ComponentDtoWithSnapshotId input) { + public String apply(@Nonnull ComponentDto input) { MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); if (measure == null || measure.getData() == null) { return null; @@ -272,29 +272,29 @@ class ComponentTreeSort { } } - private enum ComponentDtoWithSnapshotIdToName implements Function { + private enum ComponentDtoToName implements Function { INSTANCE; @Override - public String apply(@Nonnull ComponentDtoWithSnapshotId input) { + public String apply(@Nonnull ComponentDto input) { return input.name(); } } - private enum ComponentDtoWithSnapshotIdToQualifier implements Function { + private enum ComponentDtoToQualifier implements Function { INSTANCE; @Override - public String apply(@Nonnull ComponentDtoWithSnapshotId input) { + public String apply(@Nonnull ComponentDto input) { return input.qualifier(); } } - private enum ComponentDtoWithSnapshotIdToPath implements Function { + private enum ComponentDtoToPath implements Function { INSTANCE; @Override - public String apply(@Nonnull ComponentDtoWithSnapshotId input) { + public String apply(@Nonnull ComponentDto input) { return input.path(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/HasMeasure.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/HasMeasure.java index ed029069d00..55638bdc746 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/HasMeasure.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/HasMeasure.java @@ -20,59 +20,59 @@ package org.sonar.server.measure.ws; -import com.google.common.base.Predicate; import com.google.common.collect.Table; +import java.util.function.Predicate; import javax.annotation.Nonnull; -import org.sonar.db.component.ComponentDtoWithSnapshotId; +import org.sonar.db.component.ComponentDto; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; import org.sonarqube.ws.client.measure.ComponentTreeWsRequest; -class HasMeasure implements Predicate { - private final Predicate predicate; +class HasMeasure implements Predicate { + private final Predicate predicate; - HasMeasure(Table measuresByComponentUuidAndMetric, MetricDto metric, ComponentTreeWsRequest request) { + HasMeasure(Table table, MetricDto metric, ComponentTreeWsRequest request) { Integer periodIndex = request.getMetricPeriodSort(); this.predicate = periodIndex == null - ? new HasAbsoluteValue(measuresByComponentUuidAndMetric, metric) - : new HasValueOnPeriod(periodIndex, measuresByComponentUuidAndMetric, metric); + ? new HasAbsoluteValue(table, metric) + : new HasValueOnPeriod(periodIndex, table, metric); } @Override - public boolean apply(@Nonnull ComponentDtoWithSnapshotId input) { - return predicate.apply(input); + public boolean test(@Nonnull ComponentDto input) { + return predicate.test(input); } - private static class HasAbsoluteValue implements Predicate { - private final Table measuresByComponentUuidAndMetric; + private static class HasAbsoluteValue implements Predicate { + private final Table table; private final MetricDto metric; - private HasAbsoluteValue(Table measuresByComponentUuidAndMetric, MetricDto metric) { - this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; + private HasAbsoluteValue(Table table, MetricDto metric) { + this.table = table; this.metric = metric; } @Override - public boolean apply(@Nonnull ComponentDtoWithSnapshotId input) { - MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); + public boolean test(@Nonnull ComponentDto input) { + MeasureDto measure = table.get(input.uuid(), metric); return measure != null && (measure.getValue() != null || measure.getData() != null); } } - private static class HasValueOnPeriod implements Predicate { + private static class HasValueOnPeriod implements Predicate { private final int periodIndex; - private final Table measuresByComponentUuidAndMetric; + private final Table table; private final MetricDto metric; - private HasValueOnPeriod(int periodIndex, Table measuresByComponentUuidAndMetric, MetricDto metric) { + private HasValueOnPeriod(int periodIndex, Table table, MetricDto metric) { this.periodIndex = periodIndex; - this.measuresByComponentUuidAndMetric = measuresByComponentUuidAndMetric; + this.table = table; this.metric = metric; } @Override - public boolean apply(@Nonnull ComponentDtoWithSnapshotId input) { - MeasureDto measure = measuresByComponentUuidAndMetric.get(input.uuid(), metric); + public boolean test(@Nonnull ComponentDto input) { + MeasureDto measure = table.get(input.uuid(), metric); return measure != null && measure.getVariation(periodIndex) != null; } } diff --git a/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java b/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java index 96b87788136..cc75f377a9d 100644 --- a/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java @@ -35,6 +35,7 @@ import org.sonar.db.ce.CeActivityDto; import org.sonar.db.ce.CeQueueDto; import org.sonar.db.ce.CeTaskTypes; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; @@ -69,7 +70,7 @@ public class CeQueueImplTest { @Test public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() { - ComponentDto componentDto = insertComponent(newComponentDto("PROJECT_1")); + ComponentDto componentDto = insertComponent(ComponentTesting.newProjectDto("PROJECT_1")); CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto.uuid(), null); CeTask task = underTest.submit(taskSubmit); @@ -112,7 +113,7 @@ public class CeQueueImplTest { @Test public void massSubmit_populates_component_name_and_key_of_CeTask_if_component_exists() { - ComponentDto componentDto1 = insertComponent(newComponentDto("PROJECT_1")); + ComponentDto componentDto1 = insertComponent(ComponentTesting.newProjectDto("PROJECT_1")); CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, componentDto1.uuid(), null); CeTaskSubmit taskSubmit2 = createTaskSubmit("something", "non existing component uuid", null); @@ -206,10 +207,6 @@ public class CeQueueImplTest { assertThat(queueDto.get().getCreatedAt()).isEqualTo(1_450_000_000_000L); } - private static ComponentDto newComponentDto(String uuid) { - return new ComponentDto().setUuid(uuid).setRootUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); - } - private CeTask submit(String reportType, String componentUuid) { return underTest.submit(createTaskSubmit(reportType, componentUuid, null)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java index 7ff44abc27d..25322f643e9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java @@ -98,7 +98,13 @@ public class ProjectDataLoaderTest { String qualifier = scopeAndQualifier[1]; String key = "theKey_" + scope + "_" + qualifier; String uuid = "uuid_" + uuidCounter++; - dbClient.componentDao().insert(dbSession, new ComponentDto().setUuid(uuid).setRootUuid(uuid).setScope(scope).setQualifier(qualifier).setKey(key)); + dbClient.componentDao().insert(dbSession, new ComponentDto() + .setUuid(uuid) + .setUuidPath(uuid + ".") + .setRootUuid(uuid) + .setScope(scope) + .setQualifier(qualifier) + .setKey(key)); dbSession.commit(); try { diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java index a5a71be90a2..0ed28fb9c58 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java @@ -26,7 +26,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; -import org.sonar.api.resources.Qualifiers; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; import org.sonar.ce.log.CeLogging; @@ -35,7 +34,7 @@ import org.sonar.db.DbTester; import org.sonar.db.ce.CeActivityDto; import org.sonar.db.ce.CeQueueDto; import org.sonar.db.ce.CeTaskTypes; -import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import org.sonarqube.ws.WsCe; import static java.util.Arrays.asList; @@ -86,8 +85,8 @@ public class TaskFormatterTest { public void formatQueue_with_component_and_other_fields() throws IOException { when(ceLogging.getFile(any(LogFileRef.class))).thenReturn(Optional.of(temp.newFile())); String uuid = "COMPONENT_UUID"; - db.getDbClient().componentDao().insert(db.getSession(), new ComponentDto() - .setUuid(uuid).setRootUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name").setQualifier(Qualifiers.PROJECT)); + db.getDbClient().componentDao().insert(db.getSession(), + ComponentTesting.newProjectDto(uuid).setKey("COMPONENT_KEY").setName("Component Name")); CeQueueDto dto = new CeQueueDto(); dto.setUuid("UUID"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java index 054cd0c1b59..0aa8c3d09b8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceTest.java @@ -81,33 +81,33 @@ public class ComponentServiceTest { @Test public void get_by_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); assertThat(service.getByKey(project.getKey())).isNotNull(); } @Test public void get_nullable_by_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); assertThat(service.getNullableByKey(project.getKey())).isNotNull(); assertThat(service.getNullableByKey("unknown")).isNull(); } @Test public void get_by_uuid() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); assertThat(service.getNonNullByUuid(project.uuid())).isNotNull(); } @Test public void get_nullable_by_uuid() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); assertThat(service.getByUuid(project.uuid())).isPresent(); assertThat(service.getByUuid("unknown")).isAbsent(); } @Test public void update_project_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); ComponentDto file = ComponentTesting.newFileDto(project).setKey("sample:root:src/File.xoo"); dbClient.componentDao().insert(session, file); @@ -128,7 +128,7 @@ public class ComponentServiceTest { @Test public void update_module_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module"); dbClient.componentDao().insert(session, module); @@ -171,14 +171,14 @@ public class ComponentServiceTest { @Test(expected = ForbiddenException.class) public void fail_to_update_project_key_without_admin_permission() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); userSessionRule.login("john").addProjectUuidPermissions(UserRole.USER, project.uuid()); service.updateKey(project.key(), "sample2:root"); } @Test public void check_module_keys_before_renaming() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module"); dbClient.componentDao().insert(session, module); @@ -197,7 +197,7 @@ public class ComponentServiceTest { @Test public void check_module_keys_before_renaming_return_duplicate_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module"); dbClient.componentDao().insert(session, module); @@ -216,14 +216,14 @@ public class ComponentServiceTest { @Test(expected = ForbiddenException.class) public void fail_to_check_module_keys_before_renaming_without_admin_permission() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); userSessionRule.login("john").addProjectUuidPermissions(UserRole.USER, project.uuid()); service.checkModuleKeysBeforeRenaming(project.key(), "sample", "sample2"); } @Test public void bulk_update_project_key() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module"); dbClient.componentDao().insert(session, module); @@ -267,7 +267,7 @@ public class ComponentServiceTest { @Test(expected = ForbiddenException.class) public void fail_to_bulk_update_project_key_without_admin_permission() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); userSessionRule.login("john").addProjectPermissions(UserRole.USER, project.key()); service.bulkUpdateKey("sample:root", "sample", "sample2"); } @@ -425,7 +425,7 @@ public class ComponentServiceTest { @Test public void should_return_project_uuids() { - ComponentDto project = createProject("sample:root"); + ComponentDto project = createProject(); String moduleKey = "sample:root:module"; ComponentDto module = ComponentTesting.newModuleDto(project).setKey(moduleKey); dbClient.componentDao().insert(session, module); @@ -460,7 +460,7 @@ public class ComponentServiceTest { assertThat(service.componentUuids(session, Arrays.asList(moduleKey, fileKey), true)).isEmpty(); } - private ComponentDto createProject(String key) { + private ComponentDto createProject() { ComponentDto project = ComponentTesting.newProjectDto().setKey("sample:root"); dbClient.componentDao().insert(session, project); session.commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowDataTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowDataTest.java deleted file mode 100644 index 3de3853872e..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowDataTest.java +++ /dev/null @@ -1,81 +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.server.component.ws; - -import java.util.Collections; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.SnapshotDto; - -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.db.component.ComponentTesting.newProjectDto; -import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject; - -public class ShowDataTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - ComponentDto project = newProjectDto().setId(42L); - - ShowData underTest; - - @Test - public void no_ancestors() { - underTest = ShowData.builder( - newSnapshotForProject(project).setPath(null)) - .withAncestorsSnapshots(Collections.emptyList()) - .andAncestorComponents(Collections.emptyList()); - - assertThat(underTest.getComponents()).isEmpty(); - } - - @Test - public void fail_when_inconsistent_snapshot_ancestors_data() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Missing ancestor"); - - underTest = ShowData.builder( - newSnapshotForProject(project).setPath("1.2.3.")) - .withAncestorsSnapshots(newArrayList( - newSnapshotForProject(project).setId(1L), - newSnapshotForProject(project).setId(2L))) - // missing snapshot with id = 3 - .andAncestorComponents(Collections.emptyList()); - } - - @Test - public void fail_when_inconsistent_component_ancestors_data() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Missing ancestor"); - - underTest = ShowData.builder( - newSnapshotForProject(project).setPath("1.2.3.")) - .withAncestorsSnapshots(newArrayList( - newSnapshotForProject(project).setId(1L), - newSnapshotForProject(project).setId(2L), - newSnapshotForProject(project).setId(3L))) - .andAncestorComponents(Collections.emptyList()); - } -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java index 80b67c4c27f..01917262771 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java @@ -106,17 +106,18 @@ public class TreeActionTest { } @Test - public void direct_children() throws IOException { - userSession.anonymous().login().addProjectUuidPermissions(UserRole.ADMIN, "project-uuid"); + public void return_children() throws IOException { ComponentDto project = newProjectDto("project-uuid"); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); - SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(newModuleDto("module-uuid-1", project), projectSnapshot); + ComponentDto module = newModuleDto("module-uuid-1", project); + SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(module, projectSnapshot); componentDb.insertComponentAndSnapshot(newFileDto(project, 1), projectSnapshot); for (int i = 2; i <= 9; i++) { - componentDb.insertComponentAndSnapshot(newFileDto(project, i), moduleSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(module, i), moduleSnapshot); } - SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(newDirectory(project, "directory-path-1"), moduleSnapshot); - componentDb.insertComponentAndSnapshot(newFileDto(project, 10), directorySnapshot); + ComponentDto directory = newDirectory(module, "directory-path-1"); + SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(directory, moduleSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(directory, 10), directorySnapshot); db.commit(); componentDb.indexAllComponents(); @@ -135,19 +136,18 @@ public class TreeActionTest { } @Test - public void all_children() throws IOException { - userSession.anonymous().login() - .addProjectUuidPermissions(UserRole.USER, "project-uuid"); - + public void return_descendants() throws IOException { ComponentDto project = newProjectDto("project-uuid"); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); - SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(newModuleDto("module-uuid-1", project), projectSnapshot); + ComponentDto module = newModuleDto("module-uuid-1", project); + SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(module, projectSnapshot); componentDb.insertComponentAndSnapshot(newFileDto(project, 10), projectSnapshot); for (int i = 2; i <= 9; i++) { - componentDb.insertComponentAndSnapshot(newFileDto(project, i), moduleSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(module, i), moduleSnapshot); } - SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(newDirectory(project, "directory-path-1"), moduleSnapshot); - componentDb.insertComponentAndSnapshot(newFileDto(project, 1), directorySnapshot); + ComponentDto directory = newDirectory(module, "directory-path-1"); + SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(directory, moduleSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(directory, 1), directorySnapshot); db.commit(); componentDb.indexAllComponents(); @@ -166,51 +166,53 @@ public class TreeActionTest { } @Test - public void leaves_children() throws IOException { - ComponentDto project = newProjectDto().setUuid("project-uuid"); + public void filter_descendants_by_qualifier() throws IOException { + ComponentDto project = newProjectDto("project-uuid"); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); - SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(newModuleDto("module-uuid-1", project), projectSnapshot); componentDb.insertComponentAndSnapshot(newFileDto(project, 1), projectSnapshot); - componentDb.insertComponentAndSnapshot(newFileDto(project, 2), moduleSnapshot); - SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(newDirectory(project, "directory-path-1"), moduleSnapshot); - componentDb.insertComponentAndSnapshot(newFileDto(project, 3), directorySnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(project, 2), projectSnapshot); + componentDb.insertComponentAndSnapshot(newModuleDto("module-uuid-1", project), projectSnapshot); db.commit(); componentDb.indexAllComponents(); TreeWsResponse response = call(ws.newRequest() - .setParam(PARAM_STRATEGY, "leaves") - .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid") - .setParam(PARAM_QUALIFIERS, Qualifiers.FILE)); + .setParam(PARAM_STRATEGY, "all") + .setParam(PARAM_QUALIFIERS, Qualifiers.FILE) + .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")); - assertThat(response.getComponentsCount()).isEqualTo(3); - assertThat(response.getPaging().getTotal()).isEqualTo(3); - assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3"); + assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2"); } @Test - public void all_children_by_file_qualifier() throws IOException { - ComponentDto project = newProjectDto().setUuid("project-uuid"); + public void return_leaves() throws IOException { + ComponentDto project = newProjectDto("project-uuid"); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); + ComponentDto module = newModuleDto("module-uuid-1", project); + SnapshotDto moduleSnapshot = componentDb.insertComponentAndSnapshot(module, projectSnapshot); componentDb.insertComponentAndSnapshot(newFileDto(project, 1), projectSnapshot); - componentDb.insertComponentAndSnapshot(newFileDto(project, 2), projectSnapshot); - componentDb.insertComponentAndSnapshot(newModuleDto("module-uuid-1", project), projectSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(module, 2), moduleSnapshot); + ComponentDto directory = newDirectory(project, "directory-path-1"); + SnapshotDto directorySnapshot = componentDb.insertComponentAndSnapshot(directory, moduleSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(directory, 3), directorySnapshot); db.commit(); componentDb.indexAllComponents(); TreeWsResponse response = call(ws.newRequest() - .setParam(PARAM_STRATEGY, "all") - .setParam(PARAM_QUALIFIERS, Qualifiers.FILE) - .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")); + .setParam(PARAM_STRATEGY, "leaves") + .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid") + .setParam(PARAM_QUALIFIERS, Qualifiers.FILE)); - assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2"); + assertThat(response.getComponentsCount()).isEqualTo(3); + assertThat(response.getPaging().getTotal()).isEqualTo(3); + assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3"); } @Test - public void all_children_sort_by_qualifier() throws IOException { - ComponentDto project = newProjectDto().setUuid("project-uuid"); + public void sort_descendants_by_qualifier() throws IOException { + ComponentDto project = newProjectDto("project-uuid"); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); - componentDb.insertComponentAndSnapshot(newFileDto(project, 2), projectSnapshot); componentDb.insertComponentAndSnapshot(newFileDto(project, 1), projectSnapshot); + componentDb.insertComponentAndSnapshot(newFileDto(project, 2), projectSnapshot); ComponentDto module = newModuleDto("module-uuid-1", project); componentDb.insertComponentAndSnapshot(module, projectSnapshot); componentDb.insertComponentAndSnapshot(newDirectory(project, "path/directory/", "directory-uuid-1"), projectSnapshot); @@ -226,7 +228,7 @@ public class TreeActionTest { } @Test - public void direct_children_of_a_view() { + public void return_children_of_a_view() { ComponentDto view = newView("view-uuid"); SnapshotDto viewSnapshot = componentDb.insertViewAndSnapshot(view); ComponentDto project = newProjectDto("project-uuid-1").setName("project-name").setKey("project-key-1"); @@ -247,7 +249,7 @@ public class TreeActionTest { } @Test - public void empty_response_for_provisioned_project() { + public void response_is_empty_on_provisioned_projects() { componentDb.insertComponent(newProjectDto("project-uuid")); TreeWsResponse response = call(ws.newRequest() @@ -261,12 +263,13 @@ public class TreeActionTest { } @Test - public void developer_projects() { + public void return_developers() { ComponentDto project = newProjectDto("project-uuid"); componentDb.insertProjectAndSnapshot(project); ComponentDto developer = newDeveloper("developer-name"); SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); componentDb.insertComponentAndSnapshot(newDevProjectCopy("project-copy-uuid", project, developer), developerSnapshot); + db.commit(); TreeWsResponse response = call(ws.newRequest().setParam(PARAM_BASE_COMPONENT_ID, developer.uuid())); @@ -277,7 +280,7 @@ public class TreeActionTest { } @Test - public void view_projects() { + public void return_projects_composing_a_view() { ComponentDto project = newProjectDto("project-uuid"); componentDb.insertProjectAndSnapshot(project); ComponentDto view = newView("view-uuid"); @@ -400,14 +403,12 @@ public class TreeActionTest { JsonArray components = jsonTree.getAsJsonObject().getAsJsonArray("components"); for (JsonElement componentAsJsonElement : components) { JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject(); - componentDb.insertComponentAndSnapshot(new ComponentDto() - .setUuid(getJsonField(componentAsJsonObject, "id")) - .setRootUuid("root_uuid") + String uuid = getJsonField(componentAsJsonObject, "id"); + componentDb.insertComponentAndSnapshot(ComponentTesting.newChildComponent(uuid, project) .setKey(getJsonField(componentAsJsonObject, "key")) .setName(getJsonField(componentAsJsonObject, "name")) .setLanguage(getJsonField(componentAsJsonObject, "language")) .setPath(getJsonField(componentAsJsonObject, "path")) - .setProjectUuid(project.projectUuid()) .setQualifier(getJsonField(componentAsJsonObject, "qualifier")) .setDescription(getJsonField(componentAsJsonObject, "description")) .setEnabled(true) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java index 3d2b80830f5..0cf21b266ae 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/filemove/FileMoveDetectionStepTest.java @@ -32,13 +32,14 @@ import org.sonar.core.hash.SourceLinesHashesComputer; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDao; -import org.sonar.db.component.ComponentDtoWithSnapshotId; +import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTreeQuery; import org.sonar.db.source.FileSourceDao; import org.sonar.db.source.FileSourceDto; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.ReportComponent; import org.sonar.server.computation.snapshot.Snapshot; import org.sonar.server.computation.source.SourceLinesRepositoryRule; @@ -55,6 +56,7 @@ import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; import static org.sonar.server.computation.component.ReportComponent.builder; public class FileMoveDetectionStepTest { + private static final long SNAPSHOT_ID = 98765; private static final Snapshot SNAPSHOT = new Snapshot.Builder() .setId(SNAPSHOT_ID) @@ -65,6 +67,7 @@ public class FileMoveDetectionStepTest { private static final int FILE_1_REF = 2; private static final int FILE_2_REF = 3; private static final int FILE_3_REF = 4; + private static final ReportComponent PROJECT = builder(Component.Type.PROJECT, ROOT_REF).build(); private static final Component FILE_1 = fileComponent(FILE_1_REF); private static final Component FILE_2 = fileComponent(FILE_2_REF); private static final Component FILE_3 = fileComponent(FILE_3_REF); @@ -83,7 +86,7 @@ public class FileMoveDetectionStepTest { "public class Foo {", "}" }; - public static final String[] CONTENT_EMPTY = { + private static final String[] CONTENT_EMPTY = { "" }; private static final String[] CONTENT2 = { @@ -228,6 +231,7 @@ public class FileMoveDetectionStepTest { when(dbClient.openSession(false)).thenReturn(dbSession); when(dbClient.componentDao()).thenReturn(componentDao); when(dbClient.fileSourceDao()).thenReturn(fileSourceDao); + treeRootHolder.setRoot(PROJECT); } @Test @@ -236,7 +240,7 @@ public class FileMoveDetectionStepTest { } @Test - public void execute_detects_no_move_if_baseProjectSnaphost_is_null() { + public void execute_detects_no_move_if_baseProjectSnapshot_is_null() { analysisMetadataHolder.setBaseProjectSnapshot(null); underTest.execute(); @@ -267,14 +271,13 @@ public class FileMoveDetectionStepTest { public void execute_retrieves_only_file_and_unit_tests_from_last_snapshot() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); ArgumentCaptor captor = ArgumentCaptor.forClass(ComponentTreeQuery.class); - when(componentDao.selectAllChildren(eq(dbSession), captor.capture())) - .thenReturn(Collections.emptyList()); + when(componentDao.selectDescendants(eq(dbSession), captor.capture())) + .thenReturn(Collections.emptyList()); underTest.execute(); ComponentTreeQuery query = captor.getValue(); - assertThat(query.getBaseSnapshot().getId()).isEqualTo(SNAPSHOT_ID); - assertThat(query.getBaseSnapshot().getRootId()).isEqualTo(SNAPSHOT_ID); + assertThat(query.getBaseUuid()).isEqualTo(PROJECT.getUuid()); assertThat(query.getPage()).isEqualTo(1); assertThat(query.getPageSize()).isEqualTo(Integer.MAX_VALUE); assertThat(query.getSqlSort()).isEqualTo("LOWER(p.name) ASC, p.name ASC"); @@ -284,7 +287,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_there_is_no_file_in_report() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(1); + mockComponents( /* no components */); setFilesInReport(); underTest.execute(); @@ -295,7 +298,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_file_key_exists_in_both_DB_and_report() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey(), FILE_2.getKey()); + mockComponents(FILE_1.getKey(), FILE_2.getKey()); setFilesInReport(FILE_2, FILE_1); underTest.execute(); @@ -306,7 +309,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_move_if_content_of_file_is_same_in_DB_and_report() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - ComponentDtoWithSnapshotId[] dtos = mockComponentsForSnapshot(FILE_1.getKey()); + ComponentDto[] dtos = mockComponents(FILE_1.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); setFilesInReport(FILE_2); setFileContentInReport(FILE_2_REF, CONTENT1); @@ -323,7 +326,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_content_of_file_is_not_similar_enough() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey()); + mockComponents(FILE_1.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); setFilesInReport(FILE_2); setFileContentInReport(FILE_2_REF, LESS_CONTENT1); @@ -336,7 +339,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_content_of_file_is_empty_in_DB() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey()); + mockComponents(FILE_1.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT_EMPTY); setFilesInReport(FILE_2); setFileContentInReport(FILE_2_REF, CONTENT1); @@ -349,7 +352,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_content_of_file_is_empty_in_report() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey()); + mockComponents(FILE_1.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); setFilesInReport(FILE_2); setFileContentInReport(FILE_2_REF, CONTENT_EMPTY); @@ -362,7 +365,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_two_added_files_have_same_content_as_the_one_in_db() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey()); + mockComponents(FILE_1.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); setFilesInReport(FILE_2, FILE_3); setFileContentInReport(FILE_2_REF, CONTENT1); @@ -376,7 +379,7 @@ public class FileMoveDetectionStepTest { @Test public void execute_detects_no_move_if_two_deleted_files_have_same_content_as_the_one_added() { analysisMetadataHolder.setBaseProjectSnapshot(SNAPSHOT); - mockComponentsForSnapshot(FILE_1.getKey(), FILE_2.getKey()); + mockComponents(FILE_1.getKey(), FILE_2.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); mockContentOfFileIdDb(FILE_2.getKey(), CONTENT1); setFilesInReport(FILE_3); @@ -398,7 +401,7 @@ public class FileMoveDetectionStepTest { Component file4 = fileComponent(5); Component file5 = fileComponent(6); Component file6 = fileComponent(7); - ComponentDtoWithSnapshotId[] dtos = mockComponentsForSnapshot(FILE_1.getKey(), FILE_2.getKey(), file4.getKey(), file5.getKey()); + ComponentDto[] dtos = mockComponents(FILE_1.getKey(), FILE_2.getKey(), file4.getKey(), file5.getKey()); mockContentOfFileIdDb(FILE_1.getKey(), CONTENT1); mockContentOfFileIdDb(FILE_2.getKey(), LESS_CONTENT1); mockContentOfFileIdDb(file4.getKey(), new String[] {"e", "f", "g", "h", "i"}); @@ -447,22 +450,18 @@ public class FileMoveDetectionStepTest { .build()); } - private ComponentDtoWithSnapshotId[] mockComponentsForSnapshot(String... componentKeys) { - return mockComponentsForSnapshot(SNAPSHOT_ID, componentKeys); - } - - private ComponentDtoWithSnapshotId[] mockComponentsForSnapshot(long snapshotId, String... componentKeys) { - List componentDtoWithSnapshotIds = stream(componentKeys) - .map(key -> newComponentDto(snapshotId, key)) + private ComponentDto[] mockComponents(String... componentKeys) { + List componentDtos = stream(componentKeys) + .map(key -> newComponentDto(key)) .collect(toList()); - when(componentDao.selectAllChildren(eq(dbSession), any(ComponentTreeQuery.class))) - .thenReturn(componentDtoWithSnapshotIds); - return componentDtoWithSnapshotIds.toArray(new ComponentDtoWithSnapshotId[componentDtoWithSnapshotIds.size()]); + when(componentDao.selectDescendants(eq(dbSession), any(ComponentTreeQuery.class))) + .thenReturn(componentDtos); + return componentDtos.toArray(new ComponentDto[componentDtos.size()]); } - private ComponentDtoWithSnapshotId newComponentDto(long snapshotId, String key) { - ComponentDtoWithSnapshotId res = new ComponentDtoWithSnapshotId(); - res.setSnapshotId(snapshotId) + private ComponentDto newComponentDto(String key) { + ComponentDto res = new ComponentDto(); + res .setId(dbIdGenerator) .setKey(key) .setUuid(componentUuidOf(key)) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/queue/InternalCeQueueImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/queue/InternalCeQueueImplTest.java index 66ad196524d..0512c1097e1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/queue/InternalCeQueueImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/queue/InternalCeQueueImplTest.java @@ -40,6 +40,7 @@ import org.sonar.db.ce.CeActivityDto; import org.sonar.db.ce.CeQueueDto; import org.sonar.db.ce.CeTaskTypes; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import org.sonar.server.computation.monitoring.CEQueueStatusImpl; import static java.util.Arrays.asList; @@ -308,7 +309,7 @@ public class InternalCeQueueImplTest { } private static ComponentDto newComponentDto(String uuid) { - return new ComponentDto().setUuid(uuid).setRootUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); + return ComponentTesting.newProjectDto(uuid).setName("name_" + uuid).setKey("key_" + uuid); } private CeTask submit(String reportType, String componentUuid) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java index 68e97a0758c..2a823ba206f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java @@ -391,7 +391,11 @@ public class PersistMeasuresStepTest extends BaseStepTest { } private ComponentDto addComponent(String key, String uuid) { - ComponentDto componentDto = new ComponentDto().setKey(key).setUuid(uuid).setRootUuid(uuid); + ComponentDto componentDto = new ComponentDto() + .setKey(key) + .setUuid(uuid) + .setUuidPath(uuid + ".") + .setRootUuid(uuid); dbClient.componentDao().insert(dbTester.getSession(), componentDto); return componentDto; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java index 343ad0613b6..da2f180239d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java @@ -153,8 +153,8 @@ public class ComponentActionTest { SnapshotDto fileSnapshot = componentDb.insertComponentAndSnapshot(file, projectSnapshot); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot.getId()).setValue(42.0d).setDeveloperId(null), - newMeasureDto(ncloc, fileSnapshot.getId()).setValue(1984.0d).setDeveloperId(developer.getId())); + newMeasureDto(ncloc, fileSnapshot).setValue(42.0d).setDeveloperId(null), + newMeasureDto(ncloc, fileSnapshot).setValue(1984.0d).setDeveloperId(developer.getId())); db.commit(); ComponentWsResponse result = call(ws.newRequest() @@ -176,8 +176,8 @@ public class ComponentActionTest { SnapshotDto fileSnapshot = componentDb.insertComponentAndSnapshot(file, projectSnapshot); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot.getId()).setValue(42.0d).setDeveloperId(null), - newMeasureDto(ncloc, fileSnapshot.getId()).setValue(1984.0d).setDeveloperId(developer.getId())); + newMeasureDto(ncloc, fileSnapshot).setValue(42.0d).setDeveloperId(null), + newMeasureDto(ncloc, fileSnapshot).setValue(1984.0d).setDeveloperId(developer.getId())); db.commit(); ComponentWsResponse result = call(ws.newRequest() @@ -334,7 +334,7 @@ public class ComponentActionTest { MetricDto complexity = insertComplexityMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(complexity, fileSnapshot.getId()) + newMeasureDto(complexity, fileSnapshot) .setValue(12.0d) .setVariation(1, 2.0d) .setVariation(2, 0.0d) @@ -342,7 +342,7 @@ public class ComponentActionTest { MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot.getId()) + newMeasureDto(ncloc, fileSnapshot) .setValue(114.0d) .setVariation(1, 3.0d) .setVariation(2, -5.0d) @@ -350,7 +350,7 @@ public class ComponentActionTest { MetricDto newViolations = insertNewViolationMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(newViolations, fileSnapshot.getId()) + newMeasureDto(newViolations, fileSnapshot) .setVariation(1, 25.0d) .setVariation(2, 0.0d) .setVariation(3, 25.0d)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java index ca4506a38cb..258671f05d5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java @@ -155,9 +155,9 @@ public class ComponentTreeActionTest { MetricDto ncloc = insertNclocMetric(); MetricDto coverage = insertCoverageMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot.getId()).setValue(5.0d).setVariation(1, 4.0d), - newMeasureDto(coverage, fileSnapshot.getId()).setValue(15.5d).setVariation(3, 2.0d), - newMeasureDto(coverage, directorySnapshot.getId()).setValue(15.0d)); + newMeasureDto(ncloc, fileSnapshot).setValue(5.0d).setVariation(1, 4.0d), + newMeasureDto(coverage, fileSnapshot).setValue(15.5d).setVariation(3, 2.0d), + newMeasureDto(coverage, directorySnapshot).setValue(15.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -194,8 +194,8 @@ public class ComponentTreeActionTest { .setBestValue(1984.0d) .setValueType(ValueType.INT.name())); dbClient.measureDao().insert(dbSession, - newMeasureDto(coverage, fileSnapshot.getId()).setValue(15.5d), - newMeasureDto(coverage, directorySnapshot.getId()).setValue(42.0d)); + newMeasureDto(coverage, fileSnapshot).setValue(15.5d), + newMeasureDto(coverage, directorySnapshot).setValue(42.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -230,15 +230,15 @@ public class ComponentTreeActionTest { SnapshotDto fileSnapshot1 = componentDb.insertComponentAndSnapshot(newFileDto(projectDto, "file-uuid-1").setName("file-1"), projectSnapshot); MetricDto coverage = insertCoverageMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(coverage, fileSnapshot1.getId()).setValue(1.0d), - newMeasureDto(coverage, fileSnapshot2.getId()).setValue(2.0d), - newMeasureDto(coverage, fileSnapshot3.getId()).setValue(3.0d), - newMeasureDto(coverage, fileSnapshot4.getId()).setValue(4.0d), - newMeasureDto(coverage, fileSnapshot5.getId()).setValue(5.0d), - newMeasureDto(coverage, fileSnapshot6.getId()).setValue(6.0d), - newMeasureDto(coverage, fileSnapshot7.getId()).setValue(7.0d), - newMeasureDto(coverage, fileSnapshot8.getId()).setValue(8.0d), - newMeasureDto(coverage, fileSnapshot9.getId()).setValue(9.0d)); + newMeasureDto(coverage, fileSnapshot1).setValue(1.0d), + newMeasureDto(coverage, fileSnapshot2).setValue(2.0d), + newMeasureDto(coverage, fileSnapshot3).setValue(3.0d), + newMeasureDto(coverage, fileSnapshot4).setValue(4.0d), + newMeasureDto(coverage, fileSnapshot5).setValue(5.0d), + newMeasureDto(coverage, fileSnapshot6).setValue(6.0d), + newMeasureDto(coverage, fileSnapshot7).setValue(7.0d), + newMeasureDto(coverage, fileSnapshot8).setValue(8.0d), + newMeasureDto(coverage, fileSnapshot9).setValue(9.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -265,9 +265,9 @@ public class ComponentTreeActionTest { MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1); dbClient.metricDao().insert(dbSession, ncloc); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot1.getId()).setValue(1.0d), - newMeasureDto(ncloc, fileSnapshot2.getId()).setValue(2.0d), - newMeasureDto(ncloc, fileSnapshot3.getId()).setValue(3.0d)); + newMeasureDto(ncloc, fileSnapshot1).setValue(1.0d), + newMeasureDto(ncloc, fileSnapshot2).setValue(2.0d), + newMeasureDto(ncloc, fileSnapshot3).setValue(3.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -282,32 +282,36 @@ public class ComponentTreeActionTest { @Test public void remove_components_without_measure_on_the_metric_sort() { - ComponentDto projectDto = newProjectDto("project-uuid"); - SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); - SnapshotDto fileSnapshot4 = componentDb.insertComponentAndSnapshot(newFileDto(projectDto, "file-uuid-4"), projectSnapshot); - SnapshotDto fileSnapshot3 = componentDb.insertComponentAndSnapshot(newFileDto(projectDto, "file-uuid-3"), projectSnapshot); - SnapshotDto fileSnapshot2 = componentDb.insertComponentAndSnapshot(newFileDto(projectDto, "file-uuid-2"), projectSnapshot); - SnapshotDto fileSnapshot1 = componentDb.insertComponentAndSnapshot(newFileDto(projectDto, "file-uuid-1"), projectSnapshot); + ComponentDto project = newProjectDto("project-uuid"); + SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); + ComponentDto file1 = newFileDto(project, "file-uuid-1"); + ComponentDto file2 = newFileDto(project, "file-uuid-2"); + ComponentDto file3 = newFileDto(project, "file-uuid-3"); + ComponentDto file4 = newFileDto(project, "file-uuid-4"); + SnapshotDto fileSnapshot1 = componentDb.insertComponentAndSnapshot(file1, projectSnapshot); + SnapshotDto fileSnapshot2 = componentDb.insertComponentAndSnapshot(file2, projectSnapshot); + SnapshotDto fileSnapshot3 = componentDb.insertComponentAndSnapshot(file3, projectSnapshot); + SnapshotDto fileSnapshot4 = componentDb.insertComponentAndSnapshot(file4, projectSnapshot); MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1); dbClient.metricDao().insert(dbSession, ncloc); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot1.getId()).setValue(1.0d), - newMeasureDto(ncloc, fileSnapshot2.getId()).setValue(2.0d), - newMeasureDto(ncloc, fileSnapshot3.getId()).setValue(3.0d), + newMeasureDto(ncloc, fileSnapshot1).setValue(1.0d), + newMeasureDto(ncloc, fileSnapshot2).setValue(2.0d), + newMeasureDto(ncloc, fileSnapshot3).setValue(3.0d), // measure on period 1 - newMeasureDto(ncloc, fileSnapshot4.getId()).setVariation(1, 4.0d)); + newMeasureDto(ncloc, fileSnapshot4).setVariation(1, 4.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() - .setParam(PARAM_BASE_COMPONENT_ID, "project-uuid") + .setParam(PARAM_BASE_COMPONENT_ID, project.uuid()) .setParam(Param.SORT, METRIC_SORT) .setParam(PARAM_METRIC_SORT, "ncloc") .setParam(PARAM_METRIC_KEYS, "ncloc") .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)); assertThat(response.getComponentsList()).extracting("id") - .containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3") - .doesNotContain("file-uuid-4"); + .containsExactly(file1.uuid(), file2.uuid(), file3.uuid()) + .doesNotContain(file4.uuid()); assertThat(response.getPaging().getTotal()).isEqualTo(3); } @@ -321,9 +325,9 @@ public class ComponentTreeActionTest { MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1); dbClient.metricDao().insert(dbSession, ncloc); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot1.getId()).setVariation(1, 1.0d), - newMeasureDto(ncloc, fileSnapshot2.getId()).setVariation(1, 2.0d), - newMeasureDto(ncloc, fileSnapshot3.getId()).setVariation(1, 3.0d)); + newMeasureDto(ncloc, fileSnapshot1).setVariation(1, 1.0d), + newMeasureDto(ncloc, fileSnapshot2).setVariation(1, 2.0d), + newMeasureDto(ncloc, fileSnapshot3).setVariation(1, 3.0d)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -347,11 +351,11 @@ public class ComponentTreeActionTest { MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("new_ncloc").setValueType(ValueType.INT.name()).setDirection(1); dbClient.metricDao().insert(dbSession, ncloc); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, fileSnapshot1.getId()).setVariation(1, 1.0d), - newMeasureDto(ncloc, fileSnapshot2.getId()).setVariation(1, 2.0d), - newMeasureDto(ncloc, fileSnapshot3.getId()).setVariation(1, 3.0d), + newMeasureDto(ncloc, fileSnapshot1).setVariation(1, 1.0d), + newMeasureDto(ncloc, fileSnapshot2).setVariation(1, 2.0d), + newMeasureDto(ncloc, fileSnapshot3).setVariation(1, 3.0d), // file 4 measure is on absolute value and period 2 - newMeasureDto(ncloc, fileSnapshot4.getId()) + newMeasureDto(ncloc, fileSnapshot4) .setValue(4.0d) .setVariation(2, 4.0d)); db.commit(); @@ -371,15 +375,16 @@ public class ComponentTreeActionTest { @Test public void load_developer_descendants() { - ComponentDto developer = newDeveloper("developer").setUuid("developer-uuid"); ComponentDto project = newProjectDto("project-uuid").setKey("project-key"); - SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); componentDb.insertProjectAndSnapshot(project); + ComponentDto developer = newDeveloper("developer", "developer-uuid"); + SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); componentDb.insertComponentAndSnapshot(newDevProjectCopy("project-uuid-copy", project, developer), developerSnapshot); insertNclocMetric(); + db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() - .setParam(PARAM_BASE_COMPONENT_ID, "developer-uuid") + .setParam(PARAM_BASE_COMPONENT_ID, developer.uuid()) .setParam(PARAM_METRIC_KEYS, "ncloc")); assertThat(response.getComponentsCount()).isEqualTo(1); @@ -391,7 +396,7 @@ public class ComponentTreeActionTest { @Test public void load_developer_measures_by_developer_uuid() { - ComponentDto developer = newDeveloper("developer").setUuid("developer-uuid"); + ComponentDto developer = newDeveloper("developer", "developer-uuid"); ComponentDto project = newProjectDto("project-uuid").setKey("project-key"); SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); @@ -400,13 +405,13 @@ public class ComponentTreeActionTest { componentDb.insertComponentAndSnapshot(newDevProjectCopy("project-uuid-copy", project, developer), developerSnapshot); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, projectSnapshot.getId()).setDeveloperId(developer.getId()), - newMeasureDto(ncloc, file1Snapshot.getId()) + newMeasureDto(ncloc, projectSnapshot).setDeveloperId(developer.getId()), + newMeasureDto(ncloc, file1Snapshot) .setValue(3d) .setDeveloperId(developer.getId()), // measures are not specific to the developer - newMeasureDto(ncloc, file1Snapshot.getId()).setDeveloperId(null), - newMeasureDto(ncloc, file2Snapshot.getId()).setDeveloperId(null)); + newMeasureDto(ncloc, file1Snapshot).setDeveloperId(null), + newMeasureDto(ncloc, file2Snapshot).setDeveloperId(null)); db.commit(); ComponentTreeWsResponse response = call(ws.newRequest() @@ -424,7 +429,7 @@ public class ComponentTreeActionTest { @Test public void load_developer_measures_by_developer_key() { - ComponentDto developer = newDeveloper("developer").setUuid("developer-uuid"); + ComponentDto developer = newDeveloper("developer", "developer-uuid"); ComponentDto project = newProjectDto("project-uuid").setKey("project-key"); SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); @@ -432,7 +437,7 @@ public class ComponentTreeActionTest { componentDb.insertComponentAndSnapshot(newDevProjectCopy("project-uuid-copy", project, developer), developerSnapshot); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, file1Snapshot.getId()) + newMeasureDto(ncloc, file1Snapshot) .setValue(3d) .setDeveloperId(developer.getId())); db.commit(); @@ -471,7 +476,7 @@ public class ComponentTreeActionTest { public void fail_when_developer_is_unknown() { expectedException.expect(NotFoundException.class); - ComponentDto developer = newDeveloper("developer").setUuid("developer-uuid"); + ComponentDto developer = newDeveloper("developer", "developer-uuid"); ComponentDto project = newProjectDto("project-uuid").setKey("project-key"); SnapshotDto developerSnapshot = componentDb.insertDeveloperAndSnapshot(developer); SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); @@ -479,7 +484,7 @@ public class ComponentTreeActionTest { componentDb.insertComponentAndSnapshot(newDevProjectCopy("project-uuid-copy", project, developer), developerSnapshot); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, file1Snapshot.getId()) + newMeasureDto(ncloc, file1Snapshot) .setValue(3d) .setDeveloperId(developer.getId())); db.commit(); @@ -666,35 +671,35 @@ public class ComponentTreeActionTest { MetricDto complexity = insertComplexityMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(complexity, file1Snapshot.getId()) + newMeasureDto(complexity, file1Snapshot) .setValue(12.0d), - newMeasureDto(complexity, directorySnapshot.getId()) + newMeasureDto(complexity, directorySnapshot) .setValue(35.0d) .setVariation(2, 0.0d), - newMeasureDto(complexity, projectSnapshot.getId()) + newMeasureDto(complexity, projectSnapshot) .setValue(42.0d)); MetricDto ncloc = insertNclocMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(ncloc, file1Snapshot.getId()) + newMeasureDto(ncloc, file1Snapshot) .setValue(114.0d), - newMeasureDto(ncloc, directorySnapshot.getId()) + newMeasureDto(ncloc, directorySnapshot) .setValue(217.0d) .setVariation(2, 0.0d), - newMeasureDto(ncloc, projectSnapshot.getId()) + newMeasureDto(ncloc, projectSnapshot) .setValue(1984.0d)); MetricDto newViolations = insertNewViolationsMetric(); dbClient.measureDao().insert(dbSession, - newMeasureDto(newViolations, file1Snapshot.getId()) + newMeasureDto(newViolations, file1Snapshot) .setVariation(1, 25.0d) .setVariation(2, 0.0d) .setVariation(3, 25.0d), - newMeasureDto(newViolations, directorySnapshot.getId()) + newMeasureDto(newViolations, directorySnapshot) .setVariation(1, 25.0d) .setVariation(2, 0.0d) .setVariation(3, 25.0d), - newMeasureDto(newViolations, projectSnapshot.getId()) + newMeasureDto(newViolations, projectSnapshot) .setVariation(1, 255.0d) .setVariation(2, 0.0d) .setVariation(3, 255.0d)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java index af5da066369..85164209aca 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java @@ -29,7 +29,7 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric.ValueType; import org.sonar.api.resources.Qualifiers; import org.sonar.core.util.Uuids; -import org.sonar.db.component.ComponentDtoWithSnapshotId; +import org.sonar.db.component.ComponentDto; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; import org.sonarqube.ws.client.measure.ComponentTreeWsRequest; @@ -50,7 +50,7 @@ public class ComponentTreeSortTest { private List metrics; private Table measuresByComponentUuidAndMetric; - private List components; + private List components; @Before public void setUp() { @@ -77,7 +77,7 @@ public class ComponentTreeSortTest { measuresByComponentUuidAndMetric = HashBasedTable.create(components.size(), 2); // same number than path field double currentValue = 9; - for (ComponentDtoWithSnapshotId component : components) { + for (ComponentDto component : components) { measuresByComponentUuidAndMetric.put(component.uuid(), violationsMetric, new MeasureDto().setValue(currentValue) .setVariation(1, -currentValue) .setVariation(5, currentValue)); @@ -89,7 +89,7 @@ public class ComponentTreeSortTest { @Test public void sort_by_names() { ComponentTreeWsRequest wsRequest = newRequest(singletonList(NAME_SORT), true, null); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("name") .containsExactly("name-1", "name-2", "name-3", "name-4", "name-5", "name-6", "name-7", "name-8", "name-9"); @@ -99,7 +99,7 @@ public class ComponentTreeSortTest { public void sort_by_qualifier() { ComponentTreeWsRequest wsRequest = newRequest(singletonList(QUALIFIER_SORT), false, null); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("qualifier") .containsExactly("qualifier-9", "qualifier-8", "qualifier-7", "qualifier-6", "qualifier-5", "qualifier-4", "qualifier-3", "qualifier-2", "qualifier-1"); @@ -109,7 +109,7 @@ public class ComponentTreeSortTest { public void sort_by_path() { ComponentTreeWsRequest wsRequest = newRequest(singletonList(PATH_SORT), true, null); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9"); @@ -120,7 +120,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), true, NUM_METRIC_KEY); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9", "path-without-measure"); @@ -131,7 +131,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), false, NUM_METRIC_KEY); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure"); @@ -152,13 +152,13 @@ public class ComponentTreeSortTest { measuresByComponentUuidAndMetric = HashBasedTable.create(); List statuses = newArrayList("OK", "WARN", "ERROR"); for (int i = 0; i < components.size(); i++) { - ComponentDtoWithSnapshotId component = components.get(i); + ComponentDto component = components.get(i); String alertStatus = statuses.get(i % 3); measuresByComponentUuidAndMetric.put(component.uuid(), metrics.get(0), new MeasureDto().setData(alertStatus)); } ComponentTreeWsRequest wsRequest = newRequest(newArrayList(METRIC_SORT, NAME_SORT), true, CoreMetrics.ALERT_STATUS_KEY); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("name").containsExactly( "PROJECT ERROR 1", "PROJECT ERROR 2", @@ -171,7 +171,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_PERIOD_SORT), true, NUM_METRIC_KEY).setMetricPeriodSort(1); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure"); @@ -182,7 +182,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_PERIOD_SORT), false, NUM_METRIC_KEY).setMetricPeriodSort(1); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9", "path-without-measure"); @@ -193,7 +193,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), false, NUM_METRIC_KEY).setMetricPeriodSort(5); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure"); @@ -204,7 +204,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), true, TEXT_METRIC_KEY); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9", "path-without-measure"); @@ -215,7 +215,7 @@ public class ComponentTreeSortTest { components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure")); ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), false, TEXT_METRIC_KEY); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure"); @@ -229,18 +229,18 @@ public class ComponentTreeSortTest { newComponentWithoutSnapshotId("name-1", "qualifier-1", "path-1")); ComponentTreeWsRequest wsRequest = newRequest(newArrayList(NAME_SORT, QUALIFIER_SORT, PATH_SORT), true, null); - List result = sortComponents(wsRequest); + List result = sortComponents(wsRequest); assertThat(result).extracting("path") .containsExactly("path-1", "path-2", "path-3"); } - private List sortComponents(ComponentTreeWsRequest wsRequest) { + private List sortComponents(ComponentTreeWsRequest wsRequest) { return ComponentTreeSort.sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric); } - private static ComponentDtoWithSnapshotId newComponentWithoutSnapshotId(String name, String qualifier, String path) { - return (ComponentDtoWithSnapshotId) new ComponentDtoWithSnapshotId() + private static ComponentDto newComponentWithoutSnapshotId(String name, String qualifier, String path) { + return (ComponentDto) new ComponentDto() .setUuid(Uuids.createFast()) .setName(name) .setQualifier(qualifier) diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureDtoToWsMeasureTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureDtoToWsMeasureTest.java index 5b29ea233bf..48fcb3ac84c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureDtoToWsMeasureTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureDtoToWsMeasureTest.java @@ -23,6 +23,7 @@ package org.sonar.server.measure.ws; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.sonar.db.component.SnapshotDto; import org.sonar.db.metric.MetricDto; import static org.assertj.core.api.Assertions.assertThat; @@ -43,7 +44,7 @@ public class MeasureDtoToWsMeasureTest { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Error while mapping a measure of metric key 'metric-key' and parameters "); - MeasureDtoToWsMeasure.measureDtoToWsMeasure(metric, newMeasureDto(metric, 1L).setValue(5.5d).setData("data")); + MeasureDtoToWsMeasure.measureDtoToWsMeasure(metric, newMeasureDto(metric, new SnapshotDto().setId(1L).setComponentUuid("U1")).setValue(5.5d).setData("data")); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java index 3eccf26baaa..86b5f6aa934 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java @@ -111,8 +111,8 @@ public class SearchMyProjectsActionTest { long anotherTime = DateUtils.parseDateTime("2016-06-11T14:25:53+0000").getTime(); SnapshotDto jdk7Snapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(jdk7).setCreatedAt(oneTime)); SnapshotDto cLangSnapshot = dbClient.snapshotDao().insert(dbSession, newSnapshotForProject(cLang).setCreatedAt(anotherTime)); - dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, jdk7Snapshot.getId()).setData(Level.ERROR.name())); - dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, cLangSnapshot.getId()).setData(Level.OK.name())); + dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, jdk7Snapshot).setData(Level.ERROR.name())); + dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, cLangSnapshot).setData(Level.OK.name())); insertUserPermission(UserRole.ADMIN, user.getId(), jdk7.getId()); insertUserPermission(UserRole.ADMIN, user.getId(), cLang.getId()); db.commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java index a3dd6d52aeb..56259b4fce4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java @@ -99,7 +99,7 @@ public class ProjectStatusActionTest { .setEnabled(true) .setKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY)); dbClient.measureDao().insert(dbSession, - newMeasureDto(metric, snapshot.getId()) + newMeasureDto(metric, snapshot) .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json")))); dbSession.commit(); @@ -128,7 +128,7 @@ public class ProjectStatusActionTest { .setEnabled(true) .setKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY)); dbClient.measureDao().insert(dbSession, - newMeasureDto(metric, snapshot.getId()) + newMeasureDto(metric, snapshot) .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json")))); dbSession.commit(); @@ -157,7 +157,7 @@ public class ProjectStatusActionTest { .setEnabled(true) .setKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY)); dbClient.measureDao().insert(dbSession, - newMeasureDto(metric, snapshot.getId()) + newMeasureDto(metric, snapshot) .setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json")))); dbSession.commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java index 27c29402afc..80e26aff327 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java @@ -32,6 +32,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.RowNotFoundException; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import org.sonar.db.qualityprofile.QualityProfileDto; import org.sonar.db.rule.RuleDto; import org.sonar.db.rule.RuleParamDto; @@ -333,16 +334,9 @@ public class QProfileFactoryMediumTest { @Test public void get_profile_by_project_and_language() { - ComponentDto project = new ComponentDto() + ComponentDto project = ComponentTesting.newProjectDto("ABCD") .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + .setKey("org.codehaus.sonar:sonar"); db.componentDao().insert(dbSession, project); QualityProfileDto profileDto = QProfileTesting.newXooP1(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsMediumTest.java index ef9d3011859..51d14f4e597 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsMediumTest.java @@ -29,6 +29,7 @@ import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import org.sonar.db.permission.PermissionRepository; import org.sonar.db.qualityprofile.QualityProfileDto; import org.sonar.db.user.UserDto; @@ -66,15 +67,10 @@ public class QProfileProjectOperationsMediumTest { factory = tester.get(QProfileFactory.class); projectOperations = tester.get(QProfileProjectOperations.class); - project = new ComponentDto() - .setUuid(PROJECT_UUID) - .setRootUuid(PROJECT_UUID) + project = ComponentTesting.newProjectDto(PROJECT_UUID) .setKey(PROJECT_KEY) .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("PRJ") - .setEnabled(true); + .setLongName("SonarQube"); db.componentDao().insert(dbSession, project); profile = QProfileTesting.newXooP1(); @@ -122,24 +118,14 @@ public class QProfileProjectOperationsMediumTest { @Test public void remove_all_projects() { - ComponentDto project1 = new ComponentDto() - .setUuid("BCDE") - .setRootUuid("BCDE") + ComponentDto project1 = ComponentTesting.newProjectDto("BCDE") .setKey("project1") .setName("project1") - .setLongName("project1") - .setQualifier("TRK") - .setScope("PRJ") - .setEnabled(true); - ComponentDto project2 = new ComponentDto() - .setUuid("CDEF") - .setRootUuid("CDEF") + .setLongName("project1"); + ComponentDto project2 = ComponentTesting.newProjectDto("CDEF") .setKey("project2") .setName("project2") - .setLongName("project2") - .setQualifier("TRK") - .setScope("PRJ") - .setEnabled(true); + .setLongName("project2"); db.componentDao().insert(dbSession, project1); db.componentDao().insert(dbSession, project2); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index d58e2c97b48..82dd715b4b1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -34,6 +34,7 @@ import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentTesting; import org.sonar.db.qualityprofile.ActiveRuleDao; import org.sonar.db.qualityprofile.ActiveRuleDto; import org.sonar.db.qualityprofile.ActiveRuleKey; @@ -441,16 +442,7 @@ public class QProfilesWsMediumTest { @Test public void add_project_with_key_and_uuid() throws Exception { - ComponentDto project = new ComponentDto() - .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + ComponentDto project = ComponentTesting.newProjectDto("ABCD").setId(1L); db.componentDao().insert(session, project); QualityProfileDto profile = QProfileTesting.newXooP1(); db.qualityProfileDao().insert(session, profile); @@ -471,16 +463,7 @@ public class QProfilesWsMediumTest { @Test public void change_project_association_with_key_and_uuid() throws Exception { - ComponentDto project = new ComponentDto() - .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + ComponentDto project = ComponentTesting.newProjectDto("ABCD").setId(1L); db.componentDao().insert(session, project); QualityProfileDto profile1 = QProfileTesting.newXooP1(); QualityProfileDto profile2 = QProfileTesting.newXooP2(); @@ -497,16 +480,7 @@ public class QProfilesWsMediumTest { @Test public void add_project_with_name_language_and_key() throws Exception { - ComponentDto project = new ComponentDto() - .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + ComponentDto project = ComponentTesting.newProjectDto("ABCD").setId(1L); db.componentDao().insert(session, project); QualityProfileDto profile = QProfileTesting.newXooP1(); db.qualityProfileDao().insert(session, profile); @@ -563,16 +537,7 @@ public class QProfilesWsMediumTest { @Test public void remove_project_with_key_and_uuid() throws Exception { - ComponentDto project = new ComponentDto() - .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + ComponentDto project = ComponentTesting.newProjectDto("ABCD").setId(1L); db.componentDao().insert(session, project); QualityProfileDto profile = QProfileTesting.newXooP1(); db.qualityProfileDao().insert(session, profile); @@ -588,16 +553,7 @@ public class QProfilesWsMediumTest { @Test public void remove_project_with_name_language_and_key() throws Exception { - ComponentDto project = new ComponentDto() - .setId(1L) - .setUuid("ABCD") - .setRootUuid("ABCD") - .setKey("org.codehaus.sonar:sonar") - .setName("SonarQube") - .setLongName("SonarQube") - .setQualifier("TRK") - .setScope("TRK") - .setEnabled(true); + ComponentDto project = ComponentTesting.newProjectDto("ABCD").setId(1L); db.componentDao().insert(session, project); QualityProfileDto profile = QProfileTesting.newXooP1(); db.qualityProfileDao().insert(session, profile); diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java index 6ba9fc08daf..71c738b5a7a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java @@ -116,6 +116,7 @@ public class ListActionTest { TestFile2.dto(), new ComponentDto() .setUuid(mainFileUuid) + .setUuidPath(TestFile1.PROJECT_UUID + "." + mainFileUuid + ".") .setRootUuid(TestFile1.PROJECT_UUID) .setProjectUuid(TestFile1.PROJECT_UUID)); db.getSession().commit(); @@ -141,6 +142,7 @@ public class ListActionTest { TestFile2.dto(), new ComponentDto() .setUuid(sourceFileUuid) + .setUuidPath(TestFile1.PROJECT_UUID + "." + sourceFileUuid + ".") .setRootUuid(TestFile1.PROJECT_UUID) .setKey(sourceFileKey) .setProjectUuid(TestFile1.PROJECT_UUID)); @@ -194,7 +196,11 @@ public class ListActionTest { public void fail_when_no_sufficient_privilege_on_main_file_uuid() throws Exception { userSessionRule.addProjectUuidPermissions(UserRole.USER, TestFile1.PROJECT_UUID); String mainFileUuid = "MAIN-FILE-UUID"; - dbClient.componentDao().insert(db.getSession(), new ComponentDto().setUuid(mainFileUuid).setRootUuid(TestFile1.PROJECT_UUID).setProjectUuid(TestFile1.PROJECT_UUID)); + dbClient.componentDao().insert(db.getSession(), new ComponentDto() + .setUuid(mainFileUuid) + .setUuidPath(TestFile1.PROJECT_UUID + "." + mainFileUuid + ".") + .setRootUuid(TestFile1.PROJECT_UUID) + .setProjectUuid(TestFile1.PROJECT_UUID)); db.getSession().commit(); ws.newGetRequest("api/tests", "list") @@ -216,6 +222,7 @@ public class ListActionTest { private static final class TestFile1 { public static final String UUID = "TEST-UUID-1"; public static final String FILE_UUID = "ABCD"; + public static final String FILE_UUID_PATH = "PROJECT-UUID.ABCD."; public static final String PROJECT_UUID = "PROJECT-UUID"; public static final String NAME = "test1"; public static final String STATUS = "OK"; @@ -229,6 +236,7 @@ public class ListActionTest { public static ComponentDto dto() { return new ComponentDto() .setUuid(TestFile1.FILE_UUID) + .setUuidPath(TestFile1.FILE_UUID_PATH) .setRootUuid(TestFile1.PROJECT_UUID) .setLongName(TestFile1.LONG_NAME) .setProjectUuid(TestFile1.PROJECT_UUID) @@ -256,6 +264,7 @@ public class ListActionTest { private static final class TestFile2 { public static final String UUID = "TEST-UUID-2"; public static final String FILE_UUID = "BCDE"; + public static final String FILE_UUID_PATH = "PROJECT-UUID.BCDE."; public static final String PROJECT_UUID = "PROJECT-UUID"; public static final String NAME = "test2"; public static final String STATUS = "ERROR"; @@ -268,7 +277,8 @@ public class ListActionTest { public static ComponentDto dto() { return new ComponentDto() - .setUuid(TestFile2.FILE_UUID) + .setUuid(FILE_UUID) + .setUuidPath(FILE_UUID_PATH) .setRootUuid(TestFile2.PROJECT_UUID) .setLongName(TestFile2.LONG_NAME) .setProjectUuid(TestFile2.PROJECT_UUID) diff --git a/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/return_only_authorized_projects_from_view.xml b/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/return_only_authorized_projects_from_view.xml index 0c271cedf2d..530071f7ec9 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/return_only_authorized_projects_from_view.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/return_only_authorized_projects_from_view.xml @@ -1,30 +1,109 @@ - + - + - + - + - + - + - - - + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/shared.xml index 989b7def85e..88002ac3173 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/component/ws/SearchViewComponentsActionTest/shared.xml @@ -1,35 +1,129 @@ - - + + - + - + - + - + - + - + - - - + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/activity/ActivityManagerTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/activity/ActivityManagerTest/shared.xml index 3e4fda90137..01bd67a20ee 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/activity/ActivityManagerTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/activity/ActivityManagerTest/shared.xml @@ -1,13 +1,40 @@ - + + id="110" + uuid="u110" + project_id="10" + parent_snapshot_id="[null]" + root_project_id="10" + root_snapshot_id="[null]" + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1225544280000" + build_date="1225544280000" + version="[null]" + path="" + status="P" + islast="[false]" + depth="0"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MeasureRepositoryImplTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MeasureRepositoryImplTest/shared.xml index 6b25fb48b90..5815c0a7318 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MeasureRepositoryImplTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MeasureRepositoryImplTest/shared.xml @@ -1,11 +1,22 @@ - + + component_uuid="uuid_1" + root_component_uuid="uuid_1" + islast="[true]"/> - - + component_uuid="uuid_1" + root_component_uuid="uuid_1" + islast="[false]"/> + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml index cbe40829665..289d321734a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml @@ -1,55 +1,123 @@ - - - - + + + + - + - + - + - + + project_id="1" + root_project_id="1" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1225544280000" + build_date="1225544280000" + status="P" + islast="false"/> + project_id="2" + root_project_id="1" + root_snapshot_id="1000" + scope="DIR" + qualifier="PAC" + created_at="1225544280000" + build_date="1225544280000" + status="P" + islast="false"/> - - - - diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/empty.xml index a01559680bc..0cbdd6ccc10 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/empty.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/empty.xml @@ -1,5 +1,9 @@ - + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/no_previous_version.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/no_previous_version.xml index ee0040b86c3..ac942bded85 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/no_previous_version.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/no_previous_version.xml @@ -1,58 +1,180 @@ - + + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1226379600000" + build_date="1226379600000" + version="0.9" + path="" + status="P" + islast="[false]" + depth="0"/> + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1226494680000" + build_date="1226494680000" + version="1.0" + path="" + status="P" + islast="[false]" + depth="0"/> + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1227157200000" + build_date="1227157200000" + version="1.1" + path="" + status="P" + islast="[false]" + depth="0"/> + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1227358680000" + build_date="1227358680000" + version="1.1" + path="" + status="P" + islast="[false]" + depth="0"/> + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1227934800000" + build_date="1227934800000" + version="1.1" + path="" + status="P" + islast="[true]" + depth="0"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_deleted.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_deleted.xml index 73af5e041c0..d726b7c810f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_deleted.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_deleted.xml @@ -3,6 +3,7 @@ diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_is_last_one.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_is_last_one.xml index 3b718bf9810..ddf898c43b5 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_is_last_one.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/previous_version_is_last_one.xml @@ -1,18 +1,44 @@ - + + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1226379600000" + build_date="1226379600000" + version="0.9" + path="" + status="P" + islast="[true]" + depth="0"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/shared.xml index ceaa3476468..dde047d1844 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/shared.xml @@ -4,6 +4,7 @@ kee="ROOT_KEY" name="project" uuid="ABCD" + uuid_path="NOT_USED" root_uuid="ABCD"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/unprocessed_snapshots.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/unprocessed_snapshots.xml index 75bb4dd7815..05c39dd9eb3 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/unprocessed_snapshots.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/LoadPeriodsStepTest/unprocessed_snapshots.xml @@ -1,17 +1,52 @@ - + + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + scope="PRJ" + qualifier="TRK" + created_at="1226379600000" + build_date="1226379600000" + version="0.9" + path="" + status="U" + islast="[false]" + depth="0"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml index 60d27b9ae4b..bfb676b510a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_component_id_from_db.xml @@ -1,11 +1,29 @@ - + + component_uuid="ABCD" + root_component_uuid="ABCD" + islast="[true]"/> - + + component_uuid="BCDE" + root_component_uuid="ABCD" + islast="[true]"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml index a8b95ef4769..493de474817 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/load_project_id_from_db.xml @@ -1,11 +1,27 @@ - - + + + component_uuid="ABCD" + parent_snapshot_id="[null]" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + islast="[true]"/> + component_uuid="BCDE" + parent_snapshot_id="1" + root_component_uuid="ABCD" + root_snapshot_id="1" + islast="[true]"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml index 60d27b9ae4b..bfb676b510a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues.xml @@ -1,11 +1,29 @@ - + + component_uuid="ABCD" + root_component_uuid="ABCD" + islast="[true]"/> - + + component_uuid="BCDE" + root_component_uuid="ABCD" + islast="[true]"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml index fb18192c216..1d99aa35612 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml @@ -1,14 +1,32 @@ - + + component_uuid="ABCD" + root_component_uuid="ABCD" + islast="[true]"/> - + + component_uuid="BCDE" + root_component_uuid="ABCD" + islast="[true]"/> + /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/no_authorization.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/no_authorization.xml index b24592a016b..870e665683f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/no_authorization.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/no_authorization.xml @@ -1,16 +1,39 @@ - + - - + + - - + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/shared.xml index 4a8ebf00a64..fd8f98276bb 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationDaoTest/shared.xml @@ -1,36 +1,99 @@ - + - + - - - - + + + + - - - + + + - - - + + + - - - + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationIndexerTest/index.xml index 6ef3ef25402..6700e00ccbe 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueAuthorizationIndexerTest/index.xml @@ -1,22 +1,60 @@ - + - - - - + + + + - - - + + + - - + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml index 0651a152049..6ed27b0b58e 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml @@ -1,12 +1,34 @@ - + - - + + + /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index_project.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index_project.xml index e5aa741671c..15db5d0f386 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index_project.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index_project.xml @@ -1,13 +1,35 @@ - + - - + + - - + + - + - - - - + + + + + id="1" + kee="ABC" + resolution="FIXED" + status="RESOLVED" + severity="BLOCKER" + manual_severity="[false]" + assignee="guy1" + author_login="guy2" + checksum="FFFFF" + gap="[null]" + effort="10" + message="[null]" + line="444" + component_uuid="FILE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="[null]" + tags="tag1,tag2,tag3" + created_at="1400000000000" + updated_at="1400000000000" + issue_creation_date="1115848800000" + issue_update_date="1356994800000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="2" + kee="DEF" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="444" + component_uuid="ROOT_FILE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="[null]" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="3" + kee="EFG" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="[null]" + component_uuid="PROJECT" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="[null]" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="4" + kee="FGH" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="[null]" + component_uuid="MODULE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="[null]" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_file_path.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_file_path.xml index f7d0cd8bbda..7d0ec58c7ef 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_file_path.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_file_path.xml @@ -1,126 +1,167 @@ - + - - - - + + + + + id="1" + kee="ABC" + resolution="FIXED" + status="RESOLVED" + severity="BLOCKER" + manual_severity="[false]" + assignee="guy1" + author_login="guy2" + checksum="FFFFF" + gap="[null]" + effort="10" + message="[null]" + line="444" + component_uuid="FILE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="PLAN1" + tags="tag1,tag2,tag3" + created_at="1400000000000" + updated_at="1400000000000" + issue_creation_date="1115848800000" + issue_update_date="1356994800000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="2" + kee="DEF" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="444" + component_uuid="ROOT_FILE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="PLAN2" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="3" + kee="EFG" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="[null]" + component_uuid="PROJECT" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="PLAN2" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> + id="4" + kee="FGH" + resolution="[null]" + status="OPEN" + severity="MAJOR" + manual_severity="[false]" + assignee="guy2" + author_login="[null]" + checksum="FFFFF" + gap="[null]" + effort="15" + message="[null]" + line="[null]" + component_uuid="MODULE" + project_uuid="PROJECT" + rule_id="200" + reporter="[null]" + issue_attributes="JIRA=http://jira.com" + action_plan_key="PLAN2" + tags="[null]" + created_at="1400000000000" + updated_at="1450000000000" + issue_creation_date="1115848800000" + issue_update_date="1368828000000" + issue_close_date="[null]" + locations="[null]" + issue_type="1"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/many_projects.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/many_projects.xml index d7b49d669db..758f56683df 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/many_projects.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/many_projects.xml @@ -1,13 +1,35 @@ - + - - + + - - + + - + - - - - + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml index 00a834ce17f..396bb288c47 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml @@ -1,11 +1,52 @@ - + - - - - + + + + + /> + /> + /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/escape_percent_and_underscore_when_filter_by_component_name_or_key.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/escape_percent_and_underscore_when_filter_by_component_name_or_key.xml index 354308dbda2..865e3dd6cab 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/escape_percent_and_underscore_when_filter_by_component_name_or_key.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/escape_percent_and_underscore_when_filter_by_component_name_or_key.xml @@ -1,75 +1,218 @@ - + - + - + id="3" + root_uuid="ABCD"/> - + + component_uuid="ABCD" + root_component_uuid="ABCD" + root_snapshot_id="[null]" + parent_snapshot_id="[null]" + scope="FIL" + qualifier="CLA" + path="" + depth="0" + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + created_at="1229727600000" + build_date="1229727600000" + version="1.0" + status="P" + islast="[true]"/> + component_uuid="BCDE" + root_component_uuid="ABCD" + root_snapshot_id="101" + parent_snapshot_id="101" + scope="FIL" + qualifier="CLA" + path="101." + depth="1" + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + created_at="1229727600000" + build_date="1229727600000" + version="1.0" + status="P" + islast="[true]"/> + component_uuid="CDEF" + root_component_uuid="ABCD" + root_snapshot_id="101" + parent_snapshot_id="102" + scope="FIL" + qualifier="CLA" + path="101.102." + depth="2" + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + created_at="1229727600000" + build_date="1229727600000" + version="1.0" + status="P" + islast="[true]"/> + component_uuid="DEFG" + root_component_uuid="ABCD" + root_snapshot_id="101" + parent_snapshot_id="102" + scope="FIL" + qualifier="CLA" + path="101.102." + depth="2" + purge_status="[null]" + period1_mode="[null]" + period1_param="[null]" + period1_date="[null]" + period2_mode="[null]" + period2_param="[null]" + period2_date="[null]" + period3_mode="[null]" + period3_param="[null]" + period3_date="[null]" + period4_mode="[null]" + period4_param="[null]" + period4_date="[null]" + period5_mode="[null]" + period5_param="[null]" + period5_date="[null]" + created_at="1229727600000" + build_date="1229727600000" + version="1.0" + status="P" + islast="[true]"/> - - - - + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml index a1159c552a6..87064ba708a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml @@ -1,30 +1,77 @@ -