From eda9dff59cc60209b15b69ef4aa4c18885c0c744 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 17 Nov 2021 14:03:41 -0600 Subject: [PATCH] SONAR-15398 update class and method names --- .../component/ProjectViewAttributes.java | 15 +++++++-------- .../step/PersistComponentsStep.java | 4 ++-- .../step/ViewsPersistComponentsStepTest.java | 12 ++++++------ .../java/org/sonar/db/component/ComponentDto.java | 2 +- .../sonar/db/component/ComponentUpdateDto.java | 2 +- .../org/sonar/db/component/ComponentDaoTest.java | 8 ++++---- .../org/sonar/db/component/ComponentDtoTest.java | 2 +- .../org/sonar/server/component/ws/TreeAction.java | 4 ++-- .../sonar/server/measure/ws/ComponentAction.java | 4 ++-- .../measure/ws/ComponentDtoToWsComponent.java | 2 +- .../server/measure/ws/ComponentTreeAction.java | 4 ++-- 11 files changed, 29 insertions(+), 30 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectViewAttributes.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectViewAttributes.java index 2541858fc57..e787b9083fe 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectViewAttributes.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectViewAttributes.java @@ -27,21 +27,21 @@ import static java.util.Objects.requireNonNull; @Immutable public class ProjectViewAttributes { - private final String projectUuid; + private final String uuid; private final String originalKey; @CheckForNull private final Long analysisDate; private final String branchName; - public ProjectViewAttributes(String projectUuid, String originalKey, @Nullable Long analysisDate, @Nullable String branchName) { - this.projectUuid = requireNonNull(projectUuid, "projectUuid can't be null"); - this.originalKey = requireNonNull(originalKey, "projectKey can't be null"); + public ProjectViewAttributes(String uuid, String originalKey, @Nullable Long analysisDate, @Nullable String branchName) { + this.uuid = requireNonNull(uuid, "uuid can't be null"); + this.originalKey = requireNonNull(originalKey, "originalKey can't be null"); this.analysisDate = analysisDate; this.branchName = branchName; } - public String getProjectUuid() { - return projectUuid; + public String getUuid() { + return uuid; } @CheckForNull @@ -49,7 +49,6 @@ public class ProjectViewAttributes { return analysisDate; } - public String getBranchName() { return branchName; } @@ -61,7 +60,7 @@ public class ProjectViewAttributes { @Override public String toString() { return "ProjectViewAttributes{" + - ", projectUuid='" + projectUuid + '\'' + + ", uuid='" + uuid + '\'' + ", branchName='" + branchName + '\'' + ", analysisDate=" + analysisDate + '}'; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java index 788fe06929a..67538b86af0 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java @@ -340,7 +340,7 @@ public class PersistComponentsStep implements ComputationStep { res.setQualifier(PROJECT); res.setName(projectView.getName()); res.setLongName(res.name()); - res.setCopyComponentUuid(projectView.getProjectViewAttributes().getProjectUuid()); + res.setCopyComponentUuid(projectView.getProjectViewAttributes().getUuid()); setRootAndParentModule(res, path); @@ -395,7 +395,7 @@ public class PersistComponentsStep implements ComputationStep { } private static Optional compareForUpdate(ComponentDto existing, ComponentDto target) { - boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) || + boolean hasDifferences = !StringUtils.equals(existing.getCopyComponentUuid(), target.getCopyComponentUuid()) || !StringUtils.equals(existing.description(), target.description()) || !StringUtils.equals(existing.getDbKey(), target.getDbKey()) || !existing.isEnabled() || diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java index 113e4f8ec31..94500b7d4af 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java @@ -207,7 +207,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertRowsCountInTableProjects(2); ComponentDto subView = getComponentFromDb(SUBVIEW_1_KEY); - assertThat(subView.getCopyResourceUuid()).isEqualTo("ORIGINAL_UUID"); + assertThat(subView.getCopyComponentUuid()).isEqualTo("ORIGINAL_UUID"); } @Test @@ -368,7 +368,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { dbTester.commit(); ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY); - assertThat(subViewReloaded.getCopyResourceUuid()).isEqualTo("NEW_COPY"); + assertThat(subViewReloaded.getCopyComponentUuid()).isEqualTo("NEW_COPY"); } @Test @@ -504,7 +504,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + "."); assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW); assertThat(dto.scope()).isEqualTo(Scopes.PROJECT); - assertThat(dto.getCopyResourceUuid()).isNull(); + assertThat(dto.getCopyComponentUuid()).isNull(); assertThat(dto.getCreatedAt()).isEqualTo(now); } @@ -523,7 +523,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + "."); assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP); assertThat(dto.scope()).isEqualTo(Scopes.PROJECT); - assertThat(dto.getCopyResourceUuid()).isNull(); + assertThat(dto.getCopyComponentUuid()).isNull(); assertThat(dto.getCreatedAt()).isEqualTo(now); } @@ -542,7 +542,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(sv1Dto.moduleUuidPath()).isEqualTo(viewDto.moduleUuidPath() + sv1Dto.uuid() + "."); assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW); assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT); - assertThat(sv1Dto.getCopyResourceUuid()).isNull(); + assertThat(sv1Dto.getCopyComponentUuid()).isNull(); assertThat(sv1Dto.getCreatedAt()).isEqualTo(now); } @@ -558,7 +558,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { assertThat(pv1Dto.moduleUuidPath()).isEqualTo(parentViewDto.moduleUuidPath() + pv1Dto.uuid() + "."); assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT); assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE); - assertThat(pv1Dto.getCopyResourceUuid()).isEqualTo(project.uuid()); + assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid()); assertThat(pv1Dto.getCreatedAt()).isEqualTo(now); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java index 0f491d7f96a..616f456c64e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java @@ -352,7 +352,7 @@ public class ComponentDto { } @CheckForNull - public String getCopyResourceUuid() { + public String getCopyComponentUuid() { return copyComponentUuid; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java index cec683c65b4..ca262064df2 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java @@ -189,7 +189,7 @@ public class ComponentUpdateDto { .setUuid(from.uuid()) .setBChanged(false) .setBKey(from.getDbKey()) - .setBCopyComponentUuid(from.getCopyResourceUuid()) + .setBCopyComponentUuid(from.getCopyComponentUuid()) .setBDescription(from.description()) .setBEnabled(from.isEnabled()) .setBUuidPath(from.getUuidPath()) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index d5aad6f2f47..ccb93d46484 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -149,7 +149,7 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("TRK"); assertThat(result.scope()).isEqualTo("PRJ"); assertThat(result.language()).isNull(); - assertThat(result.getCopyResourceUuid()).isNull(); + assertThat(result.getCopyComponentUuid()).isNull(); assertThat(result.isPrivate()).isTrue(); assertThat(underTest.selectByUuid(dbSession, "UNKNOWN")).isEmpty(); @@ -178,7 +178,7 @@ public class ComponentDaoTest { assertThat(result.qualifier()).isEqualTo("TRK"); assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isNull(); - assertThat(result.getCopyResourceUuid()).isEqualTo(project.uuid()); + assertThat(result.getCopyComponentUuid()).isEqualTo(project.uuid()); assertThat(result.isPrivate()).isFalse(); } @@ -1272,7 +1272,7 @@ public class ComponentDaoTest { Map row1 = selectBColumnsForUuid("U1"); assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */1L, 1); assertThat(row1.get("bKey")).isEqualTo(dto1.getDbKey()); - assertThat(row1.get("bCopyComponentUuid")).isEqualTo(dto1.getCopyResourceUuid()); + assertThat(row1.get("bCopyComponentUuid")).isEqualTo(dto1.getCopyComponentUuid()); assertThat(row1.get("bDescription")).isEqualTo(dto1.description()); assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0); assertThat(row1.get("bUuidPath")).isEqualTo(dto1.getUuidPath()); @@ -1287,7 +1287,7 @@ public class ComponentDaoTest { Map row2 = selectBColumnsForUuid("U2"); assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */1L, 1); assertThat(row2.get("bKey")).isEqualTo(dto2.getDbKey()); - assertThat(row2.get("bCopyComponentUuid")).isEqualTo(dto2.getCopyResourceUuid()); + assertThat(row2.get("bCopyComponentUuid")).isEqualTo(dto2.getCopyComponentUuid()); assertThat(row2.get("bDescription")).isEqualTo(dto2.description()); assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0); assertThat(row2.get("bUuidPath")).isEqualTo(dto2.getUuidPath()); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java index bcb2da60309..64974077864 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java @@ -51,7 +51,7 @@ public class ComponentDtoTest { assertThat(componentDto.language()).isEqualTo("java"); assertThat(componentDto.description()).isEqualTo("desc"); assertThat(componentDto.getRootUuid()).isEqualTo("uuid_3"); - assertThat(componentDto.getCopyResourceUuid()).isEqualTo("uuid_5"); + assertThat(componentDto.getCopyComponentUuid()).isEqualTo("uuid_5"); assertThat(componentDto.isPrivate()).isFalse(); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java index 20b1bc58ba1..2fe046f363c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -198,7 +198,7 @@ public class TreeAction implements ComponentsWsAction { private Map searchReferenceComponentsByUuid(DbSession dbSession, List components) { List referenceComponentIds = components.stream() - .map(ComponentDto::getCopyResourceUuid) + .map(ComponentDto::getCopyComponentUuid) .filter(Objects::nonNull) .collect(toList()); if (referenceComponentIds.isEmpty()) { @@ -244,7 +244,7 @@ public class TreeAction implements ComponentsWsAction { wsComponent = componentDtoToWsComponent(component, parentProject.orElse(null), null); } - ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); + ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyComponentUuid()); if (referenceComponent != null) { wsComponent.setRefId(referenceComponent.uuid()); wsComponent.setRefKey(referenceComponent.getKey()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index cbb16109ba2..284b417b54d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -231,11 +231,11 @@ public class ComponentAction implements MeasuresWsAction { } private Optional getReferenceComponent(DbSession dbSession, ComponentDto component) { - if (component.getCopyResourceUuid() == null) { + if (component.getCopyComponentUuid() == null) { return Optional.empty(); } - return dbClient.componentDao().selectByUuid(dbSession, component.getCopyResourceUuid()); + return dbClient.componentDao().selectByUuid(dbSession, component.getCopyComponentUuid()); } private static ComponentWsResponse buildResponse(ComponentRequest request, ComponentDto component, Optional refComponent, diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java index c2df3e2d68a..69503b542c0 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java @@ -37,7 +37,7 @@ class ComponentDtoToWsComponent { Map referenceComponentsByUuid) { Component.Builder wsComponent = componentDtoToWsComponent(component); - ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); + ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyComponentUuid()); if (referenceComponent != null) { wsComponent.setRefKey(referenceComponent.getDbKey()); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java index cfd5dd1150c..19463501303 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java @@ -371,7 +371,7 @@ public class ComponentTreeAction implements MeasuresWsAction { private static Measures.Component.Builder toWsComponent(ComponentDto component, Map measures, Map referenceComponentsByUuid) { Measures.Component.Builder wsComponent = componentDtoToWsComponent(component); - ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); + ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyComponentUuid()); if (referenceComponent != null) { wsComponent.setRefKey(referenceComponent.getKey()); String displayQualifier = getDisplayQualifier(component, referenceComponent); @@ -463,7 +463,7 @@ public class ComponentTreeAction implements MeasuresWsAction { private Map searchReferenceComponentsById(DbSession dbSession, List components) { List referenceComponentUUids = components.stream() - .map(ComponentDto::getCopyResourceUuid) + .map(ComponentDto::getCopyComponentUuid) .filter(Objects::nonNull) .collect(MoreCollectors.toList(components.size())); if (referenceComponentUUids.isEmpty()) { -- 2.39.5