From: Sébastien Lesaint Date: Tue, 14 Jun 2016 13:22:05 +0000 (+0200) Subject: SONAR-7738 support in code use of *_UUID instead of PROJECTS._*ID X-Git-Tag: 6.0-RC1~299 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bdd0de3b9ff7a92ec55c271ca28be72b5347aa98;p=sonarqube.git SONAR-7738 support in code use of *_UUID instead of PROJECTS._*ID --- 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 670dfea5f9c..5af8eddb220 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 @@ -31,9 +31,9 @@ import java.util.Map; import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.i18n.I18n; import org.sonar.api.resources.Scopes; -import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; @@ -112,7 +112,7 @@ public class ComponentService { try { ComponentDto projectOrModule = getByKey(session, projectOrModuleKey); userSession.checkComponentUuidPermission(UserRole.ADMIN, projectOrModule.projectUuid()); - dbClient.resourceKeyUpdaterDao().updateKey(projectOrModule.getId(), newKey); + dbClient.resourceKeyUpdaterDao().updateKey(projectOrModule.uuid(), newKey); session.commit(); session.commit(); @@ -126,7 +126,7 @@ public class ComponentService { try { ComponentDto project = getByKey(projectKey); userSession.checkComponentUuidPermission(UserRole.ADMIN, project.projectUuid()); - return dbClient.resourceKeyUpdaterDao().checkModuleKeysBeforeRenaming(project.getId(), stringToReplace, replacementString); + return dbClient.resourceKeyUpdaterDao().checkModuleKeysBeforeRenaming(project.uuid(), stringToReplace, replacementString); } finally { session.close(); } @@ -138,7 +138,7 @@ public class ComponentService { try { ComponentDto project = getByKey(session, projectKey); userSession.checkComponentUuidPermission(UserRole.ADMIN, project.projectUuid()); - dbClient.resourceKeyUpdaterDao().bulkUpdateKey(session, project.getId(), stringToReplace, replacementString); + dbClient.resourceKeyUpdaterDao().bulkUpdateKey(session, project.uuid(), stringToReplace, replacementString); session.commit(); } finally { session.close(); @@ -185,6 +185,7 @@ public class ComponentService { String uuid = Uuids.create(); ComponentDto component = new ComponentDto() .setUuid(uuid) + .setRootUuid(uuid) .setModuleUuid(null) .setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP + uuid + ComponentDto.MODULE_UUID_PATH_SEP) .setProjectUuid(uuid) diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java index 71580811805..5e3291dbeb0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java @@ -134,11 +134,11 @@ public class AppAction implements RequestHandler { json.prop("longName", component.longName()); json.prop("q", component.qualifier()); - ComponentDto parentProject = nullableComponentById(component.parentProjectId(), session); + ComponentDto parentProject = retrieveRootIfNotCurrentComponent(component, session); ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid()); // Do not display parent project if parent project and project are the same - boolean displayParentProject = parentProject != null && !parentProject.getId().equals(project.getId()); + boolean displayParentProject = parentProject != null && !parentProject.uuid().equals(project.uuid()); json.prop("subProject", displayParentProject ? parentProject.key() : null); json.prop("subProjectName", displayParentProject ? parentProject.longName() : null); json.prop("project", project.key()); @@ -188,11 +188,11 @@ public class AppAction implements RequestHandler { } @CheckForNull - private ComponentDto nullableComponentById(@Nullable Long componentId, DbSession session) { - if (componentId != null) { - return dbClient.componentDao().selectOrFailById(session, componentId); + private ComponentDto retrieveRootIfNotCurrentComponent(ComponentDto componentDto, DbSession session) { + if (componentDto.uuid().equals(componentDto.getRootUuid())) { + return null; } - return null; + return dbClient.componentDao().selectOrFailByUuid(session, componentDto.getRootUuid()); } @CheckForNull diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java index b538fd7e56b..3fadd22a6c6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java @@ -50,11 +50,11 @@ class ComponentDtoToWsComponent { return wsComponent; } - static WsComponents.Component.Builder componentDtoToWsComponent(ComponentDto component, Map referenceComponentsById) { + static WsComponents.Component.Builder componentDtoToWsComponent(ComponentDto component, Map referenceComponentsByUuid) { WsComponents.Component.Builder wsComponent = componentDtoToWsComponent(component); - ComponentDto referenceComponent = referenceComponentsById.get(component.getCopyResourceId()); - if (!referenceComponentsById.isEmpty() && referenceComponent != null) { + ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); + if (referenceComponent != null) { wsComponent.setRefId(referenceComponent.uuid()); wsComponent.setRefKey(referenceComponent.key()); } 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 3ba6e4d9c96..41225d4d5c2 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 @@ -19,18 +19,15 @@ */ package org.sonar.server.component.ws; -import com.google.common.base.Function; 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.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import org.sonar.api.i18n.I18n; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.server.ws.Request; @@ -179,31 +176,26 @@ public class TreeAction implements ComponentsWsAction { default: throw new IllegalStateException("Unknown component tree strategy"); } - Map referenceComponentUuidsById = searchReferenceComponentUuidsById(dbSession, components); + Map referenceComponentsByUuid = searchreferenceComponentsByUuid(dbSession, components); - return buildResponse(baseComponent, components, referenceComponentUuidsById, + return buildResponse(baseComponent, components, referenceComponentsByUuid, Paging.forPageIndex(query.getPage()).withPageSize(query.getPageSize()).andTotal(total)); } finally { dbClient.closeSession(dbSession); } } - private Map searchReferenceComponentUuidsById(DbSession dbSession, List components) { - List referenceComponentIds = from(components) - .transform(ComponentDtoWithSnapshotIdToCopyResourceIdFunction.INSTANCE) - .filter(Predicates.notNull()) + private Map searchreferenceComponentsByUuid(DbSession dbSession, List components) { + List referenceComponentIds = from(components) + .transform(ComponentDto::getCopyResourceUuid) + .filter(Predicates.notNull()) .toList(); if (referenceComponentIds.isEmpty()) { return emptyMap(); } - List referenceComponents = dbClient.componentDao().selectByIds(dbSession, referenceComponentIds); - Map referenceComponentUuidsById = new HashMap<>(); - for (ComponentDto referenceComponent : referenceComponents) { - referenceComponentUuidsById.put(referenceComponent.getId(), referenceComponent); - } - - return referenceComponentUuidsById; + return from(dbClient.componentDao().selectByUuids(dbSession, referenceComponentIds)) + .uniqueIndex(ComponentDto::uuid); } private void checkPermissions(ComponentDto baseComponent) { @@ -215,8 +207,8 @@ public class TreeAction implements ComponentsWsAction { } } - private static TreeWsResponse buildResponse(ComponentDto baseComponent, List components, Map referenceComponentsById, - Paging paging) { + private static TreeWsResponse buildResponse(ComponentDto baseComponent, List components, + Map referenceComponentsByUuid, Paging paging) { TreeWsResponse.Builder response = TreeWsResponse.newBuilder(); response.getPagingBuilder() .setPageIndex(paging.pageIndex()) @@ -224,9 +216,9 @@ public class TreeAction implements ComponentsWsAction { .setTotal(paging.total()) .build(); - response.setBaseComponent(componentDtoToWsComponent(baseComponent, referenceComponentsById)); + response.setBaseComponent(componentDtoToWsComponent(baseComponent, referenceComponentsByUuid)); for (ComponentDto dto : components) { - response.addComponents(componentDtoToWsComponent(dto, referenceComponentsById)); + response.addComponents(componentDtoToWsComponent(dto, referenceComponentsByUuid)); } return response.build(); @@ -238,7 +230,7 @@ public class TreeAction implements ComponentsWsAction { .setTotal(0) .setPageIndex(request.getPage()) .setPageSize(request.getPageSize()); - response.setBaseComponent(componentDtoToWsComponent(baseComponent, Collections.emptyMap())); + response.setBaseComponent(componentDtoToWsComponent(baseComponent, Collections.emptyMap())); return response.build(); } @@ -302,11 +294,4 @@ public class TreeAction implements ComponentsWsAction { return treeWsRequest; } - private enum ComponentDtoWithSnapshotIdToCopyResourceIdFunction implements Function { - INSTANCE; - @Override - public Long apply(@Nonnull ComponentDtoWithSnapshotId input) { - return input.getCopyResourceId(); - } - } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java index 2b1b0cb2c87..646db69d9a2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ProjectViewAttributes.java @@ -25,18 +25,12 @@ import static java.util.Objects.requireNonNull; @Immutable public class ProjectViewAttributes { - private final long projectId; private final String projectUuid; - public ProjectViewAttributes(long projectId, String projectUuid) { - this.projectId = projectId; + public ProjectViewAttributes(String projectUuid) { this.projectUuid = requireNonNull(projectUuid, "projectUuid can't be null"); } - public long getProjectId() { - return projectId; - } - public String getProjectUuid() { return projectUuid; } @@ -44,7 +38,6 @@ public class ProjectViewAttributes { @Override public String toString() { return "ProjectViewAttributes{" + - "projectId=" + projectId + ", projectUuid='" + projectUuid + '\'' + '}'; } 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 d70fd5cce3e..823361a13a8 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 @@ -192,6 +192,7 @@ public class PersistComponentsStep implements ComputationStep { res.setLongName(res.name()); res.setDescription(project.getDescription()); res.setProjectUuid(res.uuid()); + res.setRootUuid(res.uuid()); res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); return res; @@ -250,6 +251,7 @@ public class PersistComponentsStep implements ComputationStep { res.setDescription(view.getDescription()); res.setLongName(res.name()); res.setProjectUuid(res.uuid()); + res.setRootUuid(res.uuid()); res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); return res; @@ -276,7 +278,7 @@ public class PersistComponentsStep implements ComputationStep { res.setQualifier(Qualifiers.PROJECT); res.setName(projectView.getName()); res.setLongName(res.name()); - res.setCopyResourceId(projectView.getProjectViewAttributes().getProjectId()); + res.setCopyComponentUuid(projectView.getProjectViewAttributes().getProjectUuid()); setRootAndParentModule(res, path); @@ -301,7 +303,7 @@ public class PersistComponentsStep implements ComputationStep { */ private static void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path path) { ComponentDto projectDto = from(path.getCurrentPath()).last().get().getElement().getDto(); - res.setParentProjectId(projectDto.getId()); + res.setRootUuid(projectDto.uuid()); res.setProjectUuid(projectDto.uuid()); ComponentDto parentModule = path.parent().getDto(); @@ -318,7 +320,7 @@ public class PersistComponentsStep implements ComputationStep { .first() .get() .getElement().getDto(); - componentDto.setParentProjectId(parentModule.getId()); + componentDto.setRootUuid(parentModule.uuid()); componentDto.setProjectUuid(parentModule.projectUuid()); componentDto.setModuleUuid(parentModule.uuid()); componentDto.setModuleUuidPath(parentModule.moduleUuidPath()); @@ -350,12 +352,12 @@ public class PersistComponentsStep implements ComputationStep { existingComponent.setModuleUuidPath(newComponent.moduleUuidPath()); modified = true; } - if (!ObjectUtils.equals(existingComponent.parentProjectId(), newComponent.parentProjectId())) { - existingComponent.setParentProjectId(newComponent.parentProjectId()); + if (!ObjectUtils.equals(existingComponent.getRootUuid(), newComponent.getRootUuid())) { + existingComponent.setRootUuid(newComponent.getRootUuid()); modified = true; } - if (!ObjectUtils.equals(existingComponent.getCopyResourceId(), newComponent.getCopyResourceId())) { - existingComponent.setCopyResourceId(newComponent.getCopyResourceId()); + if (!ObjectUtils.equals(existingComponent.getCopyResourceUuid(), newComponent.getCopyResourceUuid())) { + existingComponent.setCopyComponentUuid(newComponent.getCopyResourceUuid()); modified = true; } if (!existingComponent.isEnabled()) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsJsonWriter.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsJsonWriter.java index c741633990c..1e6cee7f956 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsJsonWriter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsJsonWriter.java @@ -84,7 +84,7 @@ public class DuplicationsJsonWriter { private void writeFiles(Map refByComponentKey, JsonWriter json, DbSession session) { Map projectsByUuid = newHashMap(); - Map parentProjectsById = newHashMap(); + Map parentProjectsByUuid = newHashMap(); for (Map.Entry entry : refByComponentKey.entrySet()) { String componentKey = entry.getKey(); String ref = entry.getValue(); @@ -95,7 +95,7 @@ public class DuplicationsJsonWriter { addFile(json, file); ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session); - ComponentDto parentProject = getParentProject(file.parentProjectId(), parentProjectsById, session); + ComponentDto parentProject = getParentProject(file.getRootUuid(), parentProjectsByUuid, session); addProject(json, project, parentProject); json.endObject(); @@ -116,7 +116,7 @@ public class DuplicationsJsonWriter { json.prop("projectName", project.longName()); // Do not return sub project if sub project and project are the same - boolean displaySubProject = subProject != null && !subProject.getId().equals(project.getId()); + boolean displaySubProject = subProject != null && !subProject.uuid().equals(project.uuid()); if (displaySubProject) { json.prop("subProject", subProject.key()); json.prop("subProjectUuid", subProject.uuid()); @@ -137,13 +137,13 @@ public class DuplicationsJsonWriter { return project; } - private ComponentDto getParentProject(@Nullable Long projectId, Map subProjectsById, DbSession session) { - ComponentDto project = subProjectsById.get(projectId); - if (project == null && projectId != null) { - Optional projectOptional = componentDao.selectById(session, projectId); + private ComponentDto getParentProject(String rootUuid, Map subProjectsByUuid, DbSession session) { + ComponentDto project = subProjectsByUuid.get(rootUuid); + if (project == null) { + Optional projectOptional = componentDao.selectByUuid(session, rootUuid); if (projectOptional.isPresent()) { project = projectOptional.get(); - subProjectsById.put(project.getId(), project); + subProjectsByUuid.put(project.uuid(), project); } } return project; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java index 5fa880c1cf7..266214b6ed3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java @@ -69,9 +69,7 @@ import static com.google.common.collect.FluentIterable.from; import static com.google.common.collect.Lists.newArrayList; import static java.lang.String.format; import static org.sonar.api.utils.DateUtils.longToDate; -import static org.sonar.db.component.ComponentDtoFunctions.toCopyResourceId; import static org.sonar.db.component.ComponentDtoFunctions.toProjectUuid; -import static org.sonar.db.component.ComponentDtoFunctions.toUuid; import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonarqube.ws.client.issue.IssueFilterParameters.COMPONENTS; @@ -403,9 +401,7 @@ public class IssueQueryService { Collection developerUuids = Collections2.transform(technicalProjects, toProjectUuid()); Collection authorsFromProjects = authorsFromParamsOrFromDeveloper(session, developerUuids, authors); builder.authors(authorsFromProjects); - Collection projectIds = Collections2.transform(technicalProjects, toCopyResourceId()); - List originalProjects = dbClient.componentDao().selectByIds(session, projectIds); - Collection projectUuids = Collections2.transform(originalProjects, toUuid()); + Collection projectUuids = Collections2.transform(technicalProjects, ComponentDto::getCopyResourceUuid); builder.projectUuids(projectUuids); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDao.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDao.java index d61b0ff76a2..96d06a875b1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDao.java @@ -92,7 +92,7 @@ public class IssueAuthorizationDao { " FROM projects " + " WHERE " + " projects.qualifier = 'TRK' " + - " AND projects.copy_resource_id is NULL " + + " AND projects.copy_component_uuid is NULL " + " {dateCondition} " + " UNION " + @@ -108,7 +108,7 @@ public class IssueAuthorizationDao { " INNER JOIN users ON users.id = user_roles.user_id " + " WHERE " + " projects.qualifier = 'TRK' " + - " AND projects.copy_resource_id is NULL " + + " AND projects.copy_component_uuid is NULL " + " {dateCondition} " + " UNION " + @@ -124,7 +124,7 @@ public class IssueAuthorizationDao { " INNER JOIN groups ON groups.id = group_roles.group_id " + " WHERE " + " projects.qualifier = 'TRK' " + - " AND projects.copy_resource_id is NULL " + + " AND projects.copy_component_uuid is NULL " + " {dateCondition} " + " AND group_id IS NOT NULL " + " UNION " + @@ -140,7 +140,7 @@ public class IssueAuthorizationDao { " INNER JOIN group_roles ON group_roles.resource_id = projects.id AND group_roles.role='user' " + " WHERE " + " projects.qualifier = 'TRK' " + - " AND projects.copy_resource_id is NULL " + + " AND projects.copy_component_uuid is NULL " + " {dateCondition} " + " AND group_roles.group_id IS NULL " + " ) project_authorization"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index f3d9f339afb..e9385a5c47d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -304,10 +304,11 @@ public class SearchResponseFormat { Collection components = data.getComponents(); if (components != null) { for (ComponentDto dto : components) { + String uuid = dto.uuid(); Issues.Component.Builder builder = Issues.Component.newBuilder() .setId(dto.getId()) .setKey(dto.key()) - .setUuid(dto.uuid()) + .setUuid(uuid) .setQualifier(dto.qualifier()) .setName(nullToEmpty(dto.name())) .setLongName(nullToEmpty(dto.longName())) @@ -320,12 +321,11 @@ public class SearchResponseFormat { } // On a root project, parentProjectId is null but projectId is equal to itself, which make no sense. - if (dto.projectUuid() != null && dto.parentProjectId() != null) { + if (!uuid.equals(dto.getRootUuid())) { ComponentDto project = data.getComponentByUuid(dto.projectUuid()); builder.setProjectId(project.getId()); - } - if (dto.parentProjectId() != null) { - builder.setSubProjectId(dto.parentProjectId()); + ComponentDto subProject = data.getComponentByUuid(dto.getRootUuid()); + builder.setSubProjectId(subProject.getId()); } result.add(builder.build()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterRow.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterRow.java index 0a8669bddd5..21fd8e7bf19 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterRow.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterRow.java @@ -24,15 +24,15 @@ import org.apache.commons.lang.StringUtils; public class MeasureFilterRow { private final long snapshotId; private final long resourceId; - private final long resourceRootId; + private final String rootComponentUuid; private String sortText = null; private Long sortDate = null; private Double sortDouble = null; - MeasureFilterRow(long snapshotId, long resourceId, long resourceRootId) { + MeasureFilterRow(long snapshotId, long resourceId, String rootComponentUuid) { this.snapshotId = snapshotId; this.resourceId = resourceId; - this.resourceRootId = resourceRootId; + this.rootComponentUuid = rootComponentUuid; } public long getSnapshotId() { @@ -43,8 +43,8 @@ public class MeasureFilterRow { return resourceId; } - public long getResourceRootId() { - return resourceRootId; + public String getRootComponentUuid() { + return rootComponentUuid; } public String getSortText() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java index 125fe79428e..211b867bcb6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java @@ -96,7 +96,7 @@ class MeasureFilterSql { private String generateSql() { StringBuilder sb = new StringBuilder(1000); - sb.append("SELECT s.id, p.id, root.id, "); + sb.append("SELECT s.id, p.id, root.uuid, "); sb.append(filter.sort().column()); sb.append(" FROM snapshots s"); sb.append(" INNER JOIN projects p ON s.component_uuid=p.uuid "); @@ -134,7 +134,7 @@ class MeasureFilterSql { private void appendResourceConditions(StringBuilder sb) { sb.append(" s.status='P' AND s.islast=").append(database.getDialect().getTrueSqlValue()); if (context.getBaseSnapshot() == null) { - sb.append(" AND p.copy_resource_id IS NULL "); + sb.append(" AND p.copy_component_uuid IS NULL "); } if (!filter.getResourceQualifiers().isEmpty()) { sb.append(" AND s.qualifier IN "); @@ -259,7 +259,7 @@ class MeasureFilterSql { static class TextSortRowProcessor extends RowProcessor { @Override MeasureFilterRow fetch(ResultSet rs) throws SQLException { - MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); + MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); row.setSortText(rs.getString(4)); return row; } @@ -304,7 +304,7 @@ class MeasureFilterSql { @Override MeasureFilterRow fetch(ResultSet rs) throws SQLException { - MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); + MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); double value = rs.getDouble(4); if (!rs.wasNull()) { row.setSortDouble(value); @@ -333,7 +333,7 @@ class MeasureFilterSql { @Override MeasureFilterRow fetch(ResultSet rs) throws SQLException { - MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); + MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); row.setSortDate(rs.getTimestamp(4).getTime()); return row; } @@ -352,7 +352,7 @@ class MeasureFilterSql { @Override MeasureFilterRow fetch(ResultSet rs) throws SQLException { - MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); + MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); row.setSortDate(rs.getLong(4)); return row; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index 5a8f2b7e18e..185bd453cfe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -58,6 +58,8 @@ import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.collect.FluentIterable.from; import static java.lang.String.format; import static java.util.Collections.emptyList; +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY; import static org.sonar.server.component.ComponentFinder.ParamNames.DEVELOPER_ID_AND_KEY; @@ -156,11 +158,11 @@ public class ComponentAction implements MeasuresWsAction { } private Optional getReferenceComponent(DbSession dbSession, ComponentDto component) { - if (component.getCopyResourceId() == null) { + if (component.getCopyResourceUuid() == null) { return Optional.absent(); } - return dbClient.componentDao().selectById(dbSession, component.getCopyResourceId()); + return dbClient.componentDao().selectByUuid(dbSession, component.getCopyResourceUuid()); } private static ComponentWsResponse buildResponse(ComponentWsRequest request, ComponentDto component, Optional refComponent, List measures, @@ -172,12 +174,12 @@ public class ComponentAction implements MeasuresWsAction { MetricDto metric = metricsById.get(measure.getMetricId()); measuresByMetric.put(metric, measure); } - Map referenceComponentUuidById = new HashMap<>(); if (refComponent.isPresent()) { - referenceComponentUuidById.put(refComponent.get().getId(), refComponent.get()); + response.setComponent(componentDtoToWsComponent(component, measuresByMetric, singletonMap(refComponent.get().uuid(), refComponent.get()))); + } else { + response.setComponent(componentDtoToWsComponent(component, measuresByMetric, emptyMap())); } - response.setComponent(componentDtoToWsComponent(component, measuresByMetric, referenceComponentUuidById)); List additionalFields = request.getAdditionalFields(); if (additionalFields != null) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java index 123dfdc9c97..ea97045cd0c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java @@ -33,11 +33,11 @@ class ComponentDtoToWsComponent { } static WsMeasures.Component.Builder componentDtoToWsComponent(ComponentDto component, Map measuresByMetric, - Map referenceComponentsById) { + Map referenceComponentsByUuid) { WsMeasures.Component.Builder wsComponent = componentDtoToWsComponent(component); - ComponentDto referenceComponent = referenceComponentsById.get(component.getCopyResourceId()); - if (!referenceComponentsById.isEmpty() && referenceComponent != null) { + ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); + if (referenceComponent != null) { wsComponent.setRefId(referenceComponent.uuid()); wsComponent.setRefKey(referenceComponent.key()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java index be23ef35f58..2b872defd6f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java @@ -216,13 +216,13 @@ public class ComponentTreeAction implements MeasuresWsAction { componentDtoToWsComponent( data.getBaseComponent(), data.getMeasuresByComponentUuidAndMetric().row(data.getBaseComponent().uuid()), - data.getReferenceComponentsById())); + data.getReferenceComponentsByUuid())); for (ComponentDto componentDto : data.getComponents()) { response.addComponents(componentDtoToWsComponent( componentDto, data.getMeasuresByComponentUuidAndMetric().row(componentDto.uuid()), - data.getReferenceComponentsById())); + data.getReferenceComponentsByUuid())); } if (areMetricsInResponse(request)) { 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 7c4505c61bf..78e779e4ff3 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 @@ -35,7 +35,7 @@ class ComponentTreeData { private final ComponentDto baseComponent; private final List components; private final int componentCount; - private final Map referenceComponentsById; + private final Map referenceComponentsByUuid; private final List metrics; private final List periods; private final Table measuresByComponentUuidAndMetric; @@ -44,7 +44,7 @@ class ComponentTreeData { this.baseComponent = builder.baseComponent; this.components = builder.componentsFromDb; this.componentCount = builder.componentCount; - this.referenceComponentsById = builder.referenceComponentsById; + this.referenceComponentsByUuid = builder.referenceComponentsByUuid; this.metrics = builder.metrics; this.measuresByComponentUuidAndMetric = builder.measuresByComponentUuidAndMetric; this.periods = builder.periods; @@ -65,8 +65,8 @@ class ComponentTreeData { } @CheckForNull - public Map getReferenceComponentsById() { - return referenceComponentsById; + public Map getReferenceComponentsByUuid() { + return referenceComponentsByUuid; } @CheckForNull @@ -91,7 +91,7 @@ class ComponentTreeData { static class Builder { private ComponentDto baseComponent; private List componentsFromDb; - private Map referenceComponentsById; + private Map referenceComponentsByUuid; private int componentCount; private List metrics; private List periods; @@ -131,8 +131,8 @@ class ComponentTreeData { return this; } - public Builder setReferenceComponentsById(Map referenceComponentsById) { - this.referenceComponentsById = referenceComponentsById; + public Builder setReferenceComponentsByUuid(Map referenceComponentsByUuid) { + this.referenceComponentsByUuid = referenceComponentsByUuid; 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 3b29e1c58a4..4063539a8d3 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 @@ -24,6 +24,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.collect.FluentIterable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -121,7 +122,7 @@ public class ComponentTreeDataLoader { components = sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric); int componentCount = computeComponentCount(componentDtosAndTotal.total, components, componentWithMeasuresOnly(wsRequest)); components = paginateComponents(components, wsRequest); - Map referenceComponentsById = searchReferenceComponentsById(dbSession, components); + Map referenceComponentsById = searchReferenceComponentsById(dbSession, components); return ComponentTreeData.builder() .setBaseComponent(baseComponent) @@ -130,7 +131,7 @@ public class ComponentTreeDataLoader { .setMeasuresByComponentUuidAndMetric(measuresByComponentUuidAndMetric) .setMetrics(metrics) .setPeriods(periods) - .setReferenceComponentsById(referenceComponentsById) + .setReferenceComponentsByUuid(referenceComponentsById) .build(); } finally { dbClient.closeSession(dbSession); @@ -150,22 +151,17 @@ public class ComponentTreeDataLoader { return componentFinder.getByUuidOrKey(dbSession, wsRequest.getDeveloperId(), wsRequest.getDeveloperKey(), DEVELOPER_ID_AND_KEY).getId(); } - private Map searchReferenceComponentsById(DbSession dbSession, List components) { - List referenceComponentIds = from(components) - .transform(ComponentDtoWithSnapshotIdToCopyResourceIdFunction.INSTANCE) - .filter(Predicates.notNull()) + private Map searchReferenceComponentsById(DbSession dbSession, List components) { + List referenceComponentUUids = from(components) + .transform(ComponentDto::getCopyResourceUuid) + .filter(Predicates.notNull()) .toList(); - if (referenceComponentIds.isEmpty()) { + if (referenceComponentUUids.isEmpty()) { return emptyMap(); } - List referenceComponents = dbClient.componentDao().selectByIds(dbSession, referenceComponentIds); - Map referenceComponentUuidsById = new HashMap<>(); - for (ComponentDto referenceComponent : referenceComponents) { - referenceComponentUuidsById.put(referenceComponent.getId(), referenceComponent); - } - - return referenceComponentUuidsById; + return FluentIterable.from(dbClient.componentDao().selectByUuids(dbSession, referenceComponentUUids)) + .uniqueIndex(ComponentDto::uuid); } private ComponentDtosAndTotal searchComponents(DbSession dbSession, ComponentTreeQuery dbQuery, ComponentTreeWsRequest wsRequest) { @@ -409,15 +405,6 @@ public class ComponentTreeDataLoader { } } - private enum ComponentDtoWithSnapshotIdToCopyResourceIdFunction implements Function { - INSTANCE; - - @Override - public Long apply(@Nonnull ComponentDtoWithSnapshotId input) { - return input.getCopyResourceId(); - } - } - private static class MatchMetricKey implements Predicate { private final String metricKeyToSort; 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 e069e6c296b..96b87788136 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 @@ -207,7 +207,7 @@ public class CeQueueImplTest { } private static ComponentDto newComponentDto(String uuid) { - return new ComponentDto().setUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); + return new ComponentDto().setUuid(uuid).setRootUuid(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/batch/ProjectDataLoaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java index cc3683e6098..7ff44abc27d 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 @@ -80,6 +80,7 @@ public class ProjectDataLoaderTest { underTest.load(ProjectDataQuery.create().setModuleKey(key)); } + private int uuidCounter = 0; @Test public void load_fails_with_BRE_if_component_is_neither_a_project_or_a_module() { String[][] allScopesAndQualifierButProjectAndModule = { @@ -96,7 +97,8 @@ public class ProjectDataLoaderTest { String scope = scopeAndQualifier[0]; String qualifier = scopeAndQualifier[1]; String key = "theKey_" + scope + "_" + qualifier; - dbClient.componentDao().insert(dbSession, new ComponentDto().setScope(scope).setQualifier(qualifier).setKey(key)); + String uuid = "uuid_" + uuidCounter++; + dbClient.componentDao().insert(dbSession, new ComponentDto().setUuid(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 620b0e7dc55..c2b3c191354 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 @@ -85,8 +85,9 @@ public class TaskFormatterTest { @Test 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("COMPONENT_UUID").setKey("COMPONENT_KEY").setName("Component Name").setQualifier(Qualifiers.PROJECT)); + .setUuid(uuid).setRootUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name").setQualifier(Qualifiers.PROJECT)); CeQueueDto dto = new CeQueueDto(); dto.setUuid("UUID"); @@ -94,14 +95,14 @@ public class TaskFormatterTest { dto.setStatus(CeQueueDto.Status.IN_PROGRESS); dto.setCreatedAt(1_450_000_000_000L); dto.setStartedAt(1_451_000_000_000L); - dto.setComponentUuid("COMPONENT_UUID"); + dto.setComponentUuid(uuid); dto.setSubmitterLogin("rob"); WsCe.Task wsTask = underTest.formatQueue(db.getSession(), dto); assertThat(wsTask.getType()).isEqualTo("TYPE"); assertThat(wsTask.getId()).isEqualTo("UUID"); - assertThat(wsTask.getComponentId()).isEqualTo("COMPONENT_UUID"); + assertThat(wsTask.getComponentId()).isEqualTo(uuid); assertThat(wsTask.getComponentKey()).isEqualTo("COMPONENT_KEY"); assertThat(wsTask.getComponentName()).isEqualTo("Component Name"); assertThat(wsTask.getComponentQualifier()).isEqualTo("TRK"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java index c2d7d1f65f0..545857ebec5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java @@ -123,9 +123,9 @@ public class AppActionTest { .setProjectUuid("THE_PROJECT") .setLongName("src/main/java/org/sonar/api/Plugin.java") .setPath("src/main/java/org/sonar/api/Plugin.java") - .setParentProjectId(5L); + .setRootUuid("uuid_5"); when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); - when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); + when(componentDao.selectOrFailByUuid(session, "uuid_5")).thenReturn(new ComponentDto().setUuid("uuid_5").setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto())); @@ -227,9 +227,9 @@ public class AppActionTest { .setName("Plugin.java") .setLongName("src/main/java/org/sonar/api/Plugin.java") .setPath("src/main/java/org/sonar/api/Plugin.java") - .setParentProjectId(5L); + .setRootUuid("uuid_5"); when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); - when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); + when(componentDao.selectOrFailByUuid(session, "uuid_5")).thenReturn(new ComponentDto().setUuid("uuid_5").setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); return file; } 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 9617ea2e474..80b67c4c27f 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 @@ -402,6 +402,7 @@ public class TreeActionTest { JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject(); componentDb.insertComponentAndSnapshot(new ComponentDto() .setUuid(getJsonField(componentAsJsonObject, "id")) + .setRootUuid("root_uuid") .setKey(getJsonField(componentAsJsonObject, "key")) .setName(getJsonField(componentAsJsonObject, "name")) .setLanguage(getJsonField(componentAsJsonObject, "language")) 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 aeedba846ce..5e407ac4fa6 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 @@ -307,7 +307,7 @@ public class InternalCeQueueImplTest { } private static ComponentDto newComponentDto(String uuid) { - return new ComponentDto().setUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); + return new ComponentDto().setUuid(uuid).setRootUuid(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 37d66d469c3..68e97a0758c 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,7 @@ public class PersistMeasuresStepTest extends BaseStepTest { } private ComponentDto addComponent(String key, String uuid) { - ComponentDto componentDto = new ComponentDto().setKey(key).setUuid(uuid); + ComponentDto componentDto = new ComponentDto().setKey(key).setUuid(uuid).setRootUuid(uuid); dbClient.componentDao().insert(dbTester.getSession(), componentDto); return componentDto; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java index 3977c052c7c..dbddd340e32 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java @@ -117,7 +117,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid()); assertThat(projectDto.qualifier()).isEqualTo("TRK"); assertThat(projectDto.scope()).isEqualTo("PRJ"); - assertThat(projectDto.parentProjectId()).isNull(); + assertThat(projectDto.getRootUuid()).isEqualTo("ABCD"); assertThat(projectDto.getCreatedAt()).isEqualTo(now); ComponentDto moduleDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); @@ -130,7 +130,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(moduleDto.projectUuid()).isEqualTo(projectDto.uuid()); assertThat(moduleDto.qualifier()).isEqualTo("BRC"); assertThat(moduleDto.scope()).isEqualTo("PRJ"); - assertThat(moduleDto.parentProjectId()).isEqualTo(projectDto.getId()); + assertThat(moduleDto.getRootUuid()).isEqualTo(projectDto.uuid()); assertThat(moduleDto.getCreatedAt()).isEqualTo(now); ComponentDto directoryDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); @@ -143,7 +143,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(directoryDto.projectUuid()).isEqualTo(projectDto.uuid()); assertThat(directoryDto.qualifier()).isEqualTo("DIR"); assertThat(directoryDto.scope()).isEqualTo("DIR"); - assertThat(directoryDto.parentProjectId()).isEqualTo(moduleDto.getId()); + assertThat(directoryDto.getRootUuid()).isEqualTo(moduleDto.uuid()); assertThat(directoryDto.getCreatedAt()).isEqualTo(now); ComponentDto fileDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get(); @@ -157,7 +157,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileDto.projectUuid()).isEqualTo(projectDto.uuid()); assertThat(fileDto.qualifier()).isEqualTo("FIL"); assertThat(fileDto.scope()).isEqualTo("FIL"); - assertThat(fileDto.parentProjectId()).isEqualTo(moduleDto.getId()); + assertThat(fileDto.getRootUuid()).isEqualTo(moduleDto.uuid()); assertThat(fileDto.getCreatedAt()).isEqualTo(now); assertThat(dbIdsRepository.getComponentId(project)).isEqualTo(projectDto.getId()); @@ -254,23 +254,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid()); - assertThat(moduleReloaded.parentProjectId()).isEqualTo(module.parentProjectId()); + assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid()); ComponentDto directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); assertThat(directory.moduleUuid()).isEqualTo(module.uuid()); assertThat(directory.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); assertThat(directory.projectUuid()).isEqualTo(project.uuid()); - assertThat(directory.parentProjectId()).isEqualTo(module.getId()); + assertThat(directory.getRootUuid()).isEqualTo(module.uuid()); ComponentDto file = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get(); assertThat(file.moduleUuid()).isEqualTo(module.uuid()); assertThat(file.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); assertThat(file.projectUuid()).isEqualTo(project.uuid()); - assertThat(file.parentProjectId()).isEqualTo(module.getId()); + assertThat(file.getRootUuid()).isEqualTo(module.uuid()); } @Test - public void compute_parent_project_id() { + public void compute_root_uuid() { treeRootHolder.setRoot( builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") @@ -298,23 +298,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { Optional project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY); assertThat(project).isPresent(); - assertThat(project.get().parentProjectId()).isNull(); + assertThat(project.get().getRootUuid()).isEqualTo("ABCD"); Optional module = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY"); assertThat(module).isPresent(); - assertThat(module.get().parentProjectId()).isEqualTo(project.get().getId()); + assertThat(module.get().getRootUuid()).isEqualTo(project.get().uuid()); Optional subModule1 = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_1_KEY"); assertThat(subModule1).isPresent(); - assertThat(subModule1.get().parentProjectId()).isEqualTo(project.get().getId()); + assertThat(subModule1.get().getRootUuid()).isEqualTo(project.get().uuid()); Optional subModule2 = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_2_KEY"); assertThat(subModule2).isPresent(); - assertThat(subModule2.get().parentProjectId()).isEqualTo(project.get().getId()); + assertThat(subModule2.get().getRootUuid()).isEqualTo(project.get().uuid()); Optional directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_2_KEY:src/main/java/dir"); assertThat(directory).isPresent(); - assertThat(directory.get().parentProjectId()).isEqualTo(subModule2.get().getId()); + assertThat(directory.get().getRootUuid()).isEqualTo(subModule2.get().uuid()); } @Test @@ -342,22 +342,22 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { ComponentDto project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get(); assertThat(project.moduleUuid()).isNull(); assertThat(project.moduleUuidPath()).isEqualTo("." + project.uuid() + "."); - assertThat(project.parentProjectId()).isNull(); + assertThat(project.getRootUuid()).isEqualTo("ABCD"); ComponentDto moduleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_A").get(); assertThat(moduleA.moduleUuid()).isEqualTo(project.uuid()); assertThat(moduleA.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleA.uuid() + "."); - assertThat(moduleA.parentProjectId()).isEqualTo(project.getId()); + assertThat(moduleA.getRootUuid()).isEqualTo(project.uuid()); ComponentDto subModuleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_A").get(); assertThat(subModuleA.moduleUuid()).isEqualTo(moduleA.uuid()); assertThat(subModuleA.moduleUuidPath()).isEqualTo(moduleA.moduleUuidPath() + subModuleA.uuid() + "."); - assertThat(subModuleA.parentProjectId()).isEqualTo(project.getId()); + assertThat(subModuleA.getRootUuid()).isEqualTo(project.uuid()); ComponentDto moduleB = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B").get(); assertThat(moduleB.moduleUuid()).isEqualTo(project.uuid()); assertThat(moduleB.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleB.uuid() + "."); - assertThat(moduleB.parentProjectId()).isEqualTo(project.getId()); + assertThat(moduleB.getRootUuid()).isEqualTo(project.uuid()); } @Test @@ -402,7 +402,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid()); assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath()); assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid()); - assertThat(projectReloaded.parentProjectId()).isEqualTo(project.parentProjectId()); + assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); assertThat(moduleReloaded.getId()).isEqualTo(module.getId()); @@ -410,14 +410,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid()); - assertThat(moduleReloaded.parentProjectId()).isEqualTo(module.parentProjectId()); + assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid()); ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid()); assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid()); assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(directory.moduleUuidPath()); assertThat(directoryReloaded.projectUuid()).isEqualTo(directory.projectUuid()); - assertThat(directoryReloaded.parentProjectId()).isEqualTo(directory.parentProjectId()); + assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid()); assertThat(directoryReloaded.name()).isEqualTo(directory.name()); assertThat(directoryReloaded.path()).isEqualTo(directory.path()); @@ -426,7 +426,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid()); assertThat(fileReloaded.moduleUuidPath()).isEqualTo(file.moduleUuidPath()); assertThat(fileReloaded.projectUuid()).isEqualTo(file.projectUuid()); - assertThat(fileReloaded.parentProjectId()).isEqualTo(file.parentProjectId()); + assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid()); assertThat(fileReloaded.name()).isEqualTo(file.name()); assertThat(fileReloaded.path()).isEqualTo(file.path()); } @@ -555,7 +555,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(moduleBReloaded.moduleUuid()).isEqualTo(moduleAreloaded.uuid()); assertThat(moduleBReloaded.moduleUuidPath()).isEqualTo(moduleAreloaded.moduleUuidPath() + moduleBReloaded.uuid() + "."); assertThat(moduleBReloaded.projectUuid()).isEqualTo(project.uuid()); - assertThat(moduleBReloaded.parentProjectId()).isEqualTo(project.getId()); + assertThat(moduleBReloaded.getRootUuid()).isEqualTo(project.uuid()); ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir").get(); assertThat(directoryReloaded).isNotNull(); @@ -563,7 +563,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(directoryReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid()); assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath()); assertThat(directoryReloaded.projectUuid()).isEqualTo(project.uuid()); - assertThat(directoryReloaded.parentProjectId()).isEqualTo(moduleBReloaded.getId()); + assertThat(directoryReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid()); ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir/Foo.java").get(); assertThat(fileReloaded).isNotNull(); @@ -571,7 +571,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid()); assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath()); assertThat(fileReloaded.projectUuid()).isEqualTo(project.uuid()); - assertThat(fileReloaded.parentProjectId()).isEqualTo(moduleBReloaded.getId()); + assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid()); } @Test @@ -638,7 +638,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid()); assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath()); assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid()); - assertThat(projectReloaded.parentProjectId()).isEqualTo(project.parentProjectId()); + assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); assertThat(projectReloaded.isEnabled()).isTrue(); ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); @@ -647,7 +647,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(moduleReloaded.moduleUuid()).isEqualTo(removedModule.moduleUuid()); assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(removedModule.moduleUuidPath()); assertThat(moduleReloaded.projectUuid()).isEqualTo(removedModule.projectUuid()); - assertThat(moduleReloaded.parentProjectId()).isEqualTo(removedModule.parentProjectId()); + assertThat(moduleReloaded.getRootUuid()).isEqualTo(removedModule.getRootUuid()); assertThat(moduleReloaded.isEnabled()).isTrue(); ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); @@ -656,7 +656,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(directoryReloaded.moduleUuid()).isEqualTo(removedDirectory.moduleUuid()); assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(removedDirectory.moduleUuidPath()); assertThat(directoryReloaded.projectUuid()).isEqualTo(removedDirectory.projectUuid()); - assertThat(directoryReloaded.parentProjectId()).isEqualTo(removedDirectory.parentProjectId()); + assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid()); assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name()); assertThat(directoryReloaded.path()).isEqualTo(removedDirectory.path()); assertThat(directoryReloaded.isEnabled()).isTrue(); @@ -667,7 +667,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.moduleUuid()).isEqualTo(removedFile.moduleUuid()); assertThat(fileReloaded.moduleUuidPath()).isEqualTo(removedFile.moduleUuidPath()); assertThat(fileReloaded.projectUuid()).isEqualTo(removedFile.projectUuid()); - assertThat(fileReloaded.parentProjectId()).isEqualTo(removedFile.parentProjectId()); + assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid()); assertThat(fileReloaded.name()).isEqualTo(removedFile.name()); assertThat(fileReloaded.path()).isEqualTo(removedFile.path()); assertThat(fileReloaded.isEnabled()).isTrue(); @@ -717,7 +717,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleReloaded.uuid()); assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleReloaded.moduleUuidPath()); assertThat(fileReloaded.projectUuid()).isEqualTo(moduleReloaded.projectUuid()); - assertThat(fileReloaded.parentProjectId()).isEqualTo(moduleReloaded.getId()); + assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleReloaded.uuid()); assertThat(fileReloaded.name()).isEqualTo(removedFile.name()); assertThat(fileReloaded.path()).isEqualTo(removedFile.path()); assertThat(fileReloaded.isEnabled()).isTrue(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java index 41266b7ed31..0aa17f31b5c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java @@ -300,7 +300,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { .setUuid(PROJECT_VIEW_1_UUID) .setName(PROJECT_VIEW_1_NAME) .setDescription("project view description is not persisted") - .setProjectViewAttributes(new ProjectViewAttributes(project.getId(), project.uuid())); + .setProjectViewAttributes(new ProjectViewAttributes(project.uuid())); } private void persistComponents(ComponentDto... componentDtos) { @@ -333,12 +333,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(projectDto.path()).isNull(); assertThat(projectDto.uuid()).isEqualTo(VIEW_UUID); assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid()); - assertThat(projectDto.parentProjectId()).isNull(); + assertThat(projectDto.getRootUuid()).isEqualTo(VIEW_UUID); assertThat(projectDto.moduleUuid()).isNull(); assertThat(projectDto.moduleUuidPath()).isEqualTo("." + projectDto.uuid() + "."); assertThat(projectDto.qualifier()).isEqualTo(Qualifiers.VIEW); assertThat(projectDto.scope()).isEqualTo(Scopes.PROJECT); - assertThat(projectDto.getCopyResourceId()).isNull(); + assertThat(projectDto.getCopyResourceUuid()).isNull(); assertThat(projectDto.getCreatedAt()).isEqualTo(now); } @@ -352,12 +352,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(sv1Dto.path()).isNull(); assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID); assertThat(sv1Dto.projectUuid()).isEqualTo(viewDto.uuid()); - assertThat(sv1Dto.parentProjectId()).isEqualTo(viewDto.getId()); + assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid()); assertThat(sv1Dto.moduleUuid()).isEqualTo(viewDto.uuid()); assertThat(sv1Dto.moduleUuidPath()).isEqualTo(viewDto.moduleUuidPath() + sv1Dto.uuid() + "."); assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW); assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT); - assertThat(sv1Dto.getCopyResourceId()).isNull(); + assertThat(sv1Dto.getCopyResourceUuid()).isNull(); assertThat(sv1Dto.getCreatedAt()).isEqualTo(now); } @@ -368,12 +368,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(pv1Dto.path()).isNull(); assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID); assertThat(pv1Dto.projectUuid()).isEqualTo(viewDto.uuid()); - assertThat(pv1Dto.parentProjectId()).isEqualTo(viewDto.getId()); + assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid()); assertThat(pv1Dto.moduleUuid()).isEqualTo(parentViewDto.uuid()); assertThat(pv1Dto.moduleUuidPath()).isEqualTo(parentViewDto.moduleUuidPath() + pv1Dto.uuid() + "."); assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT); assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE); - assertThat(pv1Dto.getCopyResourceId()).isEqualTo(project.getId()); + assertThat(pv1Dto.getCopyResourceUuid()).isEqualTo(project.uuid()); assertThat(pv1Dto.getCreatedAt()).isEqualTo(now); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java index c2dcb26c40a..5bfda9d6d01 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java @@ -70,14 +70,14 @@ public class DuplicationsJsonWriterTest { @Test public void write_duplications() { String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java"; - ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setParentProjectId(5L); + ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setRootUuid("uuid_5"); String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java"; - ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setParentProjectId(5L); + ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5"); when(componentDao.selectByKey(session, key1)).thenReturn(Optional.of(file1)); when(componentDao.selectByKey(session, key2)).thenReturn(Optional.of(file2)); - when(componentDao.selectById(session, 5L)).thenReturn(Optional.of( - new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"))); + when(componentDao.selectByUuid(session, "uuid_5")).thenReturn(Optional.of( + new ComponentDto().setUuid("uuid_5").setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"))); when(componentDao.selectByUuid(session, project.uuid())).thenReturn(Optional.of(project)); List blocks = newArrayList(); @@ -123,7 +123,7 @@ public class DuplicationsJsonWriterTest { verify(componentDao, times(2)).selectByKey(eq(session), anyString()); // Verify call to dao is cached when searching for project / sub project verify(componentDao, times(1)).selectByUuid(eq(session), eq(project.uuid())); - verify(componentDao, times(1)).selectById(eq(session), eq(5L)); + verify(componentDao, times(1)).selectByUuid(eq(session), eq("uuid_5")); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java index a3fc80c56b2..becabf75163 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java @@ -347,16 +347,12 @@ public class IssueQueryServiceTest { String login2 = "darth.vader"; String copyProjectUuid = devUuid + ":" + projectUuid; - long copyResourceId = 42L; - ComponentDto technicalProject = new ComponentDto().setProjectUuid(devUuid).setCopyResourceId(copyResourceId); + ComponentDto technicalProject = new ComponentDto().setProjectUuid(devUuid).setCopyComponentUuid(projectUuid); when(componentDao.selectByUuids(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(technicalProject)); when(componentService.getDistinctQualifiers(isA(DbSession.class), anyCollection())).thenReturn(Sets.newHashSet("DEV_PRJ")); when(authorDao.selectScmAccountsByDeveloperUuids(isA(DbSession.class), anyCollection())).thenReturn(Lists.newArrayList(login1, login2)); - ComponentDto actualProject = new ComponentDto().setUuid(projectUuid); - when(componentDao.selectByIds(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(actualProject)); - Map map = newHashMap(); map.put("componentUuids", newArrayList(copyProjectUuid)); IssueQuery query = underTest.createFromMap(map); diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterExecutorTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterExecutorTest.java index 6f8d2adabb7..d927ffcf25d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterExecutorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterExecutorTest.java @@ -19,6 +19,9 @@ */ package org.sonar.server.measure; +import static com.google.common.collect.Lists.newArrayList; +import static org.assertj.core.api.Assertions.assertThat; + import java.sql.SQLException; import java.util.Arrays; import java.util.Date; @@ -34,20 +37,19 @@ import org.sonar.db.DbTester; import org.sonar.db.component.ResourceDao; import org.sonar.db.component.SnapshotDto; -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; - public class MeasureFilterExecutorTest { private static final long JAVA_PROJECT_ID = 1L; private static final long JAVA_FILE_BIG_ID = 3L; private static final long JAVA_FILE_TINY_ID = 4L; + private static final String JAVA_PROJECT_UUID = "UUID_JAVA_PROJECT"; private static final long JAVA_PROJECT_SNAPSHOT_ID = 101L; private static final long JAVA_FILE_BIG_SNAPSHOT_ID = 103L; private static final long JAVA_FILE_TINY_SNAPSHOT_ID = 104L; private static final long JAVA_PACKAGE_SNAPSHOT_ID = 102L; private static final long PHP_PROJECT_ID = 10L; + private static final String PHP_PROJECT_UUID = "UUID_PHP_PROJECT"; private static final long PHP_SNAPSHOT_ID = 110L; private static final Metric METRIC_LINES = new Metric.Builder("lines", "Lines", Metric.ValueType.INT).create().setId(1); private static final Metric METRIC_PROFILE = new Metric.Builder("profile", "Profile", Metric.ValueType.STRING).create().setId(2); @@ -373,7 +375,7 @@ public class MeasureFilterExecutorTest { assertThat(rows).hasSize(3); verifyPhpProject(rows.get(0)); verifyJavaProject(rows.get(1)); - verifyProject(rows.get(2), 120L, 20L, 20L); + verifyProject(rows.get(2), 120L, 20L, "CDEF"); } @Test @@ -386,7 +388,7 @@ public class MeasureFilterExecutorTest { // Js Project ERROR, Java Project WARN, then Php Project OK assertThat(rows).hasSize(3); - verifyProject(rows.get(0), 120L, 20L, 20L); + verifyProject(rows.get(0), 120L, 20L, "CDEF"); verifyJavaProject(rows.get(1)); verifyPhpProject(rows.get(2)); } @@ -589,24 +591,24 @@ public class MeasureFilterExecutorTest { } private void verifyJavaProject(MeasureFilterRow row) { - verifyProject(row, JAVA_PROJECT_SNAPSHOT_ID, JAVA_PROJECT_ID, JAVA_PROJECT_ID); + verifyProject(row, JAVA_PROJECT_SNAPSHOT_ID, JAVA_PROJECT_ID, JAVA_PROJECT_UUID); } private void verifyJavaBigFile(MeasureFilterRow row) { - verifyProject(row, JAVA_FILE_BIG_SNAPSHOT_ID, JAVA_FILE_BIG_ID, JAVA_PROJECT_ID); + verifyProject(row, JAVA_FILE_BIG_SNAPSHOT_ID, JAVA_FILE_BIG_ID, JAVA_PROJECT_UUID); } private void verifyJavaTinyFile(MeasureFilterRow row) { - verifyProject(row, JAVA_FILE_TINY_SNAPSHOT_ID, JAVA_FILE_TINY_ID, JAVA_PROJECT_ID); + verifyProject(row, JAVA_FILE_TINY_SNAPSHOT_ID, JAVA_FILE_TINY_ID, JAVA_PROJECT_UUID); } private void verifyPhpProject(MeasureFilterRow row) { - verifyProject(row, PHP_SNAPSHOT_ID, PHP_PROJECT_ID, PHP_PROJECT_ID); + verifyProject(row, PHP_SNAPSHOT_ID, PHP_PROJECT_ID, PHP_PROJECT_UUID); } - private void verifyProject(MeasureFilterRow row, Long snashotId, Long resourceId, Long resourceRootId) { + private void verifyProject(MeasureFilterRow row, Long snashotId, Long resourceId, String rootComponentUuid) { assertThat(row.getSnapshotId()).isEqualTo(snashotId); assertThat(row.getResourceId()).isEqualTo(resourceId); - assertThat(row.getResourceRootId()).isEqualTo(resourceRootId); + assertThat(row.getRootComponentUuid()).isEqualTo(rootComponentUuid); } } 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 ede524fe811..27c29402afc 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 @@ -336,6 +336,7 @@ public class QProfileFactoryMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") 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 fd054edc264..ef9d3011859 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 @@ -68,6 +68,7 @@ public class QProfileProjectOperationsMediumTest { project = new ComponentDto() .setUuid(PROJECT_UUID) + .setRootUuid(PROJECT_UUID) .setKey(PROJECT_KEY) .setName("SonarQube") .setLongName("SonarQube") @@ -123,6 +124,7 @@ public class QProfileProjectOperationsMediumTest { public void remove_all_projects() { ComponentDto project1 = new ComponentDto() .setUuid("BCDE") + .setRootUuid("BCDE") .setKey("project1") .setName("project1") .setLongName("project1") @@ -131,6 +133,7 @@ public class QProfileProjectOperationsMediumTest { .setEnabled(true); ComponentDto project2 = new ComponentDto() .setUuid("CDEF") + .setRootUuid("CDEF") .setKey("project2") .setName("project2") .setLongName("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 36bd0c012f2..d58e2c97b48 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 @@ -444,6 +444,7 @@ public class QProfilesWsMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") @@ -473,6 +474,7 @@ public class QProfilesWsMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") @@ -498,6 +500,7 @@ public class QProfilesWsMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") @@ -563,6 +566,7 @@ public class QProfilesWsMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") @@ -587,6 +591,7 @@ public class QProfilesWsMediumTest { ComponentDto project = new ComponentDto() .setId(1L) .setUuid("ABCD") + .setRootUuid("ABCD") .setKey("org.codehaus.sonar:sonar") .setName("SonarQube") .setLongName("SonarQube") 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 5c02d4830aa..6ba9fc08daf 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) + .setRootUuid(TestFile1.PROJECT_UUID) .setProjectUuid(TestFile1.PROJECT_UUID)); db.getSession().commit(); @@ -140,6 +141,7 @@ public class ListActionTest { TestFile2.dto(), new ComponentDto() .setUuid(sourceFileUuid) + .setRootUuid(TestFile1.PROJECT_UUID) .setKey(sourceFileKey) .setProjectUuid(TestFile1.PROJECT_UUID)); db.getSession().commit(); @@ -192,7 +194,7 @@ 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).setProjectUuid(TestFile1.PROJECT_UUID)); + dbClient.componentDao().insert(db.getSession(), new ComponentDto().setUuid(mainFileUuid).setRootUuid(TestFile1.PROJECT_UUID).setProjectUuid(TestFile1.PROJECT_UUID)); db.getSession().commit(); ws.newGetRequest("api/tests", "list") @@ -227,6 +229,7 @@ public class ListActionTest { public static ComponentDto dto() { return new ComponentDto() .setUuid(TestFile1.FILE_UUID) + .setRootUuid(TestFile1.PROJECT_UUID) .setLongName(TestFile1.LONG_NAME) .setProjectUuid(TestFile1.PROJECT_UUID) .setKey(TestFile1.KEY); @@ -266,6 +269,7 @@ public class ListActionTest { public static ComponentDto dto() { return new ComponentDto() .setUuid(TestFile2.FILE_UUID) + .setRootUuid(TestFile2.PROJECT_UUID) .setLongName(TestFile2.LONG_NAME) .setProjectUuid(TestFile2.PROJECT_UUID) .setKey(TestFile2.KEY); 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 0bf9a7d567e..0c271cedf2d 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 @@ -4,24 +4,24 @@ - - - + uuid="JKLM" root_uuid="JKLM" root_project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> + uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> 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 2f4dbf7348d..989b7def85e 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 @@ -5,28 +5,28 @@ - - - - + uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> + uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> 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 87081a4e2d1..9c4b40ca293 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,5 +1,5 @@ - + 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 006696dc819..a01559680bc 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,5 @@ - + 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 be57cfc6d21..b984a948a37 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,6 +1,6 @@ - + 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 f8b76a17917..4008dbdd93d 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 @@ -1,6 +1,6 @@ - + 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 6a97946ef19..7f56e789607 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,6 +1,6 @@ - + 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 2c8ae5c913f..6f93823e528 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 @@ -1,6 +1,6 @@ - + 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 70de478ba1e..33c2443b3c7 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,8 +1,8 @@ - + enabled="[true]" language="java" /> - + - + 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 f17681470e3..a1508445b14 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,6 +1,6 @@ - - + + 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 1a1f7e8466a..ab190db883e 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,7 +1,7 @@ - + - + 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 832058c2eef..918d755636a 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,9 +1,9 @@ - + - + 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 c204155e2bc..4a8ebf00a64 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,15 +1,15 @@ 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 cc3f8cf7b04..6ef3ef25402 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,9 +1,9 @@ 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 dcc1e50070d..0651a152049 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 @@ -3,9 +3,9 @@ plugin_config_key="[null]" plugin_name="squid"/> + uuid="THE_PROJECT" root_uuid="THE_PROJECT" module_uuid="[null]" module_uuid_path="." path="[null]"/> + uuid="THE_PROJECT_1" root_uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> + uuid="THE_PROJECT_2" root_uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> - - - - + + + + - - - - + + + + + uuid="THE_PROJECT_1" root_uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> + uuid="THE_PROJECT_2" root_uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> - - - - + + + + - - - - + + + + + id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" + description="[null]" enabled="[true]" language="[null]" /> - + id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" + description="[null]" enabled="[true]" language="[null]"/> - - - - - - - - - - + + + + - - - - + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml index 3e944c47343..32941aa476c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml @@ -7,11 +7,12 @@ - - diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml index dbe84a89137..5ceeba2fcee 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml @@ -1,8 +1,8 @@ + uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." + enabled="[true]" path="[null]"/> - - + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml index 2c1b4111c26..9e072388a9d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml @@ -1,7 +1,7 @@ - - + - - + - - - - - - - + uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> + uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." + enabled="[true]" copy_component_uuid="[null]" path="[null]"/> select_columns, :conditions => [conditions.join(' AND '), values], :order => 'name') diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index 9be60b5114a..dfec74484a9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -327,7 +327,6 @@ class Api::ResourcesController < Api::ApiController json['version']=snapshot.version if snapshot.version json['branch']=resource.branch if resource.branch json['description']=resource.description if resource.description - json['copy']=resource.copy_resource_id if resource.copy_resource_id if include_trends json[:p1]=snapshot.period1_mode if snapshot.period1_mode json[:p1p]=snapshot.period1_param if snapshot.period1_param @@ -402,7 +401,6 @@ class Api::ResourcesController < Api::ApiController xml.date(Api::Utils.format_datetime(snapshot.created_at)) xml.creationDate(Api::Utils.format_datetime(resource.created_at)) xml.description(resource.description) if include_descriptions && resource.description - xml.copy(resource.copy_resource_id) if resource.copy_resource_id if include_trends xml.period1(snapshot.period1_mode) if snapshot.period1_mode diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 16fbb908651..62de84287c3 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -85,9 +85,8 @@ class ProjectController < ApplicationController def profile require_parameters :id @project_id = Api::Utils.project_id(params[:id]) - access_denied unless (is_admin?(@project_id) || has_role?(:profileadmin)) - # Need to display breadcrumb @project = Project.by_key(@project_id) + access_denied unless (is_admin?(@project.uuid) || has_role?(:profileadmin)) call_backend do @all_quality_profiles = Internal.quality_profiles.allProfiles().to_a @@ -118,9 +117,8 @@ class ProjectController < ApplicationController def qualitygate require_parameters :id @project_id = Api::Utils.project_id(params[:id]) - access_denied unless (is_admin?(@project_id) || has_role?(:gateadmin)) - # Need to display breadcrumb @project = Project.by_key(@project_id) + access_denied unless (is_admin?(@project.uuid) || has_role?(:gateadmin)) call_backend do @all_quality_gates = Internal.quality_gates.list().to_a diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb index 2a24b78060e..97a4942536f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -189,7 +189,7 @@ class MeasureFilter < ActiveRecord::Base def base_resource if criteria('base') - Project.first(:conditions => ['kee=? and copy_resource_id is null and person_id is null', criteria('base')]) + Project.first(:conditions => ['kee=? and copy_component_uuid is null and developer_uuid is null', criteria('base')]) end end @@ -241,9 +241,9 @@ class MeasureFilter < ActiveRecord::Base end def filter_authorized_snapshot_ids(rows, controller) - project_ids = rows.map { |row| row.getResourceRootId() }.compact.uniq - authorized_project_ids = controller.select_authorized(:user, project_ids) - snapshot_ids = rows.map { |row| row.getSnapshotId() if authorized_project_ids.include?(row.getResourceRootId()) }.compact + project_uuids = rows.map { |row| row.getRootComponentUuid() }.compact.uniq + authorized_project_uuids = controller.select_authorized(:user, project_uuids) + snapshot_ids = rows.map { |row| row.getSnapshotId() if authorized_project_uuids.include?(row.getRootComponentUuid()) }.compact @security_exclusions = (snapshot_ids.size 'resource_id' has_many :group_roles, :foreign_key => 'resource_id' has_many :manual_measures, :foreign_key => 'component_uuid', :primary_key => 'uuid' - belongs_to :root, :class_name => 'Project', :foreign_key => 'root_id' - belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_resource_id' - belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id' + belongs_to :root, :class_name => 'Project', :foreign_key => 'root_uuid', :primary_key => 'uuid' + belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_component_uuid', :primary_key => 'uuid' + belongs_to :person, :class_name => 'Project', :foreign_key => 'developer_uuid', :primary_key => 'uuid' has_many :authors, :foreign_key => 'person_id', :dependent => :delete_all has_one :index, :class_name => 'ResourceIndex', :foreign_key => 'component_uuid', :primary_key => 'uuid', :conditions => 'position=0', :select => 'kee' has_many :resource_index, :foreign_key => 'resource_id' @@ -79,7 +79,7 @@ class Project < ActiveRecord::Base def modules @modules ||= begin - Project.all(:conditions => {:root_id => self.id, :scope => 'PRJ'}) + Project.all(:conditions => ['root_uuid=? and uuid <> ? and scope=?', self.uuid, self.uuid, 'PRJ']) end end @@ -178,16 +178,16 @@ class Project < ActiveRecord::Base nil end - def resource_id_for_authorization + def component_uuid_for_authorization if library? # no security on libraries nil elsif set? - self.root_id || self.id + self.root_uuid || self.uuid elsif last_snapshot - last_snapshot.resource_id_for_authorization + last_snapshot.component_uuid_for_authorization else - nil + self.root_uuid end end @@ -217,7 +217,7 @@ class Project < ActiveRecord::Base end def parent_module(current_module) - current_module.root ? parent_module(current_module.root) : current_module + current_module.root.uuid = current_module.uuid ? current_module : parent_module(current_module.root) end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_index.rb index 6d3bb81f7fe..3e7eadffecb 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_index.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/resource_index.rb @@ -26,9 +26,8 @@ class ResourceIndex < ActiveRecord::Base MIN_SEARCH_SIZE=2 - def resource_id_for_authorization - # FIXME this generates a join for every resource - root_project.id + def component_uuid_for_authorization + root_component_uuid end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb index 9d17cfe325e..535bc0e40b8 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -216,8 +216,8 @@ class Snapshot < ActiveRecord::Base (period1_mode || period2_mode || period3_mode || period4_mode || period5_mode) != nil end - def resource_id_for_authorization - root_project.id + def component_uuid_for_authorization + root_component_uuid end def path_name diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb index 6a2330139dd..1350390f746 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb @@ -25,16 +25,16 @@ class DefaultAuthorizer global_roles(user).include?(role) end - def has_role_for_resources?(user, role, resource_ids) - return [] if resource_ids.empty? + def has_role_for_resources?(user, role, component_uuids) + return [] if component_uuids.empty? - compacted_resource_ids=resource_ids.compact + compacted_component_uuids=component_uuids.compact group_ids=user.groups.map(&:id) # Oracle is limited to 1000 elements in clause "IN" page_size=999 - page_count=(compacted_resource_ids.size/page_size) - page_count+=1 if (compacted_resource_ids.size % page_size)>0 + page_count=(compacted_component_uuids.size/page_size) + page_count+=1 if (compacted_component_uuids.size % page_size)>0 sanitized_role = ActiveRecord::Base.connection.quote_string(role.to_s) @@ -42,9 +42,9 @@ class DefaultAuthorizer if group_ids.empty? # Some databases do not support empty IN page_count.times do |page_index| - page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] + page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] group_roles.concat( - ActiveRecord::Base.connection.execute("SELECT resource_id FROM group_roles WHERE role='#{sanitized_role}' and group_id is null and resource_id in (#{page_rids.join(',')})") + ActiveRecord::Base.connection.execute("SELECT p.uuid FROM group_roles gr INNER JOIN projects p ON p.id=gr.resource_id WHERE gr.role='#{sanitized_role}' and gr.group_id is null and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") ) end else @@ -53,11 +53,11 @@ class DefaultAuthorizer gr_page_count+=1 if (compacted_group_ids.size % page_size)>0 page_count.times do |page_index| - page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] + page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] gr_page_count.times do |gr_page_index| page_grids=compacted_group_ids[gr_page_index*page_size...(gr_page_index+1)*page_size] group_roles.concat( - ActiveRecord::Base.connection.execute("SELECT resource_id FROM group_roles WHERE role='#{sanitized_role}' and (group_id is null or group_id in(#{page_grids.join(',')})) and resource_id in (#{page_rids.join(',')})") + ActiveRecord::Base.connection.execute("SELECT p.uuid FROM group_roles gr INNER JOIN projects p ON p.id=gr.resource_id WHERE gr.role='#{sanitized_role}' and (gr.group_id is null or gr.group_id in(#{page_grids.join(',')})) and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") ) end end @@ -66,21 +66,21 @@ class DefaultAuthorizer user_roles=[] if user.id page_count.times do |page_index| - page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] + page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] user_roles.concat( - ActiveRecord::Base.connection.execute("SELECT resource_id FROM user_roles WHERE role='#{sanitized_role}' and user_id=#{user.id} and resource_id in (#{page_rids.join(',')})") + ActiveRecord::Base.connection.execute("SELECT p.uuid FROM user_roles ur INNER JOIN projects p ON p.id=ur.resource_id WHERE ur.role='#{sanitized_role}' and ur.user_id=#{user.id} and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") ) end end - authorized_resource_ids={} + authorized_component_uuids={} (group_roles.concat(user_roles)).each do |x| - authorized_resource_ids[x['resource_id'].to_i]=true + authorized_component_uuids[x['uuid']]=true end - result=Array.new(resource_ids.size) - resource_ids.each_with_index do |rid,index| - result[index]=((authorized_resource_ids[rid]) || false) + result=Array.new(component_uuids.size) + component_uuids.each_with_index do |uuid,index| + result[index]=((authorized_component_uuids[uuid]) || false) end result end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb index 08d1a327b71..9f4912d0673 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb @@ -75,21 +75,21 @@ module NeedAuthorization def has_role_for_resources?(role, objects) return [] if objects.nil? || objects.size==0 - resource_ids=[] + component_uuids=[] objects.each do |obj| - resource_ids< toCopyResourceId() { - return ToCopyResourceId.INSTANCE; - } - private enum ToId implements Function { INSTANCE; @@ -86,12 +82,4 @@ public final class ComponentDtoFunctions { } } - private enum ToCopyResourceId implements Function { - INSTANCE; - - @Override - public Long apply(ComponentDto input) { - return input.getCopyResourceId(); - } - } } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java index d37fcd7da7b..9400dc07c2a 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java @@ -72,12 +72,17 @@ public class ResourceDao extends AbstractDao { public ResourceDto selectResource(String componentUuid) { SqlSession session = myBatis().openSession(false); try { - return session.getMapper(ResourceMapper.class).selectResourceByUuid(componentUuid); + return selectResource(componentUuid, session); } finally { MyBatis.closeQuietly(session); } } + @CheckForNull + private static ResourceDto selectResource(String componentUuid, SqlSession session) { + return session.getMapper(ResourceMapper.class).selectResourceByUuid(componentUuid); + } + public ResourceDto selectResource(long projectId, SqlSession session) { return session.getMapper(ResourceMapper.class).selectResource(projectId); } @@ -112,11 +117,11 @@ public class ResourceDao extends AbstractDao { private ResourceDto getRootProjectByComponentKey(DbSession session, String componentKey) { ResourceDto component = selectResource(ResourceQuery.create().setKey(componentKey), session); if (component != null) { - Long rootId = component.getRootId(); - if (rootId != null) { - return getParentModuleByComponentId(rootId, session); - } else { + String rootUuid = component.getRootUuid(); + if (rootUuid.equals(component.getUuid())) { return component; + } else { + return getParentModuleByComponentUuid(rootUuid, session); } } return null; @@ -133,14 +138,14 @@ public class ResourceDao extends AbstractDao { } @CheckForNull - private ResourceDto getParentModuleByComponentId(Long componentId, DbSession session) { - ResourceDto component = selectResource(componentId, session); + private static ResourceDto getParentModuleByComponentUuid(String componentUUid, DbSession session) { + ResourceDto component = selectResource(componentUUid, session); if (component != null) { - Long rootId = component.getRootId(); - if (rootId != null) { - return getParentModuleByComponentId(rootId, session); - } else { + String rootUuid = component.getRootUuid(); + if (rootUuid.equals(component.getUuid())) { return component; + } else { + return getParentModuleByComponentUuid(rootUuid, session); } } return null; @@ -227,11 +232,6 @@ public class ResourceDao extends AbstractDao { return newArrayList(Iterables.transform(resourceDto, ToComponent.INSTANCE)); } - public void insertUsingExistingSession(ResourceDto resourceDto, SqlSession session) { - ResourceMapper resourceMapper = session.getMapper(ResourceMapper.class); - resourceMapper.insert(resourceDto); - } - private enum ToComponent implements Function { INSTANCE; diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java index 84480314295..01aea4e456d 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceDto.java @@ -20,6 +20,8 @@ package org.sonar.db.component; import java.util.Date; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import static org.sonar.db.component.ComponentValidator.checkComponentKey; import static org.sonar.db.component.ComponentValidator.checkComponentName; @@ -35,15 +37,15 @@ public class ResourceDto { private String deprecatedKey; private String name; private String longName; - private Long rootId; + private String rootUuid; private String path; private String scope; private String qualifier; private boolean enabled = true; private String description; private String language; - private Long copyResourceId; - private Long personId; + private String copyComponentUuid; + private String developerUuid; private Date createdAt; private Long authorizationUpdatedAt; @@ -119,12 +121,12 @@ public class ResourceDto { return this; } - public Long getRootId() { - return rootId; + public String getRootUuid() { + return rootUuid; } - public ResourceDto setRootId(Long rootId) { - this.rootId = rootId; + public ResourceDto setRootUuid(String rootUuid) { + this.rootUuid = rootUuid; return this; } @@ -191,21 +193,23 @@ public class ResourceDto { return this; } - public Long getCopyResourceId() { - return copyResourceId; + @CheckForNull + public String getCopyComponentUuid() { + return copyComponentUuid; } - public ResourceDto setCopyResourceId(Long copyResourceId) { - this.copyResourceId = copyResourceId; + public ResourceDto setCopyComponentUuid(@Nullable String copyComponentUuid) { + this.copyComponentUuid = copyComponentUuid; return this; } - public Long getPersonId() { - return personId; + @CheckForNull + public String getDeveloperUuid() { + return developerUuid; } - public ResourceDto setPersonId(Long personId) { - this.personId = personId; + public ResourceDto setDeveloperUuid(@Nullable String developerUuid) { + this.developerUuid = developerUuid; return this; } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java index a5b4f7db04d..c675163fc76 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterDao.java @@ -44,7 +44,7 @@ public class ResourceKeyUpdaterDao implements Dao { this.mybatis = mybatis; } - public void updateKey(long projectId, String newKey) { + public void updateKey(String projectUuid, String newKey) { DbSession session = mybatis.openSession(true); ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); try { @@ -53,9 +53,9 @@ public class ResourceKeyUpdaterDao implements Dao { } // must SELECT first everything - ResourceDto project = mapper.selectProject(projectId); + ResourceDto project = mapper.selectProject(projectUuid); String projectOldKey = project.getKey(); - List resources = mapper.selectProjectResources(projectId); + List resources = mapper.selectProjectResources(projectUuid); resources.add(project); // and then proceed with the batch UPDATE at once @@ -67,12 +67,12 @@ public class ResourceKeyUpdaterDao implements Dao { } } - public Map checkModuleKeysBeforeRenaming(long projectId, String stringToReplace, String replacementString) { + public Map checkModuleKeysBeforeRenaming(String projectUuid, String stringToReplace, String replacementString) { SqlSession session = mybatis.openSession(false); ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); Map result = Maps.newHashMap(); try { - Set modules = collectAllModules(projectId, stringToReplace, mapper); + Set modules = collectAllModules(projectUuid, stringToReplace, mapper); for (ResourceDto module : modules) { String newKey = computeNewKey(module, stringToReplace, replacementString); if (mapper.countResourceByKey(newKey) > 0) { @@ -87,14 +87,14 @@ public class ResourceKeyUpdaterDao implements Dao { return result; } - public void bulkUpdateKey(DbSession session, long projectId, String stringToReplace, String replacementString) { + public void bulkUpdateKey(DbSession session, String projectUuid, String stringToReplace, String replacementString) { ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); // must SELECT first everything - Set modules = collectAllModules(projectId, stringToReplace, mapper); + Set modules = collectAllModules(projectUuid, stringToReplace, mapper); checkNewNameOfAllModules(modules, stringToReplace, replacementString, mapper); Map> allResourcesByModuleMap = Maps.newHashMap(); for (ResourceDto module : modules) { - allResourcesByModuleMap.put(module, mapper.selectProjectResources(module.getId())); + allResourcesByModuleMap.put(module, mapper.selectProjectResources(module.getUuid())); } // and then proceed with the batch UPDATE at once @@ -107,16 +107,6 @@ public class ResourceKeyUpdaterDao implements Dao { } } - public void bulkUpdateKey(long projectId, String stringToReplace, String replacementString) { - DbSession session = mybatis.openSession(true); - try { - bulkUpdateKey(session, projectId, stringToReplace, replacementString); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - private static String computeNewKey(ResourceDto resource, String stringToReplace, String replacementString) { return resource.getKey().replaceAll(stringToReplace, replacementString); } @@ -135,14 +125,14 @@ public class ResourceKeyUpdaterDao implements Dao { } } - private static Set collectAllModules(long projectId, String stringToReplace, ResourceKeyUpdaterMapper mapper) { - ResourceDto project = mapper.selectProject(projectId); + private static Set collectAllModules(String projectUuid, String stringToReplace, ResourceKeyUpdaterMapper mapper) { + ResourceDto project = mapper.selectProject(projectUuid); Set modules = Sets.newHashSet(); if (project.getKey().contains(stringToReplace)) { modules.add(project); } - for (ResourceDto submodule : mapper.selectDescendantProjects(projectId)) { - modules.addAll(collectAllModules(submodule.getId(), stringToReplace, mapper)); + for (ResourceDto submodule : mapper.selectDescendantProjects(projectUuid)) { + modules.addAll(collectAllModules(submodule.getUuid(), stringToReplace, mapper)); } return modules; } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterMapper.java index 6511e765202..c38ee177cf1 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceKeyUpdaterMapper.java @@ -20,6 +20,7 @@ package org.sonar.db.component; import java.util.List; +import org.apache.ibatis.annotations.Param; /** * @since 3.2 @@ -28,11 +29,11 @@ public interface ResourceKeyUpdaterMapper { int countResourceByKey(String key); - ResourceDto selectProject(long projectId); + ResourceDto selectProject(@Param("uuid") String uuid); - List selectProjectResources(long projectId); + List selectProjectResources(@Param("rootUuid") String rootUuid); - List selectDescendantProjects(long projectId); + List selectDescendantProjects(@Param("rootUuid") String rootUuid); void update(ResourceDto resource); diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceMapper.java index a77f240dad3..86e1f747c27 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceMapper.java @@ -62,10 +62,6 @@ public interface ResourceMapper { ResourceDto selectProvisionedProject(@Param("key") String key); - void insert(ResourceDto resource); - - void update(ResourceDto resource); - void updateAuthorizationDate(@Param("projectId") Long projectId, @Param("authorizationDate") Long authorizationDate); } diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java index b2c521bfac7..d5a0eef5d9a 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java @@ -29,8 +29,6 @@ import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.ibatis.session.ResultHandler; -import org.apache.ibatis.session.SqlSession; import org.sonar.db.Dao; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; @@ -47,16 +45,6 @@ public class IssueDao implements Dao { this.mybatis = mybatis; } - public void selectNonClosedIssuesByModule(long componentId, ResultHandler handler) { - SqlSession session = mybatis.openSession(false); - try { - session.select("org.sonar.db.issue.IssueMapper.selectNonClosedIssuesByModule", componentId, handler); - - } finally { - MyBatis.closeQuietly(session); - } - } - public Optional selectByKey(DbSession session, String key) { return Optional.fromNullable(mapper(session).selectByKey(key)); } diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java index 403b991e530..6e77444075a 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -132,7 +132,7 @@ public class PurgeDao implements Dao { private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper, final PurgeListener purgeListener) { final List componentIdUuids = new ArrayList<>(); - session.select("org.sonar.db.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getId(), + session.select("org.sonar.db.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getUuid(), resultContext -> { IdUuidPair componentIdUuid = (IdUuidPair) resultContext.getResultObject(); if (componentIdUuid.getId() != null) { diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 59d9e0397b3..5129d2e2681 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -16,11 +16,11 @@ p.qualifier as qualifier, p.scope as scope, p.language as language, - p.root_id as parentProjectId, + p.root_uuid as rootUuid, p.path as path, p.enabled as enabled, - p.copy_resource_id as copyResourceId, - p.person_id as developerId, + p.copy_component_uuid as copyComponentUuid, + p.developer_uuid as developerUuid, p.authorization_updated_at as authorizationUpdatedAt, p.created_at as createdAt @@ -32,7 +32,7 @@ p.kee as kee, p.qualifier as qualifier, p.scope as scope, - P.copy_resource_id as copyResourceId, + P.copy_component_uuid as copyComponentUuid, p.module_uuid as moduleUuid @@ -151,7 +151,7 @@ SELECT FROM projects p - INNER JOIN projects child ON child.root_id=p.id AND child.enabled=${_true} + INNER JOIN projects child ON child.root_uuid=p.uuid AND child.enabled=${_true} AND p.enabled=${_true} AND p.scope='PRJ' @@ -248,7 +248,7 @@ from projects p AND p.enabled=${_true} - AND p.copy_resource_id is null + AND p.copy_component_uuid is null AND p.qualifier in #{qualifier} @@ -279,7 +279,7 @@ from projects p AND p.enabled=${_true} - AND p.copy_resource_id is null + AND p.copy_component_uuid is null AND p.qualifier in @@ -373,11 +373,10 @@ WHERE ri.kee like #{query.nameOrKeyQueryToSqlForResourceIndex} ESCAPE '/' ) OR - p.copy_resource_id IN ( - SELECT p1.id - FROM resource_index ri, projects p1 + p.copy_component_uuid IN ( + SELECT ri.component_uuid + FROM resource_index ri WHERE ri.kee like #{query.nameOrKeyQueryToSqlForResourceIndex} ESCAPE '/' - and p1.uuid = ri.component_uuid ) ) @@ -388,7 +387,7 @@ from projects p p.enabled=${_true} - AND p.copy_resource_id is null + AND p.copy_component_uuid is null AND p.qualifier in #{qualifier} @@ -413,7 +412,7 @@ SELECT original.id FROM resource_index r INNER JOIN projects original ON r.component_uuid = original.uuid - INNER JOIN projects copy ON original.id = copy.copy_resource_id + INNER JOIN projects copy ON original.uuid = copy.copy_component_uuid AND copy.module_uuid_path LIKE #{viewUuidQuery} AND r.kee LIKE #{query} @@ -23,7 +23,7 @@ from projects p, projects root, snapshots s p.enabled=${_true} - and p.copy_resource_id is null + and p.copy_component_uuid is null and p.uuid=s.component_uuid and s.islast=${_true} diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml index 463b3c06a62..0d6bd0f1b6c 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/ResourceKeyUpdaterMapper.xml @@ -6,8 +6,9 @@ + - + @@ -17,16 +18,16 @@ WHERE kee = #{key} - + select * from projects where uuid=#{uuid} - + select * from projects where root_uuid=#{rootUuid} AND scope!='PRJ' - + select * from projects where scope='PRJ' and root_uuid=#{rootUuid} and uuid!=#{rootUuid} diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ResourceMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ResourceMapper.xml index ef0fce32d24..4b317231e88 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/ResourceMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/ResourceMapper.xml @@ -47,14 +47,14 @@ - + - - + + @@ -111,7 +111,7 @@ SELECT s.* from snapshots s - INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_resource_id IS NULL + INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_component_uuid is null AND p.uuid=#{uuid} AND s.islast=${_true} @@ -147,7 +147,7 @@ and p.enabled=${_true} - and p.copy_resource_id is null + and p.copy_component_uuid is null @@ -166,7 +166,7 @@ and p.enabled=${_true} - and p.copy_resource_id is null + and p.copy_component_uuid is null and s.islast=${_true} @@ -183,7 +183,7 @@ p.qualifier=#{qualifier} - and p.copy_resource_id is null + and p.copy_component_uuid is null @@ -198,7 +198,7 @@ p.qualifier=#{qualifier} - and p.copy_resource_id is null + and p.copy_component_uuid is null @@ -207,33 +207,9 @@ left join snapshots s on s.component_uuid=p.uuid where s.id is null and p.kee = #{key} - and p.copy_resource_id is null + and p.copy_component_uuid is null - - insert into projects - (uuid, project_uuid, module_uuid, module_uuid_path, name, long_name, description, scope, qualifier, kee, - deprecated_kee, path, language, root_id, copy_resource_id, person_id, - enabled, authorization_updated_at, created_at) - values ( - #{uuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR}, #{moduleUuid,jdbcType=VARCHAR}, - #{moduleUuidPath,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, - #{longName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, - #{qualifier,jdbcType=VARCHAR}, - #{key,jdbcType=VARCHAR}, #{deprecatedKey,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{language,jdbcType=VARCHAR}, - #{rootId,jdbcType=INTEGER}, #{copyResourceId,jdbcType=INTEGER}, - #{personId,jdbcType=INTEGER}, #{enabled,jdbcType=BOOLEAN}, #{authorizationUpdatedAt,jdbcType=BIGINT}, - #{createdAt,jdbcType=TIMESTAMP} - ) - - - - update projects set name=#{name}, long_name=#{longName}, description=#{description}, - scope=#{scope}, qualifier=#{qualifier}, kee=#{key}, deprecated_kee=#{deprecatedKey}, path=#{path}, - language=#{language}, root_id=#{rootId}, copy_resource_id=#{copyResourceId}, - person_id=#{personId}, enabled=#{enabled} where id=#{id} - - update projects set authorization_updated_at=#{authorizationDate} where id=#{projectId} diff --git a/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml b/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml index 2888c9aa272..909ba71449f 100644 --- a/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml @@ -162,45 +162,6 @@ i.status <> 'CLOSED' - - - select p.id, p.uuid from projects p - where (p.id=#{id} or p.root_id=#{id}) and p.enabled=${_true} + where p.root_uuid=#{uuid} and p.enabled=${_true} and not exists(select s.component_uuid from snapshots s where s.islast=${_true} and s.component_uuid=p.uuid) diff --git a/sonar-db/src/main/resources/org/sonar/db/user/AuthorizationMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/AuthorizationMapper.xml index 12bef99c2fd..f670e71ecc8 100644 --- a/sonar-db/src/main/resources/org/sonar/db/user/AuthorizationMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/user/AuthorizationMapper.xml @@ -9,7 +9,20 @@ WHERE gr.role=#{role} and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) - and (gr.resource_id = p.root_id or gr.resource_id = p.id) and + and gr.resource_id = p.id + and + + p.kee=#{element} + + UNION + SELECT p.kee + FROM group_roles gr, projects root, projects p + WHERE + gr.role=#{role} + and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) + and gr.resource_id = root.id + and p.root_uuid = root.uuid + and p.kee=#{element} @@ -19,7 +32,8 @@ INNER JOIN projects p on p.id = ur.resource_id WHERE ur.role=#{role} - and ur.user_id=#{userId} and + and ur.user_id=#{userId} + and p.kee=#{element} @@ -31,7 +45,20 @@ WHERE gr.role=#{role} and gr.group_id is null - and (gr.resource_id = p.root_id or gr.resource_id = p.id) and + and gr.resource_id = p.id + and + + p.kee=#{element} + + UNION + SELECT p.kee + FROM group_roles gr, projects root, projects p + WHERE + gr.role=#{role} + and gr.group_id is null + and gr.resource_id = root.id + and p.root_uuid = root.uuid + and p.kee=#{element} diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java index c477dc064a3..2acc84c106d 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -68,7 +68,7 @@ public class ComponentDaoTest { assertThat(result.uuid()).isEqualTo("KLMN"); assertThat(result.moduleUuid()).isEqualTo("EFGH"); assertThat(result.moduleUuidPath()).isEqualTo(".ABCD.EFGH."); - assertThat(result.parentProjectId()).isEqualTo(2); + assertThat(result.getRootUuid()).isEqualTo("EFGH"); assertThat(result.projectUuid()).isEqualTo("ABCD"); assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(result.path()).isEqualTo("src/org/struts/RequestContext.java"); @@ -77,7 +77,8 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("FIL"); assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isEqualTo("java"); - assertThat(result.getCopyResourceId()).isNull(); + assertThat(result.getCopyResourceUuid()).isNull(); + assertThat(result.getDeveloperUuid()).isNull(); assertThat(underTest.selectByUuid(dbSession, "UNKNOWN")).isAbsent(); } @@ -91,7 +92,7 @@ public class ComponentDaoTest { assertThat(result.uuid()).isEqualTo("STUV"); assertThat(result.moduleUuid()).isEqualTo("OPQR"); assertThat(result.moduleUuidPath()).isEqualTo(".OPQR."); - assertThat(result.parentProjectId()).isEqualTo(11); + assertThat(result.getRootUuid()).isEqualTo("OPQR"); assertThat(result.projectUuid()).isEqualTo("OPQR"); assertThat(result.key()).isEqualTo("DEV:anakin@skywalker.name:org.struts:struts"); assertThat(result.path()).isNull(); @@ -100,7 +101,8 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("DEV_PRJ"); assertThat(result.scope()).isEqualTo("PRJ"); assertThat(result.language()).isNull(); - assertThat(result.getCopyResourceId()).isEqualTo(1L); + assertThat(result.getCopyResourceUuid()).isEqualTo("ABCD"); + assertThat(result.getDeveloperUuid()).isEqualTo("OPQR"); } @Test @@ -108,7 +110,7 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "shared.xml"); ComponentDto result = underTest.selectByUuid(dbSession, "STUV").get(); - assertThat(result.getDeveloperId()).isEqualTo(11L); + assertThat(result.getDeveloperUuid()).isEqualTo("OPQR"); } @Test @@ -144,7 +146,8 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("FIL"); assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isEqualTo("java"); - assertThat(result.parentProjectId()).isEqualTo(2); + assertThat(result.uuid()).isEqualTo("KLMN"); + assertThat(result.getRootUuid()).isEqualTo("EFGH"); assertThat(underTest.selectByKey(dbSession, "unknown")).isAbsent(); } @@ -180,7 +183,7 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("TRK"); assertThat(result.scope()).isEqualTo("PRJ"); assertThat(result.language()).isNull(); - assertThat(result.parentProjectId()).isNull(); + assertThat(result.getRootUuid()).isEqualTo("ABCD"); assertThat(result.getAuthorizationUpdatedAt()).isEqualTo(123456789L); } @@ -200,7 +203,7 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("FIL"); assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isEqualTo("java"); - assertThat(result.parentProjectId()).isEqualTo(2); + assertThat(result.getRootUuid()).isEqualTo("EFGH"); assertThat(underTest.selectByKeys(dbSession, singletonList("unknown"))).isEmpty(); } @@ -221,7 +224,7 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("FIL"); assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isEqualTo("java"); - assertThat(result.parentProjectId()).isEqualTo(2); + assertThat(result.getRootUuid()).isEqualTo("EFGH"); assertThat(underTest.selectByIds(dbSession, newArrayList(555L))).isEmpty(); } @@ -238,7 +241,7 @@ public class ComponentDaoTest { assertThat(result.uuid()).isEqualTo("KLMN"); assertThat(result.moduleUuid()).isEqualTo("EFGH"); assertThat(result.moduleUuidPath()).isEqualTo(".ABCD.EFGH."); - assertThat(result.parentProjectId()).isEqualTo(2); + assertThat(result.getRootUuid()).isEqualTo("EFGH"); assertThat(result.projectUuid()).isEqualTo("ABCD"); assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(result.path()).isEqualTo("src/org/struts/RequestContext.java"); @@ -358,7 +361,7 @@ public class ComponentDaoTest { assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts"); // Sub project of a project - assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("ABCD"))).isEmpty(); + assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("ABCD"))).extracting("uuid").containsOnly("ABCD"); // SUb projects of a component and a sub module assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("HIJK", "FGHI"))).hasSize(2); @@ -569,9 +572,9 @@ public class ComponentDaoTest { .setLanguage("java") .setDescription("description") .setPath("src/org/struts/RequestContext.java") - .setParentProjectId(3L) - .setCopyResourceId(5L) - .setDeveloperId(7L) + .setRootUuid("uuid_3") + .setCopyComponentUuid("uuid_5") + .setDeveloperUuid("uuid_7") .setEnabled(true) .setCreatedAt(DateUtils.parseDate("2014-06-18")) .setAuthorizationUpdatedAt(123456789L); @@ -602,9 +605,9 @@ public class ComponentDaoTest { .setLanguage("java") .setDescription("description") .setPath("src/org/struts/RequestContext.java") - .setParentProjectId(3L) - .setCopyResourceId(5L) - .setDeveloperId(7L) + .setRootUuid("uuid_3") + .setCopyComponentUuid("uuid_5") + .setDeveloperUuid("uuid_7") .setEnabled(true) .setCreatedAt(DateUtils.parseDate("2014-06-18")) .setAuthorizationUpdatedAt(123456789L); @@ -634,7 +637,7 @@ public class ComponentDaoTest { .setScope("FIL") .setLanguage("java") .setPath("src/org/struts/RequestContext.java") - .setParentProjectId(3L) + .setRootUuid("uuid_3") .setEnabled(false) .setCreatedAt(DateUtils.parseDate("2014-06-18")) .setAuthorizationUpdatedAt(123456789L); @@ -664,9 +667,9 @@ public class ComponentDaoTest { .setLanguage("java2") .setDescription("description2") .setPath("src/org/struts/RequestContext2.java") - .setParentProjectId(4L) - .setCopyResourceId(6L) - .setDeveloperId(9L) + .setRootUuid("uuid_4") + .setCopyComponentUuid("uuid_6") + .setDeveloperUuid("uuid_9") .setEnabled(false) .setAuthorizationUpdatedAt(12345678910L); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java index 836149e3277..09b1ffc597b 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java @@ -40,8 +40,9 @@ public class ComponentDtoTest { .setLanguage("java") .setDescription("desc") .setPath("src/org/struts/RequestContext.java") - .setCopyResourceId(5L) - .setParentProjectId(3L) + .setCopyComponentUuid("uuid_5") + .setRootUuid("uuid_3") + .setDeveloperUuid("uuid_6") .setAuthorizationUpdatedAt(123456789L); assertThat(componentDto.getId()).isEqualTo(1L); @@ -54,8 +55,9 @@ public class ComponentDtoTest { assertThat(componentDto.path()).isEqualTo("src/org/struts/RequestContext.java"); assertThat(componentDto.language()).isEqualTo("java"); assertThat(componentDto.description()).isEqualTo("desc"); - assertThat(componentDto.parentProjectId()).isEqualTo(3L); - assertThat(componentDto.getCopyResourceId()).isEqualTo(5L); + assertThat(componentDto.getRootUuid()).isEqualTo("uuid_3"); + assertThat(componentDto.getCopyResourceUuid()).isEqualTo("uuid_5"); + assertThat(componentDto.getDeveloperUuid()).isEqualTo("uuid_6"); assertThat(componentDto.getAuthorizationUpdatedAt()).isEqualTo(123456789L); } diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java index 90b42a41772..cc5904b0b5e 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentTesting.java @@ -94,7 +94,7 @@ public class ComponentTesting { .setUuid(uuid) .setProjectUuid(uuid) .setModuleUuidPath(MODULE_UUID_PATH_SEP + uuid + MODULE_UUID_PATH_SEP) - .setParentProjectId(null) + .setRootUuid(uuid) .setKey("KEY_" + uuid) .setName("NAME_" + uuid) .setLongName("LONG_NAME_" + uuid) @@ -111,7 +111,7 @@ public class ComponentTesting { .setUuid(uuid) .setProjectUuid(uuid) .setModuleUuidPath(MODULE_UUID_PATH_SEP + uuid + MODULE_UUID_PATH_SEP) - .setParentProjectId(null) + .setRootUuid(uuid) .setKey(uuid) .setName(name) .setLongName(name) @@ -141,7 +141,7 @@ public class ComponentTesting { .setKey(view.key() + project.key()) .setName(project.name()) .setLongName(project.longName()) - .setCopyResourceId(project.getId()) + .setCopyComponentUuid(project.uuid()) .setScope(Scopes.FILE) .setQualifier(Qualifiers.PROJECT) .setPath(null) @@ -155,7 +155,7 @@ public class ComponentTesting { .setKey(developer.key() + ":" + project.key()) .setName(project.name()) .setLongName(project.longName()) - .setCopyResourceId(project.getId()) + .setCopyComponentUuid(project.uuid()) .setScope(Scopes.PROJECT) .setQualifier("DEV_PRJ") .setPath(null) @@ -168,7 +168,7 @@ public class ComponentTesting { .setProjectUuid(module.projectUuid()) .setModuleUuid(module.uuid()) .setModuleUuidPath(module.moduleUuidPath()) - .setParentProjectId(module.getId()) + .setRootUuid(module.uuid()) .setCreatedAt(new Date()) .setEnabled(true); } diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java index 0c13476bde8..60bd033b741 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java @@ -27,8 +27,6 @@ import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; import org.sonar.api.component.Component; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; @@ -87,27 +85,6 @@ public class ResourceDaoTest { assertThat(underTest.getRootProjectByComponentKey("unknown")).isNull(); } - @Test - public void should_insert_using_existing_session() { - dbTester.prepareDbUnit(getClass(), "insert.xml"); - - ResourceDto file1 = new ResourceDto().setUuid("ABCD") - .setKey("org.struts:struts:/src/main/java/org/struts/Action.java") - .setDeprecatedKey("org.struts:struts:org.struts.Action").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) - .setLanguage("java").setName("Action").setLongName("org.struts.Action"); - ResourceDto file2 = new ResourceDto().setUuid("BCDE") - .setKey("org.struts:struts:/src/main/java/org/struts/Filter.java") - .setDeprecatedKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) - .setLanguage("java").setName("Filter").setLongName("org.struts.Filter"); - - underTest.insertUsingExistingSession(file1, dbTester.getSession()); - underTest.insertUsingExistingSession(file2, dbTester.getSession()); - - dbTester.getSession().rollback(); - - assertThat(dbTester.countRowsOfTable("projects")).isZero(); - } - @Test public void should_find_component_by_key() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java index cdcce31fb4b..ecf6a506df5 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java @@ -147,7 +147,7 @@ public class ResourceIndexDaoTest { @Test public void restrict_indexed_combinations_to_400_characters() { String longName = repeat("a", 2_000); - ComponentDto project = new ComponentDto().setUuid(ROOT_UUID).setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT); + ComponentDto project = new ComponentDto().setUuid(ROOT_UUID).setRootUuid(ROOT_UUID).setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT); DbSession session = dbTester.getSession(); dbTester.getDbClient().componentDao().insert(session, project); dbTester.getDbClient().snapshotDao().insert(session, new SnapshotDto().setComponentUuid(project.uuid()).setRootComponentUuid(project.uuid()).setLast(true)); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceKeyUpdaterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceKeyUpdaterDaoTest.java index c44ee35e9e4..971aab92c4d 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceKeyUpdaterDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceKeyUpdaterDaoTest.java @@ -25,6 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.utils.System2; +import org.sonar.db.DbSession; import org.sonar.db.DbTester; import static org.assertj.core.api.Assertions.assertThat; @@ -38,6 +39,7 @@ public class ResourceKeyUpdaterDaoTest { @Rule public DbTester db = DbTester.create(System2.INSTANCE); + private DbSession dbSession = db.getSession(); ComponentDbTester componentDb = new ComponentDbTester(db); ResourceKeyUpdaterDao underTest = db.getDbClient().resourceKeyUpdaterDao(); @@ -46,7 +48,7 @@ public class ResourceKeyUpdaterDaoTest { public void shouldUpdateKey() { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.updateKey(2, "struts:core"); + underTest.updateKey("B", "struts:core"); db.assertDbUnit(getClass(), "shouldUpdateKey-result.xml", "projects"); } @@ -58,14 +60,15 @@ public class ResourceKeyUpdaterDaoTest { thrown.expect(IllegalStateException.class); thrown.expectMessage("Impossible to update key: a resource with \"org.struts:struts-ui\" key already exists."); - underTest.updateKey(2, "org.struts:struts-ui"); + underTest.updateKey("B", "org.struts:struts-ui"); } @Test public void shouldBulkUpdateKey() { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.bulkUpdateKey(1, "org.struts", "org.apache.struts"); + underTest.bulkUpdateKey(dbSession, "A", "org.struts", "org.apache.struts"); + dbSession.commit(); db.assertDbUnit(getClass(), "shouldBulkUpdateKey-result.xml", "projects"); } @@ -74,7 +77,8 @@ public class ResourceKeyUpdaterDaoTest { public void shouldBulkUpdateKeyOnOnlyOneSubmodule() { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.bulkUpdateKey(1, "struts-ui", "struts-web"); + underTest.bulkUpdateKey(dbSession, "A", "struts-ui", "struts-web"); + dbSession.commit(); db.assertDbUnit(getClass(), "shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml", "projects"); } @@ -86,14 +90,16 @@ public class ResourceKeyUpdaterDaoTest { thrown.expect(IllegalStateException.class); thrown.expectMessage("Impossible to update key: a resource with \"foo:struts-core\" key already exists."); - underTest.bulkUpdateKey(1, "org.struts", "foo"); + underTest.bulkUpdateKey(dbSession, "A", "org.struts", "foo"); + dbSession.commit(); } @Test public void shouldNotUpdateAllSubmodules() { db.prepareDbUnit(getClass(), "shouldNotUpdateAllSubmodules.xml"); - underTest.bulkUpdateKey(1, "org.struts", "org.apache.struts"); + underTest.bulkUpdateKey(dbSession, "A", "org.struts", "org.apache.struts"); + dbSession.commit(); db.assertDbUnit(getClass(), "shouldNotUpdateAllSubmodules-result.xml", "projects"); } @@ -107,14 +113,14 @@ public class ResourceKeyUpdaterDaoTest { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Component key length (405) is longer than the maximum authorized (400). '" + newLongProjectKey + ":file' was provided."); - underTest.updateKey(project.getId(), newLongProjectKey); + underTest.updateKey(project.uuid(), newLongProjectKey); } @Test public void shouldCheckModuleKeysBeforeRenaming() { db.prepareDbUnit(getClass(), "shared.xml"); - Map checkResults = underTest.checkModuleKeysBeforeRenaming(1, "org.struts", "foo"); + Map checkResults = underTest.checkModuleKeysBeforeRenaming("A", "org.struts", "foo"); assertThat(checkResults.size()).isEqualTo(3); assertThat(checkResults.get("org.struts:struts")).isEqualTo("foo:struts"); assertThat(checkResults.get("org.struts:struts-core")).isEqualTo("#duplicate_key#"); diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java index 4b48ebbce04..9fe992fd17e 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java @@ -20,7 +20,6 @@ package org.sonar.db.issue; import java.util.List; -import org.apache.ibatis.executor.result.DefaultResultHandler; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -51,52 +50,6 @@ public class IssueDaoTest { public DbTester dbTester = DbTester.create(System2.INSTANCE); IssueDao underTest = dbTester.getDbClient().issueDao(); - @Test - public void select_non_closed_issues_by_module() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_select_non_closed_issues_by_module.xml"); - - // 400 is a non-root module, we should find 2 issues from classes and one on itself - DefaultResultHandler handler = new DefaultResultHandler(); - underTest.selectNonClosedIssuesByModule(400, handler); - assertThat(handler.getResultList()).hasSize(3); - - IssueDto issue = (IssueDto) handler.getResultList().get(0); - assertThat(issue.getRuleRepo()).isNotNull(); - assertThat(issue.getRule()).isNotNull(); - assertThat(issue.getComponentKey()).isNotNull(); - assertThat(issue.getProjectKey()).isEqualTo("struts"); - - // 399 is the root module, we should only find 1 issue on itself - handler = new DefaultResultHandler(); - underTest.selectNonClosedIssuesByModule(399, handler); - assertThat(handler.getResultList()).hasSize(1); - - issue = (IssueDto) handler.getResultList().get(0); - assertThat(issue.getComponentKey()).isEqualTo("struts"); - assertThat(issue.getProjectKey()).isEqualTo("struts"); - } - - /** - * SONAR-5218 - */ - @Test - public void select_non_closed_issues_by_module_on_removed_project() { - // All issues are linked on a project that is not existing anymore - - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_select_non_closed_issues_by_module_on_removed_project.xml"); - - // 400 is a non-root module, we should find 2 issues from classes and one on itself - DefaultResultHandler handler = new DefaultResultHandler(); - underTest.selectNonClosedIssuesByModule(400, handler); - assertThat(handler.getResultList()).hasSize(3); - - IssueDto issue = (IssueDto) handler.getResultList().get(0); - assertThat(issue.getRuleRepo()).isNotNull(); - assertThat(issue.getRule()).isNotNull(); - assertThat(issue.getComponentKey()).isNotNull(); - assertThat(issue.getProjectKey()).isNull(); - } - @Test public void selectByKeyOrFail() { prepareTables(); diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml index 3097967ba2b..8d70ce24e52 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml @@ -3,8 +3,8 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml index a7021383b33..3fe7c2f0512 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml @@ -2,8 +2,8 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/multi-modules.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/multi-modules.xml index 81f5bde319d..a60d785a90a 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/multi-modules.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/multi-modules.xml @@ -1,57 +1,57 @@ - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="[null]"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> - + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> - + enabled="[false]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> - + enabled="[false]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> - + enabled="[false]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_ghost_projects.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_ghost_projects.xml index c7ad5d723ec..934d4757f1f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_ghost_projects.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_ghost_projects.xml @@ -4,16 +4,16 @@ - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> - + enabled="[false]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - - + + enabled="[true]" language="[null]" copy_component_uuid="ABCD" developer_uuid="OPQR" path="[null]" authorization_updated_at="123456789"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml index 703f88968ac..7aab8b98265 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml @@ -1,23 +1,23 @@ - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="[null]"/> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/pom.xml" authorization_updated_at="[null]"/> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> - + enabled="[false]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - - + + enabled="[true]" language="[null]" copy_component_uuid="ABCD" developer_uuid="OPQR" path="[null]" authorization_updated_at="123456789"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared.xml index adaa8d388ef..5fd182fab66 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared.xml @@ -5,10 +5,10 @@ - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]"/> + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts" authorization_updated_at="[null]"/> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" path="src/org/struts/RequestContext.java" authorization_updated_at="[null]"/> - + enabled="[false]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="123456789"/> - - + + enabled="[true]" language="[null]" copy_component_uuid="ABCD" developer_uuid="OPQR" path="[null]" authorization_updated_at="123456789"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared_views.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared_views.xml index 1eca3522d69..3f62fc3ad78 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared_views.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/shared_views.xml @@ -1,35 +1,35 @@ - - - - - - - - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update-result.xml index 62196600389..6a23654e9ff 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update-result.xml @@ -3,8 +3,8 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update.xml index fe171ca4441..68b1156822d 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/update.xml @@ -3,8 +3,8 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql index 5b314d137e7..7a309ca3e32 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql @@ -1,12 +1,12 @@ CREATE TABLE "PROJECTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(400), - "ROOT_ID" INTEGER, - "UUID" VARCHAR(50), + "UUID" VARCHAR(50) NOT NULL, + "ROOT_UUID" VARCHAR(50) NOT NULL, "PROJECT_UUID" VARCHAR(50), "MODULE_UUID" VARCHAR(50), "MODULE_UUID_PATH" VARCHAR(4000), - "NAME" VARCHAR(256), + "NAME" VARCHAR(2000), "DESCRIPTION" VARCHAR(2000), "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, "SCOPE" VARCHAR(3), @@ -14,16 +14,16 @@ CREATE TABLE "PROJECTS" ( "DEPRECATED_KEE" VARCHAR(400), "PATH" VARCHAR(2000), "LANGUAGE" VARCHAR(20), - "COPY_RESOURCE_ID" INTEGER, - "LONG_NAME" VARCHAR(256), - "PERSON_ID" INTEGER, + "COPY_COMPONENT_UUID" VARCHAR(50), + "LONG_NAME" VARCHAR(2000), + "DEVELOPER_UUID" VARCHAR(50), "CREATED_AT" TIMESTAMP, "AUTHORIZATION_UPDATED_AT" BIGINT ); CREATE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); -CREATE INDEX "PROJECTS_ROOT_ID" ON "PROJECTS" ("ROOT_ID"); +CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID"); CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/fixture-including-ghost-projects-and-technical-project.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/fixture-including-ghost-projects-and-technical-project.xml index 490e8fa0cbe..958c16c1150 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/fixture-including-ghost-projects-and-technical-project.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/fixture-including-ghost-projects-and-technical-project.xml @@ -1,10 +1,10 @@ - - - + enabled="[true]" language="java" copy_component_uuid="ABCD" developer_uuid="[null]" authorization_updated_at="[null]"/> - + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/> - - + enabled="[false]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/> - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml index a6abf2fab1b..95b4c5b19cc 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml @@ -1,9 +1,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml index 69e73cdb6df..239dcf719b1 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml @@ -1,9 +1,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/select_project_ids_from_query_and_view_or_sub_view_uuid.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/select_project_ids_from_query_and_view_or_sub_view_uuid.xml index e0cc9bc51f3..221eb458280 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/select_project_ids_from_query_and_view_or_sub_view_uuid.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/select_project_ids_from_query_and_view_or_sub_view_uuid.xml @@ -1,15 +1,15 @@ IncreasePrecisionOfNumericsTest.update_column_types:48 - - + + - - + + - + diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldIndexMultiModulesProject.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldIndexMultiModulesProject.xml index d88fef9f1b4..ff0f36d95e6 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldIndexMultiModulesProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldIndexMultiModulesProject.xml @@ -3,29 +3,29 @@ + enabled="[true]" language="java" /> + enabled="[true]" language="java" /> + enabled="[true]" language="java" /> + enabled="[true]" language="java" /> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldNotIndexPackages.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldNotIndexPackages.xml index 1072f211a68..7e76208a0ee 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldNotIndexPackages.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldNotIndexPackages.xml @@ -3,24 +3,24 @@ + enabled="[true]" language="java" /> + enabled="[true]" language="java" /> + enabled="[true]" language="java" /> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexNewTwoLettersLongResource.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexNewTwoLettersLongResource.xml index 268953293f7..1c7036cd095 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexNewTwoLettersLongResource.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexNewTwoLettersLongResource.xml @@ -2,9 +2,9 @@ + enabled="[true]" language="java"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexTwoLettersLongResource.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexTwoLettersLongResource.xml index 5b1c5fa7a1a..c7faa7de4ce 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexTwoLettersLongResource.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReIndexTwoLettersLongResource.xml @@ -2,9 +2,9 @@ + enabled="[true]" language="java" /> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReindexProjectAfterRenaming.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReindexProjectAfterRenaming.xml index e00a7602607..6b1066004b3 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReindexProjectAfterRenaming.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceIndexDaoTest/shouldReindexProjectAfterRenaming.xml @@ -2,9 +2,9 @@ + enabled="[true]" language="java" /> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml index 400243b4d19..9e8d45b55c0 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml @@ -1,71 +1,71 @@ - - +² - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml index 962995f42b6..6227c606fc2 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml @@ -1,72 +1,72 @@ - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml index 81e4290832e..1f15cb2d042 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml @@ -1,71 +1,71 @@ - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml index 83686f2ba90..85e1a75fe6c 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml @@ -1,63 +1,63 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml index 5021b0c56bc..226d5faaa08 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml @@ -1,62 +1,62 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml index a7a9d68d42a..b5e560f47e5 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml @@ -1,10 +1,10 @@ - @@ -12,62 +12,62 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/has_last_snapshot_by_component_uuid.xml b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/has_last_snapshot_by_component_uuid.xml index 3a4404377a3..84aeaa27387 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/has_last_snapshot_by_component_uuid.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/has_last_snapshot_by_component_uuid.xml @@ -1,10 +1,10 @@ - + enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" path="[null]" authorization_updated_at="[null]" /> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]" /> - + description="[null]" enabled="[true]" language="[null]" copy_component_uuid="[null]" developer_uuid="[null]" authorization_updated_at="[null]" /> + enabled="[true]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/> - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/insert.xml b/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/insert.xml index 1a168293765..02a6e33afa7 100644 --- a/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/insert.xml +++ b/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/insert.xml @@ -2,6 +2,6 @@ - + diff --git a/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/select_candidates.xml b/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/select_candidates.xml index e03ca58794e..d2eca360488 100644 --- a/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/select_candidates.xml +++ b/sonar-db/src/test/resources/org/sonar/db/duplication/DuplicationDaoTest/select_candidates.xml @@ -2,26 +2,26 @@ - + - + - + - + - + - + diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/shared.xml index f6825ce7056..306aa5b1217 100644 --- a/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/shared.xml @@ -2,14 +2,14 @@ - - - - + + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml index db64cefe322..ab4473adb1b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml @@ -15,17 +15,17 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_person_id.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_person_id.xml index cc554e9e486..55744741a7f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_person_id.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_person_id.xml @@ -4,7 +4,7 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml index cf3af96ea09..67e00418372 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml @@ -4,7 +4,7 @@ - + diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml index c9e5417e180..08a654e1d89 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml @@ -4,7 +4,7 @@ - + diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/with_some_measures_for_developer.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/with_some_measures_for_developer.xml index d1fe38a34ee..d58ef14ab2e 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/with_some_measures_for_developer.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/with_some_measures_for_developer.xml @@ -4,8 +4,8 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/apply_default_permission_template.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/apply_default_permission_template.xml index f990d2158f9..0ed1f2d089b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/apply_default_permission_template.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/apply_default_permission_template.xml @@ -1,8 +1,8 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission-result.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission-result.xml index 793d16b3bae..242b2056066 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission-result.xml @@ -7,7 +7,7 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission.xml index 8f079ec590c..62435ee6f13 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_add_user_permission.xml @@ -4,9 +4,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_apply_permission_template.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_apply_permission_template.xml index ef9212b8087..bf79d01e3e2 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_apply_permission_template.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_apply_permission_template.xml @@ -1,8 +1,8 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission-result.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission-result.xml index e77f558dc36..4cb4facedaf 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission-result.xml @@ -4,9 +4,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission.xml index 9c3bcfce197..e577bd2633d 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_group_permission.xml @@ -5,9 +5,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission-result.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission-result.xml index 8f079ec590c..62435ee6f13 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission-result.xml @@ -4,9 +4,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission.xml index fe3e01186db..0150227ccee 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_delete_user_permission.xml @@ -5,9 +5,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission-result.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission-result.xml index 276e8d7da3f..b94f939bf09 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission-result.xml @@ -5,9 +5,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission.xml index 4552a5339ee..92fe2f87d9b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_anyone_group_permission.xml @@ -4,9 +4,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission-result.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission-result.xml index 9c3bcfce197..574e36a9a6d 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission-result.xml @@ -5,9 +5,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission.xml b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission.xml index e77f558dc36..4cb4facedaf 100644 --- a/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission.xml +++ b/sonar-db/src/test/resources/org/sonar/db/permission/PermissionRepositoryTest/should_insert_group_permission.xml @@ -4,9 +4,9 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete_project_property.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete_project_property.xml index 99bd75917c1..f6e6099a954 100644 --- a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete_project_property.xml +++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/delete_project_property.xml @@ -16,7 +16,7 @@ - - - + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/findNotificationSubscribers.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/findNotificationSubscribers.xml index 9bfd1dc3001..08568ad0eee 100644 --- a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/findNotificationSubscribers.xml +++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/findNotificationSubscribers.xml @@ -10,7 +10,7 @@ login="simon" /> - + - - - + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/select_module_properties_tree.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/select_module_properties_tree.xml index 938910a0e01..5dd05ae8a5a 100644 --- a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/select_module_properties_tree.xml +++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/select_module_properties_tree.xml @@ -20,41 +20,41 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/shouldFindUsersForNotification.xml b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/shouldFindUsersForNotification.xml index 63c723d4f57..b6926426ff1 100644 --- a/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/shouldFindUsersForNotification.xml +++ b/sonar-db/src/test/resources/org/sonar/db/property/PropertiesDaoTest/shouldFindUsersForNotification.xml @@ -1,7 +1,7 @@ - - + + - + description="[null]" language="java" copy_component_uuid="[null]" developer_uuid="[null]"/> - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml index e9a7fbb175c..157ac6440f9 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml @@ -9,24 +9,24 @@ What has been changed : - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml index d80f257666d..9d795b7ea83 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml @@ -1,10 +1,10 @@ - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml index 763a93149ce..13c04211962 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml @@ -7,24 +7,24 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml index 1a20054a9cd..52ea5d63dee 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml @@ -1,24 +1,24 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml index 492010d763a..fb03c68f429 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -1,10 +1,10 @@ - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml index c4b9ccba430..6d59eb0ff86 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml @@ -4,7 +4,7 @@ diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml index ae336142fdf..89d73329dca 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml @@ -7,7 +7,7 @@ - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest/shared.xml index c58db5391e2..8f719037338 100644 --- a/sonar-db/src/test/resources/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest/shared.xml @@ -3,13 +3,13 @@ - - - - - - - + + + + + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml b/sonar-db/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml index 94df8ad98ee..32f6c7c7262 100644 --- a/sonar-db/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml +++ b/sonar-db/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml @@ -5,9 +5,9 @@ - - - + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/anonymous_should_be_authorized.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/anonymous_should_be_authorized.xml index f5730087a21..47b03de71a5 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/anonymous_should_be_authorized.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/anonymous_should_be_authorized.xml @@ -5,10 +5,10 @@ - - - - - + + + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/group_should_be_authorized.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/group_should_be_authorized.xml index 7ffca0d6f5e..07ae52a0cc8 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/group_should_be_authorized.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/group_should_be_authorized.xml @@ -7,10 +7,10 @@ - - - - - + + + + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_anonymous.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_anonymous.xml index 1c21104a7b6..e02308c9bc1 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_anonymous.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_anonymous.xml @@ -4,7 +4,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_group.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_group.xml index 17e6323ccd6..593f2936ac6 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_group.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_group.xml @@ -4,7 +4,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_user.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_user.xml index 515adaa8f48..e2994285531 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_user.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_project_ids_for_user.xml @@ -4,7 +4,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_anonymous.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_anonymous.xml index 4de4f328925..b7b48ed7ea9 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_anonymous.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_anonymous.xml @@ -12,7 +12,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_group.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_group.xml index c813b02e6f8..a354439d560 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_group.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_group.xml @@ -12,7 +12,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_user.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_user.xml index e6328ec9654..0fa56c9ee59 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_user.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/keep_authorized_users_for_role_and_project_for_user.xml @@ -9,7 +9,7 @@ - - + + diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_anonymous.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_anonymous.xml index a1aa1f05a76..7db6a43c676 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_anonymous.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_anonymous.xml @@ -4,13 +4,13 @@ - - + - - diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_group.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_group.xml index 93682166701..bf24717a9b9 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_group.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_group.xml @@ -6,13 +6,13 @@ - - + - - diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_user.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_user.xml index 060223cdfbd..6ddf4cd5cda 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_user.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/should_return_root_project_keys_for_user.xml @@ -5,13 +5,13 @@ - - + - - diff --git a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/user_should_be_authorized.xml b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/user_should_be_authorized.xml index 3771e09738d..5bed484123e 100644 --- a/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/user_should_be_authorized.xml +++ b/sonar-db/src/test/resources/org/sonar/db/user/AuthorizationDaoTest/user_should_be_authorized.xml @@ -6,6 +6,6 @@ - - + +