import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Supplier;
import java.util.stream.Collectors;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Scopes;
import org.sonar.core.component.ComponentKeys;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
public class ComponentUuidFactory {
private final Map<String, String> uuidsByKey = new HashMap<>();
- public ComponentUuidFactory(DbClient dbClient, DbSession dbSession, String rootKey, Supplier<Map<String, String>> reportModulesPath) {
- Map<String, String> modulePathsByUuid = loadModulePathsByUuid(dbClient, dbSession, rootKey, reportModulesPath);
+ public ComponentUuidFactory(DbClient dbClient, DbSession dbSession, String rootKey, Map<String, String> reportModulesPath) {
+ Map<String, String> modulePathsByUuid;
- if (modulePathsByUuid.isEmpty()) {
- // only contains root project or we don't have relative paths for other modules anyway
- List<KeyWithUuidDto> keys = dbClient.componentDao().selectUuidsByKeyFromProjectKey(dbSession, rootKey);
- keys.forEach(dto -> uuidsByKey.put(dto.key(), dto.uuid()));
+ if (reportModulesPath.isEmpty()) {
+ noMigration(dbClient, dbSession, rootKey);
} else {
- List<ComponentWithModuleUuidDto> dtos = loadComponentsWithModuleUuid(dbClient, dbSession, rootKey);
- for (ComponentWithModuleUuidDto dto : dtos) {
- String pathFromRootProject = modulePathsByUuid.get(dto.moduleUuid());
- String componentPath = StringUtils.isEmpty(pathFromRootProject) ? dto.path() : (pathFromRootProject + "/" + dto.path());
+ modulePathsByUuid = loadModulePathsByUuid(dbClient, dbSession, rootKey, reportModulesPath);
+
+ if (modulePathsByUuid.isEmpty()) {
+ noMigration(dbClient, dbSession, rootKey);
+ } else {
+ doMigration(dbClient, dbSession, rootKey, modulePathsByUuid);
+ }
+ }
+ }
+
+ private void noMigration(DbClient dbClient, DbSession dbSession, String rootKey) {
+ List<KeyWithUuidDto> keys = dbClient.componentDao().selectUuidsByKeyFromProjectKey(dbSession, rootKey);
+ keys.forEach(dto -> uuidsByKey.put(dto.key(), dto.uuid()));
+ }
+
+ private void doMigration(DbClient dbClient, DbSession dbSession, String rootKey, Map<String, String> modulePathsByUuid) {
+ List<ComponentWithModuleUuidDto> dtos = loadComponentsWithModuleUuid(dbClient, dbSession, rootKey);
+ for (ComponentWithModuleUuidDto dto : dtos) {
+ if ("/".equals(dto.path())) {
+ // skip root folders
+ continue;
+ }
+
+ if (Scopes.PROJECT.equals(dto.scope())) {
+ String modulePathFromRootProject = modulePathsByUuid.get(dto.uuid());
+ uuidsByKey.put(ComponentKeys.createEffectiveKey(rootKey, modulePathFromRootProject), dto.uuid());
+ } else {
+ String modulePathFromRootProject = modulePathsByUuid.get(dto.moduleUuid());
+ String componentPath = createComponentPath(dto, modulePathFromRootProject);
uuidsByKey.put(ComponentKeys.createEffectiveKey(rootKey, componentPath), dto.uuid());
}
}
}
+ @CheckForNull
+ private static String createComponentPath(ComponentWithModuleUuidDto dto, @Nullable String modulePathFromRootProject) {
+ if (StringUtils.isEmpty(modulePathFromRootProject)) {
+ return dto.path();
+ }
+
+ if (StringUtils.isEmpty(dto.path())) {
+ // will be the case for modules
+ return modulePathFromRootProject;
+ }
+
+ return modulePathFromRootProject + "/" + dto.path();
+ }
+
private static List<ComponentWithModuleUuidDto> loadComponentsWithModuleUuid(DbClient dbClient, DbSession dbSession, String rootKey) {
return dbClient.componentDao().selectComponentsWithModuleUuidFromProjectKey(dbSession, rootKey);
}
- private static Map<String, String> loadModulePathsByUuid(DbClient dbClient, DbSession dbSession, String rootKey, Supplier<Map<String, String>> reportModulesPath) {
+ private static Map<String, String> loadModulePathsByUuid(DbClient dbClient, DbSession dbSession, String rootKey, Map<String, String> pathByModuleKey) {
List<ComponentDto> moduleDtos = dbClient.componentDao()
.selectModulesFromProjectKey(dbSession, rootKey, false).stream()
.filter(c -> Qualifiers.MODULE.equals(c.qualifier()))
return Collections.emptyMap();
}
- Map<String, String> pathByModuleKey = reportModulesPath.get();
Map<String, String> modulePathByUuid = new HashMap<>();
for (ComponentDto dto : moduleDtos) {
String relativePath = pathByModuleKey.get(dto.getKey());
String rootKey = keyGenerator.generateKey(reportProject, null);
// loads the UUIDs from database. If they don't exist, then generate new ones
- ComponentUuidFactory componentUuidFactory = new ComponentUuidFactory(dbClient, dbSession, rootKey, reportModulesPath);
+ ComponentUuidFactory componentUuidFactory = new ComponentUuidFactory(dbClient, dbSession, rootKey, reportModulesPath.get());
String rootUuid = componentUuidFactory.getOrCreateForKey(rootKey);
SnapshotDto baseAnalysis = loadBaseAnalysis(dbSession, rootUuid);
// safeguard, reset all rows to b-changed=false
dbClient.componentDao().resetBChangedForRootComponentUuid(dbSession, projectUuid);
- Map<String, ComponentDto> existingDtosByKeys = indexExistingDtosByKey(dbSession);
- boolean isRootPrivate = isRootPrivate(treeRootHolder.getRoot(), existingDtosByKeys);
+ Map<String, ComponentDto> existingDtosByUuids = indexExistingDtosByUuids(dbSession);
+ boolean isRootPrivate = isRootPrivate(treeRootHolder.getRoot(), existingDtosByUuids);
String mainBranchProjectUuid = loadProjectUuidOfMainBranch();
- // Insert or update the components in database. They are removed from existingDtosByKeys
+ // Insert or update the components in database. They are removed from existingDtosByUuids
// at the same time.
- new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingDtosByKeys, dbSession, mainBranchProjectUuid))
+ new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingDtosByUuids, dbSession, mainBranchProjectUuid))
.visit(treeRootHolder.getRoot());
- disableRemainingComponents(dbSession, existingDtosByKeys.values());
+ disableRemainingComponents(dbSession, existingDtosByUuids.values());
ensureConsistentVisibility(dbSession, projectUuid, isRootPrivate);
dbSession.commit();
dbClient.componentDao().setPrivateForRootComponentUuid(dbSession, projectUuid, isRootPrivate);
}
- private static boolean isRootPrivate(Component root, Map<String, ComponentDto> existingDtosByKeys) {
- String rootKey = root.getDbKey();
- ComponentDto rootDto = existingDtosByKeys.get(rootKey);
+ private static boolean isRootPrivate(Component root, Map<String, ComponentDto> existingDtosByUuids) {
+ ComponentDto rootDto = existingDtosByUuids.get(root.getUuid());
if (rootDto == null) {
if (Component.Type.VIEW == root.getType()) {
return false;
}
- throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", rootKey));
+ throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", root.getDbKey()));
}
return rootDto.isPrivate();
}
* Returns a mutable map of the components currently persisted in database for the project, including
* disabled components.
*/
- private Map<String, ComponentDto> indexExistingDtosByKey(DbSession session) {
+ private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
.stream()
- .collect(Collectors.toMap(ComponentDto::getDbKey, Function.identity()));
+ .collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
}
private class PersistComponentStepsVisitor extends PathAwareVisitorAdapter<ComponentDtoHolder> {
- private final Map<String, ComponentDto> existingComponentDtosByKey;
+ private final Map<String, ComponentDto> existingComponentDtosByUuids;
private final DbSession dbSession;
@Nullable
private final String mainBranchProjectUuid;
- PersistComponentStepsVisitor(Map<String, ComponentDto> existingComponentDtosByKey, DbSession dbSession, @Nullable String mainBranchProjectUuid) {
+ PersistComponentStepsVisitor(Map<String, ComponentDto> existingComponentDtosByUuids, DbSession dbSession, @Nullable String mainBranchProjectUuid) {
super(
CrawlerDepthLimit.LEAVES,
PRE_ORDER,
return null;
}
});
- this.existingComponentDtosByKey = existingComponentDtosByKey;
+ this.existingComponentDtosByUuids = existingComponentDtosByUuids;
this.dbSession = dbSession;
this.mainBranchProjectUuid = mainBranchProjectUuid;
}
}
private ComponentDto persistComponent(ComponentDto componentDto) {
- ComponentDto existingComponent = existingComponentDtosByKey.remove(componentDto.getDbKey());
+ ComponentDto existingComponent = existingComponentDtosByUuids.remove(componentDto.uuid());
if (existingComponent == null) {
dbClient.componentDao().insert(dbSession, componentDto);
return componentDto;
// update the fields in memory in order the PathAwareVisitor.Path
// to be up-to-date
+ existingComponent.setDbKey(updateDto.getBKey());
existingComponent.setCopyComponentUuid(updateDto.getBCopyComponentUuid());
existingComponent.setDescription(updateDto.getBDescription());
existingComponent.setEnabled(updateDto.isBEnabled());
componentDto.setOrganizationUuid(analysisMetadataHolder.getOrganization().getUuid());
componentDto.setUuid(componentUuid);
componentDto.setDbKey(componentKey);
- componentDto.setDeprecatedKey(componentKey);
componentDto.setMainBranchProjectUuid(mainBranchProjectUuid);
componentDto.setEnabled(true);
componentDto.setCreatedAt(new Date(system2.now()));
private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) {
boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) ||
!StringUtils.equals(existing.description(), target.description()) ||
+ !StringUtils.equals(existing.getDbKey(), target.getDbKey()) ||
!existing.isEnabled() ||
!StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) ||
!StringUtils.equals(existing.language(), target.language()) ||
import org.sonar.db.component.ComponentTesting;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class ComponentUuidFactoryTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- private ReportModulesPath reportModulesPath = mock(ReportModulesPath.class);
-
@Test
public void load_uuids_from_existing_components_in_db() {
ComponentDto project = db.components().insertPrivateProject();
- ComponentDto module = db.components().insertComponent(ComponentTesting
- .newModuleDto(project));
- when(reportModulesPath.get()).thenReturn(Collections.singletonMap(module.getKey(), "module1_path"));
+ ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
+ Map<String, String> reportModulesPath = Collections.singletonMap(module.getKey(), "module1_path");
ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), reportModulesPath);
assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
- assertThat(underTest.getOrCreateForKey(module.getDbKey())).isNotEqualTo(module.uuid());
+ assertThat(underTest.getOrCreateForKey(module.getDbKey())).isNotIn(project.uuid(), module.uuid());
}
@Test
Map<String, String> modulesRelativePaths = new HashMap<>();
modulesRelativePaths.put("project:module1", "module1_path");
modulesRelativePaths.put("project:module1:module2", "module1_path/module2_path");
- when(reportModulesPath.get()).thenReturn(modulesRelativePaths);
- ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), reportModulesPath);
+ ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), modulesRelativePaths);
// migrated files
assertThat(underTest.getOrCreateForKey("project:file1_path")).isEqualTo(file1.uuid());
assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
// old keys with modules don't exist
- assertThat(underTest.getOrCreateForKey(module1.getDbKey())).isNotEqualTo(module1.uuid());
- assertThat(underTest.getOrCreateForKey(module2.getDbKey())).isNotEqualTo(module2.uuid());
- assertThat(underTest.getOrCreateForKey(file1.getDbKey())).isNotEqualTo(file1.uuid());
- assertThat(underTest.getOrCreateForKey(file2.getDbKey())).isNotEqualTo(file2.uuid());
+ assertThat(underTest.getOrCreateForKey(module1.getDbKey())).isNotIn(project.uuid(), module1.uuid(), module2.uuid(), file1.uuid(), file2.uuid());
+ assertThat(underTest.getOrCreateForKey(module2.getDbKey())).isNotIn(project.uuid(), module1.uuid(), module2.uuid(), file1.uuid(), file2.uuid());
+ assertThat(underTest.getOrCreateForKey(file1.getDbKey())).isNotIn(project.uuid(), module1.uuid(), module2.uuid(), file1.uuid(), file2.uuid());
+ assertThat(underTest.getOrCreateForKey(file2.getDbKey())).isNotIn(project.uuid(), module1.uuid(), module2.uuid(), file1.uuid(), file2.uuid());
+ }
+
+ @Test
+ public void migrate_project_with_root_folders() {
+ ComponentDto project = db.components().insertPrivateProject(dto -> dto.setDbKey("project"));
+ ComponentDto module1 = db.components().insertComponent(ComponentTesting.newModuleDto(project)
+ .setDbKey("project:module1"));
+ ComponentDto dir1 = db.components().insertComponent(ComponentTesting.newDirectory(module1, "/")
+ .setDbKey("project:module1:/"));
+
+ Map<String, String> modulesRelativePaths = Collections.singletonMap("project:module1", "module1_path");
+ ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), modulesRelativePaths);
+
+ // project remains the same
+ assertThat(underTest.getOrCreateForKey(project.getDbKey())).isEqualTo(project.uuid());
+
+ // module migrated to folder
+ assertThat(underTest.getOrCreateForKey("project:module1_path")).isEqualTo(module1.uuid());
+
+ // doesnt exist
+ assertThat(underTest.getOrCreateForKey("project:module1_path/")).isNotIn(project.uuid(), module1.uuid(), dir1.uuid());
+ assertThat(underTest.getOrCreateForKey("project:module1")).isNotIn(project.uuid(), module1.uuid(), dir1.uuid());
}
@Test
.setDbKey("project:file1")
.setEnabled(false)
.setPath("file1_path"));
- when(reportModulesPath.get()).thenReturn(Collections.singletonMap("project:module1", "module1_path"));
+ Map<String, String> modulesRelativePaths = Collections.singletonMap("project:module1", "module1_path");
- ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), reportModulesPath);
+ ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), project.getDbKey(), modulesRelativePaths);
- // migrated files
+ // migrated file
assertThat(underTest.getOrCreateForKey("project:module1_path/file1_path")).isEqualTo(file1.uuid());
}
@Test
public void generate_uuid_if_it_does_not_exist_in_db() {
- when(reportModulesPath.get()).thenReturn(Collections.emptyMap());
- ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), "theProjectKey", reportModulesPath);
+ ComponentUuidFactory underTest = new ComponentUuidFactory(db.getDbClient(), db.getSession(), "theProjectKey", Collections.emptyMap());
String generatedKey = underTest.getOrCreateForKey("foo");
assertThat(generatedKey).isNotEmpty();
private String scope;
private String qualifier;
private String path;
- private String deprecatedKey;
private String name;
private String longName;
private String language;
return this;
}
- @CheckForNull
- public String deprecatedKey() {
- return deprecatedKey;
- }
-
- public ComponentDto setDeprecatedKey(@Nullable String deprecatedKey) {
- this.deprecatedKey = deprecatedKey;
- return this;
- }
-
/**
* Return the root project uuid. On a root project, return itself
*/
.append("mainBranchProjectUuid", mainBranchProjectUuid)
.append("copyComponentUuid", copyComponentUuid)
.append("path", path)
- .append("deprecatedKey", deprecatedKey)
.append("name", name)
.append("longName", longName)
.append("language", language)
copy.scope = scope;
copy.qualifier = qualifier;
copy.path = path;
- copy.deprecatedKey = deprecatedKey;
copy.name = name;
copy.longName = longName;
copy.language = language;
* See https://jira.sonarsource.com/browse/SONAR-7700
*/
private boolean bChanged;
+ /**
+ * Component keys are normally immutable. But in SQ 7.6 we have to migrate component keys to drop modules.
+ */
+ private String bKey;
private String bCopyComponentUuid;
private String bDescription;
private boolean bEnabled;
return bChanged;
}
+ public String getBKey() {
+ return bKey;
+ }
+
@CheckForNull
public String getBCopyComponentUuid() {
return bCopyComponentUuid;
return this;
}
+ public ComponentUpdateDto setBKey(String s) {
+ this.bKey = s;
+ return this;
+ }
+
public ComponentUpdateDto setBCopyComponentUuid(@Nullable String s) {
this.bCopyComponentUuid = s;
return this;
return new ComponentUpdateDto()
.setUuid(from.uuid())
.setBChanged(false)
+ .setBKey(from.getDbKey())
.setBCopyComponentUuid(from.getCopyResourceUuid())
.setBDescription(from.description())
.setBEnabled(from.isEnabled())
private final String uuid;
private final String moduleUuid;
private final String path;
+ private final String scope;
- public ComponentWithModuleUuidDto(String uuid, String moduleUuid, String path) {
+ public ComponentWithModuleUuidDto(String uuid, String moduleUuid, String path, String scope) {
this.uuid = uuid;
this.moduleUuid = moduleUuid;
this.path = path;
+ this.scope = scope;
}
public String path() {
public String uuid() {
return uuid;
}
+
+ public String scope() {
+ return scope;
+ }
}
p.module_uuid_path as moduleUuidPath,
p.main_branch_project_uuid as mainBranchProjectUuid,
p.kee as kee,
- p.deprecated_kee as deprecatedKey,
p.name as name,
p.long_name as longName,
p.description as description,
<select id="selectComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid">
SELECT
- p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path
+ p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path, p.scope as scope
FROM
projects p
INNER JOIN
INSERT INTO projects (
organization_uuid,
kee,
- deprecated_kee,
uuid,
uuid_path,
project_uuid,
enabled,
created_at,
b_changed,
+ deprecated_kee,
b_copy_component_uuid,
b_description,
b_enabled,
VALUES (
#{organizationUuid,jdbcType=VARCHAR},
#{kee,jdbcType=VARCHAR},
- #{deprecatedKey,jdbcType=VARCHAR},
#{uuid,jdbcType=VARCHAR},
#{uuidPath,jdbcType=VARCHAR},
#{projectUuid,jdbcType=VARCHAR},
${_false},
null,
null,
+ null,
${_false},
null,
null,
<update id="update" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
update projects set
b_changed = #{bChanged,jdbcType=BOOLEAN},
+ <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
+ deprecated_kee = #{bKey,jdbcType=VARCHAR},
b_copy_component_uuid = #{bCopyComponentUuid,jdbcType=VARCHAR},
b_description = #{bDescription,jdbcType=VARCHAR},
b_enabled = #{bEnabled,jdbcType=BOOLEAN},
<update id="updateBEnabledToFalse" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
update projects set
b_changed = ${_true},
+ <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
+ deprecated_kee = kee,
b_copy_component_uuid = copy_component_uuid,
b_description = description,
b_enabled = ${_false},
<update id="applyBChangesForRootComponentUuid" parameterType="string" useGeneratedKeys="false">
update projects set
+ <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
+ kee = deprecated_kee,
copy_component_uuid = b_copy_component_uuid,
description = b_description,
enabled = b_enabled,
path = b_path,
qualifier = b_qualifier,
b_changed = ${_false},
+ <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
+ deprecated_kee = null,
b_copy_component_uuid = null,
b_description = null,
b_enabled = ${_false},
<update id="resetBChangedForRootComponentUuid" parameterType="map" >
update projects
- set b_changed = ${_false}
+ set b_changed = ${_false},
+ <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
+ deprecated_kee = kee
where
project_uuid = #{projectUuid,jdbcType=VARCHAR} and
b_changed = ${_true}
underTest.update(dbSession, new ComponentUpdateDto()
.setUuid("U1")
+ .setBKey("key")
.setBCopyComponentUuid("copy")
.setBChanged(true)
.setBDescription("desc")
Map<String, Object> row = selectBColumnsForUuid("U1");
assertThat(row.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
+ assertThat(row.get("bKey")).isEqualTo("key");
assertThat(row.get("bCopyComponentUuid")).isEqualTo("copy");
assertThat(row.get("bDescription")).isEqualTo("desc");
assertThat(row.get("bEnabled")).isIn(true, /* for Oracle */1L, 1);
Map<String, Object> 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("bDescription")).isEqualTo(dto1.description());
assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
Map<String, Object> 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("bDescription")).isEqualTo(dto2.description());
assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
private Map<String, Object> selectBColumnsForUuid(String uuid) {
return db.selectFirst(
- "select b_changed as \"bChanged\", b_copy_component_uuid as \"bCopyComponentUuid\", b_description as \"bDescription\", " +
+ "select b_changed as \"bChanged\", deprecated_kee as \"bKey\", b_copy_component_uuid as \"bCopyComponentUuid\", b_description as \"bDescription\", " +
"b_enabled as \"bEnabled\", b_uuid_path as \"bUuidPath\", b_language as \"bLanguage\", b_long_name as \"bLongName\"," +
"b_module_uuid as \"bModuleUuid\", b_module_uuid_path as \"bModuleUuidPath\", b_name as \"bName\", " +
"b_path as \"bPath\", b_qualifier as \"bQualifier\" " +
ComponentDto componentDto = new ComponentDto()
.setId(1L)
.setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
- .setDeprecatedKey("org.struts:struts-core:src/org/struts/RequestContext.java")
.setName("RequestContext.java")
.setLongName("org.struts.RequestContext")
.setQualifier("FIL")
assertThat(componentDto.getId()).isEqualTo(1L);
assertThat(componentDto.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
- assertThat(componentDto.deprecatedKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(componentDto.getBranch()).isNull();
assertThat(componentDto.name()).isEqualTo("RequestContext.java");
assertThat(componentDto.longName()).isEqualTo("org.struts.RequestContext");
.setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + uuid + ComponentDto.UUID_PATH_SEPARATOR)
.setProjectUuid(uuid)
.setDbKey(keyWithBranch)
- .setDeprecatedKey(keyWithBranch)
.setName(newComponent.name())
.setLongName(newComponent.name())
.setScope(Scopes.PROJECT)
ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
assertThat(loaded.getDbKey()).isEqualTo(DEFAULT_PROJECT_KEY);
- assertThat(loaded.deprecatedKey()).isEqualTo(DEFAULT_PROJECT_KEY);
assertThat(loaded.name()).isEqualTo(DEFAULT_PROJECT_NAME);
assertThat(loaded.longName()).isEqualTo(DEFAULT_PROJECT_NAME);
assertThat(loaded.qualifier()).isEqualTo(Qualifiers.PROJECT);