assertThat(task.getComponentKey()).isNull();
assertThat(task.getComponentName()).isNull();
} else {
- assertThat(task.getComponentKey()).isEqualTo(componentDto.key());
+ assertThat(task.getComponentKey()).isEqualTo(componentDto.getDbKey());
assertThat(task.getComponentName()).isEqualTo(componentDto.name());
}
assertThat(task.getSubmitterLogin()).isEqualTo(taskSubmit.getSubmitterLogin());
}
private ComponentDto newComponentDto(String uuid) {
- return ComponentTesting.newPublicProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setKey("key_" + uuid);
+ return ComponentTesting.newPublicProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setDbKey("key_" + uuid);
}
private CeTask submit(String reportType, String componentUuid) {
return UUID_PATH_SPLITTER.splitToList(uuidPath);
}
- public String key() {
+ /**
+ * Used my MyBatis mapper
+ */
+ private String getKee(){
+ return kee;
+ }
+
+ /**
+ * Used my MyBatis mapper
+ */
+ private void setKee(String kee){
+ this.kee = kee;
+ }
+
+ public String getDbKey() {
return kee;
}
+ public ComponentDto setDbKey(String key) {
+ this.kee = checkComponentKey(key);
+ return this;
+ }
+
+ public String getKey() {
+ return getDbKey();
+ }
+
public String scope() {
return scope;
}
return this;
}
- public String getKey() {
- return key();
- }
-
- public ComponentDto setKey(String key) {
- this.kee = checkComponentKey(key);
- return this;
- }
-
public boolean isRootProject() {
return moduleUuid == null && Scopes.PROJECT.equals(scope);
}
}
public IssueDto setComponent(ComponentDto component) {
- this.componentKey = component.getKey();
+ this.componentKey = component.getDbKey();
this.componentUuid = component.uuid();
this.moduleUuid = component.moduleUuid();
this.moduleUuidPath = component.moduleUuidPath();
}
public IssueDto setProject(ComponentDto project) {
- this.projectKey = project.getKey();
+ this.projectKey = project.getDbKey();
this.projectUuid = project.uuid();
return this;
}
assertThat(result.moduleUuidPath()).isEqualTo("module_uuid_path_of_U1");
assertThat(result.getRootUuid()).isEqualTo("U1");
assertThat(result.projectUuid()).isEqualTo("U1");
- assertThat(result.key()).isEqualTo("org.struts:struts");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts");
assertThat(result.path()).isEqualTo("path_of_U1");
assertThat(result.name()).isEqualTo("Struts");
assertThat(result.longName()).isEqualTo("Apache Struts");
assertThat(result.moduleUuidPath()).isEqualTo("module_uuid_path_of_U7");
assertThat(result.getRootUuid()).isEqualTo("root_uuid_of_U7");
assertThat(result.projectUuid()).isEqualTo("project_uuid_of_U7");
- assertThat(result.key()).isEqualTo("DEV:anakin@skywalker.name:org.struts:struts");
+ assertThat(result.getDbKey()).isEqualTo("DEV:anakin@skywalker.name:org.struts:struts");
assertThat(result.path()).isNull();
assertThat(result.name()).isEqualTo("Apache Struts");
assertThat(result.longName()).isEqualTo("Apache Struts");
ComponentDto result = optional.get();
assertThat(result.getOrganizationUuid()).isEqualTo("org1");
assertThat(result.uuid()).isEqualTo("U4");
- assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("path_of_U4");
assertThat(result.name()).isEqualTo("RequestContext.java");
assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
db.prepareDbUnit(getClass(), "shared.xml");
ComponentDto result = underTest.selectOrFailByKey(dbSession, "org.struts:struts");
- assertThat(result.key()).isEqualTo("org.struts:struts");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts");
assertThat(result.uuid()).isEqualTo("U1");
assertThat(result.getUuidPath()).isEqualTo("uuid_path_of_U1");
assertThat(result.deprecatedKey()).isEqualTo("org.struts:struts");
ComponentDto result = results.get(0);
assertThat(result).isNotNull();
- assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("path_of_U4");
assertThat(result.name()).isEqualTo("RequestContext.java");
assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
ComponentDto result = results.get(0);
assertThat(result).isNotNull();
- assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("path_of_U4");
assertThat(result.name()).isEqualTo("RequestContext.java");
assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
assertThat(result.moduleUuidPath()).isEqualTo("module_uuid_path_of_U4");
assertThat(result.getRootUuid()).isEqualTo("U1");
assertThat(result.projectUuid()).isEqualTo("U1");
- assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("path_of_U4");
assertThat(result.name()).isEqualTo("RequestContext.java");
assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
// Sub project of a file
List<ComponentDto> results = underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("HIJK"));
assertThat(results).hasSize(1);
- assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
+ assertThat(results.get(0).getDbKey()).isEqualTo("org.struts:struts-data");
// Sub project of a directory
results = underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("GHIJ"));
assertThat(results).hasSize(1);
- assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
+ assertThat(results.get(0).getDbKey()).isEqualTo("org.struts:struts-data");
// Sub project of a sub module
results = underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("FGHI"));
assertThat(results).hasSize(1);
- assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
+ assertThat(results.get(0).getDbKey()).isEqualTo("org.struts:struts");
// Sub project of a module
results = underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("EFGH"));
assertThat(results).hasSize(1);
- assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
+ assertThat(results.get(0).getDbKey()).isEqualTo("org.struts:struts");
// Sub project of a project
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("ABCD"))).extracting("uuid").containsOnly("ABCD");
@Test
public void select_provisioned() {
OrganizationDto organization = db.organizations().insert();
- ComponentDto provisionedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project"));
+ ComponentDto provisionedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization).setDbKey("provisioned.project").setName("Provisioned Project"));
ComponentDto provisionedView = db.components().insertView(organization);
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid();
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid();
.containsOnly(provisionedProject.uuid(), provisionedView.uuid());
// match key
- assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), provisionedProject.getKey(), projectQualifiers, new RowBounds(0, 10)))
+ assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), provisionedProject.getDbKey(), projectQualifiers, new RowBounds(0, 10)))
.extracting(ComponentDto::uuid)
.containsExactly(provisionedProject.uuid());
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), "pROvisiONed.proJEcT", projectQualifiers, new RowBounds(0, 10)))
.setProjectUuid("ABCD")
.setModuleUuid("EFGH")
.setModuleUuidPath(".ABCD.EFGH.")
- .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+ .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")
.setProjectUuid("ABCD")
.setModuleUuid("EFGH")
.setModuleUuidPath(".ABCD.EFGH.")
- .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+ .setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
.setName("RequestContext.java")
.setLongName("org.struts.RequestContext")
.setQualifier("FIL")
underTest.updateTags(dbSession, project.setTags(newArrayList("finance", "toto", "tutu")));
dbSession.commit();
- assertThat(underTest.selectOrFailByKey(dbSession, project.key()).getTags()).containsOnly("finance", "toto", "tutu");
+ assertThat(underTest.selectOrFailByKey(dbSession, project.getDbKey()).getTags()).containsOnly("finance", "toto", "tutu");
}
@Test
public void delete() throws Exception {
- ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_1"));
- db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_2"));
+ ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setDbKey("PROJECT_1"));
+ db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setDbKey("PROJECT_2"));
underTest.delete(dbSession, project1.getId());
dbSession.commit();
@Test
public void selectByQuery_key_with_special_characters() {
- db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("project-_%-key"));
+ db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("project-_%-key"));
ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("project-_%-key").setQualifiers(Qualifiers.PROJECT).build();
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
assertThat(result).hasSize(1);
- assertThat(result.get(0).key()).isEqualTo("project-_%-key");
+ assertThat(result.get(0).getDbKey()).isEqualTo("project-_%-key");
}
@Test
public void selectByQuery_filter_on_language() {
- db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("java-project-key").setLanguage("java"));
- db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("cpp-project-key").setLanguage("cpp"));
+ db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("java-project-key").setLanguage("java"));
+ db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("cpp-project-key").setLanguage("cpp"));
ComponentQuery query = ComponentQuery.builder().setLanguage("java").setQualifiers(Qualifiers.PROJECT).build();
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
assertThat(result).hasSize(1);
- assertThat(result.get(0).key()).isEqualTo("java-project-key");
+ assertThat(result.get(0).getDbKey()).isEqualTo("java-project-key");
}
@Test
public void selectByQuery_filter_on_visibility() {
- db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("private-key"));
- db.components().insertComponent(ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setKey("public-key"));
+ db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("private-key"));
+ db.components().insertComponent(ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setDbKey("public-key"));
ComponentQuery privateProjectsQuery = ComponentQuery.builder().setPrivate(true).setQualifiers(Qualifiers.PROJECT).build();
ComponentQuery publicProjectsQuery = ComponentQuery.builder().setPrivate(false).setQualifiers(Qualifiers.PROJECT).build();
ComponentQuery allProjectsQuery = ComponentQuery.builder().setPrivate(null).setQualifiers(Qualifiers.PROJECT).build();
- assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("private-key");
- assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("public-key");
- assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsOnly("public-key", "private-key");
+ assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("private-key");
+ assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("public-key");
+ assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsOnly("public-key", "private-key");
}
@Test
db.components().insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
db.components().insertComponent(module);
- ComponentDto file1 = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
+ ComponentDto file1 = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One");
db.components().insertComponent(file1);
- ComponentDto file2 = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
+ ComponentDto file2 = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two");
db.components().insertComponent(file2);
- ComponentDto file3 = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
+ ComponentDto file3 = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three");
db.components().insertComponent(file3);
db.commit();
@Test
public void select_components_having_same_key() {
OrganizationDto organizationDto = db.organizations().insert();
- insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
- insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
- insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(PROJECT_KEY));
- insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("ANOTHER_PROJECT_KEY"));
+ insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY));
+ insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY));
+ insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(PROJECT_KEY));
+ insertProject(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("ANOTHER_PROJECT_KEY"));
assertThat(underTest.selectComponentsHavingSameKeyOrderedById(db.getSession(), PROJECT_KEY)).hasSize(3);
}
public void setters_and_getters() {
ComponentDto componentDto = new ComponentDto()
.setId(1L)
- .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+ .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")
.setDeveloperUuid("uuid_6");
assertThat(componentDto.getId()).isEqualTo(1L);
- assertThat(componentDto.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ 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.name()).isEqualTo("RequestContext.java");
assertThat(componentDto.longName()).isEqualTo("org.struts.RequestContext");
@Test
public void updateKey_does_not_updated_inactive_components() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setKey("my_project"));
- ComponentDto directory = db.components().insertComponent(newDirectory(project, "/directory").setKey("my_project:directory"));
- db.components().insertComponent(newFileDto(project, directory).setKey("my_project:directory/file"));
- ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setKey("my_project:inactive_directory").setEnabled(false));
- db.components().insertComponent(newFileDto(project, inactiveDirectory).setKey("my_project:inactive_directory/file").setEnabled(false));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setDbKey("my_project"));
+ ComponentDto directory = db.components().insertComponent(newDirectory(project, "/directory").setDbKey("my_project:directory"));
+ db.components().insertComponent(newFileDto(project, directory).setDbKey("my_project:directory/file"));
+ ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setDbKey("my_project:inactive_directory").setEnabled(false));
+ db.components().insertComponent(newFileDto(project, inactiveDirectory).setDbKey("my_project:inactive_directory/file").setEnabled(false));
underTest.updateKey(dbSession, "A", "your_project");
dbSession.commit();
List<ComponentDto> result = dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, "your_project");
- assertThat(result).hasSize(5).extracting(ComponentDto::getKey)
+ assertThat(result).hasSize(5).extracting(ComponentDto::getDbKey)
.containsOnlyOnce("your_project", "your_project:directory", "your_project:directory/file", "my_project:inactive_directory", "my_project:inactive_directory/file");
}
@Test
public void bulk_update_key_does_not_update_inactive_components() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setKey("my_project"));
- db.components().insertComponent(newModuleDto(project).setKey("my_project:module"));
- db.components().insertComponent(newModuleDto(project).setKey("my_project:inactive_module").setEnabled(false));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setDbKey("my_project"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("my_project:module"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("my_project:inactive_module").setEnabled(false));
underTest.bulkUpdateKey(dbSession, "A", "my_", "your_");
List<ComponentDto> result = dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, "your_project");
- assertThat(result).hasSize(3).extracting(ComponentDto::getKey)
+ assertThat(result).hasSize(3).extracting(ComponentDto::getDbKey)
.containsOnlyOnce("your_project", "your_project:module", "my_project:inactive_module");
}
@Test
public void updateKey_throws_IAE_when_sub_component_key_is_too_long() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setKey("old-project-key");
+ ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setDbKey("old-project-key");
db.components().insertComponent(project);
- db.components().insertComponent(newFileDto(project, null).setKey("old-project-key:file"));
+ db.components().insertComponent(newFileDto(project, null).setDbKey("old-project-key:file"));
String newLongProjectKey = Strings.repeat("a", 400);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component key length (405) is longer than the maximum authorized (400). '" + newLongProjectKey + ":file' was provided.");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Malformed key for 'my?project?key'. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.");
- underTest.bulkUpdateKey(dbSession, project.uuid(), project.key(), "my?project?key");
+ underTest.bulkUpdateKey(dbSession, project.uuid(), project.getDbKey(), "my?project?key");
}
@Test
@Test
public void check_component_keys_checks_inactive_components() {
OrganizationDto organizationDto = db.organizations().insert();
- db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("my-project"));
- db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("your-project").setEnabled(false));
+ db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("my-project"));
+ db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("your-project").setEnabled(false));
Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("my-project", "your-project", "new-project"));
@Test
public void simulate_bulk_update_key_do_not_return_disable_components() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setKey("project"));
- db.components().insertComponent(newModuleDto(project).setKey("project:enabled-module"));
- db.components().insertComponent(newModuleDto(project).setKey("project:disabled-module").setEnabled(false));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setDbKey("project"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("project:enabled-module"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("project:disabled-module").setEnabled(false));
Map<String, String> result = underTest.simulateBulkUpdateKey(dbSession, "A", "project", "new-project");
@Test
public void simulate_bulk_update_key_fails_if_invalid_componentKey() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setKey("project"));
- db.components().insertComponent(newModuleDto(project).setKey("project:enabled-module"));
- db.components().insertComponent(newModuleDto(project).setKey("project:disabled-module").setEnabled(false));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "A").setDbKey("project"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("project:enabled-module"));
+ db.components().insertComponent(newModuleDto(project).setDbKey("project:disabled-module").setEnabled(false));
thrown.expect(IllegalArgumentException.class);
String filename = "NAME_" + fileUuid;
String path = directory != null ? directory.path() + "/" + filename : module.path() + "/" + filename;
return newChildComponent(fileUuid, module, directory == null ? module : directory)
- .setKey("KEY_" + fileUuid)
+ .setDbKey("KEY_" + fileUuid)
.setName(filename)
.setLongName(path)
.setScope(Scopes.FILE)
public static ComponentDto newDirectory(ComponentDto module, String uuid, String path) {
return newChildComponent(uuid, module, module)
- .setKey(!path.equals("/") ? module.getKey() + ":" + path : module.getKey() + ":/")
+ .setDbKey(!path.equals("/") ? module.getDbKey() + ":" + path : module.getDbKey() + ":/")
.setName(path)
.setLongName(path)
.setPath(path)
public static ComponentDto newSubView(ComponentDto viewOrSubView, String uuid, String key) {
return newChildComponent(uuid, viewOrSubView, viewOrSubView)
- .setKey(key)
+ .setDbKey(key)
.setName(key)
.setLongName(key)
.setScope(Scopes.PROJECT)
public static ComponentDto newModuleDto(String uuid, ComponentDto parentModuleOrProject) {
return newChildComponent(uuid, parentModuleOrProject, parentModuleOrProject)
.setModuleUuidPath(parentModuleOrProject.moduleUuidPath() + uuid + UUID_PATH_SEPARATOR)
- .setKey("KEY_" + uuid)
+ .setDbKey("KEY_" + uuid)
.setName("NAME_" + uuid)
.setLongName("LONG_NAME_" + uuid)
.setPath("module")
.setProjectUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
.setRootUuid(uuid)
- .setKey("KEY_" + uuid)
+ .setDbKey("KEY_" + uuid)
.setName("NAME_" + uuid)
.setLongName("LONG_NAME_" + uuid)
.setDescription("DESCRIPTION_" + uuid)
checkNotNull(project.getId(), "The project need to be persisted before creating this technical project.");
return newChildComponent(uuid, view, view)
.setUuid(uuid)
- .setKey(view.key() + project.key())
+ .setDbKey(view.getDbKey() + project.getDbKey())
.setName(project.name())
.setLongName(project.longName())
.setCopyComponentUuid(project.uuid())
private static IssueDto newIssueDto(String key) {
IssueDto dto = new IssueDto();
- dto.setComponent(new ComponentDto().setKey("struts:Action").setId(123L).setUuid("component-uuid"));
- dto.setProject(new ComponentDto().setKey("struts").setId(100L).setUuid("project-uuid"));
+ dto.setComponent(new ComponentDto().setDbKey("struts:Action").setId(123L).setUuid("component-uuid"));
+ dto.setProject(new ComponentDto().setDbKey("struts").setId(100L).setUuid("project-uuid"));
dto.setRule(RuleTesting.newRule(RuleKey.of("squid", "S001")).setId(200));
dto.setKee(key);
dto.setType(2);
private void prepareTables() {
db.rules().insertRule(RULE);
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto projectDto = db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
- db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
+ ComponentDto projectDto = db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
+ db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setDbKey(FILE_KEY));
underTest.insert(db.getSession(), newIssueDto(ISSUE_KEY1)
.setMessage("the message")
.setRuleId(RULE.getId())
.setProjectUuid("don't care")
.setRootUuid("don't care")
.setUuidPath("don't care")
- .setKey("kee_" + uuid)
+ .setDbKey("kee_" + uuid)
.setEnabled(enabled);
db.getDbClient().componentDao().insert(db.getSession(), componentDto);
return uuid;
public void return_project_measure() {
MetricDto metric1 = insertIntMetric("ncloc");
MetricDto metric2 = insertIntMetric("coverage");
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java");
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setDbKey("Project-Key").setName("Project Name").setTagsString("platform,java");
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project);
insertMeasure(project, analysis, metric1, 10d);
insertMeasure(project, analysis, metric2, 20d);
ProjectMeasures doc = docsById.get(project.uuid());
assertThat(doc).isNotNull();
assertThat(doc.getProject().getUuid()).isEqualTo(project.uuid());
- assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project.getKey());
+ assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project.getDbKey());
assertThat(doc.getProject().getName()).isNotNull().isEqualTo(project.name());
assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis.getCreatedAt());
}
int userId2 = insertUser("user2");
ComponentDto projectDto = insertProject("PROJECT_A");
long projectId = projectDto.getId();
- String projectKey = projectDto.key();
+ String projectKey = projectDto.getDbKey();
// global subscription
insertProperty("notification.DispatcherWithGlobalSubscribers.Email", "true", null, userId2);
insertProperty("project.one", "Pone", projectId, null);
insertProperty("project.two", "Ptwo", projectId, null);
- List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.key());
+ List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
assertThat(dtos)
.hasSize(2);
assertThatDto(findByKey(dtos, "project.one"))
ComponentDto projectDto = insertProject("A");
insertProperty("project.one", dbValue, projectDto.getId(), null);
- List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.key());
+ List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
assertThat(dtos).hasSize(1);
assertThatDto(dtos.iterator().next())
.hasKey("project.one")
private ComponentDto insertProject(String uuid) {
String key = "project" + uuid;
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setKey(key);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setDbKey(key);
dbClient.componentDao().insert(session, project);
dbTester.commit();
return project;
assertThat(underTest.selectSelectedProjects(dbSession, organization, profile1, null))
.extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey")
.containsOnly(
- tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKee()),
- tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), profile1.getKee()));
+ tuple(project1.getId(), project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
+ tuple(project2.getId(), project2.uuid(), project2.getDbKey(), project2.name(), profile1.getKee()));
assertThat(underTest.selectSelectedProjects(dbSession, organization, profile1, "ect1")).hasSize(1);
assertThat(underTest.selectSelectedProjects(dbSession, organization, profile3, null)).isEmpty();
assertThat(underTest.selectDeselectedProjects(dbSession, organization, profile1, null))
.extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey")
.containsExactly(
- tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null),
- tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null));
+ tuple(project2.getId(), project2.uuid(), project2.getDbKey(), project2.name(), null),
+ tuple(project3.getId(), project3.uuid(), project3.getDbKey(), project3.name(), null));
assertThat(underTest.selectDeselectedProjects(dbSession, organization, profile1, "ect2")).hasSize(1);
assertThat(underTest.selectDeselectedProjects(dbSession, organization, profile3, null)).hasSize(3);
assertThat(underTest.selectProjectAssociations(dbSession, organization, profile1, null))
.extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey")
.containsOnly(
- tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKee()),
- tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null),
- tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null));
+ tuple(project1.getId(), project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
+ tuple(project2.getId(), project2.uuid(), project2.getDbKey(), project2.name(), null),
+ tuple(project3.getId(), project3.uuid(), project3.getDbKey(), project3.name(), null));
assertThat(underTest.selectProjectAssociations(dbSession, organization, profile1, "ect2")).hasSize(1);
assertThat(underTest.selectProjectAssociations(dbSession, organization, profile3, null)).hasSize(3);
ComponentDto component = componentDtoByUuid.get(componentUuid);
if (component != null) {
builder.setOrganizationUuid(component.getOrganizationUuid());
- builder.setComponentKey(component.getKey());
+ builder.setComponentKey(component.getDbKey());
builder.setComponentName(component.name());
}
}
if (Scopes.PROJECT.equals(component.scope())) {
List<ComponentDto> modulesTree = dbClient.componentDao().selectDescendantModules(session, component.uuid());
for (ComponentDto componentDto : modulesTree) {
- keysByUUid.put(componentDto.uuid(), componentDto.key());
+ keysByUUid.put(componentDto.uuid(), componentDto.getDbKey());
}
} else {
String moduleUuid = component.moduleUuid();
throw new IllegalArgumentException(String.format("The component '%s' has no module uuid", component.uuid()));
}
ComponentDto module = dbClient.componentDao().selectOrFailByUuid(session, moduleUuid);
- keysByUUid.put(module.uuid(), module.key());
+ keysByUUid.put(module.uuid(), module.getDbKey());
}
return keysByUUid;
}
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.FilePathWithHashDto;
+import org.sonar.db.permission.OrganizationPermission;
import org.sonar.db.property.PropertyDto;
import org.sonar.scanner.protocol.input.FileData;
import org.sonar.scanner.protocol.input.ProjectRepositories;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.db.permission.OrganizationPermission;
import org.sonar.server.user.UserSession;
import static com.google.common.collect.Lists.newArrayList;
checkPermission(query.isIssuesMode(), hasScanPerm, hasBrowsePerm);
ComponentDto project = getProject(module, session);
- if (!project.key().equals(module.key())) {
- addSettings(data, module.getKey(), getSettingsFromParents(module, hasScanPerm, session));
+ if (!project.getDbKey().equals(module.getDbKey())) {
+ addSettings(data, module.getDbKey(), getSettingsFromParents(module, hasScanPerm, session));
}
List<ComponentDto> modulesTree = dbClient.componentDao().selectEnabledDescendantModules(session, module.uuid());
Map<String, String> parentProperties = newHashMap();
for (ComponentDto parent : parents) {
- parentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(session, parent.key()), hasScanPerm));
+ parentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(session, parent.getDbKey()), hasScanPerm));
}
return parentProperties;
}
addSettings(ref, moduleKey, currentParentProperties);
for (ComponentDto childModule : treeModuleSettings.findChildrenModule(moduleKey)) {
- addSettings(ref, childModule.getKey(), currentParentProperties);
- addSettingsToChildrenModules(ref, childModule.getKey(), currentParentProperties, treeModuleSettings, hasScanPerm);
+ addSettings(ref, childModule.getDbKey(), currentParentProperties);
+ addSettingsToChildrenModules(ref, childModule.getDbKey(), currentParentProperties, treeModuleSettings, hasScanPerm);
}
}
private static void addFileData(ProjectRepositories data, List<ComponentDto> moduleChildren, List<FilePathWithHashDto> files) {
Map<String, String> moduleKeysByUuid = newHashMap();
for (ComponentDto module : moduleChildren) {
- moduleKeysByUuid.put(module.uuid(), module.key());
+ moduleKeysByUuid.put(module.uuid(), module.getDbKey());
}
for (FilePathWithHashDto file : files) {
private static Map<String, String> moduleUuidsByKey(List<ComponentDto> moduleChildren) {
Map<String, String> moduleUuidsByKey = newHashMap();
for (ComponentDto componentDto : moduleChildren) {
- moduleUuidsByKey.put(componentDto.key(), componentDto.uuid());
+ moduleUuidsByKey.put(componentDto.getDbKey(), componentDto.uuid());
}
return moduleUuidsByKey;
}
private static Map<String, Long> moduleIdsByKey(List<ComponentDto> moduleChildren) {
Map<String, Long> moduleIdsByKey = newHashMap();
for (ComponentDto componentDto : moduleChildren) {
- moduleIdsByKey.put(componentDto.key(), componentDto.getId());
+ moduleIdsByKey.put(componentDto.getDbKey(), componentDto.getId());
}
return moduleIdsByKey;
}
private static void buildComponent(WsCe.Task.Builder builder, @Nullable ComponentDto componentDto) {
if (componentDto != null) {
- builder.setComponentKey(componentDto.getKey());
+ builder.setComponentKey(componentDto.getDbKey());
builder.setComponentName(componentDto.name());
builder.setComponentQualifier(componentDto.qualifier());
}
checkRequest(component.scope().equals(Scopes.PROJECT) && rootQualifiers.contains(component.qualifier()),
format(
"Component '%s' (id: %s) must be a project%s.",
- component.key(), component.uuid(),
+ component.getDbKey(), component.uuid(),
rootQualifiers.contains(Qualifiers.VIEW) ? " or a view" : ""));
return component;
public ComponentDto create(DbSession dbSession, NewComponent newComponent, @Nullable Integer userId) {
checkKeyFormat(newComponent.qualifier(), newComponent.key());
ComponentDto componentDto = createRootComponent(dbSession, newComponent);
- removeDuplicatedProjects(dbSession, componentDto.getKey());
+ removeDuplicatedProjects(dbSession, componentDto.getDbKey());
handlePermissionTemplate(dbSession, componentDto, newComponent.getOrganizationUuid(), userId);
projectIndexers.commitAndIndex(dbSession, singletonList(componentDto), Cause.PROJECT_CREATION);
return componentDto;
.setModuleUuid(null)
.setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + uuid + ComponentDto.UUID_PATH_SEPARATOR)
.setProjectUuid(uuid)
- .setKey(keyWithBranch)
+ .setDbKey(keyWithBranch)
.setDeprecatedKey(keyWithBranch)
.setName(newComponent.name())
.setLongName(newComponent.name())
return new ComponentDoc()
.setId(component.uuid())
.setName(component.name())
- .setKey(component.key())
+ .setKey(component.getDbKey())
.setProjectUuid(component.projectUuid())
.setQualifier(component.qualifier());
}
session);
boolean isFavourite = propertyDtos.size() == 1;
- json.prop("key", component.key());
+ json.prop("key", component.getDbKey());
json.prop("uuid", component.uuid());
json.prop("path", component.path());
json.prop("name", component.name());
// Do not display parent project if parent project and project are the same
boolean displayParentProject = parentProject != null && !parentProject.uuid().equals(project.uuid());
- json.prop("subProject", displayParentProject ? parentProject.key() : null);
+ json.prop("subProject", displayParentProject ? parentProject.getDbKey() : null);
json.prop("subProjectName", displayParentProject ? parentProject.longName() : null);
- json.prop("project", project.key());
+ json.prop("project", project.getDbKey());
json.prop("projectName", project.longName());
json.prop("fav", isFavourite);
WsComponents.Component.Builder wsComponent = WsComponents.Component.newBuilder()
.setOrganization(organizationDtoKey)
.setId(dto.uuid())
- .setKey(dto.key())
+ .setKey(dto.getDbKey())
.setName(dto.name())
.setQualifier(dto.qualifier());
setNullable(emptyToNull(dto.path()), wsComponent::setPath);
.map(ComponentDto::projectUuid)
.collect(toHashSet());
List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuidsToSearch);
- return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::key));
+ return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getDbKey));
}
private static ComponentQuery buildQuery(SearchWsRequest request) {
WsComponents.Component.Builder builder = WsComponents.Component.newBuilder()
.setOrganization(organization.getKey())
.setId(dto.uuid())
- .setKey(dto.key())
+ .setKey(dto.getDbKey())
.setProject(projectKey)
.setName(dto.name())
.setQualifier(dto.qualifier());
.clear()
.setOrganization(organizationDto.getKey())
.setId(dbComponent.uuid())
- .setKey(dbComponent.key())
+ .setKey(dbComponent.getDbKey())
.setName(dbComponent.name())
.setVisibility(Visibility.getLabel(dbComponent.isPrivate()));
wsComponent.getTagsBuilder().addAllTags(dbComponent.getTags());
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceType;
import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.resources.Qualifiers;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
}
List<ComponentDto> favorites = favoriteFinder.list();
- Set<String> favoriteKeys = favorites.stream().map(ComponentDto::getKey).collect(MoreCollectors.toSet(favorites.size()));
+ Set<String> favoriteKeys = favorites.stream().map(ComponentDto::getDbKey).collect(MoreCollectors.toSet(favorites.size()));
ComponentIndexQuery.Builder queryBuilder = ComponentIndexQuery.builder()
.setQuery(query)
.setRecentlyBrowsedKeys(recentlyBrowsedKeys)
checkState(organizationKey != null, "Organization with uuid '%s' not found", result.getOrganizationUuid());
Suggestion.Builder builder = Suggestion.newBuilder()
.setOrganization(organizationKey)
- .setKey(result.getKey())
+ .setKey(result.getDbKey())
.setName(result.name())
.setMatch(hit.getHighlightedText().orElse(HtmlEscapers.htmlEscaper().escape(result.name())))
- .setIsRecentlyBrowsed(recentlyBrowsedKeys.contains(result.getKey()))
+ .setIsRecentlyBrowsed(recentlyBrowsedKeys.contains(result.getDbKey()))
.setIsFavorite(favoriteUuids.contains(result.uuid()));
if (QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT.contains(result.qualifier())) {
- builder.setProject(projectsByUuids.get(result.projectUuid()).getKey());
+ builder.setProject(projectsByUuids.get(result.projectUuid()).getDbKey());
}
return builder.build();
}
private static List<Project> toProjects(Map<String, ComponentDto> projectsByUuids) {
return projectsByUuids.values().stream()
.map(p -> Project.newBuilder()
- .setKey(p.key())
+ .setKey(p.getDbKey())
.setName(p.longName())
.build())
.collect(Collectors.toList());
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_COMPONENT;
import static org.sonar.server.component.ws.ComponentDtoToWsComponent.componentDtoToWsComponent;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
-import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
+import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsUtils.checkRequest;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE;
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
if (referenceComponent != null) {
wsComponent.setRefId(referenceComponent.uuid());
- wsComponent.setRefKey(referenceComponent.key());
+ wsComponent.setRefKey(referenceComponent.getDbKey());
}
return wsComponent;
import org.sonar.db.ce.CeTaskTypes;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.organization.OrganizationDto;
+import org.sonar.db.permission.OrganizationPermission;
import org.sonar.server.component.ComponentUpdater;
import org.sonar.server.component.NewComponent;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.db.permission.OrganizationPermission;
import org.sonar.server.permission.PermissionTemplateService;
import org.sonar.server.user.UserSession;
if (project.isPresent()) {
checkArgument(project.get().getOrganizationUuid().equals(organizationDto.getUuid()),
"Organization of component with key '%s' does not match specified organization '%s'",
- project.get().key(), organizationDto.getKey());
+ project.get().getDbKey(), organizationDto.getKey());
}
}
try (DbSession dbSession = dbClient.openSession(false)) {
List<ComponentDto> components = dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, rootKey);
for (ComponentDto componentDto : components) {
- uuidsByKey.put(componentDto.getKey(), componentDto.uuid());
+ uuidsByKey.put(componentDto.getDbKey(), componentDto.uuid());
}
}
}
.setStrategy(Strategy.LEAVES)
.build());
return from(componentDtos)
- .transform(componentDto -> new DbComponent(componentDto.getId(), componentDto.key(), componentDto.uuid(), componentDto.path()))
+ .transform(componentDto -> new DbComponent(componentDto.getId(), componentDto.getDbKey(), componentDto.uuid(), componentDto.path()))
.uniqueIndex(DbComponent::getKey);
}
}
private Map<String, ComponentDto> indexExistingDtosByKey(DbSession session) {
return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getKey())
.stream()
- .collect(java.util.stream.Collectors.toMap(ComponentDto::key, Function.identity()));
+ .collect(java.util.stream.Collectors.toMap(ComponentDto::getDbKey, Function.identity()));
}
private class PersistComponentStepsVisitor extends PathAwareVisitorAdapter<ComponentDtoHolder> {
}
private ComponentDto persistComponent(ComponentDto componentDto) {
- ComponentDto existingComponent = existingComponentDtosByKey.remove(componentDto.getKey());
+ ComponentDto existingComponent = existingComponentDtosByKey.remove(componentDto.getDbKey());
if (existingComponent == null) {
dbClient.componentDao().insert(dbSession, componentDto);
return componentDto;
ComponentDto componentDto = new ComponentDto();
componentDto.setOrganizationUuid(analysisMetadataHolder.getOrganization().getUuid());
componentDto.setUuid(componentUuid);
- componentDto.setKey(componentKey);
+ componentDto.setDbKey(componentKey);
componentDto.setDeprecatedKey(componentKey);
componentDto.setEnabled(true);
componentDto.setCreatedAt(new Date(system2.now()));
try (DbSession dbSession = dbClient.openSession(false)) {
Component root = treeRootHolder.getRoot();
List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getKey());
- Map<String, ComponentDto> baseModulesByKey = from(baseModules).uniqueIndex(ComponentDto::key);
+ Map<String, ComponentDto> baseModulesByKey = from(baseModules).uniqueIndex(ComponentDto::getDbKey);
ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao(), baseModulesByKey);
new DepthTraversalTypeAwareCrawler(visitor).visit(root);
ComponentDto anotherBaseProject = componentDao.selectOrFailByUuid(session, baseProject.get().projectUuid());
validationMessages.add(format("The project \"%s\" is already defined in SonarQube but as a module of project \"%s\". "
+ "If you really want to stop directly analysing project \"%s\", please first delete it from SonarQube and then relaunch the analysis of project \"%s\".",
- rawProjectKey, anotherBaseProject.key(), anotherBaseProject.key(), rawProjectKey));
+ rawProjectKey, anotherBaseProject.getDbKey(), anotherBaseProject.getDbKey(), rawProjectKey));
}
}
private void validateModuleKeyIsNotAlreadyUsedInAnotherProject(ComponentDto baseModule, String rawModuleKey) {
if (!baseModule.projectUuid().equals(baseModule.uuid()) && !baseModule.projectUuid().equals(rawProject.getUuid())) {
ComponentDto projectModule = componentDao.selectOrFailByUuid(session, baseModule.projectUuid());
- validationMessages.add(format("Module \"%s\" is already part of project \"%s\"", rawModuleKey, projectModule.key()));
+ validationMessages.add(format("Module \"%s\" is already part of project \"%s\"", rawModuleKey, projectModule.getDbKey()));
}
}
String ref = null;
ComponentDto componentDto = duplication.file();
if (componentDto != null) {
- String componentKey = componentDto.key();
+ String componentKey = componentDto.getDbKey();
ref = refByComponentKey.get(componentKey);
if (ref == null) {
ref = Integer.toString(refByComponentKey.size() + 1);
private static WsDuplications.File toWsFile(ComponentDto file, @Nullable ComponentDto project, @Nullable ComponentDto subProject) {
WsDuplications.File.Builder wsFile = WsDuplications.File.newBuilder();
- wsFile.setKey(file.key());
+ wsFile.setKey(file.getDbKey());
wsFile.setUuid(file.uuid());
wsFile.setName(file.longName());
if (project != null) {
- wsFile.setProject(project.key());
+ wsFile.setProject(project.getDbKey());
wsFile.setProjectUuid(project.uuid());
wsFile.setProjectName(project.longName());
// Do not return sub project if sub project and project are the same
boolean displaySubProject = subProject != null && !subProject.uuid().equals(project.uuid());
if (displaySubProject) {
- wsFile.setSubProject(subProject.key());
+ wsFile.setSubProject(subProject.getDbKey());
wsFile.setSubProjectUuid(subProject.uuid());
wsFile.setSubProjectName(subProject.longName());
}
.setUserId(userId)
.setComponentId(componentDto.getId())
.build(), dbSession);
- checkRequest(existingFavoriteOnComponent.isEmpty(), "Component '%s' is already a favorite", componentDto.getKey());
+ checkRequest(existingFavoriteOnComponent.isEmpty(), "Component '%s' is already a favorite", componentDto.getDbKey());
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto()
.setKey(PROP_FAVORITE_KEY)
.setResourceId(componentDto.getId())
.setKey(PROP_FAVORITE_KEY)
.setResourceId(component.getId())
.setUserId(userId));
- checkRequest(result == 1, "Component '%s' is not a favorite", component.key());
+ checkRequest(result == 1, "Component '%s' is not a favorite", component.getDbKey());
}
}
builder
.clear()
.setOrganization(organization.getKey())
- .setKey(componentDto.key());
+ .setKey(componentDto.getDbKey());
setNullable(componentDto.name(), builder::setName);
setNullable(componentDto.qualifier(), builder::setQualifier);
return builder.build();
.setIssue(issue)
.setChangeAuthorLogin(context.login())
.setRuleName(rule.map(RuleDefinitionDto::getName).orElse(null))
- .setProject(project.getKey(), project.name())
+ .setProject(project.getDbKey(), project.name())
.setComponent(component)
.setComment(comment));
return issueDto;
public IssueChangeNotification setProject(ComponentDto project) {
setFieldValue("projectName", project.longName());
- setFieldValue("projectKey", project.key());
+ setFieldValue("projectKey", project.getDbKey());
return this;
}
ComponentDto component = data.getComponentByUuid(dto.getComponentUuid());
issueBuilder.setOrganization(data.getOrganizationKey(component.getOrganizationUuid()));
- issueBuilder.setComponent(component.key());
+ issueBuilder.setComponent(component.getDbKey());
ComponentDto project = data.getComponentByUuid(dto.getProjectUuid());
if (project != null) {
- issueBuilder.setProject(project.getKey());
+ issueBuilder.setProject(project.getDbKey());
ComponentDto subProject = data.getComponentByUuid(dto.getModuleUuid());
- if (subProject != null && !subProject.getKey().equals(project.getKey())) {
- issueBuilder.setSubProject(subProject.getKey());
+ if (subProject != null && !subProject.getDbKey().equals(project.getDbKey())) {
+ issueBuilder.setSubProject(subProject.getDbKey());
}
}
issueBuilder.setRule(dto.getRuleKey().toString());
String uuid = dto.uuid();
Component.Builder builder = Component.newBuilder()
.setOrganization(data.getOrganizationKey(dto.getOrganizationUuid()))
- .setKey(dto.key())
+ .setKey(dto.getDbKey())
.setUuid(uuid)
.setQualifier(dto.qualifier())
.setName(nullToEmpty(dto.name()))
}
private static void checkIsProjectOrModule(ComponentDto component) {
- checkRequest(Scopes.PROJECT.equals(component.scope()), "Component '%s' (id: %s) must be a project or a module.", component.key(), component.uuid());
+ checkRequest(Scopes.PROJECT.equals(component.scope()), "Component '%s' (id: %s) must be a project or a module.", component.getDbKey(), component.uuid());
}
private void checkMeasureDoesNotExistAlready(DbSession dbSession, ComponentDto component, MetricDto metric) {
int nbMeasuresOnSameMetricAndMeasure = dbClient.customMeasureDao().countByComponentIdAndMetricId(dbSession, component.uuid(), metric.getId());
checkRequest(nbMeasuresOnSameMetricAndMeasure == 0,
"A measure already exists for project '%s' (id: %s) and metric '%s' (id: '%d')",
- component.key(), component.uuid(), metric.getKey(), metric.getId());
+ component.getDbKey(), component.uuid(), metric.getKey(), metric.getId());
}
private MetricDto searchMetric(DbSession dbSession, Request request) {
MetricJsonWriter.write(json, metric, MetricJsonWriter.MANDATORY_FIELDS);
}
writeIfNeeded(json, component.uuid(), FIELD_PROJECT_ID, fieldsToReturn);
- writeIfNeeded(json, component.key(), FIELD_PROJECT_KEY, fieldsToReturn);
+ writeIfNeeded(json, component.getDbKey(), FIELD_PROJECT_KEY, fieldsToReturn);
writeIfNeeded(json, new Date(measure.getCreatedAt()), FIELD_CREATED_AT, fieldsToReturn);
writeIfNeeded(json, new Date(measure.getUpdatedAt()), FIELD_UPDATED_AT, fieldsToReturn);
writeIfNeeded(json, isPending, FIELD_PENDING, fieldsToReturn);
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
if (referenceComponent != null) {
wsComponent.setRefId(referenceComponent.uuid());
- wsComponent.setRefKey(referenceComponent.key());
+ wsComponent.setRefKey(referenceComponent.getDbKey());
}
WsMeasures.Measure.Builder measureBuilder = WsMeasures.Measure.newBuilder();
static Component.Builder componentDtoToWsComponent(ComponentDto component) {
Component.Builder wsComponent = Component.newBuilder()
.setId(component.uuid())
- .setKey(component.key())
+ .setKey(component.getDbKey())
.setName(component.name())
.setQualifier(component.qualifier());
if (component.path() != null) {
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
if (referenceComponent != null) {
wsComponent.setRefId(referenceComponent.uuid());
- wsComponent.setRefKey(referenceComponent.key());
+ wsComponent.setRefKey(referenceComponent.getDbKey());
}
WsMeasures.Measure.Builder measureBuilder = WsMeasures.Measure.newBuilder();
for (Map.Entry<MetricDto, ComponentTreeData.Measure> entry : measures.entrySet()) {
private List<Measure> buildWsMeasures() {
Map<String, ComponentDto> componentsByUuid = projects.stream().collect(toMap(ComponentDto::uuid, Function.identity()));
- Map<String, String> componentNamesByKey = projects.stream().collect(toMap(ComponentDto::key, ComponentDto::name));
+ Map<String, String> componentNamesByKey = projects.stream().collect(toMap(ComponentDto::getDbKey, ComponentDto::name));
Map<Integer, MetricDto> metricsById = metrics.stream().collect(toMap(MetricDto::getId, identity()));
Function<MeasureDto, MetricDto> dbMeasureToDbMetric = dbMeasure -> metricsById.get(dbMeasure.getMetricId());
return measures.stream()
.map(dbMeasure -> {
updateMeasureBuilder(measureBuilder, dbMeasureToDbMetric.apply(dbMeasure), dbMeasure);
- measureBuilder.setComponent(componentsByUuid.get(dbMeasure.getComponentUuid()).getKey());
+ measureBuilder.setComponent(componentsByUuid.get(dbMeasure.getComponentUuid()).getDbKey());
Measure measure = measureBuilder.build();
measureBuilder.clear();
return measure;
checkArgument(organizationDto != null, "No organization for uuid '%s'", organizationUuid);
return notification.setOrganization(organizationDto.getKey())
- .setProject(project.getKey())
+ .setProject(project.getDbKey())
.setProjectName(project.name());
}
}
String effectiveKey = ComponentKeys.createKey(projectKey, branch);
- ComponentDto dto = new ComponentDto().setOrganizationUuid(organizationUuid).setKey(effectiveKey).setQualifier(qualifier);
+ ComponentDto dto = new ComponentDto().setOrganizationUuid(organizationUuid).setDbKey(effectiveKey).setQualifier(qualifier);
PermissionTemplateDto template = findTemplate(dbSession, organizationUuid, dto);
if (template == null) {
return false;
List<PermissionTemplateDto> matchingTemplates = new ArrayList<>();
for (PermissionTemplateDto permissionTemplateDto : allPermissionTemplates) {
String keyPattern = permissionTemplateDto.getKeyPattern();
- if (StringUtils.isNotBlank(keyPattern) && component.getKey().matches(keyPattern)) {
+ if (StringUtils.isNotBlank(keyPattern) && component.getDbKey().matches(keyPattern)) {
matchingTemplates.add(permissionTemplateDto);
}
}
- checkAtMostOneMatchForComponentKey(component.getKey(), matchingTemplates);
+ checkAtMostOneMatchForComponentKey(component.getDbKey(), matchingTemplates);
if (matchingTemplates.size() == 1) {
return matchingTemplates.get(0);
}
rootComponentBuilder
.clear()
.setId(rootComponent.uuid())
- .setKey(rootComponent.key())
+ .setKey(rootComponent.getDbKey())
.setQualifier(rootComponent.qualifier())
.setName(rootComponent.name());
for (String permission : data.permissions(rootComponent.getId())) {
private static CreateWsResponse toCreateResponse(ComponentDto componentDto) {
return CreateWsResponse.newBuilder()
.setProject(CreateWsResponse.Project.newBuilder()
- .setKey(componentDto.key())
+ .setKey(componentDto.getDbKey())
.setName(componentDto.name())
.setQualifier(componentDto.qualifier())
.setVisibility(Visibility.getLabel(componentDto.isPrivate())))
for (ComponentDto project : projects) {
json.beginObject();
json.prop("uuid", project.uuid());
- writeIfWished(json, "key", project.key(), fieldsToReturn);
+ writeIfWished(json, "key", project.getDbKey(), fieldsToReturn);
writeIfWished(json, "name", project.name(), fieldsToReturn);
writeIfWished(json, "creationDate", project.getCreatedAt(), fieldsToReturn);
writeIfWished(json, "visibility", project.isPrivate() ? PRIVATE.getLabel() : PUBLIC.getLabel(), fieldsToReturn);
private static void addProject(JsonWriter json, ComponentDto project) {
json.beginObject()
.prop("id", project.getId())
- .prop("k", project.getKey())
+ .prop("k", project.getDbKey())
.prop("nm", project.name())
.prop("sc", project.scope())
.prop("qu", project.qualifier())
private static List<Component> writeProjects(List<ComponentDto> projects, Set<String> desiredFields) {
return projects.stream().map(project -> {
Component.Builder compBuilder = Component.newBuilder().setUuid(project.uuid());
- writeIfNeeded("key", project.key(), compBuilder::setKey, desiredFields);
+ writeIfNeeded("key", project.getDbKey(), compBuilder::setKey, desiredFields);
writeIfNeeded("name", project.name(), compBuilder::setName, desiredFields);
writeIfNeeded("creationDate", project.getCreatedAt(), compBuilder::setCreationDate, desiredFields);
writeIfNeeded("visibility", project.isPrivate() ? PRIVATE.getLabel() : PUBLIC.getLabel(), compBuilder::setVisibility, desiredFields);
Component.Builder builder = Component.newBuilder()
.setOrganization(organization.getKey())
.setId(dto.uuid())
- .setKey(dto.key())
+ .setKey(dto.getDbKey())
.setName(dto.name())
.setQualifier(dto.qualifier())
.setVisibility(dto.isPrivate() ? PRIVATE.getLabel() : PUBLIC.getLabel());
Project.Builder project = Project.newBuilder();
project
.setId(dto.uuid())
- .setKey(dto.key())
+ .setKey(dto.getDbKey())
.setName(dto.name());
data.lastAnalysisDateFor(dto.uuid()).ifPresent(project::setLastAnalysisDate);
data.qualityGateStatusFor(dto.uuid()).ifPresent(project::setQualityGate);
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto project = componentFinder.getByKey(dbSession, projectKey);
- checkRequest(PROJECT.equals(project.qualifier()), "Component '%s' is not a project", project.key());
+ checkRequest(PROJECT.equals(project.qualifier()), "Component '%s' is not a project", project.getDbKey());
userSession.checkComponentPermission(UserRole.ADMIN, project);
project.setTags(tags);
ComponentDto project = componentFinder.getByKey(dbSession, request.getProjectKey());
if (!project.getOrganizationUuid().equals(organization.getUuid())) {
- throw new NotFoundException(format("Component key '%s' not found", project.getKey()));
+ throw new NotFoundException(format("Component key '%s' not found", project.getDbKey()));
}
if (project.isRoot()) {
return project;
int from = request.mandatoryParamAsInt(PARAM_FROM);
int to = MoreObjects.firstNonNull(request.paramAsInt(PARAM_TO), Integer.MAX_VALUE);
- Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.key());
+ Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getDbKey());
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject();
writeSource(lines, json);
LOG.warn("We detected that the following projects have not been analysed on a SonarQube version greater than 4.2 (included):");
hasDetectDeprecatedProjects = true;
}
- LOG.warn(" - {}", project.getKey());
+ LOG.warn(" - {}", project.getDbKey());
}
}
if (hasDetectDeprecatedProjects) {
fileBuilder.setCoveredLines(doc.coveredLines().size());
ComponentDto component = componentsByUuid.get(doc.fileUuid());
if (component != null) {
- fileBuilder.setKey(component.key());
+ fileBuilder.setKey(component.getDbKey());
fileBuilder.setLongName(component.longName());
}
testBuilder.setFileId(testDoc.fileUuid());
ComponentDto component = componentsByTestFileUuid.get(testDoc.fileUuid());
if (component != null) {
- testBuilder.setFileKey(component.getKey());
+ testBuilder.setFileKey(component.getDbKey());
testBuilder.setFileName(component.longName());
}
testBuilder.setStatus(WsTests.TestStatus.valueOf(testDoc.status()));
}
private void writeComponent(JsonWriter json, DbSession session, ComponentDto component, OrganizationDto organizationDto, @Nullable SnapshotDto analysis) {
- json.prop("key", component.key())
+ json.prop("key", component.getDbKey())
.prop("organization", organizationDto.getKey())
.prop("id", component.uuid())
.prop("name", component.name())
for (ComponentDto c : breadcrumb) {
json.beginObject()
- .prop("key", c.key())
+ .prop("key", c.getDbKey())
.prop("name", c.name())
.prop("qualifier", c.qualifier())
.endObject();
.setUrl(dto.getUrl())
.setSuccess(dto.isSuccess())
.setCeTaskId(dto.getCeTaskUuid())
- .setComponentKey(component.getKey());
+ .setComponentKey(component.getDbKey());
if (dto.getHttpStatus() != null) {
builder.setHttpStatus(dto.getHttpStatus());
}
assertThat(task.getComponentKey()).isNull();
assertThat(task.getComponentName()).isNull();
} else {
- assertThat(task.getComponentKey()).isEqualTo(componentDto.key());
+ assertThat(task.getComponentKey()).isEqualTo(componentDto.getDbKey());
assertThat(task.getComponentName()).isEqualTo(componentDto.name());
}
assertThat(task.getSubmitterLogin()).isEqualTo(taskSubmit.getSubmitterLogin());
.setAssignee(null));
addPermissionTo(project);
- ServerIssue serverIssue = call(project.key());
+ ServerIssue serverIssue = call(project.getDbKey());
assertThat(serverIssue.getKey()).isEqualTo(issue.getKey());
- assertThat(serverIssue.getModuleKey()).isEqualTo(module.getKey());
+ assertThat(serverIssue.getModuleKey()).isEqualTo(module.getDbKey());
assertThat(serverIssue.getRuleRepository()).isEqualTo(rule.getRepositoryKey());
assertThat(serverIssue.getRuleKey()).isEqualTo(rule.getRuleKey());
assertThat(serverIssue.getStatus()).isEqualTo("OPEN");
.setAssignee("foo"));
addPermissionTo(project);
- ServerIssue serverIssue = call(project.key());
+ ServerIssue serverIssue = call(project.getDbKey());
assertThat(serverIssue.getKey()).isEqualTo(issue.getKey());
- assertThat(serverIssue.getModuleKey()).isEqualTo(module.getKey());
+ assertThat(serverIssue.getModuleKey()).isEqualTo(module.getDbKey());
assertThat(serverIssue.getRuleRepository()).isEqualTo(rule.getRepositoryKey());
assertThat(serverIssue.getRuleKey()).isEqualTo(rule.getRuleKey());
assertThat(serverIssue.getStatus()).isEqualTo("OPEN");
IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT"));
addPermissionTo(project);
- try (CloseableIterator<ServerIssue> result = callStream(project.key())) {
+ try (CloseableIterator<ServerIssue> result = callStream(project.getDbKey())) {
assertThat(result)
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey)
.containsExactlyInAnyOrder(
- tuple(issueOnFile.getKey(), module.key()),
- tuple(issueOnModule.getKey(), module.key()),
- tuple(issueOnProject.getKey(), project.key()));
+ tuple(issueOnFile.getKey(), module.getDbKey()),
+ tuple(issueOnModule.getKey(), module.getDbKey()),
+ tuple(issueOnProject.getKey(), project.getDbKey()));
}
}
IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT"));
addPermissionTo(project);
- try (CloseableIterator<ServerIssue> result = callStream(module.key())) {
+ try (CloseableIterator<ServerIssue> result = callStream(module.getDbKey())) {
assertThat(result)
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey)
.containsExactlyInAnyOrder(
- tuple(issueOnFile.getKey(), module.key()),
- tuple(issueOnModule.getKey(), module.key()));
+ tuple(issueOnFile.getKey(), module.getDbKey()),
+ tuple(issueOnModule.getKey(), module.getDbKey()));
}
}
IssueDto issueOnProject = db.issues().insert(rule, project, project);
addPermissionTo(project);
- try (CloseableIterator<ServerIssue> result = callStream(file.key())) {
+ try (CloseableIterator<ServerIssue> result = callStream(file.getDbKey())) {
assertThat(result)
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey)
.containsExactlyInAnyOrder(
- tuple(issueOnFile.getKey(), module.key()));
+ tuple(issueOnFile.getKey(), module.getDbKey()));
}
}
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Component of scope 'DIR' is not allowed");
- call(directory.key());
+ call(directory.getDbKey());
}
@Test
IssueDto issue = db.issues().insert(rule, project, file);
addPermissionTo(project);
- try (CloseableIterator<ServerIssue> result = callStream(project.key())) {
+ try (CloseableIterator<ServerIssue> result = callStream(project.getDbKey())) {
// Module key of removed file should be returned
assertThat(result)
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey)
- .containsExactly(tuple(issue.getKey(), module.key()));
+ .containsExactly(tuple(issue.getKey(), module.getDbKey()));
}
}
expectedException.expect(ForbiddenException.class);
- tester.newRequest().setParam("key", file.key()).execute();
+ tester.newRequest().setParam("key", file.getDbKey()).execute();
}
@Test
dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
- Map<String, String> projectSettings = ref.settings(project.key());
+ Map<String, String> projectSettings = ref.settings(project.getDbKey());
assertThat(projectSettings).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
- Map<String, String> projectSettings = ref.settings(project.key());
+ Map<String, String> projectSettings = ref.settings(project.getDbKey());
assertThat(projectSettings).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
- Map<String, String> projectSettings = ref.settings(project.key());
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(true));
+ Map<String, String> projectSettings = ref.settings(project.getDbKey());
assertThat(projectSettings).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR"));
}
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
- assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(module.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-SERVER",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
- assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(module.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
}
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
- assertThat(ref.settings(module.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(module.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-SERVER",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
- assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(subModule.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-SERVER-DAO",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
- assertThat(ref.settings(module1.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(module1.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-SERVER",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
- assertThat(ref.settings(module2.key())).isEqualTo(ImmutableMap.of(
+ assertThat(ref.settings(module2.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-APPLICATION",
"sonar.jira.login.secured", "john"));
}
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john"));
}
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
- assertThat(ref.settings(project.key())).isEmpty();
- assertThat(ref.settings(module.key())).isEmpty();
- assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEmpty();
+ assertThat(ref.settings(module.getDbKey())).isEmpty();
+ assertThat(ref.settings(subModule.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
- assertThat(ref.settings(project.key())).isEmpty();
- assertThat(ref.settings(module.key())).isEmpty();
- assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEmpty();
+ assertThat(ref.settings(module.getDbKey())).isEmpty();
+ assertThat(ref.settings(subModule.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
- assertThat(ref.settings(project.key())).isEmpty();
- assertThat(ref.settings(module.key())).isEmpty();
- assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEmpty();
+ assertThat(ref.settings(module.getDbKey())).isEmpty();
+ assertThat(ref.settings(subModule.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
- assertThat(ref.settings(project.key())).isEmpty();
- assertThat(ref.settings(module.key())).isEmpty();
- assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of(
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.getDbKey()));
+ assertThat(ref.settings(project.getDbKey())).isEmpty();
+ assertThat(ref.settings(module.getDbKey())).isEmpty();
+ assertThat(ref.settings(subModule.getDbKey())).isEqualTo(ImmutableMap.of(
"sonar.jira.project.key", "SONAR-SERVER",
"sonar.jira.login.secured", "john",
"sonar.coverage.exclusions", "**/*.java"));
dbSession.commit();
try {
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage(Messages.NO_PERMISSION);
thrown.expect(ForbiddenException.class);
thrown.expectMessage("You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. " +
"Please contact your SonarQube administrator.");
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(false));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(false));
}
@Test
thrown.expect(ForbiddenException.class);
thrown.expectMessage("You don't have the required permissions to access this project. Please contact your SonarQube administrator.");
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(true));
}
@Test
tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(file).setSrcHash("123456"));
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.fileDataByPath(project.key())).hasSize(1);
- FileData fileData = ref.fileData(project.key(), file.path());
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.fileDataByPath(project.getDbKey())).hasSize(1);
+ FileData fileData = ref.fileData(project.getDbKey(), file.path());
assertThat(fileData.hash()).isEqualTo("123456");
}
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
- assertThat(ref.fileData(project.key(), projectFile.path()).hash()).isEqualTo("123456");
- assertThat(ref.fileData(module.key(), moduleFile.path()).hash()).isEqualTo("789456");
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
+ assertThat(ref.fileData(project.getDbKey(), projectFile.path()).hash()).isEqualTo("123456");
+ assertThat(ref.fileData(module.getDbKey(), moduleFile.path()).hash()).isEqualTo("789456");
}
@Test
dbSession.commit();
- ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(module.key()));
- assertThat(ref.fileData(module.key(), moduleFile.path()).hash()).isEqualTo("789456");
- assertThat(ref.fileData(module.key(), moduleFile.path()).revision()).isEqualTo("123456789");
- assertThat(ref.fileData(project.key(), projectFile.path())).isNull();
+ ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(module.getDbKey()));
+ assertThat(ref.fileData(module.getDbKey(), moduleFile.path()).hash()).isEqualTo("789456");
+ assertThat(ref.fileData(module.getDbKey(), moduleFile.path()).revision()).isEqualTo("123456789");
+ assertThat(ref.fileData(project.getDbKey(), projectFile.path())).isNull();
}
private void addDefaultProfile() {
.setProjectUuid(uuid)
.setScope(scope)
.setQualifier(qualifier)
- .setKey(key));
+ .setDbKey(key));
dbSession.commit();
try {
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("You're not authorized to execute any SonarQube analysis");
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
}
@Test
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server");
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()));
}
@Test
ComponentDto project = dbTester.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
- ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
+ ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(true));
assertThat(repositories).isNotNull();
}
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("You don't have the required permissions to access this project");
- underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
+ underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(true));
}
@Test
userSession.logIn().addPermission(SCAN, project.getOrganizationUuid());
userSession.logIn().addProjectPermission(UserRole.USER, project);
- ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
+ ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.getDbKey()).setIssuesMode(true));
assertThat(repositories).isNotNull();
}
db.components().insertComponent(project);
expectedException.expect(IllegalArgumentException.class);
- callByComponentUuidOrComponentKey(project.uuid(), project.key());
+ callByComponentUuidOrComponentKey(project.uuid(), project.getDbKey());
}
@Test
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
- callByComponentKey(project.key());
+ callByComponentKey(project.getDbKey());
}
private void insertInQueue(CeQueueDto.Status status, @Nullable String componentUuid) {
insertActivity("T1", project.uuid(), CeActivityDto.Status.SUCCESS);
WsCe.ProjectResponse response = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEY, project.key())
+ .setParam(PARAM_COMPONENT_KEY, project.getDbKey())
.executeProtobuf(WsCe.ProjectResponse.class);
assertThat(response.hasCurrent()).isTrue();
}
assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo("john");
assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
- assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
+ assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.getDbKey());
assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
assertThat(taskResponse.getTask().getLogs()).isFalse();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
assertThat(task.getComponentId()).isEqualTo(project.uuid());
- assertThat(task.getComponentKey()).isEqualTo(project.key());
+ assertThat(task.getComponentKey()).isEqualTo(project.getDbKey());
assertThat(task.getComponentName()).isEqualTo(project.name());
assertThat(task.getAnalysisId()).isEqualTo(activityDto.getAnalysisUuid());
assertThat(task.getExecutionTimeMs()).isEqualTo(500L);
public void formatQueue_with_component_and_other_fields() throws IOException {
String uuid = "COMPONENT_UUID";
OrganizationDto organizationDto = db.organizations().insert();
- db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name"));
+ db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(uuid).setDbKey("COMPONENT_KEY").setName("Component Name"));
CeQueueDto dto = new CeQueueDto();
dto.setUuid("UUID");
private DbData insertData(int id) {
String suffix = String.valueOf(id);
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid-" + suffix)
- .setKey("project-key-" + suffix);
+ .setDbKey("project-key-" + suffix);
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("sonarqube", "rule-" + suffix));
dbClient.ruleDao().insert(dbSession, rule);
IssueDto issue = IssueTesting.newIssue(rule, project, project).setKee("issue-key-" + suffix).setUpdatedAt(new Date().getTime());
@Test
public void fail_when_component_key_is_removed() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
+ db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
expectedException.expect(NotFoundException.class);
@Test
public void get_component_by_key() {
- db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key"));
+ db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("project-key"));
ComponentDto component = underTest.getByUuidOrKey(dbSession, null, "project-key", ID_AND_KEY);
- assertThat(component.key()).isEqualTo("project-key");
+ assertThat(component.getDbKey()).isEqualTo("project-key");
}
}
@Test
public void bulk_update() {
- ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey("my_project"));
- ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
- ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
- ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
- ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
+ ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setDbKey("my_project"));
+ ComponentDto module = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:module"));
+ ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:inactive_module").setEnabled(false));
+ ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/File.xoo"));
+ ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
underTest.bulkUpdateKey(dbSession, project, "my_", "your_");
- assertComponentKeyUpdated(project.key(), "your_project");
- assertComponentKeyUpdated(module.key(), "your_project:root:module");
- assertComponentKeyUpdated(file.key(), "your_project:root:module:src/File.xoo");
- assertComponentKeyNotUpdated(inactiveModule.key());
- assertComponentKeyNotUpdated(inactiveFile.key());
+ assertComponentKeyUpdated(project.getDbKey(), "your_project");
+ assertComponentKeyUpdated(module.getDbKey(), "your_project:root:module");
+ assertComponentKeyUpdated(file.getDbKey(), "your_project:root:module:src/File.xoo");
+ assertComponentKeyNotUpdated(inactiveModule.getDbKey());
+ assertComponentKeyNotUpdated(inactiveFile.getDbKey());
}
private void assertComponentKeyUpdated(String oldKey, String newKey) {
@Test
public void update_project_key() {
ComponentDto project = insertSampleRootProject();
- ComponentDto file = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setKey("sample:root:src/File.xoo"));
- ComponentDto inactiveFile = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setKey("sample:root:src/InactiveFile.xoo").setEnabled(false));
+ ComponentDto file = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setDbKey("sample:root:src/File.xoo"));
+ ComponentDto inactiveFile = componentDb.insertComponent(ComponentTesting.newFileDto(project, null).setDbKey("sample:root:src/InactiveFile.xoo").setEnabled(false));
dbSession.commit();
dbSession.commit();
// Check project key has been updated
- assertThat(db.getDbClient().componentDao().selectByKey(dbSession, project.key())).isAbsent();
+ assertThat(db.getDbClient().componentDao().selectByKey(dbSession, project.getDbKey())).isAbsent();
assertThat(db.getDbClient().componentDao().selectByKey(dbSession, "sample2:root")).isNotNull();
// Check file key has been updated
- assertThat(db.getDbClient().componentDao().selectByKey(dbSession, file.key())).isAbsent();
+ assertThat(db.getDbClient().componentDao().selectByKey(dbSession, file.getDbKey())).isAbsent();
assertThat(db.getDbClient().componentDao().selectByKey(dbSession, "sample2:root:src/File.xoo")).isNotNull();
- assertThat(dbClient.componentDao().selectByKey(dbSession, inactiveFile.getKey())).isPresent();
+ assertThat(dbClient.componentDao().selectByKey(dbSession, inactiveFile.getDbKey())).isPresent();
org.assertj.core.api.Assertions.assertThat(projectIndexers.hasBeenCalled(project.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE)).isTrue();
}
@Test
public void update_module_key() {
ComponentDto project = insertSampleRootProject();
- ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
+ ComponentDto module = ComponentTesting.newModuleDto(project).setDbKey("sample:root:module");
db.components().insertComponent(module);
- ComponentDto file = ComponentTesting.newFileDto(module, null).setKey("sample:root:module:src/File.xoo");
+ ComponentDto file = ComponentTesting.newFileDto(module, null).setDbKey("sample:root:module:src/File.xoo");
db.components().insertComponent(file);
logInAsProjectAdministrator(project);
underTest.updateKey(dbSession, module, "sample:root2:module");
dbSession.commit();
- assertThat(dbClient.componentDao().selectByKey(dbSession, project.key())).isPresent();
- assertComponentKeyHasBeenUpdated(module.key(), "sample:root2:module");
- assertComponentKeyHasBeenUpdated(file.key(), "sample:root2:module:src/File.xoo");
+ assertThat(dbClient.componentDao().selectByKey(dbSession, project.getDbKey())).isPresent();
+ assertComponentKeyHasBeenUpdated(module.getDbKey(), "sample:root2:module");
+ assertComponentKeyHasBeenUpdated(file.getDbKey(), "sample:root2:module:src/File.xoo");
// do not index the module but the project
org.assertj.core.api.Assertions.assertThat(projectIndexers.hasBeenCalled(project.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE)).isTrue();
underTest.updateKey(dbSession, provisionedProject, "provisionedProject2");
dbSession.commit();
- assertComponentKeyHasBeenUpdated(provisionedProject.key(), "provisionedProject2");
+ assertComponentKeyHasBeenUpdated(provisionedProject.getDbKey(), "provisionedProject2");
org.assertj.core.api.Assertions.assertThat(projectIndexers.hasBeenCalled(provisionedProject.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE)).isTrue();
}
logInAsProjectAdministrator(project);
expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Impossible to update key: a component with key \"" + anotherProject.key() + "\" already exists.");
+ expectedException.expectMessage("Impossible to update key: a component with key \"" + anotherProject.getDbKey() + "\" already exists.");
- underTest.updateKey(dbSession, project, anotherProject.key());
+ underTest.updateKey(dbSession, project, anotherProject.getDbKey());
}
@Test
@Test
public void bulk_update_key() {
- ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my_project"));
- ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
- ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
- ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
- ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
+ ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("my_project"));
+ ComponentDto module = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:module"));
+ ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:inactive_module").setEnabled(false));
+ ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/File.xoo"));
+ ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
underTest.bulkUpdateKey(dbSession, project, "my_", "your_");
- assertComponentKeyUpdated(project.key(), "your_project");
- assertComponentKeyUpdated(module.key(), "your_project:root:module");
- assertComponentKeyUpdated(file.key(), "your_project:root:module:src/File.xoo");
- assertComponentKeyNotUpdated(inactiveModule.key());
- assertComponentKeyNotUpdated(inactiveFile.key());
+ assertComponentKeyUpdated(project.getDbKey(), "your_project");
+ assertComponentKeyUpdated(module.getDbKey(), "your_project:root:module");
+ assertComponentKeyUpdated(file.getDbKey(), "your_project:root:module:src/File.xoo");
+ assertComponentKeyNotUpdated(inactiveModule.getDbKey());
+ assertComponentKeyNotUpdated(inactiveFile.getDbKey());
}
private void assertComponentKeyUpdated(String oldKey, String newKey) {
}
private ComponentDto insertProject(String key) {
- ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey(key));
+ ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey(key));
return project;
}
ComponentDto returned = underTest.create(db.getSession(), project, null);
ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
- assertThat(loaded.getKey()).isEqualTo(DEFAULT_PROJECT_KEY);
+ 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);
.build(),
null);
- assertThat(project.getKey()).isEqualTo("project-key:origin/master");
+ assertThat(project.getDbKey()).isEqualTo("project-key:origin/master");
}
@Test
ComponentDto returned = underTest.create(db.getSession(), view, null);
ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
- assertThat(loaded.getKey()).isEqualTo("view-key");
+ assertThat(loaded.getDbKey()).isEqualTo("view-key");
assertThat(loaded.name()).isEqualTo("view-name");
assertThat(loaded.qualifier()).isEqualTo("VW");
assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
ComponentDto returned = underTest.create(db.getSession(), view, null);
ComponentDto loaded = db.getDbClient().componentDao().selectOrFailByUuid(db.getSession(), returned.uuid());
- assertThat(loaded.getKey()).isEqualTo("app-key");
+ assertThat(loaded.getDbKey()).isEqualTo("app-key");
assertThat(loaded.name()).isEqualTo("app-name");
assertThat(loaded.qualifier()).isEqualTo("APP");
assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
ComponentDto returned = underTest.create(db.getSession(), view, null);
- ComponentDto loaded = db.getDbClient().componentDao().selectByKey(db.getSession(), returned.key()).get();
- assertThat(loaded.getKey()).isEqualTo("app-key");
+ ComponentDto loaded = db.getDbClient().componentDao().selectByKey(db.getSession(), returned.getDbKey()).get();
+ assertThat(loaded.getDbKey()).isEqualTo("app-key");
assertThat(loaded.name()).isEqualTo("app-name");
assertThat(loaded.qualifier()).isEqualTo("APP");
assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
ComponentDto existing = db.components().insertPrivateProject();
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Could not create Project, key already exists: " + existing.key());
+ expectedException.expectMessage("Could not create Project, key already exists: " + existing.getDbKey());
underTest.create(db.getSession(),
NewComponent.newComponentBuilder()
- .setKey(existing.key())
+ .setKey(existing.getDbKey())
.setName(DEFAULT_PROJECT_NAME)
.setOrganizationUuid(existing.getOrganizationUuid())
.build(),
ComponentDto existing = db.components().insertPrivateProject(db.organizations().insert());
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Could not create Project, key already exists: " + existing.key());
+ expectedException.expectMessage("Could not create Project, key already exists: " + existing.getDbKey());
underTest.create(db.getSession(),
NewComponent.newComponentBuilder()
- .setKey(existing.key())
+ .setKey(existing.getDbKey())
.setName(DEFAULT_PROJECT_NAME)
.setOrganizationUuid(existing.getOrganizationUuid())
.build(),
ComponentIndexQuery query1 = ComponentIndexQuery.builder()
.setQuery("SonarQube")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project1.getKey()))
+ .setFavoriteKeys(of(project1.getDbKey()))
.build();
assertSearch(query1).containsExactly(uuids(project1, project2));
ComponentIndexQuery query2 = ComponentIndexQuery.builder()
.setQuery("SonarQube")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project2.getKey()))
+ .setFavoriteKeys(of(project2.getDbKey()))
.build();
assertSearch(query2).containsExactly(uuids(project2, project1));
}
ComponentIndexQuery query1 = ComponentIndexQuery.builder()
.setQuery("bar")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project1.getKey()))
+ .setFavoriteKeys(of(project1.getDbKey()))
.build();
assertSearch(query1).isEmpty();
}
ComponentIndexQuery query1 = ComponentIndexQuery.builder()
.setQuery("SonarQube")
.setQualifiers(Collections.singletonList(PROJECT))
- .setRecentlyBrowsedKeys(of(project1.getKey()))
+ .setRecentlyBrowsedKeys(of(project1.getDbKey()))
.build();
assertSearch(query1).containsExactly(uuids(project1, project2));
ComponentIndexQuery query2 = ComponentIndexQuery.builder()
.setQuery("SonarQube")
.setQualifiers(Collections.singletonList(PROJECT))
- .setRecentlyBrowsedKeys(of(project2.getKey()))
+ .setRecentlyBrowsedKeys(of(project2.getDbKey()))
.build();
assertSearch(query2).containsExactly(uuids(project2, project1));
}
assertSearch(ComponentIndexQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
- .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getKey()))
- .setFavoriteKeys(ImmutableSet.of(file2.getKey()))
+ .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getDbKey()))
+ .setFavoriteKeys(ImmutableSet.of(file2.getDbKey()))
.build()).containsExactly(uuids(file2, file1));
assertSearch(ComponentIndexQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
- .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getKey()))
- .setFavoriteKeys(ImmutableSet.of(file1.getKey()))
+ .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getDbKey()))
+ .setFavoriteKeys(ImmutableSet.of(file1.getDbKey()))
.build()).containsExactly(uuids(file1, file2));
}
index(ComponentTesting.newFileDto(project)
.setName("DbTester.java")
- .setKey("java/org/example/DbTester.java")
+ .setDbKey("java/org/example/DbTester.java")
.setUuid("UUID-DbTester"));
index(ComponentTesting.newFileDto(project)
.setName("WebhookDbTesting.java")
- .setKey("java/org/example/WebhookDbTesting.java")
+ .setDbKey("java/org/example/WebhookDbTesting.java")
.setUuid("UUID-WebhookDbTesting"));
assertSearch("dbt").containsExactly(
protected ComponentDto indexProject(String key, String name) {
return index(
ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key)
- .setKey(key)
+ .setDbKey(key)
.setName(name));
}
protected ComponentDto newProject(String key, String name) {
return ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key)
- .setKey(key)
+ .setDbKey(key)
.setName(name);
}
protected ComponentDto indexFile(ComponentDto project, String fileKey, String fileName) {
return index(
ComponentTesting.newFileDto(project)
- .setKey(fileKey)
+ .setDbKey(fileKey)
.setName(fileName));
}
private ComponentDto[] insertComponentsAndAnalysis() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), PROJECT_UUID)
.setLongName("SonarQube")
- .setKey(PROJECT_KEY);
+ .setDbKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project)
.setLongName("SonarQube :: Plugin API")
- .setKey(MODULE_KEY);
+ .setDbKey(MODULE_KEY);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID)
- .setKey(FILE_KEY)
+ .setDbKey(FILE_KEY)
.setName("Plugin.java")
.setLongName("src/main/java/org/sonar/api/Plugin.java")
.setPath("src/main/java/org/sonar/api/Plugin.java");
@Test
public void search_by_key_query() throws IOException {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("project-_%-key"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("project-key-without-escaped-characters"));
SearchWsResponse response = call(new SearchWsRequest().setQuery("project-_%-key").setQualifiers(singletonList(PROJECT)));
@Test
public void search_for_files() throws IOException {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
- ComponentDto file1 = newFileDto(project).setKey("file1");
- ComponentDto file2 = newFileDto(project).setKey("file2");
+ ComponentDto file1 = newFileDto(project).setDbKey("file1");
+ ComponentDto file2 = newFileDto(project).setDbKey("file2");
db.components().insertComponents(project, file1, file2);
setBrowsePermissionOnUser(project);
- SearchWsResponse response = call(new SearchWsRequest().setQuery(file1.key()).setQualifiers(singletonList(FILE)));
+ SearchWsResponse response = call(new SearchWsRequest().setQuery(file1.getDbKey()).setQualifiers(singletonList(FILE)));
- assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey());
+ assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getDbKey());
}
@Test
OrganizationDto organizationDto = db.organizations().insert();
List<ComponentDto> componentDtoList = new ArrayList<>();
for (int i = 1; i <= 9; i++) {
- componentDtoList.add(newPrivateProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
+ componentDtoList.add(newPrivateProjectDto(organizationDto, "project-uuid-" + i).setDbKey("project-key-" + i).setName("Project Name " + i));
}
insertProjectsAuthorizedForUser(componentDtoList.toArray(new ComponentDto[] {}));
public void search_with_language() throws IOException {
OrganizationDto organizationDto = db.organizations().insert();
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(organizationDto).setKey("java-project").setLanguage("java"),
- ComponentTesting.newPrivateProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp"));
+ ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("java-project").setLanguage("java"),
+ ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("cpp-project").setLanguage("cpp"));
SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT)));
@Test
public void return_only_components_from_projects_on_which_user_has_browse_permission() throws IOException {
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
- ComponentDto file1 = newFileDto(project1).setKey("file1");
- ComponentDto file2 = newFileDto(project1).setKey("file2");
+ ComponentDto file1 = newFileDto(project1).setDbKey("file1");
+ ComponentDto file2 = newFileDto(project1).setDbKey("file2");
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
- ComponentDto file3 = newFileDto(project2).setKey("file3");
+ ComponentDto file3 = newFileDto(project2).setDbKey("file3");
db.components().insertComponents(project1, file1, file2, project2, file3);
setBrowsePermissionOnUser(project1);
SearchWsResponse response = call(new SearchWsRequest().setQualifiers(singletonList(FILE)));
- assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
+ assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getDbKey(), file2.getDbKey());
}
@Test
public void return_project_key() throws IOException {
ComponentDto project = ComponentTesting.newPublicProjectDto(db.getDefaultOrganization());
ComponentDto module = ComponentTesting.newModuleDto(project);
- ComponentDto file1 = newFileDto(module).setKey("file1");
- ComponentDto file2 = newFileDto(module).setKey("file2");
- ComponentDto file3 = newFileDto(project).setKey("file3");
+ ComponentDto file1 = newFileDto(module).setDbKey("file1");
+ ComponentDto file2 = newFileDto(module).setDbKey("file2");
+ ComponentDto file3 = newFileDto(project).setDbKey("file3");
db.components().insertComponents(project, module, file1, file2, file3);
SearchWsResponse response = call(new SearchWsRequest().setQualifiers(asList(PROJECT, MODULE, FILE)));
assertThat(response.getComponentsList()).extracting(Component::getKey, Component::getProject)
- .containsOnly(tuple(project.getKey(), project.getKey()),
- tuple(module.getKey(), project.getKey()),
- tuple(file1.getKey(), project.getKey()),
- tuple(file2.getKey(), project.getKey()),
- tuple(file3.getKey(), project.getKey()));
+ .containsOnly(tuple(project.getDbKey(), project.getDbKey()),
+ tuple(module.getDbKey(), project.getDbKey()),
+ tuple(file1.getDbKey(), project.getDbKey()),
+ tuple(file2.getDbKey(), project.getDbKey()),
+ tuple(file3.getDbKey(), project.getDbKey()));
}
@Test
assertThat(call(request).getComponentsCount()).isZero();
userSession.logIn().setRoot();
- assertThat(call(request).getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
+ assertThat(call(request).getComponentsList()).extracting(Component::getKey).containsOnly(file1.getDbKey(), file2.getDbKey());
}
@Test
public void test_json_example() {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
db.components().insertComponent(newView(organizationDto));
- ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setName("Project Name").setKey("project-key");
- ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setKey("module-key");
- ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setKey("directory-key").setName("Directory Name");
+ ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setName("Project Name").setDbKey("project-key");
+ ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setDbKey("module-key");
+ ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setDbKey("directory-key").setName("Directory Name");
db.components().insertComponents(project, module, directory,
- newFileDto(module, directory, "file-uuid").setKey("file-key").setLanguage("java").setName("File Name"));
+ newFileDto(module, directory, "file-uuid").setDbKey("file-key").setLanguage("java").setName("File Name"));
userSession.addProjectPermission(UserRole.USER, project);
String response = ws.newRequest()
import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.DATA;
import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.PERCENT;
import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.RATING;
-import static org.sonar.server.es.ProjectIndexer.Cause.PROJECT_CREATION;
import static org.sonar.test.JsonAssert.assertJson;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_FILTER;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
OrganizationDto organization1Dto = db.organizations().insertForKey("my-org-key-1");
OrganizationDto organization2Dto = db.organizations().insertForKey("my-org-key-2");
ComponentDto project1 = insertProject(organization1Dto, c -> c
- .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_001)
+ .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_001)
.setName("My Project 1")
.setTagsString("finance, java"));
insertProject(organization1Dto, c -> c
- .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_002)
+ .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_002)
.setName("My Project 2"));
insertProject(organization2Dto, c -> c
- .setKey(KeyExamples.KEY_PROJECT_EXAMPLE_003)
+ .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_003)
.setName("My Project 3")
.setTagsString("sales, offshore, java"));
addFavourite(project1);
SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80 and ncloc <= 10000"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
@Test
assertThat(call(request.setOrganization(null)).getComponentsList())
.extracting(Component::getKey)
- .containsOnly(project1.getKey(), project2.getKey(), project3.getKey());
+ .containsOnly(project1.getDbKey(), project2.getDbKey(), project3.getDbKey());
assertThat(call(request.setOrganization(organization1.getKey())).getComponentsList())
.extracting(Component::getKey)
- .containsOnly(project1.getKey(), project2.getKey());
+ .containsOnly(project1.getDbKey(), project2.getDbKey());
assertThat(call(request.setOrganization(organization2.getKey())).getComponentsList())
.extracting(Component::getKey)
- .containsOnly(project3.getKey());
+ .containsOnly(project3.getDbKey());
}
@Test
assertThat(result.getComponentsList())
.extracting(Component::getKey)
- .containsExactlyInAnyOrder(project1.getKey(), project2.getKey());
+ .containsExactlyInAnyOrder(project1.getDbKey(), project2.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("languages IN (java, js, <null>)"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project2.getKey(), project4.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project2.getDbKey(), project4.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter(metricKey + " = 2"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter(newMetricKey + " = 2"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("tags in (finance, offshore)"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("new_coverage <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density = NO_DATA"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("new_duplicated_lines_density <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("ncloc <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
SearchProjectsWsResponse result = call(request.setFilter("new_lines <= 80"));
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getKey(), project3.key());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
@Test
public void filter_projects_by_text_query() {
userSession.logIn();
OrganizationDto organizationDto = db.organizations().insert();
- insertProject(organizationDto, c -> c.setKey("sonar-java").setName("Sonar Java"));
- insertProject(organizationDto, c -> c.setKey("sonar-groovy").setName("Sonar Groovy"));
- insertProject(organizationDto, c -> c.setKey("sonar-markdown").setName("Sonar Markdown"));
- insertProject(organizationDto, c -> c.setKey("sonarqube").setName("Sonar Qube"));
+ insertProject(organizationDto, c -> c.setDbKey("sonar-java").setName("Sonar Java"));
+ insertProject(organizationDto, c -> c.setDbKey("sonar-groovy").setName("Sonar Groovy"));
+ insertProject(organizationDto, c -> c.setDbKey("sonar-markdown").setName("Sonar Markdown"));
+ insertProject(organizationDto, c -> c.setDbKey("sonarqube").setName("Sonar Qube"));
assertThat(call(request.setFilter("query = \"Groovy\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Groovy");
assertThat(call(request.setFilter("query = \"oNar\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Groovy", "Sonar Markdown",
SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
assertThat(result.getComponentsCount()).isEqualTo(2);
- assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getKey(), markDownProject.getKey());
+ assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getDbKey(), markDownProject.getDbKey());
}
@Test
ComponentDto project4 = insertProject(organizationDto, c -> c.setName("Sonar Qube"), new Measure(coverage, c -> c.setValue(80d)));
assertThat(call(request.setSort(COVERAGE).setAsc(true)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
+ .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
assertThat(call(request.setSort(COVERAGE).setAsc(false)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project2.getKey(), project1.getKey(), project3.getKey(), project4.getKey());
+ .containsExactly(project2.getDbKey(), project1.getDbKey(), project3.getDbKey(), project4.getDbKey());
}
@Test
ComponentDto project4 = insertProject(organization, c -> c.setName("Sonar Qube"), new Measure(qualityGateStatus, c -> c.setData("OK")));
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(true)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
+ .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(false)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project1.getKey(), project2.getKey(), project3.getKey(), project4.getKey());
+ .containsExactly(project1.getDbKey(), project2.getDbKey(), project3.getDbKey(), project4.getDbKey());
}
@Test
public void sort_by_last_analysis_date() throws Exception {
userSession.logIn();
OrganizationDto organization = db.organizations().insert();
- ComponentDto project1 = db.components().insertPublicProject(organization, p -> p.setKey("project1"));
+ ComponentDto project1 = db.components().insertPublicProject(organization, p -> p.setDbKey("project1"));
authorizationIndexerTester.allowOnlyAnyone(project1);
- ComponentDto project2 = db.components().insertPublicProject(organization, p -> p.setKey("project2"));
+ ComponentDto project2 = db.components().insertPublicProject(organization, p -> p.setDbKey("project2"));
db.components().insertSnapshot(project2, snapshot -> snapshot.setCreatedAt(40_000_000_000L).setLast(true));
authorizationIndexerTester.allowOnlyAnyone(project2);
- ComponentDto project3 = db.components().insertPublicProject(organization, p -> p.setKey("project3"));
+ ComponentDto project3 = db.components().insertPublicProject(organization, p -> p.setDbKey("project3"));
db.components().insertSnapshot(project3, snapshot -> snapshot.setCreatedAt(20_000_000_000L).setLast(true));
authorizationIndexerTester.allowOnlyAnyone(project3);
- ComponentDto project4 = db.components().insertPublicProject(organization, p -> p.setKey("project4"));
+ ComponentDto project4 = db.components().insertPublicProject(organization, p -> p.setDbKey("project4"));
db.components().insertSnapshot(project4, snapshot -> snapshot.setCreatedAt(10_000_000_000L).setLast(false));
db.components().insertSnapshot(project4, snapshot -> snapshot.setCreatedAt(30_000_000_000L).setLast(true));
authorizationIndexerTester.allowOnlyAnyone(project4);
projectMeasuresIndexer.indexOnStartup(null);
assertThat(call(request.setSort(ANALYSIS_DATE).setAsc(true)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project3.getKey(), project4.getKey(), project2.getKey(), project1.getKey());
+ .containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
assertThat(call(request.setSort(ANALYSIS_DATE).setAsc(false)).getComponentsList()).extracting(Component::getKey)
- .containsExactly(project2.getKey(), project4.getKey(), project3.getKey(), project1.getKey());
+ .containsExactly(project2.getDbKey(), project4.getDbKey(), project3.getDbKey(), project1.getDbKey());
}
@Test
assertThat(result.getComponentsList()).extracting(Component::getKey, Component::hasAnalysisDate, Component::getAnalysisDate)
.containsOnly(
- tuple(project1.getKey(), true, formatDateTime(new Date(20_000_000_000L))),
- tuple(project2.getKey(), true, formatDateTime(new Date(30_000_000_000L))),
- tuple(project3.getKey(), false, ""));
+ tuple(project1.getDbKey(), true, formatDateTime(new Date(20_000_000_000L))),
+ tuple(project2.getDbKey(), true, formatDateTime(new Date(30_000_000_000L))),
+ tuple(project3.getDbKey(), false, ""));
}
@Test
assertThat(result.getComponentsList()).extracting(Component::getKey, Component::hasLeakPeriodDate, Component::getLeakPeriodDate)
.containsOnly(
- tuple(project1.getKey(), true, formatDateTime(new Date(10_000_000_000L))),
- tuple(project2.getKey(), false, ""),
- tuple(project3.getKey(), false, ""));
+ tuple(project1.getDbKey(), true, formatDateTime(new Date(10_000_000_000L))),
+ tuple(project2.getDbKey(), false, ""),
+ tuple(project3.getDbKey(), false, ""));
}
@Test
assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getVisibility)
.containsExactly(
- tuple(privateProject.getKey(), privateProject.isPrivate() ? "private" : "public"),
- tuple(publicProject.getKey(), publicProject.isPrivate() ? "private" : "public"));
+ tuple(privateProject.getDbKey(), privateProject.isPrivate() ? "private" : "public"),
+ tuple(publicProject.getDbKey(), publicProject.isPrivate() ? "private" : "public"));
}
@Test
ComponentDto file = db.components().insertComponent(newFileDto(directory));
userSession.addProjectPermission(USER, project);
- ShowWsResponse response = newRequest(null, file.key());
+ ShowWsResponse response = newRequest(null, file.getDbKey());
- assertThat(response.getComponent().getKey()).isEqualTo(file.key());
- assertThat(response.getAncestorsList()).extracting(WsComponents.Component::getKey).containsOnly(directory.key(), module.key(), project.key());
+ assertThat(response.getComponent().getKey()).isEqualTo(file.getDbKey());
+ assertThat(response.getAncestorsList()).extracting(WsComponents.Component::getKey).containsOnly(directory.getDbKey(), module.getDbKey(), project.getDbKey());
}
@Test
db.components().insertComponent(newModuleDto(project));
userSession.addProjectPermission(USER, project);
- ShowWsResponse response = newRequest(null, project.key());
+ ShowWsResponse response = newRequest(null, project.getDbKey());
- assertThat(response.getComponent().getKey()).isEqualTo(project.key());
+ assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
assertThat(response.getAncestorsList()).isEmpty();
}
newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
userSession.addProjectPermission(USER, project);
- ShowWsResponse response = newRequest(null, project.key());
+ ShowWsResponse response = newRequest(null, project.getDbKey());
assertThat(response.getComponent().getAnalysisDate()).isNotEmpty().isEqualTo(formatDateTime(new Date(3_000_000_000L)));
}
userSession.addProjectPermission(USER, project);
- ShowWsResponse response = newRequest(null, project.key());
+ ShowWsResponse response = newRequest(null, project.getDbKey());
assertThat(response.getComponent().getLeakPeriodDate()).isNotEmpty().isEqualTo(formatDateTime(new Date(3_000_000_000L)));
}
ComponentDto file = db.components().insertComponent(newFileDto(directory));
userSession.addProjectPermission(USER, project);
- ShowWsResponse response = newRequest(null, file.key());
+ ShowWsResponse response = newRequest(null, file.getDbKey());
String expectedDate = formatDateTime(new Date(3_000_000_000L));
assertThat(response.getAncestorsList()).extracting(WsComponents.Component::getAnalysisDate)
userSession.logIn().setRoot();
ComponentDto privateProject = db.components().insertPrivateProject();
- ShowWsResponse result = newRequest(null, privateProject.key());
+ ShowWsResponse result = newRequest(null, privateProject.getDbKey());
assertThat(result.getComponent().hasVisibility()).isTrue();
assertThat(result.getComponent().getVisibility()).isEqualTo("private");
}
userSession.logIn().setRoot();
ComponentDto publicProject = db.components().insertPublicProject();
- ShowWsResponse result = newRequest(null, publicProject.key());
+ ShowWsResponse result = newRequest(null, publicProject.getDbKey());
assertThat(result.getComponent().hasVisibility()).isTrue();
assertThat(result.getComponent().getVisibility()).isEqualTo("public");
}
userSession.logIn().setRoot();
ComponentDto view = db.components().insertView();
- ShowWsResponse result = newRequest(null, view.key());
+ ShowWsResponse result = newRequest(null, view.getDbKey());
assertThat(result.getComponent().hasVisibility()).isTrue();
}
ComponentDto privateProject = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(newModuleDto(privateProject));
- ShowWsResponse result = newRequest(null, module.key());
+ ShowWsResponse result = newRequest(null, module.getDbKey());
assertThat(result.getComponent().hasVisibility()).isFalse();
}
public void fail_if_component_is_removed() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
+ db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Component key 'file-key' not found");
private void insertJsonExampleComponentsAndSnapshots() {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW")
- .setKey("com.sonarsource:java-markdown")
+ .setDbKey("com.sonarsource:java-markdown")
.setName("Java Markdown")
.setDescription("Java Markdown Project")
.setQualifier(Qualifiers.PROJECT)
.setCreatedAt(parseDateTime("2017-03-01T11:39:03+0100").getTime())
.setPeriodDate(parseDateTime("2017-01-01T11:39:03+0100").getTime()));
ComponentDto directory = newDirectory(project, "AVIF-FfgA3Ax6PH2efPF", "src/main/java/com/sonarsource/markdown/impl")
- .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
+ .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
.setName("src/main/java/com/sonarsource/markdown/impl")
.setQualifier(Qualifiers.DIRECTORY);
db.components().insertComponent(directory);
db.components().insertComponent(
newFileDto(directory, directory, "AVIF-FffA3Ax6PH2efPD")
- .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java")
+ .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java")
.setName("Rule.java")
.setPath("src/main/java/com/sonarsource/markdown/impl/Rule.java")
.setLanguage("java")
@Test
public void test_example_json_response() {
OrganizationDto organization = db.organizations().insert(o -> o.setKey("default-organization").setName("Default Organization"));
- ComponentDto project1 = db.components().insertPublicProject(organization, p -> p.setKey("org.sonarsource:sonarqube").setName("SonarSource :: SonarQube"));
- ComponentDto project2 = db.components().insertPublicProject(organization, p -> p.setKey("org.sonarsource:sonarlint").setName("SonarSource :: SonarLint"));
+ ComponentDto project1 = db.components().insertPublicProject(organization, p -> p.setDbKey("org.sonarsource:sonarqube").setName("SonarSource :: SonarQube"));
+ ComponentDto project2 = db.components().insertPublicProject(organization, p -> p.setDbKey("org.sonarsource:sonarlint").setName("SonarSource :: SonarLint"));
componentIndexer.indexOnStartup(null);
authorizationIndexerTester.allowOnlyAnyone(project1);
authorizationIndexerTester.allowOnlyAnyone(project2);
TestResponse wsResponse = ws.newRequest()
.setParam(PARAM_QUERY, "Sonar")
- .setParam(PARAM_RECENTLY_BROWSED, project1.key())
+ .setParam(PARAM_RECENTLY_BROWSED, project1.getDbKey())
.setMethod("POST")
.setMediaType(MediaTypes.JSON)
.execute();
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
// assert match in qualifier "TRK"
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsRecentlyBrowsed)
- .containsExactly(tuple(project.getKey(), true));
+ .containsExactly(tuple(project.getDbKey(), true));
}
@Test
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
// assert match in qualifier "TRK"
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsRecentlyBrowsed)
- .containsExactly(tuple(project.getKey(), true));
+ .containsExactly(tuple(project.getDbKey(), true));
}
@Test
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.getKey())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsFavorite)
- .containsExactly(tuple(project.getKey(), true));
+ .containsExactly(tuple(project.getDbKey(), true));
}
@Test
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.key())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
// assert match in qualifier "TRK"
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsFavorite, Suggestion::getIsRecentlyBrowsed)
- .containsExactly(tuple(project.getKey(), true, true));
+ .containsExactly(tuple(project.getDbKey(), true, true));
}
@Test
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, Stream.of(project3, project1).map(ComponentDto::getKey).collect(joining(",")))
+ .setParam(PARAM_RECENTLY_BROWSED, Stream.of(project3, project1).map(ComponentDto::getDbKey).collect(joining(",")))
.executeProtobuf(SuggestionsWsResponse.class);
// assert order of keys
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.key())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_RECENTLY_BROWSED, project.key())
+ .setParam(PARAM_RECENTLY_BROWSED, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_QUERY, project.getKey())
+ .setParam(PARAM_QUERY, project.getDbKey())
.executeProtobuf(SuggestionsWsResponse.class);
// assert match in qualifier "TRK"
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getOrganization)
- .containsExactly(tuple(project.getKey(), organization.getKey()));
+ .containsExactly(tuple(project.getDbKey(), organization.getKey()));
}
@Test
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey)
- .contains(project.getKey());
+ .contains(project.getDbKey());
assertThat(response.getWarning()).contains(SHORT_INPUT_WARNING);
}
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getName)
- .containsExactlyInAnyOrder(tuple(project1.getKey(), project1.name()));
+ .containsExactlyInAnyOrder(tuple(project1.getDbKey(), project1.name()));
}
@Test
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getProject)
- .containsOnly(project.key());
+ .containsOnly(project.getDbKey());
assertThat(response.getProjectsList())
.extracting(Project::getKey, Project::getName)
.containsExactlyInAnyOrder(
- tuple(project.key(), project.longName()));
+ tuple(project.getDbKey(), project.longName()));
}
@Test
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_QUERY, "Module")
- .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getKey()).collect(joining(",")))
+ .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey()).collect(joining(",")))
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsFavorite)
- .containsExactly(tuple(favorite.getKey(), true), tuple(nonFavorite.getKey(), false));
+ .containsExactly(tuple(favorite.getDbKey(), true), tuple(nonFavorite.getDbKey(), false));
}
@Test
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto view = newView(organizationDto, "view-uuid");
componentDb.insertViewAndSnapshot(view);
- ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid-1").setName("project-name").setKey("project-key-1");
+ ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid-1").setName("project-name").setDbKey("project-key-1");
componentDb.insertProjectAndSnapshot(project);
componentDb.insertComponent(newProjectCopy("project-uuid-1-copy", project, view));
componentDb.insertComponent(newSubView(view, "sub-view-uuid", "sub-view-key").setName("sub-view-name"));
@Test
public void fail_when_base_component_is_removed() {
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- componentDb.insertComponent(ComponentTesting.newFileDto(project).setKey("file-key").setEnabled(false));
+ componentDb.insertComponent(ComponentTesting.newFileDto(project).setDbKey("file-key").setEnabled(false));
logInWithBrowsePermission(project);
expectedException.expect(NotFoundException.class);
private static ComponentDto newFileDto(ComponentDto moduleOrProject, @Nullable ComponentDto directory, int i) {
return ComponentTesting.newFileDto(moduleOrProject, directory, "file-uuid-" + i)
.setName("file-name-" + i)
- .setKey("file-key-" + i)
+ .setDbKey("file-key-" + i)
.setPath("file-path-" + i);
}
private ComponentDto initJsonExampleComponents() throws IOException {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
ComponentDto project = newPrivateProjectDto(organizationDto, "MY_PROJECT_ID")
- .setKey("MY_PROJECT_KEY")
+ .setDbKey("MY_PROJECT_KEY")
.setName("Project Name");
componentDb.insertProjectAndSnapshot(project);
Date now = new Date();
JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject();
String uuid = getJsonField(componentAsJsonObject, "id");
componentDb.insertComponent(newChildComponent(uuid, project, project)
- .setKey(getJsonField(componentAsJsonObject, "key"))
+ .setDbKey(getJsonField(componentAsJsonObject, "key"))
.setName(getJsonField(componentAsJsonObject, "name"))
.setLanguage(getJsonField(componentAsJsonObject, "language"))
.setPath(getJsonField(componentAsJsonObject, "path"))
ComponentDto project = db.components().insertPrivateProject(organization);
mockSuccessfulPrepareSubmitCall();
- underTest.submit(organization.getKey(), project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
+ underTest.submit(organization.getKey(), project.getDbKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
}
@Test
mockSuccessfulPrepareSubmitCall();
- underTest.submit(defaultOrganizationKey, project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
+ underTest.submit(defaultOrganizationKey, project.getDbKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
verifyReportIsPersisted(TASK_UUID);
verifyZeroInteractions(permissionTemplateService);
.addPermission(PROVISION_PROJECTS, organization);
mockSuccessfulPrepareSubmitCall();
- ComponentDto createdProject = newPrivateProjectDto(organization, PROJECT_UUID).setKey(PROJECT_KEY);
+ ComponentDto createdProject = newPrivateProjectDto(organization, PROJECT_UUID).setDbKey(PROJECT_KEY);
when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(createdProject);
when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(organization.getUuid()), anyInt(), anyString(),
eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
.addPermission(PROVISION_PROJECTS, db.getDefaultOrganization());
mockSuccessfulPrepareSubmitCall();
- ComponentDto createdProject = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
+ ComponentDto createdProject = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setDbKey(PROJECT_KEY);
when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(createdProject);
when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(defaultOrganizationUuid), anyInt(), anyString(),
eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
.addPermission(PROVISION_PROJECTS, db.getDefaultOrganization());
mockSuccessfulPrepareSubmitCall();
- ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
+ ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setDbKey(PROJECT_KEY);
when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(project);
when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(DbSession.class), eq(defaultOrganizationUuid), anyInt(), anyString(),
eq(PROJECT_KEY), eq(Qualifiers.PROJECT)))
mockSuccessfulPrepareSubmitCall();
- underTest.submit(org.getKey(), project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
+ underTest.submit(org.getKey(), project.getDbKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
verify(queue).submit(any(CeTaskSubmit.class));
}
mockSuccessfulPrepareSubmitCall();
- underTest.submit(defaultOrganizationKey, project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
+ underTest.submit(defaultOrganizationKey, project.getDbKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
verify(queue).submit(any(CeTaskSubmit.class));
}
userSession.addProjectPermission(SCAN_EXECUTION, ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
mockSuccessfulPrepareSubmitCall();
- when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(new ComponentDto().setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+ when(componentUpdater.create(any(DbSession.class), any(NewComponent.class), eq(null))).thenReturn(new ComponentDto().setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
thrown.expect(ForbiddenException.class);
underTest.submit(defaultOrganizationKey, PROJECT_KEY, null, PROJECT_NAME, IOUtils.toInputStream("{binary}"));
// user does not have the "scan" permission on the branch, so it can't scan it
String branchName = "branchFoo";
- ComponentDto branchProject = db.components().insertPrivateProject(p -> p.setKey(mainProject.getKey() + ":" + branchName));
+ ComponentDto branchProject = db.components().insertPrivateProject(p -> p.setDbKey(mainProject.getDbKey() + ":" + branchName));
thrown.expect(ForbiddenException.class);
- underTest.submit(defaultOrganizationKey, mainProject.key(), branchName, PROJECT_NAME, IOUtils.toInputStream("{binary}"));
+ underTest.submit(defaultOrganizationKey, mainProject.getDbKey(), branchName, PROJECT_NAME, IOUtils.toInputStream("{binary}"));
}
private void verifyReportIsPersisted(String taskUuid) {
@Test
public void get_project_settings_from_db() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setDbKey(ROOT.getKey());
dbClient.componentDao().insert(session, project);
dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"));
session.commit();
assertThat(movedFilesRepository.getComponentsWithOriginal()).containsExactly(FILE_2);
MovedFilesRepository.OriginalFile originalFile = movedFilesRepository.getOriginalFile(FILE_2).get();
assertThat(originalFile.getId()).isEqualTo(dtos[0].getId());
- assertThat(originalFile.getKey()).isEqualTo(dtos[0].getKey());
+ assertThat(originalFile.getKey()).isEqualTo(dtos[0].getDbKey());
assertThat(originalFile.getUuid()).isEqualTo(dtos[0].uuid());
}
assertThat(movedFilesRepository.getComponentsWithOriginal()).containsOnly(FILE_3, file6);
MovedFilesRepository.OriginalFile originalFile2 = movedFilesRepository.getOriginalFile(FILE_3).get();
assertThat(originalFile2.getId()).isEqualTo(dtos[0].getId());
- assertThat(originalFile2.getKey()).isEqualTo(dtos[0].getKey());
+ assertThat(originalFile2.getKey()).isEqualTo(dtos[0].getDbKey());
assertThat(originalFile2.getUuid()).isEqualTo(dtos[0].uuid());
MovedFilesRepository.OriginalFile originalFile5 = movedFilesRepository.getOriginalFile(file6).get();
assertThat(originalFile5.getId()).isEqualTo(dtos[3].getId());
- assertThat(originalFile5.getKey()).isEqualTo(dtos[3].getKey());
+ assertThat(originalFile5.getKey()).isEqualTo(dtos[3].getDbKey());
assertThat(originalFile5.getUuid()).isEqualTo(dtos[3].uuid());
}
ComponentDto res = new ComponentDto();
res
.setId(dbIdGenerator)
- .setKey(key)
+ .setDbKey(key)
.setUuid(componentUuidOf(key))
.setPath("path_" + key);
dbIdGenerator++;
}
private void addBaseIssue(RuleKey ruleKey) {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY);
- ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setDbKey(PROJECT_KEY);
+ ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setDbKey(FILE_KEY);
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, file);
RuleDto ruleDto = RuleTesting.newDto(ruleKey);
@Test
public void return_existing_uuids() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
- ComponentDto module = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY));
+ ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
+ ComponentDto module = insertComponent(newModuleDto("BCDE", project).setDbKey(REPORT_MODULE_KEY));
ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_KEY_1);
- insertComponent(directory.setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
- insertComponent(newFileDto(module, directory, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1));
+ insertComponent(directory.setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1));
+ insertComponent(newFileDto(module, directory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
@Test
public void return_existing_uuids_when_components_were_removed() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
- ComponentDto removedModule = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY).setEnabled(false));
- ComponentDto removedDirectory = insertComponent(newDirectory(removedModule, "CDEF", REPORT_DIR_KEY_1).setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1).setEnabled(false));
- insertComponent(newFileDto(removedModule, removedDirectory, "DEFG").setKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
+ ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
+ ComponentDto removedModule = insertComponent(newModuleDto("BCDE", project).setDbKey(REPORT_MODULE_KEY).setEnabled(false));
+ ComponentDto removedDirectory = insertComponent(newDirectory(removedModule, "CDEF", REPORT_DIR_KEY_1).setDbKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1).setEnabled(false));
+ insertComponent(newFileDto(removedModule, removedDirectory, "DEFG").setDbKey(REPORT_MODULE_KEY + ":" + REPORT_FILE_KEY_1).setEnabled(false));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, MODULE_REF));
reportReader.putComponent(componentWithKey(MODULE_REF, MODULE, REPORT_MODULE_KEY, DIR_REF_1));
@Test
public void set_no_base_project_snapshot_when_no_last_snapshot() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+ ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
insertSnapshot(newAnalysis(project).setLast(false));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
@Test
public void set_base_project_snapshot_when_last_snapshot_exist() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY));
+ ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setDbKey(REPORT_PROJECT_KEY));
insertSnapshot(newAnalysis(project).setLast(true));
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
.build()),
Arrays.asList(
new Block.Builder()
- .setResourceId(otherFile.getKey())
+ .setResourceId(otherFile.getDbKey())
.setBlockHash(new ByteArray(hash))
.setIndexInFile(duplicate.getIndexInFile())
.setLines(duplicate.getStartLine(), duplicate.getEndLine())
Map<Integer, Block> duplicationBlocksByIndex = blocksByIndexInFile(duplicationBlocks.getValue());
assertThat(duplicationBlocksByIndex.get(0)).isEqualTo(
new Block.Builder()
- .setResourceId(otherFile.getKey())
+ .setResourceId(otherFile.getDbKey())
.setBlockHash(new ByteArray(originBlock1.getHash()))
.setIndexInFile(duplicate1.getIndexInFile())
.setLines(duplicate1.getStartLine(), duplicate1.getEndLine())
.build());
assertThat(duplicationBlocksByIndex.get(1)).isEqualTo(
new Block.Builder()
- .setResourceId(otherFile.getKey())
+ .setResourceId(otherFile.getDbKey())
.setBlockHash(new ByteArray(originBlock2.getHash()))
.setIndexInFile(duplicate2.getIndexInFile())
.setLines(duplicate2.getStartLine(), duplicate2.getEndLine())
}
private ComponentDto createProject(String projectKey) {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(projectKey);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setDbKey(projectKey);
dbClient.componentDao().insert(dbSession, project);
dbSession.commit();
return project;
private ComponentDto createFile(String fileKey, ComponentDto project) {
ComponentDto file = ComponentTesting.newFileDto(project, null)
- .setKey(fileKey)
+ .setDbKey(fileKey)
.setLanguage(XOO_LANGUAGE);
dbClient.componentDao().insert(dbSession, file);
dbSession.commit();
private ComponentDto addComponent(String key, String uuid) {
ComponentDto componentDto = new ComponentDto()
.setOrganizationUuid("org1")
- .setKey(key)
+ .setDbKey(key)
.setUuid(uuid)
.setUuidPath(uuid + ".")
.setRootUuid(uuid)
@Test
public void persist_analysis() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
- ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
+ ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setDbKey("MODULE_KEY").setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), moduleDto);
- ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
+ ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setDbKey("MODULE_KEY:src/main/java/dir");
dbClient.componentDao().insert(dbTester.getSession(), directoryDto);
- ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), fileDto);
dbTester.getSession().commit();
@Test
public void persist_snapshots_with_leak_period() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1"));
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
- ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
+ ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setDbKey("MODULE_KEY").setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), moduleDto);
- ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setKey("MODULE_KEY:src/main/java/dir");
+ ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setDbKey("MODULE_KEY:src/main/java/dir");
dbClient.componentDao().insert(dbTester.getSession(), directoryDto);
- ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), fileDto);
dbTester.getSession().commit();
@Test
public void set_no_period_on_snapshots_when_no_period() {
- ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), projectDto);
SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto);
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
@Test
public void persist_only_new_components() {
// Project and module already exists
- ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
}
private ReportComponent.Builder asTreeRoot(ComponentDto project) {
- return builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.key()).setName(project.name());
+ return builder(PROJECT, 1).setUuid(project.uuid()).setKey(project.getDbKey()).setName(project.name());
}
public ComponentDto insertProject() {
@Test
public void nothing_to_persist() {
- ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), module);
- ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir");
+ ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_KEY:src/main/java/dir");
ComponentDto file = ComponentTesting.newFileDto(module, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
- .setKey("MODULE_KEY:src/main/java/dir/Foo.java");
+ .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), directory, file);
dbTester.getSession().commit();
@Test
public void update_module_name_and_description() {
- ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description");
+ ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setDbKey(PROJECT_KEY).setName("Project").setDescription("Project description");
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
@Test
public void update_module_path() {
- ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path");
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module").setPath("path");
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
@Test
public void update_module_uuid_when_moving_a_module() {
- ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project)
- .setKey("MODULE_A")
+ .setDbKey("MODULE_A")
.setName("Module A");
ComponentDto moduleB = ComponentTesting.newModuleDto("BCDE", project)
- .setKey("MODULE_B")
+ .setDbKey("MODULE_B")
.setName("Module B");
dbClient.componentDao().insert(dbTester.getSession(), moduleA, moduleB);
- ComponentDto directory = ComponentTesting.newDirectory(moduleB, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_B:src/main/java/dir");
+ ComponentDto directory = ComponentTesting.newDirectory(moduleB, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_B:src/main/java/dir");
ComponentDto file = ComponentTesting.newFileDto(moduleB, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
- .setKey("MODULE_B:src/main/java/dir/Foo.java");
+ .setDbKey("MODULE_B:src/main/java/dir/Foo.java");
dbClient.componentDao().insert(dbTester.getSession(), directory, file);
dbTester.getSession().commit();
@Test
public void do_not_update_created_at_on_existing_component() {
Date oldDate = DateUtils.parseDate("2015-01-01");
- ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate);
+ ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setDbKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate);
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path").setCreatedAt(oldDate);
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module").setPath("path").setCreatedAt(oldDate);
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
@Test
public void persist_components_that_were_previously_removed() {
- ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project)
- .setKey(MODULE_KEY)
+ .setDbKey(MODULE_KEY)
.setName("Module")
.setEnabled(false);
dbClient.componentDao().insert(dbTester.getSession(), removedModule);
ComponentDto removedDirectory = ComponentTesting.newDirectory(removedModule, "src/main/java/dir")
.setUuid("CDEF")
- .setKey("MODULE_KEY:src/main/java/dir")
+ .setDbKey("MODULE_KEY:src/main/java/dir")
.setEnabled(false);
ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, removedDirectory, "DEFG")
.setPath("src/main/java/dir/Foo.java")
.setName("Foo.java")
- .setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+ .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java")
.setEnabled(false);
dbClient.componentDao().insert(dbTester.getSession(), removedDirectory, removedFile);
dbTester.getSession().commit();
assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get().getId()).isEqualTo(removedModule.getId());
assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get().getId()).isEqualTo(removedDirectory.getId());
assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(removedFile.getId());
- assertExistButDisabled(removedModule.key(), removedDirectory.getKey(), removedFile.getKey());
+ assertExistButDisabled(removedModule.getDbKey(), removedDirectory.getDbKey(), removedFile.getDbKey());
// commit the functional transaction
dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), project.uuid());
@Test
public void update_module_uuid_when_reactivating_removed_component() {
- ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project");
+ ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(dbTester.getSession(), project);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module");
- ComponentDto removedModule = ComponentTesting.newModuleDto("EDCD", project).setKey("REMOVED_MODULE_KEY").setName("Removed Module").setEnabled(false);
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setDbKey(MODULE_KEY).setName("Module");
+ ComponentDto removedModule = ComponentTesting.newModuleDto("EDCD", project).setDbKey("REMOVED_MODULE_KEY").setName("Removed Module").setEnabled(false);
dbClient.componentDao().insert(dbTester.getSession(), module, removedModule);
- ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir");
+ ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setDbKey("MODULE_KEY:src/main/java/dir");
// The file was attached to another module
ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, directory, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java")
- .setKey("MODULE_KEY:src/main/java/dir/Foo.java").setEnabled(false);
+ .setDbKey("MODULE_KEY:src/main/java/dir/Foo.java").setEnabled(false);
dbClient.componentDao().insert(dbTester.getSession(), directory, removedFile);
dbTester.getSession().commit();
public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
boolean isRootPrivate = new Random().nextBoolean();
OrganizationDto organization = dbTester.organizations().insert();
- ComponentDto project = newPrivateProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
+ ComponentDto project = newPrivateProjectDto(organization, "ABCD").setDbKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate);
dbTester.components().insertComponent(project);
- ComponentDto module = newModuleDto(project).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
+ ComponentDto module = newModuleDto(project).setUuid("BCDE").setDbKey("MODULE").setPrivate(!isRootPrivate);
dbTester.components().insertComponent(module);
- dbTester.components().insertComponent(newDirectory(module, "DEFG", "Directory").setKey("DIR").setPrivate(isRootPrivate));
+ dbTester.components().insertComponent(newDirectory(module, "DEFG", "Directory").setDbKey("DIR").setPrivate(isRootPrivate));
treeRootHolder.setRoot(createSampleProjectComponentTree(project));
underTest.execute();
}
private ReportComponent createSampleProjectComponentTree(ComponentDto project) {
- return createSampleProjectComponentTree(project.uuid(), project.key());
+ return createSampleProjectComponentTree(project.uuid(), project.getDbKey());
}
private ReportComponent createSampleProjectComponentTree(String projectUuid, String projectKey) {
import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
public class ValidateProjectStepTest {
.build());
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- ComponentDto project = ComponentTesting.newView(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
+ ComponentDto project = ComponentTesting.newView(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
dbTester.getSession().commit();
.setKey(MODULE_KEY)
.build());
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(MODULE_KEY);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(MODULE_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
dbTester.getSession().commit();
.build());
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY);
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(organizationDto).setKey(anotherProjectKey);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setDbKey(PROJECT_KEY);
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(anotherProjectKey);
dbClient.componentDao().insert(dbTester.getSession(), project, anotherProject);
- ComponentDto module = ComponentTesting.newModuleDto("BCDE", anotherProject).setKey(MODULE_KEY);
+ ComponentDto module = ComponentTesting.newModuleDto("BCDE", anotherProject).setDbKey(MODULE_KEY);
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
.setKey(MODULE_KEY)
.build());
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(anotherProjectKey);
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setDbKey(anotherProjectKey);
dbClient.componentDao().insert(dbTester.getSession(), anotherProject);
- ComponentDto module = ComponentTesting.newModuleDto("ABCD", anotherProject).setKey(PROJECT_KEY);
+ ComponentDto module = ComponentTesting.newModuleDto("ABCD", anotherProject).setDbKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), module);
dbTester.getSession().commit();
.addChildRef(2)
.build());
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1420088400000L)); // 2015-01-01
dbTester.getSession().commit();
.addChildRef(2)
.build());
- ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setDbKey(PROJECT_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project);
dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1433131200000L)); // 2015-06-01
dbTester.getSession().commit();
@Test
public void persist_analysis() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW"));
+ ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setDbKey("KEY_VIEW"));
save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
save(newPrivateProjectDto(organizationDto, "proj"));
dbTester.getSession().commit();
@Test
public void persist_snapshots_with_leak_period() {
OrganizationDto organizationDto = dbTester.organizations().insert();
- ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW"));
+ ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setDbKey("KEY_VIEW"));
ComponentDto subViewDto = save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
dbTester.getSession().commit();
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
+import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT_VIEW;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.SUBVIEW;
persistComponents(view, project);
ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view)
.setOrganizationUuid(ORGANIZATION_UUID)
- .setKey(PROJECT_VIEW_1_KEY)
+ .setDbKey(PROJECT_VIEW_1_KEY)
.setName("Old name")
.setCreatedAt(now);
persistComponents(projectView);
// Project view in DB is associated to project1
ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view)
- .setKey(PROJECT_VIEW_1_KEY)
+ .setDbKey(PROJECT_VIEW_1_KEY)
.setCreatedAt(now);
persistComponents(projectView);
boolean isRootPrivate = new Random().nextBoolean();
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
OrganizationDto organization = dbTester.organizations().insert();
- ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
+ ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setDbKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
dbTester.components().insertComponent(view);
treeRootHolder.setRoot(
createViewBuilder(PORTFOLIO)
boolean isRootPrivate = new Random().nextBoolean();
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()));
OrganizationDto organization = dbTester.organizations().insert();
- ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
+ ComponentDto view = newViewDto(organization).setUuid(VIEW_UUID).setDbKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
dbTester.components().insertComponent(view);
- ComponentDto subView = newSubView(view).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
+ ComponentDto subView = newSubView(view).setUuid("BCDE").setDbKey("MODULE").setPrivate(!isRootPrivate);
dbTester.components().insertComponent(subView);
- dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setKey("DIR").setPrivate(isRootPrivate));
+ dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setDbKey("DIR").setPrivate(isRootPrivate));
treeRootHolder.setRoot(
createViewBuilder(PORTFOLIO)
.addChildren(
private ComponentDto newViewDto(OrganizationDto organizationDto) {
return ComponentTesting.newView(organizationDto, VIEW_UUID)
.setOrganizationUuid(ORGANIZATION_UUID)
- .setKey(VIEW_KEY)
+ .setDbKey(VIEW_KEY)
.setName(VIEW_NAME);
}
project1 = ComponentTesting.newPrivateProjectDto(organizationDto)
.setName("SonarQube")
.setLongName("SonarQube")
- .setKey("org.codehaus.sonar:sonar");
+ .setDbKey("org.codehaus.sonar:sonar");
project2 = ComponentTesting.newPrivateProjectDto(organizationDto);
componentDao.insert(dbSession, project1, project2);
// Current file
String key1 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java";
- currentFile = newFileDto(project1, null).setKey(key1).setLongName("CommandExecutor");
+ currentFile = newFileDto(project1, null).setDbKey(key1).setLongName("CommandExecutor");
// File on same project
String key2 = "org.codehaus.sonar:sonar-plugin-api:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
- fileOnSameProject = newFileDto(project1, null).setKey(key2).setLongName("CommandExecutor");
+ fileOnSameProject = newFileDto(project1, null).setDbKey(key2).setLongName("CommandExecutor");
// File on different project
String key3 = "com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java";
- fileOnDifferentProject = newFileDto(project2, null).setKey(key3).setLongName("CommandExecutor");
+ fileOnDifferentProject = newFileDto(project2, null).setDbKey(key3).setLongName("CommandExecutor");
componentDao.insert(dbSession, currentFile, fileOnSameProject, fileOnDifferentProject);
dbSession.commit();
assertThat(duplication1.from()).isEqualTo(31);
assertThat(duplication1.size()).isEqualTo(5);
- DuplicationsParser.Duplication duplication2 = duplication(duplications, fileOnSameProject.key());
+ DuplicationsParser.Duplication duplication2 = duplication(duplications, fileOnSameProject.getDbKey());
assertThat(duplication2.file()).isEqualTo(fileOnSameProject);
assertThat(duplication2.from()).isEqualTo(20);
assertThat(duplication2.size()).isEqualTo(5);
return Iterables.find(duplications, new Predicate<DuplicationsParser.Duplication>() {
@Override
public boolean apply(@Nullable DuplicationsParser.Duplication input) {
- return input != null && (componentKey == null ? input.file() == null : input.file() != null && componentKey.equals(input.file().key()));
+ return input != null && (componentKey == null ? input.file() == null : input.file() != null && componentKey.equals(input.file().getDbKey()));
}
});
}
@Test
public void get_duplications_by_file_key() throws Exception {
TestRequest request = newBaseRequest();
- verifyCallToFileWithDuplications(file -> request.setParam("key", file.key()));
+ verifyCallToFileWithDuplications(file -> request.setParam("key", file.getDbKey()));
}
@Test
@Test
public void return_file_with_missing_duplication_data() throws Exception {
ComponentDto project = db.components().insertPrivateProject();
- ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
+ ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("foo.js"));
db.components().insertSnapshot(newAnalysis(project));
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project);
- TestResponse result = newBaseRequest().setParam("key", file.key()).execute();
+ TestResponse result = newBaseRequest().setParam("key", file.getDbKey()).execute();
assertJson(result.getInput()).isSimilarTo("{\n" +
" \"duplications\": [],\n" +
expectedException.expect(ForbiddenException.class);
- newBaseRequest().setParam("key", file.key()).execute();
+ newBaseRequest().setParam("key", file.getDbKey()).execute();
}
@Test
private void verifyCallToFileWithDuplications(Function<ComponentDto, TestRequest> requestFactory) throws Exception {
ComponentDto project = db.components().insertPrivateProject();
- ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js"));
+ ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("foo.js"));
SnapshotDto snapshot = db.components().insertSnapshot(newAnalysis(project));
String xml = "<duplications>\n" +
" <g>\n" +
project = newPrivateProjectDto(organization)
.setName("SonarQube")
.setLongName("SonarQube")
- .setKey("org.codehaus.sonar:sonar");
+ .setDbKey("org.codehaus.sonar:sonar");
db.components().insertComponent(project);
}
@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, null).setKey(key1).setLongName("PropertyDeleteQuery").setRootUuid("uuid_5");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setDbKey(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, null).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5");
- ComponentDto project2 = db.components().insertPrivateProject(organization, p -> p.setUuid("uuid_5").setKey("org.codehaus.sonar:sonar-ws-client")
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setQualifier("FIL").setDbKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5");
+ ComponentDto project2 = db.components().insertPrivateProject(organization, p -> p.setUuid("uuid_5").setDbKey("org.codehaus.sonar:sonar-ws-client")
.setLongName("SonarQube :: Web Service Client"));
db.components().insertComponent(file1);
@Test
public void write_duplications_without_sub_project() {
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
- ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setDbKey(key1).setLongName("PropertyDeleteQuery");
String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java";
- ComponentDto file2 = ComponentTesting.newFileDto(project, null).setId(11L).setKey(key2).setLongName("PropertyUpdateQuery");
+ ComponentDto file2 = ComponentTesting.newFileDto(project, null).setId(11L).setDbKey(key2).setLongName("PropertyUpdateQuery");
db.components().insertComponent(file1);
db.components().insertComponent(file2);
@Test
public void write_duplications_with_a_removed_component() {
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java";
- ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery");
+ ComponentDto file1 = ComponentTesting.newFileDto(project, null).setId(10L).setDbKey(key1).setLongName("PropertyDeleteQuery");
db.components().insertComponent(file1);
List<DuplicationsParser.Block> blocks = newArrayList();
private static final String COMPONENT_KEY = "K1";
private static final ComponentDto COMPONENT = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto())
.setId(COMPONENT_ID)
- .setKey(COMPONENT_KEY);
+ .setDbKey(COMPONENT_KEY);
private static final int USER_ID = 42;
@Rule
ComponentDto file = db.components().insertComponent(newFileDto(project));
userSession.addProjectPermission(UserRole.USER, project, file);
- call(file.key());
+ call(file.getDbKey());
List<PropertyDto> favorites = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder()
.setUserId(USER_ID)
}
private ComponentDto insertProject() {
- return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
+ return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setDbKey(PROJECT_KEY));
}
private ComponentDto insertProjectAndPermissions() {
}
private ComponentDto insertProject() {
- return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY));
+ return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setDbKey(PROJECT_KEY));
}
private ComponentDto insertProjectAndPermissions() {
@Test
public void return_favorites() {
- ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "P1").setKey("K1").setName("N1");
+ ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "P1").setDbKey("K1").setName("N1");
addComponent(project);
- addComponent(newFileDto(project).setKey("K11").setName("N11"));
- addComponent(newPrivateProjectDto(db.getDefaultOrganization(), "P2").setKey("K2").setName("N2"));
+ addComponent(newFileDto(project).setDbKey("K11").setName("N11"));
+ addComponent(newPrivateProjectDto(db.getDefaultOrganization(), "P2").setDbKey("K2").setName("N2"));
SearchResponse result = call();
@Test
public void filter_authorized_components() {
OrganizationDto organizationDto = db.organizations().insert();
- addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1"));
+ addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("K1"));
ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto));
db.favorites().add(unauthorizedProject, USER_ID);
@Test
public void paginate_results() {
IntStream.rangeClosed(1, 9)
- .forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("K" + i).setName("N" + i)));
+ .forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("K" + i).setName("N" + i)));
ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
db.favorites().add(unauthorizedProject, USER_ID);
@Test
public void return_only_users_favorite() {
OrganizationDto organizationDto = db.organizations().insert();
- addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1"));
- ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K42");
+ addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("K1"));
+ ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("K42");
db.components().insertComponent(otherUserFavorite);
db.favorites().add(otherUserFavorite, 42);
db.commit();
public void json_example() {
OrganizationDto organization1 = db.organizations().insertForKey("my-org");
OrganizationDto organization2 = db.organizations().insertForKey("openjdk");
- addComponent(ComponentTesting.newPrivateProjectDto(organization1).setKey("K1").setName("Samba"));
- addComponent(ComponentTesting.newPrivateProjectDto(organization1).setKey("K2").setName("Apache HBase"));
- addComponent(ComponentTesting.newPrivateProjectDto(organization2).setKey("K3").setName("JDK9"));
+ addComponent(ComponentTesting.newPrivateProjectDto(organization1).setDbKey("K1").setName("Samba"));
+ addComponent(ComponentTesting.newPrivateProjectDto(organization1).setDbKey("K2").setName("Apache HBase"));
+ addComponent(ComponentTesting.newPrivateProjectDto(organization2).setDbKey("K3").setName("JDK9"));
String result = ws.newRequest().execute().getInput();
@Rule
public UserSessionRule userSession = UserSessionRule.standalone().logIn("arthur");
- private ComponentDto project = newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setKey(PROJECT_KEY);
+ private ComponentDto project = newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setDbKey(PROJECT_KEY);
private IssueDto issue = newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY);
private ActionFinder underTest = new ActionFinder(userSession);
.setStatuses(asList("CLOSED"))
.setResolutions(asList("FALSE-POSITIVE"))
.setResolved(true)
- .setProjectKeys(asList(project.key()))
+ .setProjectKeys(asList(project.getDbKey()))
.setModuleUuids(asList(module.uuid()))
.setDirectories(asList("aDirPath"))
.setFileUuids(asList(file.uuid()))
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
SearchWsRequest request = new SearchWsRequest()
- .setComponentRoots(asList(project.key(), file.key()));
+ .setComponentRoots(asList(project.getDbKey(), file.getDbKey()));
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("All components must have the same qualifier, found FIL,TRK");
public void onComponentOnly_restricts_search_to_specified_componentKeys() {
ComponentDto project = db.components().insertPrivateProject();
SearchWsRequest request = new SearchWsRequest()
- .setComponentKeys(asList(project.key()))
+ .setComponentKeys(asList(project.getDbKey()))
.setOnComponentOnly(true);
IssueQuery query = underTest.create(request);
assertThat(issueChangeNotification.getFieldValue("key")).isEqualTo(issue.key());
assertThat(issueChangeNotification.getFieldValue("old.severity")).isEqualTo(MAJOR);
assertThat(issueChangeNotification.getFieldValue("new.severity")).isEqualTo(BLOCKER);
- assertThat(issueChangeNotification.getFieldValue("componentKey")).isEqualTo(file.key());
+ assertThat(issueChangeNotification.getFieldValue("componentKey")).isEqualTo(file.getDbKey());
assertThat(issueChangeNotification.getFieldValue("componentName")).isEqualTo(file.longName());
- assertThat(issueChangeNotification.getFieldValue("projectKey")).isEqualTo(project.key());
+ assertThat(issueChangeNotification.getFieldValue("projectKey")).isEqualTo(project.getDbKey());
assertThat(issueChangeNotification.getFieldValue("projectName")).isEqualTo(project.name());
assertThat(issueChangeNotification.getFieldValue("ruleName")).isEqualTo(rule.getName());
assertThat(issueChangeNotification.getFieldValue("changeAuthor")).isEqualTo("john");
userSessionRule.logIn(user1);
assertThatSearchReturnsOnly(IssueQuery.builder(), "I1");
- assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(asList(project3.key())));
+ assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(asList(project3.getDbKey())));
userSessionRule.logIn(user2);
assertThatSearchReturnsOnly(IssueQuery.builder(), "I2");
@Test
public void set_component() {
- IssueChangeNotification result = notification.setComponent(new ComponentDto().setKey("MyService").setLongName("My Service"));
+ IssueChangeNotification result = notification.setComponent(new ComponentDto().setDbKey("MyService").setLongName("My Service"));
assertThat(result.getFieldValue("componentName")).isEqualTo("My Service");
}
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("key")).isEqualTo(issueDto.getKey());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("componentName")).isEqualTo(file.longName());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("projectName")).isEqualTo(project.longName());
- assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("projectKey")).isEqualTo(project.key());
+ assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("projectKey")).isEqualTo(project.getDbKey());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("ruleName")).isEqualTo(rule.getName());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("changeAuthor")).isEqualTo(user.getLogin());
}
@Test
public void issues_on_different_projects() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
IssueDto issue = IssueTesting.newDto(rule, file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setStatus("OPEN").setResolution("OPEN")
.setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
db.issueDao().insert(session, issue);
- ComponentDto project2 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P2").setKey("PK2"));
- ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
+ ComponentDto project2 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P2").setDbKey("PK2"));
+ ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setDbKey("FK2"));
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2)
.setKee("92fd47d4-b650-4037-80bc-7b112bd4eac2")
.setStatus("OPEN").setResolution("OPEN")
@Test
public void do_not_return_module_key_on_single_module_projects() throws IOException {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
- ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto module = insertComponent(newModuleDto("M1", project).setDbKey("MK1"));
+ ComponentDto file = insertComponent(newFileDto(module, null, "F1").setDbKey("FK1"));
RuleDto newRule = newRule();
IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
@Test
public void search_by_project_uuid() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@Test
public void search_since_leak_period_on_project() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
db.snapshotDao().insert(session,
newAnalysis(project)
.setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
@Test
public void search_since_leak_period_on_file_in_module_project() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
ComponentDto module = insertComponent(newModuleDto(project));
- ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
+ ComponentDto file = insertComponent(newFileDto(module, null, "F1").setDbKey("FK1"));
db.snapshotDao().insert(session,
newAnalysis(project).setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
RuleDto rule = newRule();
@Test
public void project_facet_is_sticky() throws Exception {
- ComponentDto project1 = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto project2 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P2").setKey("PK2"));
- ComponentDto project3 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P3").setKey("PK3"));
- ComponentDto file1 = insertComponent(newFileDto(project1, null, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
- ComponentDto file3 = insertComponent(newFileDto(project3, null, "F3").setKey("FK3"));
+ ComponentDto project1 = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto project2 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P2").setDbKey("PK2"));
+ ComponentDto project3 = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P3").setDbKey("PK3"));
+ ComponentDto file1 = insertComponent(newFileDto(project1, null, "F1").setDbKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setDbKey("FK2"));
+ ComponentDto file3 = insertComponent(newFileDto(project3, null, "F3").setDbKey("FK3"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file1, project1).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@Test
public void search_by_file_uuid() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@Test
public void search_by_file_key() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
- ComponentDto unitTest = insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+ ComponentDto unitTest = insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setDbKey("FK2"));
RuleDto rule = newRule();
IssueDto issueOnFile = IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issueOnTest = IssueTesting.newDto(rule, unitTest, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
indexPermissions();
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH)
- .setParam(IssuesWsParameters.PARAM_COMPONENTS, file.key())
+ .setParam(IssuesWsParameters.PARAM_COMPONENTS, file.getDbKey())
.execute()
.assertJson(this.getClass(), "search_by_file_key.json");
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH)
- .setParam(IssuesWsParameters.PARAM_COMPONENTS, unitTest.key())
+ .setParam(IssuesWsParameters.PARAM_COMPONENTS, unitTest.getDbKey())
.execute()
.assertJson(this.getClass(), "search_by_test_key.json");
}
@Test
public void display_file_facet() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setKey("PK1"));
- ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setKey("FK2"));
- ComponentDto file3 = insertComponent(newFileDto(project, null, "F3").setKey("FK3"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setDbKey("PK1"));
+ ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setDbKey("FK2"));
+ ComponentDto file3 = insertComponent(newFileDto(project, null, "F3").setDbKey("FK3"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file2, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@Test
public void search_by_directory_path() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1").setPath(directory.path() + "/MyComponent.java"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@Test
public void search_by_directory_path_in_different_modules() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setKey("PK1"));
- ComponentDto module1 = insertComponent(newModuleDto("M1", project).setKey("MK1"));
- ComponentDto module2 = insertComponent(newModuleDto("M2", project).setKey("MK2"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setDbKey("PK1"));
+ ComponentDto module1 = insertComponent(newModuleDto("M1", project).setDbKey("MK1"));
+ ComponentDto module2 = insertComponent(newModuleDto("M2", project).setDbKey("MK2"));
ComponentDto directory1 = insertComponent(ComponentTesting.newDirectory(module1, "D1", "src/main/java/dir"));
ComponentDto directory2 = insertComponent(ComponentTesting.newDirectory(module2, "D2", "src/main/java/dir"));
- ComponentDto file1 = insertComponent(newFileDto(module1, directory1, "F1").setKey("FK1").setPath(directory1.path() + "/MyComponent.java"));
- insertComponent(newFileDto(module2, directory2, "F2").setKey("FK2").setPath(directory2.path() + "/MyComponent.java"));
+ ComponentDto file1 = insertComponent(newFileDto(module1, directory1, "F1").setDbKey("FK1").setPath(directory1.path() + "/MyComponent.java"));
+ insertComponent(newFileDto(module2, directory2, "F2").setDbKey("FK2").setPath(directory2.path() + "/MyComponent.java"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue1);
@Test
public void display_module_facet() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setKey("PK1"));
- ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
- ComponentDto subModule1 = insertComponent(newModuleDto("SUBM1", module).setKey("SUBMK1"));
- ComponentDto subModule2 = insertComponent(newModuleDto("SUBM2", module).setKey("SUBMK2"));
- ComponentDto subModule3 = insertComponent(newModuleDto("SUBM3", module).setKey("SUBMK3"));
- ComponentDto file1 = insertComponent(newFileDto(subModule1, null, "F1").setKey("FK1"));
- ComponentDto file2 = insertComponent(newFileDto(subModule2, null, "F2").setKey("FK2"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "P1").setDbKey("PK1"));
+ ComponentDto module = insertComponent(newModuleDto("M1", project).setDbKey("MK1"));
+ ComponentDto subModule1 = insertComponent(newModuleDto("SUBM1", module).setDbKey("SUBMK1"));
+ ComponentDto subModule2 = insertComponent(newModuleDto("SUBM2", module).setDbKey("SUBMK2"));
+ ComponentDto subModule3 = insertComponent(newModuleDto("SUBM3", module).setDbKey("SUBMK3"));
+ ComponentDto file1 = insertComponent(newFileDto(subModule1, null, "F1").setDbKey("FK1"));
+ ComponentDto file2 = insertComponent(newFileDto(subModule2, null, "F2").setDbKey("FK2"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file2, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
@Test
public void display_directory_facet() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
- ComponentDto file = insertComponent(newFileDto(project, directory, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
+ ComponentDto file = insertComponent(newFileDto(project, directory, "F1").setDbKey("FK1").setPath(directory.path() + "/MyComponent.java"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
@Test
public void search_by_view_uuid() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
- ComponentDto view = insertComponent(ComponentTesting.newView(defaultOrganization, "V1").setKey("MyView"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
+ ComponentDto view = insertComponent(ComponentTesting.newView(defaultOrganization, "V1").setDbKey("MyView"));
indexView(view.uuid(), newArrayList(project.uuid()));
indexPermissions();
@Test
public void search_by_sub_view_uuid() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
- ComponentDto view = insertComponent(ComponentTesting.newView(otherOrganization1, "V1").setKey("MyView"));
+ ComponentDto view = insertComponent(ComponentTesting.newView(otherOrganization1, "V1").setDbKey("MyView"));
indexView(view.uuid(), newArrayList(project.uuid()));
ComponentDto subView = insertComponent(ComponentTesting.newSubView(view, "SV1", "MySubView"));
indexView(subView.uuid(), newArrayList(project.uuid()));
@Test
public void search_by_sub_view_uuid_return_only_authorized_view() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
- ComponentDto view = insertComponent(ComponentTesting.newView(otherOrganization1, "V1").setKey("MyView"));
+ ComponentDto view = insertComponent(ComponentTesting.newView(otherOrganization1, "V1").setDbKey("MyView"));
indexView(view.uuid(), newArrayList(project.uuid()));
ComponentDto subView = insertComponent(ComponentTesting.newSubView(view, "SV1", "MySubView"));
indexView(subView.uuid(), newArrayList(project.uuid()));
@Test
public void search_by_author() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setKey("PK1"));
- ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "P1").setDbKey("PK1"));
+ ComponentDto file = insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("leia").setKee("2bd4eac2-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("luke@skywalker.name").setKee("82fd47d4-b650-4037-80bc-7b1182fd47d4");
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.executeProtobuf(SearchWsResponse.class);
assertThat(result.getIssuesList()).extracting(Issue::getKey)
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.executeProtobuf(SearchWsResponse.class);
assertThat(result.getIssuesList()).isEmpty();
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.executeProtobuf(SearchWsResponse.class);
assertThat(result.getIssuesList()).isEmpty();
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
- .setParam(PARAM_PROJECT_KEYS, project1.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+ .setParam(PARAM_PROJECT_KEYS, project1.getDbKey())
.executeProtobuf(SearchWsResponse.class);
assertThat(result.getIssuesList()).extracting(Issue::getKey)
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
- .setParam(PARAM_PROJECT_KEYS, project1.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
+ .setParam(PARAM_PROJECT_KEYS, project1.getDbKey())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);
indexIssuesAndViews();
SearchWsResponse result = ws.newRequest()
- .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+ .setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);
db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setEffort(10L)
db.userDao().insert(session, new UserDto().setLogin("john").setName("John"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
public void load_additional_fields() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("js"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
public void load_additional_fields_with_issue_admin_permission() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
grantPermissionToAnyone(project, ISSUE_ADMIN);
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("js"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
@Test
public void issue_on_removed_file() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project, null).setUuid("REMOVED_FILE_ID")
- .setKey("REMOVED_FILE_KEY")
+ .setDbKey("REMOVED_FILE_KEY")
.setEnabled(false));
IssueDto issue = IssueTesting.newDto(rule, removedFile, project)
@Test
public void apply_paging_with_one_component() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < SearchOptions.MAX_LIMIT + 1; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
- WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_COMPONENTS, file.getKey()).execute();
+ WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_COMPONENTS, file.getDbKey()).execute();
result.assertJson(this.getClass(), "apply_paging_with_one_component.json");
}
@Test
public void components_contains_sub_projects() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("ProjectHavingModule"));
indexPermissions();
- ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile"));
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setKey("FileLinkedToModule"));
+ ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setDbKey("ModuleHavingFile"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setDbKey("FileLinkedToModule"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project);
db.issueDao().insert(session, issue);
session.commit();
@Test
public void display_facets() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
@Test
public void display_facets_in_effort_mode() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
@Test
public void display_zero_valued_facets_for_selected_items() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
public void filter_by_assigned_to_me() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
public void filter_by_assigned_to_me_unauthenticated() throws Exception {
userSessionRule.logIn();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setStatus("OPEN")
public void assigned_to_me_facet_is_sticky_relative_to_assignees() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newRule();
IssueDto issue1 = IssueTesting.newDto(rule, file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
@Test
public void sort_by_updated_at() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
db.issueDao().insert(session, IssueTesting.newDto(rule, file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac1")
.setIssueUpdateDate(DateUtils.parseDateTime("2014-11-02T00:00:00+0100")));
@Test
public void paging() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@Test
public void paging_with_page_size_to_minus_one() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization2, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@Test
public void deprecated_paging() throws Exception {
RuleDto rule = newRule();
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(defaultOrganization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
tester.get(IssueDao.class).insert(session, issue);
@Test
public void display_deprecated_debt_fields() throws Exception {
- ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
+ ComponentDto project = insertComponent(ComponentTesting.newPublicProjectDto(otherOrganization1, "PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
- ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
+ ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setIssueCreationDate(DateUtils.parseDate("2014-09-04"))
.setIssueUpdateDate(DateUtils.parseDate("2017-12-04"))
dbSession.commit();
OrganizationDto organizationDto = db.organizations().insert();
- project = ComponentTesting.newPrivateProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setKey(DEFAULT_PROJECT_KEY);
+ project = ComponentTesting.newPrivateProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setDbKey(DEFAULT_PROJECT_KEY);
dbClient.componentDao().insert(dbSession, project);
dbSession.commit();
userSession.logIn("login").addProjectPermission(UserRole.ADMIN, project);
public void fail_when_not_a_project() throws Exception {
MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(STRING.name()).setKey("metric-key");
dbClient.metricDao().insert(dbSession, metric);
- dbClient.componentDao().insert(dbSession, ComponentTesting.newDirectory(project, "directory-uuid", "path/to/directory").setKey("directory-key"));
+ dbClient.componentDao().insert(dbSession, ComponentTesting.newDirectory(project, "directory-uuid", "path/to/directory").setDbKey("directory-key"));
dbSession.commit();
expectedException.expect(ServerException.class);
private ComponentDto insertProject(String projectUuid, String projectKey) {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), projectUuid)
- .setKey(projectKey);
+ .setDbKey(projectKey);
dbClient.componentDao().insert(dbSession, project);
dbSession.commit();
private ComponentDto insertProject(String projectUuid, String projectKey) {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert(), projectUuid)
- .setKey(projectKey);
+ .setDbKey(projectKey);
dbClient.componentDao().insert(dbSession, project);
dbSession.commit();
.setKey("metric-key");
dbClient.metricDao().insert(dbSession, metric);
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid").setKey("project-key");
+ ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid").setDbKey("project-key");
dbClient.componentDao().insert(dbSession, component);
CustomMeasureDto customMeasure = newCustomMeasure(component, metric)
.setCreatedAt(100_000_000L)
private static final String LANGUAGES = "languages";
private static final OrganizationDto ORG = OrganizationTesting.newOrganizationDto();
- private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-1").setName("Project 1").setKey("key-1");
- private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-2").setName("Project 2").setKey("key-2");
- private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-3").setName("Project 3").setKey("key-3");
+ private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-1").setName("Project 1").setDbKey("key-1");
+ private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-2").setName("Project 2").setDbKey("key-2");
+ private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-3").setName("Project 3").setDbKey("key-3");
private static final UserDto USER1 = newUserDto();
private static final UserDto USER2 = newUserDto();
private static final GroupDto GROUP1 = newGroupDto();
@Test
public void default_sort_is_by_ascending_case_insensitive_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setDbKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setDbKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setDbKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setDbKey("project4");
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
assertResults(new ProjectMeasuresQuery(), apache1, apache2, apachee, windows);
@Test
public void sort_by_a_metric_then_by_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setDbKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setDbKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setDbKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setDbKey("project4");
index(
newDoc(windows, NCLOC, 10_000d),
newDoc(apachee, NCLOC, 5_000d),
@Test
public void sort_by_quality_gate_status() {
- ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
+ ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setDbKey("key-4");
index(
newDoc(PROJECT1).setQualityGateStatus(OK.name()),
newDoc(PROJECT2).setQualityGateStatus(ERROR.name()),
@Test
public void sort_by_quality_gate_status_then_by_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setDbKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setDbKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setDbKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setDbKey("project4");
index(
newDoc(windows).setQualityGateStatus(WARN.name()),
newDoc(apachee).setQualityGateStatus(OK.name()),
@Test
public void filter_on_languages() {
- ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4");
+ ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setDbKey("key-4");
index(
newDoc(PROJECT1).setLanguages(singletonList("java")),
newDoc(PROJECT2).setLanguages(singletonList("xoo")),
@Test
public void filter_on_query_text() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows").setDbKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee").setDbKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-1").setName("Apache").setDbKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache-2").setName("Apache").setDbKey("project4");
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
assertResults(new ProjectMeasuresQuery().setQueryText("windows"), windows);
return new ProjectMeasuresDoc()
.setOrganizationUuid(project.getOrganizationUuid())
.setId(project.uuid())
- .setKey(project.key())
+ .setKey(project.getDbKey())
.setName(project.name());
}
@Test
public void match_exact_case_insensitive_key() {
index(
- newDoc(newPrivateProjectDto(ORG).setUuid("project1").setName("Windows").setKey("project1")),
- newDoc(newPrivateProjectDto(ORG).setUuid("project2").setName("apachee").setKey("project2")));
+ newDoc(newPrivateProjectDto(ORG).setUuid("project1").setName("Windows").setDbKey("project1")),
+ newDoc(newPrivateProjectDto(ORG).setUuid("project2").setName("apachee").setDbKey("project2")));
assertTextQueryResults("project1", "project1");
assertTextQueryResults("PROJECT1", "project1");
@Test
public void match_key_with_dot() {
index(
- newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube")),
- newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setKey("sonarqube")));
+ newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube")),
+ newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setDbKey("sonarqube")));
assertTextQueryResults("org.sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@Test
public void match_key_with_dash() {
index(
- newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setKey("org-sonarqube")),
- newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setKey("sonarqube")));
+ newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setDbKey("org-sonarqube")),
+ newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setDbKey("sonarqube")));
assertTextQueryResults("org-sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@Test
public void match_key_with_colon() {
index(
- newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setKey("org:sonarqube")),
- newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setKey("sonarqube")));
+ newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setDbKey("org:sonarqube")),
+ newDoc(newPrivateProjectDto(ORG).setUuid("sq").setName("SQ").setDbKey("sonarqube")));
assertTextQueryResults("org:sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@Test
public void match_key_having_all_special_characters() {
- index(newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube:sonar-sérvèr_ç")));
+ index(newDoc(newPrivateProjectDto(ORG).setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube:sonar-sérvèr_ç")));
assertTextQueryResults("org.sonarqube:sonar-sérvèr_ç", "sonarqube");
}
@Test
public void does_not_match_partial_key() {
- index(newDoc(newPrivateProjectDto(ORG).setUuid("project").setName("some name").setKey("theKey")));
+ index(newDoc(newPrivateProjectDto(ORG).setUuid("project").setName("some name").setDbKey("theKey")));
assertNoResults("theke");
assertNoResults("hekey");
public void facets_take_into_account_text_search() {
index(
// docs with ncloc<1K
- newDoc(newPrivateProjectDto(ORG).setName("Windows").setKey("project1"), NCLOC, 0d),
- newDoc(newPrivateProjectDto(ORG).setName("apachee").setKey("project2"), NCLOC, 999d),
+ newDoc(newPrivateProjectDto(ORG).setName("Windows").setDbKey("project1"), NCLOC, 0d),
+ newDoc(newPrivateProjectDto(ORG).setName("apachee").setDbKey("project2"), NCLOC, 999d),
// docs with ncloc>=1K and ncloc<10K
- newDoc(newPrivateProjectDto(ORG).setName("Apache").setKey("project3"), NCLOC, 1_000d),
+ newDoc(newPrivateProjectDto(ORG).setName("Apache").setDbKey("project3"), NCLOC, 1_000d),
// docs with ncloc>=100K and ncloc<500K
- newDoc(newPrivateProjectDto(ORG).setName("Apache Foundation").setKey("project4"), NCLOC, 100_000d));
+ newDoc(newPrivateProjectDto(ORG).setName("Apache Foundation").setDbKey("project4"), NCLOC, 100_000d));
assertNclocFacet(new ProjectMeasuresQuery().setQueryText("apache"), 1L, 1L, 0L, 1L, 0L);
assertNclocFacet(new ProjectMeasuresQuery().setQueryText("PAch"), 1L, 1L, 0L, 1L, 0L);
@Test
public void filter_by_metric_take_into_account_text_search() {
index(
- newDoc(newPrivateProjectDto(ORG).setUuid("project1").setName("Windows").setKey("project1"), NCLOC, 30_000d),
- newDoc(newPrivateProjectDto(ORG).setUuid("project2").setName("apachee").setKey("project2"), NCLOC, 40_000d),
- newDoc(newPrivateProjectDto(ORG).setUuid("project3").setName("Apache").setKey("project3"), NCLOC, 50_000d),
- newDoc(newPrivateProjectDto(ORG).setUuid("project4").setName("Apache").setKey("project4"), NCLOC, 60_000d));
+ newDoc(newPrivateProjectDto(ORG).setUuid("project1").setName("Windows").setDbKey("project1"), NCLOC, 30_000d),
+ newDoc(newPrivateProjectDto(ORG).setUuid("project2").setName("apachee").setDbKey("project2"), NCLOC, 40_000d),
+ newDoc(newPrivateProjectDto(ORG).setUuid("project3").setName("Apache").setDbKey("project3"), NCLOC, 50_000d),
+ newDoc(newPrivateProjectDto(ORG).setUuid("project4").setName("Apache").setDbKey("project4"), NCLOC, 60_000d));
assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, GT, 20_000d)), "project3", "project4", "project2");
assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, LT, 55_000d)), "project3", "project2");
return new ProjectMeasuresDoc()
.setOrganizationUuid(project.getOrganizationUuid())
.setId(project.uuid())
- .setKey(project.key())
+ .setKey(project.getDbKey())
.setName(project.name());
}
@Test
public void reference_uuid_in_the_response() {
- ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key");
+ ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid").setDbKey("project-key");
componentDb.insertProjectAndSnapshot(project);
ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid");
componentDb.insertViewAndSnapshot(view);
@Test
public void fail_when_component_is_removed() {
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- componentDb.insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
+ componentDb.insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
userSession.addProjectPermission(USER, project);
insertNclocMetric();
.setPeriodParam("1.0-SNAPSHOT");
ComponentDto file = newFileDto(project, null)
.setUuid("AVIwDXE-bJbJqrw6wFv5")
- .setKey("MY_PROJECT:ElementImpl.java")
+ .setDbKey("MY_PROJECT:ElementImpl.java")
.setName("ElementImpl.java")
.setQualifier(Qualifiers.FILE)
.setLanguage("java")
@Test
public void fail_when_component_is_removed() {
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- componentDb.insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
+ componentDb.insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
userSession.anonymous().addProjectPermission(UserRole.USER, project);
insertNclocMetric();
private void insertJsonExampleData() {
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-id")
- .setKey("MY_PROJECT")
+ .setDbKey("MY_PROJECT")
.setName("My Project")
.setQualifier(Qualifiers.PROJECT);
componentDb.insertComponent(project);
ComponentDto file1 = componentDb.insertComponent(newFileDto(project, null)
.setUuid("AVIwDXE-bJbJqrw6wFv5")
- .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/ElementImpl.java")
+ .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/ElementImpl.java")
.setName("ElementImpl.java")
.setLanguage("java")
.setQualifier(Qualifiers.FILE)
.setPath("src/main/java/com/sonarsource/markdown/impl/ElementImpl.java"));
ComponentDto file2 = componentDb.insertComponent(newFileDto(project, null)
.setUuid("AVIwDXE_bJbJqrw6wFwJ")
- .setKey("com.sonarsource:java-markdown:src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java")
+ .setDbKey("com.sonarsource:java-markdown:src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java")
.setName("ElementImplTest.java")
.setLanguage("java")
.setQualifier(Qualifiers.UNIT_TEST_FILE)
.setPath("src/test/java/com/sonarsource/markdown/impl/ElementImplTest.java"));
ComponentDto dir = componentDb.insertComponent(newDirectory(project, "src/main/java/com/sonarsource/markdown/impl")
.setUuid("AVIwDXE-bJbJqrw6wFv8")
- .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
+ .setDbKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl")
.setQualifier(Qualifiers.DIRECTORY));
MetricDto complexity = insertComplexityMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, project, projectSnapshot).setValue(15.5d));
db.commit();
- SearchWsResponse result = call(singletonList(project.key()), singletonList("coverage"));
+ SearchWsResponse result = call(singletonList(project.getDbKey()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
.setVariation(10d));
db.commit();
- SearchWsResponse result = call(singletonList(project.key()), singletonList("coverage"));
+ SearchWsResponse result = call(singletonList(project.getDbKey()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
dbClient.measureDao().insert(dbSession, newMeasureDto(complexity, project3, projectSnapshot3).setValue(20d));
db.commit();
- SearchWsResponse result = call(asList(project1.key(), project2.key(), project3.key()), asList("coverage", "complexity"));
+ SearchWsResponse result = call(asList(project1.getDbKey(), project2.getDbKey(), project3.getDbKey()), asList("coverage", "complexity"));
assertThat(result.getMeasuresList()).extracting(Measure::getMetric, Measure::getComponent)
.containsExactly(
- tuple("complexity", project2.key()), tuple("complexity", project3.key()), tuple("complexity", project1.key()),
- tuple("coverage", project2.key()), tuple("coverage", project3.key()), tuple("coverage", project1.key()));
+ tuple("complexity", project2.getDbKey()), tuple("complexity", project3.getDbKey()), tuple("complexity", project1.getDbKey()),
+ tuple("coverage", project2.getDbKey()), tuple("coverage", project3.getDbKey()), tuple("coverage", project1.getDbKey()));
}
@Test
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, view, viewSnapshot).setValue(15.5d));
db.commit();
- SearchWsResponse result = call(singletonList(view.key()), singletonList("coverage"));
+ SearchWsResponse result = call(singletonList(view.getDbKey()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, application, viewSnapshot).setValue(15.5d));
db.commit();
- SearchWsResponse result = call(singletonList(application.key()), singletonList("coverage"));
+ SearchWsResponse result = call(singletonList(application.getDbKey()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, subView, viewSnapshot).setValue(15.5d));
db.commit();
- SearchWsResponse result = call(singletonList(subView.key()), singletonList("coverage"));
+ SearchWsResponse result = call(singletonList(subView.getDbKey()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
db.commit();
setBrowsePermissionOnUser(project1);
- SearchWsResponse result = call(asList(project1.key(), project2.key()), singletonList("complexity"));
+ SearchWsResponse result = call(asList(project1.getDbKey(), project2.getDbKey()), singletonList("complexity"));
- assertThat(result.getMeasuresList()).extracting(Measure::getComponent).containsOnly(project1.key());
+ assertThat(result.getMeasuresList()).extracting(Measure::getComponent).containsOnly(project1.getDbKey());
}
@Test
db.commit();
userSession.setNonRoot();
- SearchWsResponse result = call(asList(project1.key()), singletonList("complexity"));
+ SearchWsResponse result = call(asList(project1.getDbKey()), singletonList("complexity"));
assertThat(result.getMeasuresCount()).isEqualTo(0);
userSession.setRoot();
- result = call(asList(project1.key()), singletonList("complexity"));
+ result = call(asList(project1.getDbKey()), singletonList("complexity"));
assertThat(result.getMeasuresCount()).isEqualTo(1);
}
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("The following metrics are not found: ncloc, violations");
- call(singletonList(project.key()), newArrayList("violations", "complexity", "ncloc"));
+ call(singletonList(project.getDbKey()), newArrayList("violations", "complexity", "ncloc"));
}
@Test
public void fail_if_more_than_100_project_keys() {
List<String> keys = IntStream.rangeClosed(1, 101)
.mapToObj(i -> db.components().insertPrivateProject())
- .map(ComponentDto::key)
+ .map(ComponentDto::getDbKey)
.collect(Collectors.toList());
insertComplexityMetric();
public void does_not_fail_on_100_projects() {
List<String> keys = IntStream.rangeClosed(1, 100)
.mapToObj(i -> db.components().insertPrivateProject())
- .map(ComponentDto::key)
+ .map(ComponentDto::getDbKey)
.collect(Collectors.toList());
insertComplexityMetric();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
- call(singletonList(module.key()), singletonList("complexity"));
+ call(singletonList(module.getDbKey()), singletonList("complexity"));
}
@Test
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
- call(singletonList(dir.key()), singletonList("complexity"));
+ call(singletonList(dir.getDbKey()), singletonList("complexity"));
}
@Test
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Only component of qualifiers [TRK, APP, VW, SVW] are allowed");
- call(singletonList(file.key()), singletonList("complexity"));
+ call(singletonList(file.getDbKey()), singletonList("complexity"));
}
@Test
private List<String> insertJsonExampleData() {
List<String> projectKeys = new ArrayList<>();
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_1").setName("Project 1");
- ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_2").setName("Project 2");
- ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("MY_PROJECT_3").setName("Project 3");
- projectKeys.addAll(asList(project1.key(), project2.key(), project3.key()));
+ ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("MY_PROJECT_1").setName("Project 1");
+ ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("MY_PROJECT_2").setName("Project 2");
+ ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("MY_PROJECT_3").setName("Project 3");
+ projectKeys.addAll(asList(project1.getDbKey(), project2.getDbKey(), project3.getDbKey()));
db.components().insertComponents(project1, project2, project3);
SnapshotDto projectSnapshot1 = dbClient.snapshotDao().insert(dbSession, newAnalysis(project1)
.setPeriodDate(parseDateTime("2016-01-11T10:49:50+0100").getTime())
complexityMetric = insertComplexityMetric();
newViolationMetric = insertNewViolationMetric();
metrics = newArrayList(nclocMetric.getKey(), complexityMetric.getKey(), newViolationMetric.getKey());
- wsRequest = SearchHistoryRequest.builder().setComponent(project.getKey()).setMetrics(metrics);
+ wsRequest = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(metrics);
}
@Test
project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
wsRequest
- .setComponent(project.getKey())
+ .setComponent(project.getDbKey())
.setMetrics(singletonList(complexityMetric.getKey()));
SearchHistoryResponse result = call();
analysis = db.components().insertSnapshot(project);
userSession.addProjectPermission(UserRole.USER, project);
wsRequest
- .setComponent(project.getKey())
+ .setComponent(project.getDbKey())
.setMetrics(singletonList(complexityMetric.getKey()));
SearchHistoryResponse result = call();
.map(a -> formatDateTime(a.getCreatedAt()))
.collect(MoreCollectors.toList());
db.commit();
- wsRequest.setComponent(project.getKey()).setPage(2).setPageSize(3);
+ wsRequest.setComponent(project.getDbKey()).setPage(2).setPageSize(3);
SearchHistoryResponse result = call();
.map(a -> formatDateTime(a.getCreatedAt()))
.collect(MoreCollectors.toList());
db.commit();
- wsRequest.setComponent(project.getKey()).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3));
+ wsRequest.setComponent(project.getDbKey()).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3));
SearchHistoryResponse result = call();
dbClient.metricDao().insert(dbSession, newMetricDto().setKey("new_optimized").setValueType(ValueType.INT.name()).setOptimizedBestValue(true).setBestValue(789d));
db.commit();
ComponentDto file = db.components().insertComponent(newFileDto(project));
- wsRequest.setComponent(file.getKey()).setMetrics(Arrays.asList("optimized", "new_optimized"));
+ wsRequest.setComponent(file.getDbKey()).setMetrics(Arrays.asList("optimized", "new_optimized"));
SearchHistoryResponse result = call();
assertThat(result.getMeasuresList().get(1).getHistoryList()).extracting(HistoryValue::getValue).containsExactly("456");
// Best value is not applied to project
- wsRequest.setComponent(project.getKey());
+ wsRequest.setComponent(project.getDbKey());
result = call();
assertThat(result.getMeasuresList().get(0).getHistoryCount()).isEqualTo(1);
assertThat(result.getMeasuresList().get(0).getHistory(0).hasDate()).isTrue();
@Test
public void fail_when_component_is_removed() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization()));
- db.components().insertComponent(newFileDto(project).setKey("file-key").setEnabled(false));
+ db.components().insertComponent(newFileDto(project).setDbKey("file-key").setEnabled(false));
userSession.addProjectPermission(UserRole.USER, project);
expectedException.expect(NotFoundException.class);
db.commit();
String result = ws.newRequest()
- .setParam(PARAM_COMPONENT, project.getKey())
+ .setParam(PARAM_COMPONENT, project.getDbKey())
.setParam(PARAM_METRICS, String.join(",", metrics))
.execute().getInput();
public void add_a_project_notification() {
ComponentDto project = db.components().insertPrivateProject();
- call(request.setProject(project.getKey()));
+ call(request.setProject(project.getDbKey()));
db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUserId(), project);
}
@Test
public void add_a_global_notification_when_a_project_one_exists() {
ComponentDto project = db.components().insertPrivateProject();
- call(request.setProject(project.getKey()));
+ call(request.setProject(project.getDbKey()));
call(request.setProject(null));
ComponentDto project = db.components().insertPrivateProject();
call(request);
- call(request.setProject(project.getKey()));
+ call(request.setProject(project.getDbKey()));
db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUserId(), project);
db.notifications().assertExists(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, userSession.getUserId(), null);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher3]");
- call(request.setType("Dispatcher42").setProject(project.key()));
+ call(request.setType("Dispatcher42").setProject(project.getDbKey()));
}
@Test
@Test
public void fail_when_component_is_not_a_project() {
- db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setKey("VIEW_1"));
+ db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setDbKey("VIEW_1"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Component 'VIEW_1' must be a project");
@Test
public void filter_unauthorized_projects() {
- ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("K1"));
+ ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("K1"));
ComponentDto anotherProject = db.components().insertPrivateProject();
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, project);
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, anotherProject);
@Test
public void filter_per_project_dispatchers() {
- ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("K1"));
+ ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("K1"));
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, project);
notificationUpdater.add(dbSession, emailChannel.getKey(), "Unknown Notification", user, project);
dbSession.commit();
@Test
public void order_with_global_then_by_channel_and_dispatcher() {
OrganizationDto organization = db.organizations().insert();
- ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("K1"));
+ ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setDbKey("K1"));
notificationUpdater.add(dbSession, twitterChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_NEW_ISSUES, user, null);
@Test
public void json_example() {
OrganizationDto organization = db.organizations().insertForKey("my-org-1");
- ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
+ ComponentDto project = addComponent(ComponentTesting.newPrivateProjectDto(organization).setDbKey(KEY_PROJECT_EXAMPLE_001).setName("My Project"));
notificationUpdater.add(dbSession, twitterChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null);
notificationUpdater.add(dbSession, emailChannel.getKey(), NOTIF_NEW_ISSUES, user, null);
notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, project);
dbSession.commit();
- call(request.setProject(project.getKey()));
+ call(request.setProject(project.getDbKey()));
db.notifications().assertDoesNotExist(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user.getId(), project);
}
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Notification doesn't exist");
- call(request.setProject(project.getKey()));
+ call(request.setProject(project.getDbKey()));
}
@Test
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher3]");
- call(request.setType("Dispatcher42").setProject(project.key()));
+ call(request.setType("Dispatcher42").setProject(project.getDbKey()));
}
@Test
@Test
public void fail_when_component_is_not_a_project() {
- db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setKey("VIEW_1"));
+ db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setDbKey("VIEW_1"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Component 'VIEW_1' must be a project");
@Test
public void add_permission_to_project_referenced_by_its_id() throws Exception {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
loginAsAdmin(db.getDefaultOrganization());
newRequest()
@Test
public void add_permission_to_project_referenced_by_its_key() throws Exception {
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
loginAsAdmin(db.getDefaultOrganization());
newRequest()
public void add_with_view_uuid() throws Exception {
OrganizationDto organizationDto = db.getDefaultOrganization();
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
- ComponentDto view = db.components().insertComponent(newView(organizationDto, "view-uuid").setKey("view-key"));
+ ComponentDto view = db.components().insertComponent(newView(organizationDto, "view-uuid").setDbKey("view-key"));
loginAsAdmin(db.getDefaultOrganization());
newRequest()
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + file.key() + "' (id: " + file.uuid() + ") must be a project or a view.");
+ expectedException.expectMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
newRequest()
.setParam(PARAM_GROUP_NAME, group.getName())
public void adding_a_project_permission_fails_if_component_is_not_a_project() throws Exception {
OrganizationDto organizationDto = db.getDefaultOrganization();
GroupDto group = db.users().insertGroup(organizationDto, "sonar-administrators");
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project, null, "file-uuid"));
loginAsAdmin(db.getDefaultOrganization());
.setParam(PARAM_GROUP_NAME, group.getName())
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
.setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
newRequest()
.setParam(PARAM_GROUP_NAME, group.getName())
.setParam(PARAM_PERMISSION, PROVISIONING)
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
.execute();
@Test
public void add_permission_to_view() throws Exception {
- ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setKey("view-key"));
+ ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setDbKey("view-key"));
loginAsAdmin(db.getDefaultOrganization());
newRequest()
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + file.key() + "' (id: " + file.uuid() + ") must be a project or a view.");
+ expectedException.expectMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_PERMISSION, UserRole.ISSUE_ADMIN)
.execute();
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_ORGANIZATION, "an_org")
.setParam(PARAM_PERMISSION, ISSUE_ADMIN)
.execute();
@Test
public void search_groups_on_views() throws Exception {
- ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setKey("view-key"));
+ ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setDbKey("view-key"));
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "project-group-name");
db.users().insertProjectPermissionOnGroup(group, ISSUE_ADMIN, view);
@Test
public void fail_if_project_uuid_and_project_key_are_provided() throws Exception {
- db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
+ db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setDbKey("project-key"));
expectedException.expect(BadRequestException.class);
newRequest()
.setParam(PARAM_GROUP_NAME, aGroup.getName())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_PERMISSION, ADMIN)
.execute();
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + file.key() + "' (id: " + file.uuid() + ") must be a project or a view.");
+ expectedException.expectMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
newRequest()
.setParam(PARAM_GROUP_NAME, aGroup.getName())
.setParam(PARAM_GROUP_NAME, aGroup.getName())
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
.setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
newRequest()
.setParam(PARAM_GROUP_NAME, aGroup.getName())
.setParam(PARAM_PERMISSION, PROVISIONING)
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
@Test
public void remove_permission_from_project() throws Exception {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
db.users().insertProjectPermissionOnUser(user, CODEVIEWER, project);
db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
loginAsAdmin(db.getDefaultOrganization());
@Test
public void remove_with_project_key() throws Exception {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, project);
db.users().insertProjectPermissionOnUser(user, CODEVIEWER, project);
loginAsAdmin(db.getDefaultOrganization());
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_PERMISSION, ISSUE_ADMIN)
.execute();
@Test
public void remove_with_view_uuid() throws Exception {
- ComponentDto view = db.components().insertComponent(newView(db.organizations().insert(), "view-uuid").setKey("view-key"));
+ ComponentDto view = db.components().insertComponent(newView(db.organizations().insert(), "view-uuid").setDbKey("view-key"));
db.users().insertProjectPermissionOnUser(user, ISSUE_ADMIN, view);
db.users().insertProjectPermissionOnUser(user, ADMIN, view);
loginAsAdmin(db.getDefaultOrganization());
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
- .setParam(PARAM_PROJECT_KEY, view.getKey())
+ .setParam(PARAM_PROJECT_KEY, view.getDbKey())
.setParam(PARAM_PERMISSION, ISSUE_ADMIN)
.execute();
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + file.key() + "' (id: " + file.uuid() + ") must be a project or a view.");
+ expectedException.expectMessage("Component '" + file.getDbKey() + "' (id: " + file.uuid() + ") must be a project or a view.");
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
@Test
public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setKey(A_PROJECT_KEY));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), A_PROJECT_UUID).setDbKey(A_PROJECT_KEY));
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
.setParam(PARAM_USER_LOGIN, user.getLogin())
.setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
newRequest()
.setParam(PARAM_USER_LOGIN, user.getLogin())
.setParam(PARAM_PERMISSION, ISSUE_ADMIN)
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.execute();
}
" \"projects\": [" +
" {" +
" \"id\": \"" + project.uuid() + "\"," +
- " \"key\": \"" + project.key() + "\"," +
+ " \"key\": \"" + project.getDbKey() + "\"," +
" \"name\": \"" + project.name() + "\"," +
" \"qualifier\": \"TRK\"," +
" \"permissions\": []" +
" \"projects\": [" +
" {" +
" \"id\": \"" + project.uuid() + "\"," +
- " \"key\": \"" + project.key() + "\"," +
+ " \"key\": \"" + project.getDbKey() + "\"," +
" \"name\": \"" + project.name() + "\"," +
" \"qualifier\": \"TRK\"," +
" \"permissions\": []" +
@Test
public void search_by_query_on_key_must_match_exactly() throws Exception {
OrganizationDto organizationDto = db.organizations().insert();
- componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("project-key"));
- componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("another-key"));
+ componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("project-key"));
+ componentDb.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("another-key"));
String result = newRequest()
.setParam(TEXT_QUERY, "project-key")
return db.components().insertComponent(newView(db.getDefaultOrganization())
.setUuid("752d8bfd-420c-4a83-a4e5-8ab19b13c8fc")
.setName("Java")
- .setKey("Java"));
+ .setDbKey("Java"));
}
private ComponentDto insertProjectInView(ComponentDto project, ComponentDto view) {
private ComponentDto insertClang() {
return db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-2")
.setName("Clang")
- .setKey("clang")
+ .setDbKey("clang")
.setUuid("ce4c03d6-430f-40a9-b777-ad877c00aa4d"));
}
private ComponentDto insertJdk7() {
return db.components().insertComponent(ComponentTesting.newPublicProjectDto(db.getDefaultOrganization())
.setName("JDK 7")
- .setKey("net.java.openjdk:jdk7")
+ .setDbKey("net.java.openjdk:jdk7")
.setUuid("0bd7b1e7-91d6-439e-a607-4a3a9aad3c6a"));
}
}
@Test
public void fail_if_project_uuid_and_project_key_are_provided() throws Exception {
- db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setKey("project-key"));
+ db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setDbKey("project-key"));
loginAsAdmin(db.getDefaultOrganization());
expectedException.expect(BadRequestException.class);
public void apply_template_with_project_key() throws Exception {
loginAsAdmin(db.getDefaultOrganization());
- newRequest(template1.getUuid(), null, project.key());
+ newRequest(template1.getUuid(), null, project.getDbKey());
assertTemplate1AppliedToProject();
}
@Test
public void apply_template_by_query_on_name_and_key_public_project() throws Exception {
- ComponentDto publicProjectFoundByKey = ComponentTesting.newPublicProjectDto(organization).setKey("sonar");
+ ComponentDto publicProjectFoundByKey = ComponentTesting.newPublicProjectDto(organization).setDbKey("sonar");
db.components().insertProjectAndSnapshot(publicProjectFoundByKey);
ComponentDto publicProjectFoundByName = ComponentTesting.newPublicProjectDto(organization).setName("name-sonar-name");
db.components().insertProjectAndSnapshot(publicProjectFoundByName);
// match must be exact on key
- ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto(organization).setKey("new-sonar").setName("project-name");
+ ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto(organization).setDbKey("new-sonar").setName("project-name");
db.components().insertProjectAndSnapshot(projectUntouched);
loginAsAdmin(organization);
@Test
public void apply_template_by_query_on_name_and_key() throws Exception {
- ComponentDto privateProjectFoundByKey = ComponentTesting.newPrivateProjectDto(organization).setKey("sonar");
+ ComponentDto privateProjectFoundByKey = ComponentTesting.newPrivateProjectDto(organization).setDbKey("sonar");
db.components().insertProjectAndSnapshot(privateProjectFoundByKey);
ComponentDto privateProjectFoundByName = ComponentTesting.newPrivateProjectDto(organization).setName("name-sonar-name");
db.components().insertProjectAndSnapshot(privateProjectFoundByName);
// match must be exact on key
- ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto(organization).setKey("new-sonar").setName("project-name");
+ ComponentDto projectUntouched = ComponentTesting.newPublicProjectDto(organization).setDbKey("new-sonar").setName("project-name");
db.components().insertProjectAndSnapshot(projectUntouched);
loginAsAdmin(organization);
ComponentDto toKeep = db.components().insertPrivateProject(org2);
WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
- .setParam("keys", toDeleteInOrg1.key() + "," + toDeleteInOrg2.key())
+ .setParam("keys", toDeleteInOrg1.getDbKey() + "," + toDeleteInOrg2.getDbKey())
.execute();
result.assertNoContent();
ComponentDto toDelete2 = db.components().insertPrivateProject(org1);
WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
- .setParam("keys", toDelete1.key() + ",missing," + toDelete2.key() + ",doesNotExist")
+ .setParam("keys", toDelete1.getDbKey() + ",missing," + toDelete2.getDbKey() + ",doesNotExist")
.execute();
result.assertNoContent();
expectedException.expectMessage("Insufficient privileges");
ws.newPostRequest("api/projects", ACTION)
- .setParam("keys", project.key())
+ .setParam("keys", project.getDbKey())
.execute();
verifyNoDeletions();
WsTester.Result result = ws.newPostRequest("api/projects", ACTION)
.setParam("organization", org1.getKey())
- .setParam("keys", toDelete.key() + "," + cantBeDeleted.key())
+ .setParam("keys", toDelete.getDbKey() + "," + cantBeDeleted.getDbKey())
.execute();
result.assertNoContent();
@Test
public void json_example() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("my_project"));
- componentDb.insertComponent(newModuleDto(project).setKey("my_project:module_1"));
- ComponentDto anotherProject = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("another_project"));
- componentDb.insertComponent(newModuleDto(anotherProject).setKey("my_new_project:module_1"));
- ComponentDto module2 = componentDb.insertComponent(newModuleDto(project).setKey("my_project:module_2"));
+ ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("my_project"));
+ componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:module_1"));
+ ComponentDto anotherProject = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("another_project"));
+ componentDb.insertComponent(newModuleDto(anotherProject).setDbKey("my_new_project:module_1"));
+ ComponentDto module2 = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:module_2"));
componentDb.insertComponent(newFileDto(module2, null));
String result = ws.newRequest()
@Test
public void bulk_update_project_key() {
ComponentDto project = insertMyProject();
- ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
- ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
- ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
- ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
+ ComponentDto module = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:module"));
+ ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setDbKey("my_project:root:inactive_module").setEnabled(false));
+ ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/File.xoo"));
+ ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setDbKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
BulkUpdateKeyWsResponse result = callByUuid(project.uuid(), FROM, TO);
assertThat(result.getKeysCount()).isEqualTo(2);
assertThat(result.getKeysList()).extracting(Key::getKey, Key::getNewKey, Key::getDuplicate)
.containsExactly(
- tuple(project.key(), "your_project", false),
- tuple(module.key(), "your_project:root:module", false));
+ tuple(project.getDbKey(), "your_project", false),
+ tuple(module.getDbKey(), "your_project:root:module", false));
verify(componentService).bulkUpdateKey(any(DbSession.class), eq(project), eq(FROM), eq(TO));
}
String newKey = "provisionedProject2";
ComponentDto provisionedProject = componentDb.insertPrivateProject();
- callByKey(provisionedProject.key(), provisionedProject.getKey(), newKey);
+ callByKey(provisionedProject.getDbKey(), provisionedProject.getDbKey(), newKey);
- verify(componentService).bulkUpdateKey(any(DbSession.class), eq(provisionedProject), eq(provisionedProject.getKey()), eq(newKey));
+ verify(componentService).bulkUpdateKey(any(DbSession.class), eq(provisionedProject), eq(provisionedProject.getDbKey()), eq(newKey));
}
@Test
public void fail_to_bulk_if_a_component_already_exists_with_the_same_key() {
- componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("my_project"));
- componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("your_project"));
+ componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("my_project"));
+ componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("your_project"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Impossible to update key: a component with key \"your_project\" already exists.");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Component updated must be a module or a key");
- callByKey(file.key(), FROM, TO);
+ callByKey(file.getDbKey(), FROM, TO);
}
@Test
ComponentDto project = insertMyProject();
- callDryRunByKey(project.key(), null, TO);
+ callDryRunByKey(project.getDbKey(), null, TO);
}
@Test
ComponentDto project = insertMyProject();
- callDryRunByKey(project.key(), FROM, null);
+ callDryRunByKey(project.getDbKey(), FROM, null);
}
@Test
ComponentDto project = insertMyProject();
- call(project.uuid(), project.key(), FROM, TO, false);
+ call(project.uuid(), project.getDbKey(), FROM, TO, false);
}
@Test
}
private ComponentDto insertMyProject() {
- return componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey(MY_PROJECT_KEY));
+ return componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey(MY_PROJECT_KEY));
}
private BulkUpdateKeyWsResponse callDryRunByUuid(@Nullable String uuid, @Nullable String from, @Nullable String to) {
.extracting(Project::getKey, Project::getName, Project::getQualifier, Project::getVisibility)
.containsOnly(DEFAULT_PROJECT_KEY, DEFAULT_PROJECT_NAME, "TRK", "public");
assertThat(db.getDbClient().componentDao().selectByKey(db.getSession(), DEFAULT_PROJECT_KEY).get())
- .extracting(ComponentDto::getKey, ComponentDto::name, ComponentDto::qualifier, ComponentDto::scope, ComponentDto::isPrivate)
+ .extracting(ComponentDto::getDbKey, ComponentDto::name, ComponentDto::qualifier, ComponentDto::scope, ComponentDto::isPrivate)
.containsOnly(DEFAULT_PROJECT_KEY, DEFAULT_PROJECT_NAME, "TRK", "PRJ", false);
}
@Test
public void fail_when_project_already_exists() throws Exception {
OrganizationDto organization = db.organizations().insert();
- db.components().insertPublicProject(project -> project.setKey(DEFAULT_PROJECT_KEY));
+ db.components().insertPublicProject(project -> project.setDbKey(DEFAULT_PROJECT_KEY));
userSession.addPermission(PROVISION_PROJECTS, organization);
expectedException.expect(BadRequestException.class);
WsTester.TestRequest request = newRequest().setParam(PARAM_PROJECT_ID, project.uuid());
call(request);
- assertThat(verifyDeletedKey()).isEqualTo(project.key());
+ assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
}
@Test
ComponentDto project = componentDbTester.insertPrivateProject();
userSessionRule.logIn().addPermission(ADMINISTER, project.getOrganizationUuid());
- call(newRequest().setParam(PARAM_PROJECT, project.key()));
+ call(newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
- assertThat(verifyDeletedKey()).isEqualTo(project.key());
+ assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
}
private String verifyDeletedKey() {
ArgumentCaptor<ComponentDto> argument = ArgumentCaptor.forClass(ComponentDto.class);
verify(componentCleanerService).delete(any(DbSession.class), argument.capture());
- return argument.getValue().key();
+ return argument.getValue().getDbKey();
}
@Test
call(newRequest().setParam(PARAM_PROJECT_ID, project.uuid()));
- assertThat(verifyDeletedKey()).isEqualTo(project.key());
+ assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
}
@Test
ComponentDto project = componentDbTester.insertPrivateProject();
userSessionRule.logIn().addProjectPermission(UserRole.ADMIN, project);
- call(newRequest().setParam(PARAM_PROJECT, project.key()));
+ call(newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
- assertThat(verifyDeletedKey()).isEqualTo(project.key());
+ assertThat(verifyDeletedKey()).isEqualTo(project.getDbKey());
}
@Test
" \"projects\": [" +
" {" +
" \"uuid\": \"" + ghost1.uuid() + "\"," +
- " \"key\": \"" + ghost1.key() + "\"," +
+ " \"key\": \"" + ghost1.getDbKey() + "\"," +
" \"name\": \"" + ghost1.name() + "\"," +
" \"visibility\": \"private\"" +
" }," +
" {" +
" \"uuid\": \"" + ghost2.uuid() + "\"," +
- " \"key\": \"" + ghost2.key() + "\"," +
+ " \"key\": \"" + ghost2.getDbKey() + "\"," +
" \"name\": \"" + ghost2.name() + "\"," +
" \"visibility\": \"private\"" +
" }" +
OrganizationDto organization = db.organizations().insert();
for (int i = 1; i <= 10; i++) {
int count = i;
- insertGhostProject(organization, dto -> dto.setKey("ghost-key-" + count));
+ insertGhostProject(organization, dto -> dto.setDbKey("ghost-key-" + count));
}
userSessionRule.logIn().addPermission(ADMINISTER, organization);
@Test
public void ghost_projects_with_partial_query_on_key() throws Exception {
OrganizationDto organization = db.organizations().insert();
- insertGhostProject(organization, dto -> dto.setKey("ghost-key-1"));
+ insertGhostProject(organization, dto -> dto.setDbKey("ghost-key-1"));
userSessionRule.logIn().addPermission(ADMINISTER, organization);
public void ghost_projects_base_on_json_example() throws Exception {
OrganizationDto organization = db.organizations().insert();
ComponentDto hBaseProject = ComponentTesting.newPrivateProjectDto(organization, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
- .setKey("org.apache.hbas:hbase")
+ .setDbKey("org.apache.hbas:hbase")
.setName("HBase")
.setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"))
.setPrivate(false);
dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(hBaseProject)
.setStatus(STATUS_UNPROCESSED));
ComponentDto roslynProject = ComponentTesting.newPrivateProjectDto(organization, "c526ef20-131b-4486-9357-063fa64b5079")
- .setKey("com.microsoft.roslyn:roslyn")
+ .setDbKey("com.microsoft.roslyn:roslyn")
.setName("Roslyn")
.setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
dbClient.componentDao().insert(db.getSession(), roslynProject);
@Test
public void search_all_projects() throws Exception {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(null, null, null);
@Test
public void search_projects_with_modules() throws Exception {
- ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
- ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
+ ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+ ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
insertProjectsAuthorizedForUser(project1, project2);
db.components().insertComponents(
- newModuleDto(project1).setKey("org.jenkins-ci.plugins:sonar-common").setName("Common"),
- newModuleDto(project2).setKey("org.codehaus.sonar-plugins:sonar-ant-db").setName("Ant DB"));
+ newModuleDto(project1).setDbKey("org.jenkins-ci.plugins:sonar-common").setName("Common"),
+ newModuleDto(project2).setDbKey("org.codehaus.sonar-plugins:sonar-ant-db").setName("Ant DB"));
String result = call(null, null, true);
@Test
public void search_project_by_key() throws Exception {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call("org.jenkins-ci.plugins:sonar", null, null);
@Test
public void search_project_by_id() throws Exception {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
insertProjectsAuthorizedForUser(
project,
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(Long.toString(project.getId()), null, null);
@Test
public void search_projects_by_name() throws Exception {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(null, "Plu", null);
@Test
public void search_projects_with_modules_by_name() throws Exception {
- ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
- ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
+ ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin");
+ ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task");
insertProjectsAuthorizedForUser(project1, project2);
db.components().insertComponents(
- newModuleDto(project1).setKey("org.jenkins-ci.plugins:sonar-common-db").setName("Jenkins Common DB"),
- newModuleDto(project1).setKey("org.jenkins-ci.plugins:sonar-common-server").setName("Jenkins Common Server"),
- newModuleDto(project2).setKey("org.codehaus.sonar-plugins:sonar-ant-db").setName("Ant DB"));
+ newModuleDto(project1).setDbKey("org.jenkins-ci.plugins:sonar-common-db").setName("Jenkins Common DB"),
+ newModuleDto(project1).setDbKey("org.jenkins-ci.plugins:sonar-common-server").setName("Jenkins Common Server"),
+ newModuleDto(project2).setDbKey("org.codehaus.sonar-plugins:sonar-ant-db").setName("Ant DB"));
String result = call(null, "Com", true);
@Test
public void return_empty_list_when_no_project_match_search() throws Exception {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(null, "Unknown", null);
@Test
public void return_only_projects_authorized_for_user() throws Exception {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"));
db.components()
- .insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ .insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(null, null, null);
@Test
public void do_not_verify_permissions_if_user_is_root() throws Exception {
- ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("P1").setName("POne"));
+ ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("P1").setName("POne"));
String result = call(null, null, null);
@Test
public void test_example() {
insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.jenkins-ci.plugins:sonar").setName("Jenkins Sonar Plugin"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-ant-task").setName("Sonar Ant Task"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("org.codehaus.sonar-plugins:sonar-build-breaker-plugin").setName("Sonar Build Breaker Plugin"));
String result = call(null, null, null);
public void provisioned_projects_as_defined_in_the_example() throws Exception {
OrganizationDto org = db.organizations().insert();
ComponentDto hBaseProject = ComponentTesting.newPrivateProjectDto(org, "ce4c03d6-430f-40a9-b777-ad877c00aa4d")
- .setKey("org.apache.hbas:hbase")
+ .setDbKey("org.apache.hbas:hbase")
.setName("HBase")
.setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"))
.setPrivate(false);
ComponentDto roslynProject = ComponentTesting.newPrivateProjectDto(org, "c526ef20-131b-4486-9357-063fa64b5079")
- .setKey("com.microsoft.roslyn:roslyn")
+ .setDbKey("com.microsoft.roslyn:roslyn")
.setName("Roslyn")
.setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
db.components().insertComponents(hBaseProject, roslynProject);
return ComponentTesting
.newPrivateProjectDto(organizationDto, "provisioned-uuid-" + uuid)
.setName("provisioned-name-" + uuid)
- .setKey("provisioned-key-" + uuid);
+ .setDbKey("provisioned-key-" + uuid);
}
}
public void search_by_key_query() throws IOException {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("project-_%-key"),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("project-key-without-escaped-characters"));
SearchWsResponse response = call(SearchWsRequest.builder().setQuery("project-_%-key").build());
public void search_private_projects() {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("private-key"),
- ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setKey("public-key"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("private-key"),
+ ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setDbKey("public-key"));
SearchWsResponse response = call(SearchWsRequest.builder().setVisibility("private").build());
public void search_public_projects() {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("private-key"),
- ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setKey("public-key"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("private-key"),
+ ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()).setDbKey("public-key"));
SearchWsResponse response = call(SearchWsRequest.builder().setVisibility("public").build());
public void search_projects_when_no_qualifier_set() throws IOException {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1),
newView(db.getDefaultOrganization()));
SearchWsResponse response = call(SearchWsRequest.builder().build());
@Test
public void search_projects() throws IOException {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1);
+ ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1);
ComponentDto module = newModuleDto(project);
ComponentDto directory = newDirectory(module, "dir");
ComponentDto file = newFileDto(directory);
db.components().insertComponents(
project, module, directory, file,
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_2),
newView(db.getDefaultOrganization()));
SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(singletonList("TRK")).build());
public void search_views() throws IOException {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
- newView(db.getDefaultOrganization()).setKey("view1"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1),
+ newView(db.getDefaultOrganization()).setDbKey("view1"));
SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(singletonList("VW")).build());
public void search_projects_and_views() throws IOException {
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
- newView(db.getDefaultOrganization()).setKey("view1"));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1),
+ newView(db.getDefaultOrganization()).setDbKey("view1"));
SearchWsResponse response = call(SearchWsRequest.builder().setQualifiers(asList("TRK", "VW")).build());
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
OrganizationDto otherOrganization = db.organizations().insert();
db.components().insertComponents(
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_1),
- ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey(PROJECT_KEY_2),
- ComponentTesting.newPrivateProjectDto(otherOrganization).setKey(PROJECT_KEY_3));
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1),
+ ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_2),
+ ComponentTesting.newPrivateProjectDto(otherOrganization).setDbKey(PROJECT_KEY_3));
SearchWsResponse response = call(SearchWsRequest.builder().build());
SearchWsResponse response = call(SearchWsRequest.builder().setOrganization(organization1.getKey()).build());
- assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(project1.key(), project2.key());
+ assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(project1.getDbKey(), project2.getDbKey());
}
@Test
userSession.addPermission(ADMINISTER, db.getDefaultOrganization());
List<ComponentDto> componentDtoList = new ArrayList<>();
for (int i = 1; i <= 9; i++) {
- componentDtoList.add(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
+ componentDtoList.add(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid-" + i).setDbKey("project-key-" + i).setName("Project Name " + i));
}
db.components().insertComponents(componentDtoList.toArray(new ComponentDto[] {}));
OrganizationDto organization = db.organizations().insertForKey("my-org-1");
userSession.addPermission(ADMINISTER, organization);
db.components().insertComponents(
- newPrivateProjectDto(organization, "project-uuid-1").setName("Project Name 1").setKey("project-key-1").setPrivate(false),
- newPrivateProjectDto(organization, "project-uuid-2").setName("Project Name 1").setKey("project-key-2"));
+ newPrivateProjectDto(organization, "project-uuid-1").setName("Project Name 1").setDbKey("project-key-1").setPrivate(false),
+ newPrivateProjectDto(organization, "project-uuid-2").setName("Project Name 1").setDbKey("project-key-2"));
String response = ws.newRequest()
.setMediaType(MediaTypes.JSON)
private ComponentDto insertClang(OrganizationDto organizationDto) {
return db.components().insertComponent(newPrivateProjectDto(organizationDto, Uuids.UUID_EXAMPLE_01)
.setName("Clang")
- .setKey("clang"));
+ .setDbKey("clang"));
}
private ComponentDto insertJdk7(OrganizationDto organizationDto) {
return db.components().insertComponent(newPrivateProjectDto(organizationDto, Uuids.UUID_EXAMPLE_02)
.setName("JDK 7")
- .setKey("net.java.openjdk:jdk7")
+ .setDbKey("net.java.openjdk:jdk7")
.setDescription("JDK"));
}
private ComponentDto insertView(OrganizationDto organizationDto) {
return db.components().insertComponent(newView(organizationDto, "752d8bfd-420c-4a83-a4e5-8ab19b13c8fc")
.setName("Java")
- .setKey("Java"));
+ .setDbKey("Java"));
}
private SearchMyProjectsWsResponse call_ws() {
public void call_by_key() {
ComponentDto project = insertProject();
- callByKey(project.key(), ANOTHER_KEY);
+ callByKey(project.getDbKey(), ANOTHER_KEY);
assertCallComponentService(ANOTHER_KEY);
}
ComponentDto project = insertProject();
- callByKey(project.key(), null);
+ callByKey(project.getDbKey(), null);
}
@Test
ComponentDto project = insertProject();
- call(project.uuid(), project.key(), ANOTHER_KEY);
+ call(project.uuid(), project.getDbKey(), ANOTHER_KEY);
}
@Test
Stream.of(module, dir, file, view, subView, projectCopy)
.forEach(nonRootComponent -> {
- request.setParam(PARAM_PROJECT, nonRootComponent.key())
+ request.setParam(PARAM_PROJECT, nonRootComponent.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
try {
public void execute_throws_ForbiddenException_if_user_has_no_permission_on_specified_component() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPrivateProject(organization);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
expectInsufficientPrivilegeException();
public void execute_throws_ForbiddenException_if_user_has_all_permissions_but_ADMIN_on_specified_component() {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPublicProject(organization);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
userSessionRule.addProjectPermission(UserRole.ISSUE_ADMIN, project);
Arrays.stream(OrganizationPermission.values())
.forEach(perm -> userSessionRule.addPermission(perm, organization));
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
expectInsufficientPrivilegeException();
ComponentDto project = randomPublicOrPrivateProject();
IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.forEach(i -> insertPendingTask(project));
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
ComponentDto project = randomPublicOrPrivateProject();
IntStream.range(0, 1 + Math.abs(random.nextInt(5)))
.forEach(i -> insertInProgressTask(project));
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, randomVisibility);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage(format("Could not find organization with uuid '%s' of project '%s'", organization.getUuid(), project.key()));
+ expectedException.expectMessage(format("Could not find organization with uuid '%s' of project '%s'", organization.getUuid(), project.getDbKey()));
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
}
dbTester.components().insertComponents(module, dir, file);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, initiallyPrivate ? PUBLIC : PRIVATE)
.execute();
dbTester.components().insertComponents(module, dir, file);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, initiallyPrivate ? PRIVATE : PUBLIC)
.execute();
unsafeGiveAllPermissionsToRootComponent(project, user, group, organization);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
unsafeGiveAllPermissionsToRootComponent(project, user, group, organization);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
unsafeGiveAllPermissionsToRootComponent(project, user, group, organization);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PUBLIC)
.execute();
unsafeGiveAllPermissionsToRootComponent(project, user, group, organization);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PUBLIC)
.execute();
boolean initiallyPrivate = project.isPrivate();
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, initiallyPrivate ? PUBLIC : PRIVATE)
.execute();
boolean initiallyPrivate = project.isPrivate();
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, initiallyPrivate ? PRIVATE : PUBLIC)
.execute();
dbTester.users().insertProjectPermissionOnUser(user2, "p2", project);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
dbTester.users().insertProjectPermissionOnGroup(group2, "p2", project);
userSessionRule.addProjectPermission(UserRole.ADMIN, project);
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("This organization cannot use project private");
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
}
doThrow(new BillingValidations.BillingValidationsException("This organization cannot use project private")).when(billingValidations)
.checkCanUpdateProjectVisibility(any(BillingValidations.Organization.class), eq(true));
- request.setParam(PARAM_PROJECT, project.key())
+ request.setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_VISIBILITY, PUBLIC)
.execute();
}
@Test
public void json_example() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey(KEY_PROJECT_EXAMPLE_001));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey(KEY_PROJECT_EXAMPLE_001));
userSession.addProjectPermission(UserRole.USER, project);
SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(parseDateTime("2016-12-11T17:12:45+0100").getTime()));
SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(parseDateTime("2016-12-12T17:12:45+0100").getTime()));
@Test
public void return_analyses_ordered_by_analysis_date() {
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("P1"));
userSession.addProjectPermission(UserRole.USER, project);
db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
@Test
public void return_only_processed_analyses() {
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("P1"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey("P1"));
userSession.addProjectPermission(UserRole.USER, project);
db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setStatus(SnapshotDto.STATUS_UNPROCESSED));
@Test
public void return_events() {
OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("P1"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("P1"));
userSession.addProjectPermission(UserRole.USER, project);
SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(ComponentTesting.newPrivateProjectDto(organizationDto)).setUuid("A42"));
SnapshotDto secondAnalysis = db.components().insertSnapshot(newAnalysis(application).setCreatedAt(2_000_000L));
SnapshotDto thirdAnalysis = db.components().insertSnapshot(newAnalysis(application).setCreatedAt(3_000_000L));
- List<Analysis> result = call(application.key()).getAnalysesList();
+ List<Analysis> result = call(application.getDbKey()).getAnalysesList();
assertThat(result).hasSize(3);
assertThat(result).extracting(Analysis::getKey).containsExactly(thirdAnalysis.getUuid(), secondAnalysis.getUuid(), firstAnalysis.getUuid());
IntStream.rangeClosed(1, 9).forEach(i -> db.components().insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000L * i).setUuid("A" + i)));
SearchResponse result = call(SearchRequest.builder()
- .setProject(project.key())
+ .setProject(project.getDbKey())
.setPage(2)
.setPageSize(3)
.build());
@Test
public void filter_by_category() {
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("P1"));
userSession.addProjectPermission(UserRole.USER, project);
SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1"));
SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2"));
@Test
public void paginate_with_filter_on_category() {
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("P1"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("P1"));
userSession.addProjectPermission(UserRole.USER, project);
SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
SearchResponse result = call(SearchRequest.builder()
- .setProject(project.key())
+ .setProject(project.getDbKey())
.setFrom(formatDateTime(2_000_000_000L))
.build());
SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
SearchResponse result = call(SearchRequest.builder()
- .setProject(project.key())
+ .setProject(project.getDbKey())
.setTo(formatDateTime(2_000_000_000L))
.build());
SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
SearchResponse result = call(SearchRequest.builder()
- .setProject(project.key())
+ .setProject(project.getDbKey())
.setFrom(formatDateTime(2_000_000_000L))
.setTo(formatDateTime(3_000_000_000L))
.build());
SnapshotDto a4 = db.components().insertSnapshot(newAnalysis(project).setUuid("a4").setCreatedAt(4_000_000_000L));
SearchResponse result = call(SearchRequest.builder()
- .setProject(project.key())
+ .setProject(project.getDbKey())
.setFrom(formatDate(new Date(2_000_000_000L)))
.setTo(formatDate(new Date(3_000_000_000L)))
.build());
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
- SearchResponse result = call(project.key());
+ SearchResponse result = call(project.getDbKey());
assertThat(result.hasPaging()).isTrue();
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 0);
expectedException.expect(ForbiddenException.class);
- call(project.key());
+ call(project.getDbKey());
}
@Test
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("A project or application is required");
- call(view.key());
+ call(view.getDbKey());
}
private static Function<Event, String> wsToDbCategory() {
String result = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_NAME, "Custom")
.setParam(PARAM_URL, "http://example.org")
.execute().getInput();
userSession.logIn().addProjectPermission(UserRole.ADMIN, root);
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + component.key() + "' (id: " + component.uuid() + ") must be a project");
+ expectedException.expectMessage("Component '" + component.getDbKey() + "' (id: " + component.uuid() + ") must be a project");
TestRequest testRequest = ws.newRequest();
if (new Random().nextBoolean()) {
- testRequest.setParam(PARAM_PROJECT_KEY, component.key());
+ testRequest.setParam(PARAM_PROJECT_KEY, component.getDbKey());
} else {
testRequest.setParam(PARAM_PROJECT_ID, component.uuid());
}
private ComponentDto insertProject() {
OrganizationDto org = db.organizations().insert();
return db.components().insertComponent(
- ComponentTesting.newPrivateProjectDto(org, PROJECT_UUID).setKey(PROJECT_KEY));
+ ComponentTesting.newPrivateProjectDto(org, PROJECT_UUID).setDbKey(PROJECT_KEY));
}
private void createAndTest(ComponentDto project, String name, String url, String type) throws IOException {
WsProjectLinks.CreateWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_NAME, name)
.setParam(PARAM_URL, url)
.executeProtobuf(WsProjectLinks.CreateWsResponse.class);
return componentDb.insertComponent(new ComponentDto()
.setOrganizationUuid("org1")
.setUuid(projectUuid)
- .setKey(projectKey)
+ .setDbKey(projectKey)
.setUuidPath("")
.setRootUuid("")
.setProjectUuid(""));
insertHomepageLink(project.uuid());
logInAsProjectAdministrator(project);
- SearchWsResponse response = callByKey(project.key());
+ SearchWsResponse response = callByKey(project.getDbKey());
assertThat(response.getLinksCount()).isEqualTo(1);
assertThat(response.getLinks(0).getName()).isEqualTo("Homepage");
ComponentLinkDto customLink = insertCustomLink(project.uuid());
logInAsProjectAdministrator(project);
- SearchWsResponse response = callByKey(project.key());
+ SearchWsResponse response = callByKey(project.getDbKey());
assertThat(response.getLinksCount()).isEqualTo(2);
assertThat(response.getLinksList()).extracting(Link::getId, Link::getName, Link::getType, Link::getUrl)
insertCustomLink(project2.uuid());
userSession.logIn().setRoot();
- SearchWsResponse response = callByKey(project1.key());
+ SearchWsResponse response = callByKey(project1.getDbKey());
assertThat(response.getLinksCount()).isEqualTo(1);
assertThat(response.getLinks(0).getId()).isEqualTo(customLink1.getIdAsString());
insertLink(foo);
logInAsProjectAdministrator(project);
- callByKey(project.key());
+ callByKey(project.getDbKey());
}
@Test
insertLink(foo);
logInAsProjectAdministrator(project);
- callByKey(project.key());
+ callByKey(project.getDbKey());
}
@Test
userSession.logIn().addProjectPermission(UserRole.ADMIN, root);
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Component '" + component.key() + "' (id: " + component.uuid() + ") must be a project");
+ expectedException.expectMessage("Component '" + component.getDbKey() + "' (id: " + component.uuid() + ") must be a project");
TestRequest testRequest = ws.newRequest();
if (new Random().nextBoolean()) {
- testRequest.setParam(PARAM_PROJECT_KEY, component.key());
+ testRequest.setParam(PARAM_PROJECT_KEY, component.getDbKey());
} else {
testRequest.setParam(PARAM_PROJECT_ID, component.uuid());
}
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_PROJECT_ID, project.uuid())
.execute();
}
}
private ComponentDto insertProject(String projectKey, String projectUuid) {
- return componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), projectUuid).setKey(projectKey));
+ return componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), projectUuid).setDbKey(projectKey));
}
private ComponentDto insertProject() {
private void checkItWorks(ComponentDto project) throws IOException {
insertHomepageLink(project.uuid());
- SearchWsResponse response = callByKey(project.key());
+ SearchWsResponse response = callByKey(project.getDbKey());
assertThat(response.getLinksCount()).isEqualTo(1);
assertThat(response.getLinks(0).getName()).isEqualTo("Homepage");
}
return new ProjectMeasuresDoc()
.setOrganizationUuid(project.getOrganizationUuid())
.setId(project.uuid())
- .setKey(project.key())
+ .setKey(project.getDbKey())
.setName(project.name());
}
@Test
public void set_tags_exclude_empty_and_blank_values() {
- TestResponse response = call(project.key(), "finance , offshore, platform, ,");
+ TestResponse response = call(project.getDbKey(), "finance , offshore, platform, ,");
- assertTags(project.key(), "finance", "offshore", "platform");
+ assertTags(project.getDbKey(), "finance", "offshore", "platform");
// FIXME verify(indexer).indexProject(project.uuid(), PROJECT_TAGS_UPDATE);
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
public void reset_tags() {
project = db.components().insertPrivateProject(p -> p.setTagsString("platform,scanner"));
- call(project.key(), "");
+ call(project.getDbKey(), "");
- assertNoTags(project.key());
+ assertNoTags(project.getDbKey());
}
@Test
public void override_existing_tags() {
project = db.components().insertPrivateProject(p -> p.setTagsString("marketing,languages"));
- call(project.key(), "finance,offshore,platform");
+ call(project.getDbKey(), "finance,offshore,platform");
- assertTags(project.key(), "finance", "offshore", "platform");
+ assertTags(project.getDbKey(), "finance", "offshore", "platform");
}
@Test
public void set_tags_as_project_admin() {
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
- call(project.key(), "platform, lambda");
+ call(project.getDbKey(), "platform, lambda");
- assertTags(project.key(), "platform", "lambda");
+ assertTags(project.getDbKey(), "platform", "lambda");
}
@Test
public void do_not_duplicate_tags() {
- call(project.key(), "atlas, atlas, atlas");
+ call(project.getDbKey(), "atlas, atlas, atlas");
- assertTags(project.key(), "atlas");
+ assertTags(project.getDbKey(), "atlas");
}
@Test
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("_finance_' is invalid. Project tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
- call(project.key(), "_finance_");
+ call(project.getDbKey(), "_finance_");
}
@Test
expectedException.expect(ForbiddenException.class);
- call(project.key(), "platform");
+ call(project.getDbKey(), "platform");
}
@Test
public void fail_if_no_tags() {
expectedException.expect(IllegalArgumentException.class);
- call(project.key(), null);
+ call(project.getDbKey(), null);
}
@Test
public void fail_if_component_is_a_view() {
- ComponentDto view = db.components().insertView(v -> v.setKey("VIEW_KEY"));
+ ComponentDto view = db.components().insertView(v -> v.setDbKey("VIEW_KEY"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Component 'VIEW_KEY' is not a project");
- call(view.key(), "point-of-view");
+ call(view.getDbKey(), "point-of-view");
}
@Test
public void fail_if_component_is_a_module() {
- ComponentDto module = db.components().insertComponent(newModuleDto(project).setKey("MODULE_KEY"));
+ ComponentDto module = db.components().insertComponent(newModuleDto(project).setDbKey("MODULE_KEY"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Component 'MODULE_KEY' is not a project");
- call(module.key(), "modz");
+ call(module.getDbKey(), "modz");
}
@Test
public void fail_if_component_is_a_file() {
- ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("FILE_KEY"));
+ ComponentDto file = db.components().insertComponent(newFileDto(project).setDbKey("FILE_KEY"));
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Component 'FILE_KEY' is not a project");
- call(file.getKey(), "secret");
+ call(file.getDbKey(), "secret");
}
@Test
// The property is overriding global value
newComponentPropertyDto(project).setKey("property").setValue("two"));
- executeAndVerify(project.key(), null, "return_project_values.json");
+ executeAndVerify(project.getDbKey(), null, "return_project_values.json");
}
@Test
// The property is overriding global value
newComponentPropertyDto(module).setKey("property").setValue("two"));
- executeAndVerify(module.key(), "property", "return_module_values.json");
+ executeAndVerify(module.getDbKey(), "property", "return_module_values.json");
}
@Test
newComponentPropertyDto(project).setKey("projectProperty").setValue("project"),
newComponentPropertyDto(module).setKey("moduleProperty").setValue("module"));
- executeAndVerify(module.key(), null, "return_inherited_values_on_module.json");
+ executeAndVerify(module.getDbKey(), null, "return_inherited_values_on_module.json");
}
@Test
newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"),
newComponentPropertyDto(project).setKey("plugin.licenseHash.secured").setValue("987654321"));
- executeAndVerify(project.key(), null, "return_secured_and_license_settings_when_project_admin.json");
+ executeAndVerify(project.getDbKey(), null, "return_secured_and_license_settings_when_project_admin.json");
}
@Test
newComponentPropertyDto(project).setKey("not_defined").setValue("ABCD"),
newGlobalPropertyDto().setKey("global_not_defined").setValue("ABCD"));
- executeAndVerify(project.key(), null, "return_all_project_settings_when_component_and_no_key.json");
+ executeAndVerify(project.getDbKey(), null, "return_all_project_settings_when_component_and_no_key.json");
}
@Test
newGlobalPropertyDto().setKey("foo").setValue("one"),
newGlobalPropertyDto().setKey("bar").setValue("two"));
- executeAndVerify(project.key(), "foo", "return_only_one_setting_when_key_is_provided.json");
- executeAndVerify(project.key(), "unknown", "empty.json");
+ executeAndVerify(project.getDbKey(), "foo", "return_only_one_setting_when_key_is_provided.json");
+ executeAndVerify(project.getDbKey(), "unknown", "empty.json");
}
@Test
definitions.addComponent(PropertyDefinition.builder("foo").build());
propertyDb.insertProperties(newComponentPropertyDto(project).setKey("foo").setValue("one"));
- executeAndVerify(project.key(), null, "does_not_fail_when_user_has_not_project_browse_permission.json");
+ executeAndVerify(project.getDbKey(), null, "does_not_fail_when_user_has_not_project_browse_permission.json");
}
@Test
when(dbClient.componentDao()).thenReturn(componentDao);
when(componentDao.selectOrFailById(eq(dbSession), anyLong())).thenReturn(
- newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setId(1L).setKey(PROJECT_KEY));
+ newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setId(1L).setDbKey(PROJECT_KEY));
underTest = new QualityGates(dbClient, metricFinder, userSession);
String gateId = String.valueOf(gate.getId());
associateProjectToQualityGate(project.getId(), gateId);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
assertDeselected(project.getId());
}
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
assertDeselected(project.getId());
}
public void fail_when_no_quality_gate() throws Exception {
expectedException.expect(NotFoundException.class);
- callByKey("-1", project.getKey());
+ callByKey("-1", project.getDbKey());
}
@Test
userSession.anonymous();
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
@Test
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
@Test
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
private QualityGateDto insertQualityGate() {
associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
logInAsProjectUser(project);
- GetByProjectWsResponse result = callByKey(project.key());
+ GetByProjectWsResponse result = callByKey(project.getDbKey());
assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
}
@Test
public void return_status_by_project_key() throws IOException {
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("project-key"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("project-key"));
SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)
.setPeriodMode("last_version")
.setPeriodParam("2015-12-07")
logInAsRoot();
String gateId = String.valueOf(gate.getId());
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
assertSelected(gateId, project.getId());
}
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
String gateId = String.valueOf(gate.getId());
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
assertSelected(gateId, project.getId());
}
userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES, project.getOrganizationUuid());
String gateId = String.valueOf(gate.getId());
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
assertSelected(gateId, project.getId());
}
@Test
public void fail_when_no_quality_gate() throws Exception {
expectedException.expect(NotFoundException.class);
- callByKey("1", project.getKey());
+ callByKey("1", project.getDbKey());
}
@Test
userSession.anonymous();
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
@Test
userSession.logIn().addProjectPermission(UserRole.ISSUE_ADMIN, project);
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
@Test
userSession.logIn();
expectedException.expect(ForbiddenException.class);
- callByKey(gateId, project.getKey());
+ callByKey(gateId, project.getDbKey());
}
private QualityGateDto insertQualityGate() {
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.key()));
+ SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.getDbKey()));
assertThat(result.getProfilesList())
.extracting(QualityProfile::getKey)
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.key()));
+ SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
assertThat(result.getProfilesList())
.extracting(QualityProfile::getKey)
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
SearchWsResponse result = call(ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList())
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
SearchWsResponse result = call(ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey())
.setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList()).isEmpty();
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(format("Project uuid of component uuid '%s' does not exist", module.uuid()));
- call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.key()));
+ call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
}
@Test
ComponentDto project = db.components().insertPrivateProject(anotherOrganization);
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage(format("Component key '%s' not found", project.getKey()));
+ expectedException.expectMessage(format("Component key '%s' not found", project.getDbKey()));
call(ws.newRequest()
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PROJECT_KEY, project.getKey()));
+ .setParam(PARAM_PROJECT_KEY, project.getDbKey()));
}
@Test
.onQualifiers(PROJECT)
.build());
- ListDefinitionsWsResponse result = executeRequest(project.key());
+ ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
assertThat(result.getDefinitionsList()).hasSize(1);
}
PropertyDefinition.builder("only-on-project").onlyOnQualifiers(PROJECT).build(),
PropertyDefinition.builder("only-on-module").onlyOnQualifiers(MODULE).build()));
- ListDefinitionsWsResponse result = executeRequest(project.key());
+ ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
assertThat(result.getDefinitionsList()).extracting("key").containsOnly("global-and-project", "only-on-project");
}
PropertyDefinition.builder("secret.secured").onQualifiers(PROJECT).build(),
PropertyDefinition.builder("plugin.license.secured").onQualifiers(PROJECT).type(PropertyType.LICENSE).build()));
- ListDefinitionsWsResponse result = executeRequest(project.key());
+ ListDefinitionsWsResponse result = executeRequest(project.getDbKey());
assertThat(result.getDefinitionsList()).extracting(Settings.Definition::getKey).containsOnly("foo", "secret.secured", "plugin.license.secured");
}
expectedException.expect(ForbiddenException.class);
- executeRequest(project.key());
+ executeRequest(project.getDbKey());
}
@Test
}
private void executeRequestOnProjectSetting(String key) {
- executeRequest(key, project.key());
+ executeRequest(key, project.getDbKey());
}
private void executeRequestOnComponentSetting(String key, ComponentDto componentDto) {
- executeRequest(key, componentDto.key());
+ executeRequest(key, componentDto.getDbKey());
}
private void executeRequest(String key, @Nullable String componentKey) {
ComponentDto project = db.components().insertPrivateProject();
logInAsProjectAdministrator(project);
- callForProjectSettingByKey("my.key", "my project value", project.key());
+ callForProjectSettingByKey("my.key", "my project value", project.getDbKey());
assertGlobalSetting("my.key", "my global value");
assertComponentSetting("my.key", "my project value", project.getId());
ComponentDto project = db.components().insertPrivateProject();
logInAsProjectAdministrator(project);
- callForProjectSettingByKey("my.key", "my value", project.key());
+ callForProjectSettingByKey("my.key", "my value", project.getDbKey());
assertComponentSetting("my.key", "my value", project.getId());
}
assertComponentSetting("my.key", "my project value", project.getId());
logInAsProjectAdministrator(project);
- callForProjectSettingByKey("my.key", "my new project value", project.key());
+ callForProjectSettingByKey("my.key", "my new project value", project.getDbKey());
assertComponentSetting("my.key", "my new project value", project.getId());
}
callForComponentPropertySet("my.key", newArrayList(
GSON.toJson(ImmutableMap.of("firstField", "firstValue", "secondField", "secondValue")),
GSON.toJson(ImmutableMap.of("firstField", "anotherFirstValue", "secondField", "anotherSecondValue"))),
- project.key());
+ project.getDbKey());
assertThat(dbClient.propertiesDao().selectGlobalProperties(dbSession)).hasSize(3);
- assertThat(dbClient.propertiesDao().selectProjectProperties(dbSession, project.key())).hasSize(5);
+ assertThat(dbClient.propertiesDao().selectProjectProperties(dbSession, project.getDbKey())).hasSize(5);
assertGlobalSetting("my.key", "1");
assertGlobalSetting("my.key.1.firstField", "oldFirstValue");
assertGlobalSetting("my.key.1.secondField", "oldSecondValue");
expectedException.expectMessage("Setting 'my.key' cannot be set on a View");
logInAsProjectAdministrator(view);
- callForProjectSettingByKey("my.key", "My Value", view.key());
+ callForProjectSettingByKey("my.key", "My Value", view.getDbKey());
}
@Test
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Setting 'my.key' cannot be set on a CptLabel");
- callForProjectSettingByKey("my.key", "My Value", file.key());
+ callForProjectSettingByKey("my.key", "My Value", file.getDbKey());
}
@Test
private void succeedForPropertyWithoutDefinitionAndValidComponent(ComponentDto project, ComponentDto module) {
logInAsProjectAdministrator(project);
- callForProjectSettingByKey("my.key", "My Value", module.key());
+ callForProjectSettingByKey("my.key", "My Value", module.getDbKey());
assertComponentSetting("my.key", "My Value", module.getId());
}
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Setting 'my.key' cannot be set on a QualifierLabel");
- callForProjectSettingByKey("my.key", "My Value", component.key());
+ callForProjectSettingByKey("my.key", "My Value", component.getDbKey());
}
@Test
expectedException.expectMessage("Setting 'my.key' cannot be set on a Project");
callForComponentPropertySet("my.key", newArrayList(
- GSON.toJson(ImmutableMap.of("firstField", "firstValue"))), project.key());
+ GSON.toJson(ImmutableMap.of("firstField", "firstValue"))), project.getDbKey());
}
@Test
expectedException.expect(ForbiddenException.class);
- executeRequest(project.key(), "foo");
+ executeRequest(project.getDbKey(), "foo");
}
@Test
}
private ValuesWsResponse executeRequestForComponentProperties(ComponentDto componentDto, String... keys) {
- return executeRequest(componentDto.key(), keys);
+ return executeRequest(componentDto.getDbKey(), keys);
}
private ValuesWsResponse executeRequestForProjectProperties(String... keys) {
- return executeRequest(project.key(), keys);
+ return executeRequest(project.getDbKey(), keys);
}
private ValuesWsResponse executeRequestForGlobalProperties(String... keys) {
insertFileWithData(file, newData("public class HelloWorld {", "}"));
TestResponse request = tester.newRequest()
- .setParam("resource", file.getKey())
+ .setParam("resource", file.getDbKey())
.execute();
assertJson(request.getInput()).isSimilarTo("[\n" +
insertFileWithData(file, newData("/**", " */", "public class HelloWorld {", "}", "", "foo"));
TestResponse request = tester.newRequest()
- .setParam("resource", file.getKey())
+ .setParam("resource", file.getDbKey())
.setParam("from", "3")
.setParam("to", "5")
.execute();
expectedException.expect(ForbiddenException.class);
tester.newRequest()
- .setParam("resource", file.getKey())
+ .setParam("resource", file.getDbKey())
.execute();
}
wsTester = new WsTester(new SourcesWs(
new LinesAction(TestComponentFinder.from(dbTester), dbTester.getDbClient(), sourceService, htmlSourceDecorator, userSessionRule)));
project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
- file = newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
+ file = newFileDto(project, null, FILE_UUID).setDbKey(FILE_KEY);
}
@Test
@Test
public void fail_when_file_is_removed() throws Exception {
- ComponentDto file = newFileDto(project).setKey("file-key").setEnabled(false);
+ ComponentDto file = newFileDto(project).setDbKey("file-key").setEnabled(false);
dbTester.components().insertComponents(project, file);
setUserWithValidPermission();
new SourcesWs(new ScmAction(dbClient, new SourceService(dbTester.getDbClient(), new HtmlSourceDecorator()), userSessionRule, TestComponentFinder.from(dbTester))));
project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID);
- file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
+ file = ComponentTesting.newFileDto(project, null, FILE_UUID).setDbKey(FILE_KEY);
dbClient.componentDao().insert(dbTester.getSession(), project, file);
dbTester.getSession().commit();
}
public void display_log_on_deprecated_project() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
- .setKey(DEPRECATED_PROJECT_KEY)
+ .setDbKey(DEPRECATED_PROJECT_KEY)
.setDeprecatedKey(null));
dbSession.commit();
public void not_display_log_when_task_already_executed() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
- .setKey(DEPRECATED_PROJECT_KEY)
+ .setDbKey(DEPRECATED_PROJECT_KEY)
.setDeprecatedKey(null));
dbSession.commit();
public void nothing_do_when_no_deprecated_project() throws Exception {
OrganizationDto organizationDto = dbTester.organizations().insert();
dbClient.componentDao().insert(dbSession, ComponentTesting.newPrivateProjectDto(organizationDto)
- .setKey(PROJECT_KEY)
+ .setDbKey(PROJECT_KEY)
.setDeprecatedKey(PROJECT_KEY));
dbSession.commit();
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
Arrays.asList(
- newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
- newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+ newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setDbKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+ newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setDbKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
TestRequest request = ws.newRequest().setParam(TEST_ID, "test-uuid");
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(
Arrays.asList(
- newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
- newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
+ newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_1_ID).setDbKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"),
+ newFileDto(ComponentTesting.newPrivateProjectDto(organizationDto), null, FILE_2_ID).setDbKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Test with id 'test-uuid' is not found");
assertThat(result.getName()).isEqualTo(test.getName());
assertThat(result.getStatus()).isEqualTo(WsTests.TestStatus.OK);
assertThat(result.getFileId()).isEqualTo(testFile.uuid());
- assertThat(result.getFileKey()).isEqualTo(testFile.key());
+ assertThat(result.getFileKey()).isEqualTo(testFile.getDbKey());
assertThat(result.getFileName()).isEqualTo(testFile.path());
assertThat(result.getDurationInMs()).isEqualTo(test.getExecutionTimeMs());
assertThat(result.getMessage()).isEqualTo(test.getMsg());
insertTests(testFile, test1, test2);
insertTests(anotherTestFile, test3);
- ListResponse request = call(ws.newRequest().setParam(TEST_FILE_KEY, testFile.key()));
+ ListResponse request = call(ws.newRequest().setParam(TEST_FILE_KEY, testFile.getDbKey()));
assertThat(request.getTestsList()).extracting(WsTests.Test::getId).containsOnly(test1.getUuid(), test2.getUuid());
}
DbFileSources.Test test4 = newTest(anotherMainFile, 11).build();
insertTests(testFile, test1, test2, test3, test4);
- ListResponse request = call(ws.newRequest().setParam(SOURCE_FILE_KEY, mainFile.key()).setParam(SOURCE_FILE_LINE_NUMBER, "10"));
+ ListResponse request = call(ws.newRequest().setParam(SOURCE_FILE_KEY, mainFile.getDbKey()).setParam(SOURCE_FILE_LINE_NUMBER, "10"));
assertThat(request.getTestsList()).extracting(WsTests.Test::getId).containsOnly(test1.getUuid(), test3.getUuid());
}
insertTests(testFile, newTest(mainFile, 10).build());
expectedException.expect(ForbiddenException.class);
- call(ws.newRequest().setParam(TEST_FILE_KEY, testFile.key()));
+ call(ws.newRequest().setParam(TEST_FILE_KEY, testFile.getDbKey()));
}
@Test
public void before() {
OrganizationDto organization = dbTester.organizations().insertForKey("my-org");
project = newPrivateProjectDto(organization, "abcd")
- .setKey("polop")
+ .setDbKey("polop")
.setName("Polop")
.setDescription("test project")
.setLanguage("xoo");
init();
expectedException.expect(NotFoundException.class);
- execute(project.key());
+ execute(project.getDbKey());
}
@Test
userSession.logIn();
expectedException.expect(ForbiddenException.class);
- execute(project.key());
+ execute(project.getDbKey());
}
@Test
componentDbTester.insertComponent(project);
userSession.logIn().addProjectPermission(UserRole.USER, project);
- verifySuccess(project.key());
+ verifySuccess(project.getDbKey());
}
@Test
componentDbTester.insertComponent(project);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
- verifySuccess(project.key());
+ verifySuccess(project.getDbKey());
}
@Test
componentDbTester.insertComponent(project);
userSession.logIn().setSystemAdministrator();
- verifySuccess(project.key());
+ verifySuccess(project.getDbKey());
}
@Test
componentDbTester.insertComponent(project);
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_component_info_when_anonymous_no_snapshot.json");
+ executeAndVerify(project.getDbKey(), "return_component_info_when_anonymous_no_snapshot.json");
}
@Test
propertyDbTester.insertProperty(new PropertyDto().setKey("favourite").setResourceId(project.getId()).setUserId(user.getId()));
userSession.logIn(user).addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_component_info_with_favourite.json");
+ executeAndVerify(project.getDbKey(), "return_component_info_with_favourite.json");
}
@Test
.setLast(true));
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_component_info_when_snapshot.json");
+ executeAndVerify(project.getDbKey(), "return_component_info_when_snapshot.json");
}
@Test
createQProfile("qp2", "Sonar Way Xoo", "xoo"));
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_quality_profiles.json");
+ executeAndVerify(project.getDbKey(), "return_quality_profiles.json");
}
@Test
componentDbTester.insertComponent(project);
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_empty_quality_profiles_when_no_measure.json");
+ executeAndVerify(project.getDbKey(), "return_empty_quality_profiles_when_no_measure.json");
}
@Test
dbTester.qualityGates().associateProjectToQualityGate(project, qualityGateDto);
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_quality_gate.json");
+ executeAndVerify(project.getDbKey(), "return_quality_gate.json");
}
@Test
dbTester.qualityGates().createDefaultQualityGate("Sonar way");
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_default_quality_gate.json");
+ executeAndVerify(project.getDbKey(), "return_default_quality_gate.json");
}
@Test
componentDbTester.insertComponent(project);
userSession.addProjectPermission(UserRole.USER, project);
- String json = execute(project.key());
+ String json = execute(project.getDbKey());
assertThat(json).doesNotContain("qualityGate");
}
componentDbTester.insertComponent(project);
userSession.anonymous().addProjectPermission(UserRole.USER, project);
- executeAndVerify(project.key(), "return_extensions.json");
+ executeAndVerify(project.getDbKey(), "return_extensions.json");
}
@Test
userSession.registerComponents(application);
String result = ws.newRequest()
- .setParam(PARAM_COMPONENT, application.key())
+ .setParam(PARAM_COMPONENT, application.getDbKey())
.execute().getInput();
assertThat(result).contains("my_plugin/app_page");
.addProjectPermission(UserRole.USER, project)
.addProjectPermission(UserRole.ADMIN, project);
- executeAndVerify(project.key(), "return_extensions_for_admin.json");
+ executeAndVerify(project.getDbKey(), "return_extensions_for_admin.json");
}
@Test
.build();
init(page1, page2);
- executeAndVerify(project.key(), "return_configuration_for_admin.json");
+ executeAndVerify(project.getDbKey(), "return_configuration_for_admin.json");
}
@Test
when(resourceTypes.get(project.qualifier()))
.thenReturn(projectResourceType);
- executeAndVerify(project.key(), "return_configuration_with_all_properties.json");
+ executeAndVerify(project.getDbKey(), "return_configuration_with_all_properties.json");
}
@Test
public void return_breadcrumbs_on_module() throws Exception {
init();
ComponentDto project = componentDbTester.insertComponent(this.project);
- ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
+ ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
userSession.anonymous()
.addProjectPermission(UserRole.USER, project)
.addProjectPermission(UserRole.ADMIN, project);
- executeAndVerify(module.key(), "return_breadcrumbs_on_module.json");
+ executeAndVerify(module.getDbKey(), "return_breadcrumbs_on_module.json");
}
@Test
.addProjectPermission(UserRole.USER, project)
.addPermission(ADMINISTER_QUALITY_PROFILES, project.getOrganizationUuid());
- executeAndVerify(project.key(), "return_configuration_for_quality_profile_admin.json");
+ executeAndVerify(project.getDbKey(), "return_configuration_for_quality_profile_admin.json");
}
@Test
.addProjectPermission(UserRole.USER, project)
.addPermission(ADMINISTER_QUALITY_GATES, project.getOrganizationUuid());
- executeAndVerify(project.key(), "return_configuration_for_quality_gate_admin.json");
+ executeAndVerify(project.getDbKey(), "return_configuration_for_quality_gate_admin.json");
}
@Test
public void return_bread_crumbs_on_several_levels() throws Exception {
init();
ComponentDto project = componentDbTester.insertComponent(this.project);
- ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setKey("palap").setName("Palap"));
+ ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
ComponentDto file = componentDbTester.insertComponent(newFileDto(directory, directory, "cdef").setName("Source.xoo")
- .setKey("palap:src/main/xoo/Source.xoo")
+ .setDbKey("palap:src/main/xoo/Source.xoo")
.setPath(directory.path()));
userSession.addProjectPermission(UserRole.USER, project);
- executeAndVerify(file.key(), "return_bread_crumbs_on_several_levels.json");
+ executeAndVerify(file.getDbKey(), "return_bread_crumbs_on_several_levels.json");
}
@Test
componentDbTester.insertProjectAndSnapshot(project);
userSession.addProjectPermission(UserRole.ADMIN, project);
- execute(project.key());
+ execute(project.getDbKey());
}
@Test
init(createPages());
OrganizationDto organizationDto = dbTester.organizations().insertForKey("my-org-1");
ComponentDto project = newPrivateProjectDto(organizationDto, "ABCD")
- .setKey("org.codehaus.sonar:sonar")
+ .setDbKey("org.codehaus.sonar:sonar")
.setName("Sonarqube")
.setDescription("Open source platform for continuous inspection of code quality");
componentDbTester.insertComponent(project);
.addProjectPermission(UserRole.USER, project)
.addProjectPermission(UserRole.ADMIN, project);
- String result = execute(project.key());
+ String result = execute(project.getDbKey());
assertJson(result).ignoreFields("snapshotDate", "key", "qualityGate.key").isSimilarTo(ws.getDef().responseExampleAsString());
}
userSession.logIn()
.addProjectPermission(UserRole.ADMIN, project)
.addPermission(OrganizationPermission.ADMINISTER, org);
- assertJson(execute(project.key())).isSimilarTo("{\"visibility\": \"private\"}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"private\"}");
}
@Test
userSession.logIn()
.addProjectPermission(UserRole.ADMIN, project)
.addPermission(OrganizationPermission.ADMINISTER, org);
- assertJson(execute(project.key())).isSimilarTo("{\"visibility\": \"public\"}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"public\"}");
}
@Test
userSession.logIn()
.addProjectPermission(UserRole.ADMIN, project)
.addPermission(OrganizationPermission.ADMINISTER, org);
- String json = execute(module.key());
+ String json = execute(module.getDbKey());
assertThat(json).doesNotContain("visibility");
}
userSession.logIn()
.addProjectPermission(UserRole.ADMIN, project)
.addPermission(OrganizationPermission.ADMINISTER, org);
- assertJson(execute(project.key())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": true}}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": true}}");
userSession.logIn()
.addProjectPermission(UserRole.ADMIN, project);
- assertJson(execute(project.key())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": false}}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canApplyPermissionTemplate\": false}}");
}
@Test
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
when(billingValidations.canUpdateProjectVisibilityToPrivate(any(BillingValidations.Organization.class))).thenReturn(false);
- assertJson(execute(project.key())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": false}}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": false}}");
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
when(billingValidations.canUpdateProjectVisibilityToPrivate(any(BillingValidations.Organization.class))).thenReturn(true);
- assertJson(execute(project.key())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": true}}");
+ assertJson(execute(project.getDbKey())).isSimilarTo("{\"configuration\": {\"canUpdateProjectVisibilityToPrivate\": true}}");
}
private void init(Page... pages) {
organization = db.organizations().insert();
publicProject = db.components().insertPublicProject(organization, PUBLIC_PROJECT_UUID);
privateProject = db.components().insertPrivateProject(organization, dto -> dto.setUuid(PRIVATE_PROJECT_UUID).setProjectUuid(PRIVATE_PROJECT_UUID).setPrivate(true));
- db.components().insertComponent(ComponentTesting.newFileDto(publicProject, null, FILE_UUID).setKey(FILE_KEY));
+ db.components().insertComponent(ComponentTesting.newFileDto(publicProject, null, FILE_UUID).setDbKey(FILE_KEY));
user = db.users().insertUser(LOGIN);
groupOfUser = db.users().insertGroup(organization);
}
ComponentFinder componentFinder = TestComponentFinder.from(db);
WebhookDeliveriesAction underTest = new WebhookDeliveriesAction(dbClient, userSession, componentFinder);
ws = new WsActionTester(underTest);
- project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my-project"));
+ project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("my-project"));
}
@Test
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
Webhooks.DeliveriesWsResponse response = ws.newRequest()
- .setParam("componentKey", project.getKey())
+ .setParam("componentKey", project.getDbKey())
.executeProtobuf(Webhooks.DeliveriesWsResponse.class);
assertThat(response.getDeliveriesCount()).isEqualTo(0);
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
String json = ws.newRequest()
- .setParam("componentKey", project.getKey())
+ .setParam("componentKey", project.getDbKey())
.execute()
.getInput();
expectedException.expectMessage("Insufficient privileges");
ws.newRequest()
- .setParam("componentKey", project.getKey())
+ .setParam("componentKey", project.getDbKey())
.execute();
}
expectedException.expectMessage("Either parameter 'ceTaskId' or 'componentKey' must be defined");
ws.newRequest()
- .setParam("componentKey", project.getKey())
+ .setParam("componentKey", project.getDbKey())
.setParam("ceTaskId", "t1")
.execute();
}
ComponentFinder componentFinder = TestComponentFinder.from(db);
WebhookDeliveryAction underTest = new WebhookDeliveryAction(dbClient, userSession, componentFinder);
ws = new WsActionTester(underTest);
- project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("my-project"));
+ project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setDbKey("my-project"));
}
@Test