@@ -713,7 +713,7 @@ public class InternalCeQueueImplTest { | |||
} | |||
private ComponentDto newComponentDto(String uuid) { | |||
return ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
return ComponentTesting.newPublicProjectDto(dbTester.getDefaultOrganization(), uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
} | |||
private CeTask submit(String reportType, String componentUuid) { |
@@ -54,7 +54,7 @@ import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectCopy; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newSubView; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN; | |||
@@ -534,11 +534,11 @@ public class ComponentDaoTest { | |||
@Test | |||
public void select_projects() { | |||
OrganizationDto organization = db.organizations().insert(); | |||
ComponentDto provisionedProject = db.components().insertProject(); | |||
ComponentDto provisionedProject = db.components().insertPrivateProject(); | |||
ComponentDto provisionedView = db.components().insertView(organization, (dto) -> { | |||
}); | |||
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid(); | |||
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid(); | |||
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid(); | |||
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid(); | |||
String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid(); | |||
assertThat(underTest.selectProjects(dbSession)) | |||
@@ -549,10 +549,10 @@ public class ComponentDaoTest { | |||
@Test | |||
public void select_provisioned() { | |||
OrganizationDto organization = db.organizations().insert(); | |||
ComponentDto provisionedProject = db.components().insertComponent(newProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project")); | |||
ComponentDto provisionedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project")); | |||
ComponentDto provisionedView = db.components().insertView(organization); | |||
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid(); | |||
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid(); | |||
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)).getComponentUuid(); | |||
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid(); | |||
String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid(); | |||
Set<String> projectQualifiers = newHashSet(Qualifiers.PROJECT); | |||
@@ -595,8 +595,8 @@ public class ComponentDaoTest { | |||
@Test | |||
public void count_provisioned() { | |||
OrganizationDto organization = db.organizations().insert(); | |||
db.components().insertProject(organization); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)); | |||
db.components().insertPrivateProject(organization); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organization)); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)); | |||
assertThat(underTest.countProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.PROJECT))).isEqualTo(1); | |||
@@ -609,25 +609,25 @@ public class ComponentDaoTest { | |||
OrganizationDto organization = db.organizations().insert(); | |||
// ghosts because has at least one snapshot with status U but none with status P | |||
ComponentDto ghostProject = db.components().insertProject(organization); | |||
ComponentDto ghostProject = db.components().insertPrivateProject(organization); | |||
db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U")); | |||
db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U")); | |||
ComponentDto ghostProject2 = db.components().insertProject(organization); | |||
ComponentDto ghostProject2 = db.components().insertPrivateProject(organization); | |||
db.components().insertSnapshot(ghostProject2, dto -> dto.setStatus("U")); | |||
ComponentDto disabledGhostProject = db.components().insertProject(dto -> dto.setEnabled(false)); | |||
ComponentDto disabledGhostProject = db.components().insertPrivateProject(dto -> dto.setEnabled(false)); | |||
db.components().insertSnapshot(disabledGhostProject, dto -> dto.setStatus("U")); | |||
ComponentDto project1 = db.components().insertProject(organization); | |||
ComponentDto project1 = db.components().insertPrivateProject(organization); | |||
db.components().insertSnapshot(project1, dto -> dto.setStatus("P")); | |||
db.components().insertSnapshot(project1, dto -> dto.setStatus("U")); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(project1)); | |||
ComponentDto dir = db.components().insertComponent(newDirectory(module, "foo")); | |||
db.components().insertComponent(newFileDto(module, dir, "bar")); | |||
ComponentDto provisionedProject = db.components().insertProject(organization); | |||
ComponentDto provisionedProject = db.components().insertPrivateProject(organization); | |||
// not a ghost because has at least one snapshot with status P | |||
ComponentDto project2 = db.components().insertProject(organization); | |||
ComponentDto project2 = db.components().insertPrivateProject(organization); | |||
db.components().insertSnapshot(project2, dto -> dto.setStatus("P")); | |||
// not a ghost because it's not a project | |||
@@ -748,7 +748,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void update() { | |||
db.components().insertProject(db.getDefaultOrganization(), "U1"); | |||
db.components().insertPrivateProject(db.getDefaultOrganization(), "U1"); | |||
underTest.update(dbSession, new ComponentUpdateDto() | |||
.setUuid("U1") | |||
@@ -783,9 +783,9 @@ public class ComponentDaoTest { | |||
@Test | |||
public void updateBEnabledToFalse() { | |||
ComponentDto dto1 = newProjectDto(db.getDefaultOrganization(), "U1"); | |||
ComponentDto dto2 = newProjectDto(db.getDefaultOrganization(), "U2"); | |||
ComponentDto dto3 = newProjectDto(db.getDefaultOrganization(), "U3"); | |||
ComponentDto dto1 = newPrivateProjectDto(db.getDefaultOrganization(), "U1"); | |||
ComponentDto dto2 = newPrivateProjectDto(db.getDefaultOrganization(), "U2"); | |||
ComponentDto dto3 = newPrivateProjectDto(db.getDefaultOrganization(), "U3"); | |||
underTest.insert(dbSession, dto1, dto2, dto3); | |||
underTest.updateBEnabledToFalse(dbSession, asList("U1", "U2")); | |||
@@ -834,7 +834,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void update_tags() { | |||
ComponentDto project = db.components().insertProject(p -> p.setTags(emptyList())); | |||
ComponentDto project = db.components().insertPrivateProject(p -> p.setTags(emptyList())); | |||
underTest.updateTags(dbSession, project.setTags(newArrayList("finance", "toto", "tutu"))); | |||
dbSession.commit(); | |||
@@ -844,8 +844,8 @@ public class ComponentDaoTest { | |||
@Test | |||
public void delete() throws Exception { | |||
ComponentDto project1 = db.components().insertProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_1")); | |||
db.components().insertProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_2")); | |||
ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_1")); | |||
db.components().insertPrivateProject(db.getDefaultOrganization(), (t) -> t.setKey("PROJECT_2")); | |||
underTest.delete(dbSession, project1.getId()); | |||
dbSession.commit(); | |||
@@ -873,10 +873,10 @@ public class ComponentDaoTest { | |||
@Test | |||
public void selectByQuery_with_paging_query_and_qualifiers() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
db.components().insertProjectAndSnapshot(newProjectDto(organizationDto).setName("aaaa-name")); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setName("aaaa-name")); | |||
db.components().insertProjectAndSnapshot(newView(organizationDto)); | |||
for (int i = 9; i >= 1; i--) { | |||
db.components().insertProjectAndSnapshot(newProjectDto(organizationDto).setName("project-" + i)); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project-" + i)); | |||
} | |||
ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("oJect").setQualifiers(Qualifiers.PROJECT).build(); | |||
@@ -893,8 +893,8 @@ public class ComponentDaoTest { | |||
public void selectByQuery_with_organization_filters_on_specified_organization() { | |||
OrganizationDto organization1 = db.organizations().insert(); | |||
OrganizationDto organization2 = db.organizations().insert(); | |||
ComponentDto project1 = db.components().insertProject(organization1); | |||
ComponentDto project2 = db.components().insertProject(organization2); | |||
ComponentDto project1 = db.components().insertPrivateProject(organization1); | |||
ComponentDto project2 = db.components().insertPrivateProject(organization2); | |||
assertThat(underTest.selectByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY, 0, 2)) | |||
.extracting(ComponentDto::uuid) | |||
@@ -913,8 +913,8 @@ public class ComponentDaoTest { | |||
public void countByQuery_with_organization_filters_on_specified_organization() { | |||
OrganizationDto organization1 = db.organizations().insert(); | |||
OrganizationDto organization2 = db.organizations().insert(); | |||
ComponentDto project1 = db.components().insertProject(organization1); | |||
ComponentDto project2 = db.components().insertProject(organization2); | |||
ComponentDto project1 = db.components().insertPrivateProject(organization1); | |||
ComponentDto project2 = db.components().insertPrivateProject(organization2); | |||
assertThat(underTest.countByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY)) | |||
.isEqualTo(2); | |||
@@ -928,7 +928,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void selectByQuery_name_with_special_characters() { | |||
db.components().insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization()).setName("project-\\_%/-name")); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("project-\\_%/-name")); | |||
ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("-\\_%/-").setQualifiers(Qualifiers.PROJECT).build(); | |||
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10); | |||
@@ -939,7 +939,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void selectByQuery_key_with_special_characters() { | |||
db.components().insertProjectAndSnapshot(newProjectDto(db.organizations().insert()).setKey("project-_%-key")); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey("project-_%-key")); | |||
ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("project-_%-key").setQualifiers(Qualifiers.PROJECT).build(); | |||
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10); | |||
@@ -950,8 +950,8 @@ public class ComponentDaoTest { | |||
@Test | |||
public void selectByQuery_filter_on_language() { | |||
db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("java-project-key").setLanguage("java")); | |||
db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("cpp-project-key").setLanguage("cpp")); | |||
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")); | |||
ComponentQuery query = ComponentQuery.builder().setLanguage("java").setQualifiers(Qualifiers.PROJECT).build(); | |||
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10); | |||
@@ -973,9 +973,9 @@ public class ComponentDaoTest { | |||
@Test | |||
public void selectByQuery_on_component_ids() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto sonarqube = db.components().insertComponent(newProjectDto(organizationDto)); | |||
ComponentDto jdk8 = db.components().insertComponent(newProjectDto(organizationDto)); | |||
ComponentDto cLang = db.components().insertComponent(newProjectDto(organizationDto)); | |||
ComponentDto sonarqube = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
ComponentDto jdk8 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
ComponentDto cLang = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
ComponentQuery query = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT) | |||
.setComponentIds(newHashSet(sonarqube.getId(), jdk8.getId())).build(); | |||
@@ -991,7 +991,7 @@ public class ComponentDaoTest { | |||
// organization | |||
OrganizationDto organization = db.organizations().insert(); | |||
// project -> module -> file | |||
ComponentDto project = newProjectDto(organization, PROJECT_UUID); | |||
ComponentDto project = newPrivateProjectDto(organization, PROJECT_UUID); | |||
db.components().insertProjectAndSnapshot(project); | |||
ComponentDto module = newModuleDto(MODULE_UUID, project); | |||
db.components().insertComponent(module); | |||
@@ -1015,7 +1015,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void select_descendants_with_children_stragegy() { | |||
// project has 2 children: module and file 1. Other files are part of module. | |||
ComponentDto project = newProjectDto(db.organizations().insert(), PROJECT_UUID); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID); | |||
db.components().insertProjectAndSnapshot(project); | |||
ComponentDto module = newModuleDto(MODULE_UUID, project); | |||
db.components().insertComponent(module); | |||
@@ -1080,7 +1080,7 @@ public class ComponentDaoTest { | |||
@Test | |||
public void select_descendants_with_leaves_strategy() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID); | |||
db.components().insertProjectAndSnapshot(project); | |||
db.components().insertComponent(newModuleDto("module-1-uuid", project)); | |||
db.components().insertComponent(newFileDto(project, null, "file-1-uuid")); | |||
@@ -1110,7 +1110,7 @@ public class ComponentDaoTest { | |||
ComponentDto subView = newSubView(view, "subview-uuid", "subview-key").setName("subview name"); | |||
db.components().insertComponent(subView); | |||
// one project and its copy linked to the view | |||
ComponentDto project = newProjectDto(organizationDto, PROJECT_UUID).setName("project name"); | |||
ComponentDto project = newPrivateProjectDto(organizationDto, PROJECT_UUID).setName("project name"); | |||
db.components().insertProjectAndSnapshot(project); | |||
db.components().insertComponent(newProjectCopy("project-copy-uuid", project, view)); | |||
ComponentTreeQuery dbQuery = newTreeQuery(A_VIEW_UUID).setNameOrKeyQuery("name").setStrategy(CHILDREN).build(); | |||
@@ -1123,12 +1123,12 @@ public class ComponentDaoTest { | |||
@Test | |||
public void select_projects_by_name_query() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project1 = db.components().insertComponent(newProjectDto(organizationDto).setName("project1")); | |||
ComponentDto project1 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project1")); | |||
ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setName("module1")); | |||
ComponentDto subModule1 = db.components().insertComponent(newModuleDto(module1).setName("subModule1")); | |||
db.components().insertComponent(newFileDto(subModule1).setName("file")); | |||
ComponentDto project2 = db.components().insertComponent(newProjectDto(organizationDto).setName("project2")); | |||
ComponentDto project3 = db.components().insertComponent(newProjectDto(organizationDto).setName("project3")); | |||
ComponentDto project2 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project2")); | |||
ComponentDto project3 = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("project3")); | |||
assertThat(underTest.selectProjectsByNameQuery(dbSession, null, false)).extracting(ComponentDto::uuid) | |||
.containsOnly(project1.uuid(), project2.uuid(), project3.uuid()); | |||
@@ -1149,11 +1149,11 @@ public class ComponentDaoTest { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
String[] uuids = { | |||
db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(true)).uuid(), | |||
db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(false)).uuid(), | |||
db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(true)).uuid(), | |||
db.components().insertComponent(newProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(false)).uuid(), | |||
db.components().insertComponent(newProjectDto(organizationDto).setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(), | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(true)).uuid(), | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid1).setPrivate(false)).uuid(), | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(true)).uuid(), | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setProjectUuid(uuid2).setPrivate(false)).uuid(), | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(), | |||
}; | |||
underTest.setPrivateForRootComponentUuid(db.getSession(), uuid1, true); |
@@ -28,7 +28,6 @@ import org.sonar.db.DbTester; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
/** | |||
* On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique, | |||
@@ -50,10 +49,10 @@ public class ComponentDaoWithDuplicatedKeysTest { | |||
@Test | |||
public void select_components_having_same_key() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY)); | |||
insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY)); | |||
insertProject(newProjectDto(organizationDto).setKey(PROJECT_KEY)); | |||
insertProject(newProjectDto(organizationDto).setKey("ANOTHER_PROJECT_KEY")); | |||
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")); | |||
assertThat(underTest.selectComponentsHavingSameKeyOrderedById(db.getSession(), PROJECT_KEY)).hasSize(3); | |||
} |
@@ -21,13 +21,16 @@ package org.sonar.db.component; | |||
import java.util.Arrays; | |||
import java.util.function.Consumer; | |||
import javax.annotation.Nullable; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import static com.google.common.base.Preconditions.checkState; | |||
import static java.util.Arrays.asList; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPublicProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
@@ -59,53 +62,75 @@ public class ComponentDbTester { | |||
} | |||
public ComponentDto insertComponent(ComponentDto component) { | |||
return insertComponentImpl(component, noExtraConfiguration()); | |||
return insertComponentImpl(component, null, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertProject() { | |||
return insertComponentImpl(newProjectDto(db.getDefaultOrganization()), noExtraConfiguration()); | |||
public ComponentDto insertPrivateProject() { | |||
return insertComponentImpl(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()), true, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertPublicProject() { | |||
return insertComponentImpl(ComponentTesting.newPublicProjectDto(db.getDefaultOrganization()), false, noExtraConfiguration()); | |||
} | |||
@SafeVarargs | |||
public final ComponentDto insertPrivateProject(Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()), true, dtoPopulators); | |||
} | |||
@SafeVarargs | |||
public final ComponentDto insertPublicProject(Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(newPublicProjectDto(db.getDefaultOrganization()), false, dtoPopulators); | |||
} | |||
@SafeVarargs | |||
public final ComponentDto insertProject(Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(newProjectDto(db.getDefaultOrganization()), dtoPopulators); | |||
public final ComponentDto insertPrivateProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(ComponentTesting.newPrivateProjectDto(organizationDto), true, dtoPopulators); | |||
} | |||
@SafeVarargs | |||
public final ComponentDto insertProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(newProjectDto(organizationDto), dtoPopulators); | |||
public final ComponentDto insertPublicProject(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) { | |||
return insertComponentImpl(newPublicProjectDto(organizationDto), true, dtoPopulators); | |||
} | |||
public ComponentDto insertPrivateProject(OrganizationDto organizationDto) { | |||
return insertComponentImpl(ComponentTesting.newPrivateProjectDto(organizationDto), true, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertPublicProject(OrganizationDto organizationDto) { | |||
return insertComponentImpl(newPublicProjectDto(organizationDto), false, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertProject(OrganizationDto organizationDto) { | |||
return insertComponentImpl(newProjectDto(organizationDto), noExtraConfiguration()); | |||
public ComponentDto insertPrivateProject(OrganizationDto organizationDto, String uuid) { | |||
return insertComponentImpl(newPrivateProjectDto(organizationDto, uuid), true, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertProject(OrganizationDto organizationDto, String uuid) { | |||
return insertComponentImpl(newProjectDto(organizationDto, uuid), noExtraConfiguration()); | |||
public ComponentDto insertPublicProject(OrganizationDto organizationDto, String uuid) { | |||
return insertComponentImpl(newPublicProjectDto(organizationDto, uuid), false, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertView() { | |||
return insertComponentImpl(newView(db.getDefaultOrganization()), noExtraConfiguration()); | |||
return insertComponentImpl(newView(db.getDefaultOrganization()), false, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertView(Consumer<ComponentDto> dtoPopulator) { | |||
return insertComponentImpl(newView(db.getDefaultOrganization()), dtoPopulator); | |||
return insertComponentImpl(newView(db.getDefaultOrganization()), false, dtoPopulator); | |||
} | |||
public ComponentDto insertView(OrganizationDto organizationDto) { | |||
return insertComponentImpl(newView(organizationDto), noExtraConfiguration()); | |||
return insertComponentImpl(newView(organizationDto), false, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertView(OrganizationDto organizationDto, Consumer<ComponentDto> dtoPopulator) { | |||
return insertComponentImpl(newView(organizationDto), dtoPopulator); | |||
return insertComponentImpl(newView(organizationDto), false, dtoPopulator); | |||
} | |||
public ComponentDto insertView(String uuid) { | |||
return insertComponentImpl(newView(db.getDefaultOrganization(), uuid), noExtraConfiguration()); | |||
return insertComponentImpl(newView(db.getDefaultOrganization(), uuid), false, noExtraConfiguration()); | |||
} | |||
public ComponentDto insertView(OrganizationDto organizationDto, String uuid) { | |||
return insertComponentImpl(newView(organizationDto, uuid), noExtraConfiguration()); | |||
return insertComponentImpl(newView(organizationDto, uuid), false, noExtraConfiguration()); | |||
} | |||
private static <T> Consumer<T> noExtraConfiguration() { | |||
@@ -114,9 +139,10 @@ public class ComponentDbTester { | |||
} | |||
@SafeVarargs | |||
private final ComponentDto insertComponentImpl(ComponentDto component, Consumer<ComponentDto>... dtoPopulators) { | |||
private final ComponentDto insertComponentImpl(ComponentDto component, @Nullable Boolean isPrivate, Consumer<ComponentDto>... dtoPopulators) { | |||
Arrays.stream(dtoPopulators) | |||
.forEach(dtoPopulator -> dtoPopulator.accept(component)); | |||
checkState(isPrivate == null || component.isPrivate() == isPrivate, "Illegal modification of private flag"); | |||
dbClient.componentDao().insert(dbSession, component); | |||
db.commit(); | |||
@@ -94,7 +94,7 @@ public class ComponentDtoTest { | |||
@Test | |||
public void test_formatUuidPathFromParent() { | |||
ComponentDto parent = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "123").setUuidPath(ComponentDto.UUID_PATH_OF_ROOT); | |||
ComponentDto parent = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "123").setUuidPath(ComponentDto.UUID_PATH_OF_ROOT); | |||
assertThat(ComponentDto.formatUuidPathFromParent(parent)).isEqualTo(".123."); | |||
} | |||
@@ -38,7 +38,7 @@ import static org.sonar.db.component.ComponentKeyUpdaterDao.computeNewKey; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
public class ComponentKeyUpdaterDaoTest { | |||
@@ -63,7 +63,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void updateKey_does_not_updated_inactive_components() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "A").setKey("my_project")); | |||
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)); | |||
@@ -89,7 +89,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void bulk_update_key_does_not_update_inactive_components() { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "A").setKey("my_project")); | |||
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)); | |||
@@ -144,7 +144,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void updateKey_throws_IAE_when_sub_component_key_is_too_long() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = newProjectDto(organizationDto, "project-uuid").setKey("old-project-key"); | |||
ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid").setKey("old-project-key"); | |||
db.components().insertComponent(project); | |||
db.components().insertComponent(newFileDto(project, null).setKey("old-project-key:file")); | |||
String newLongProjectKey = Strings.repeat("a", 400); | |||
@@ -156,7 +156,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void fail_when_new_key_is_invalid() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
thrown.expect(IllegalArgumentException.class); | |||
thrown.expectMessage("Malformed key for 'my?project?key'. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit."); | |||
@@ -178,8 +178,8 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void check_component_keys_checks_inactive_components() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
db.components().insertComponent(newProjectDto(organizationDto).setKey("my-project")); | |||
db.components().insertComponent(newProjectDto(organizationDto).setKey("your-project").setEnabled(false)); | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("my-project")); | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("your-project").setEnabled(false)); | |||
Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("my-project", "your-project", "new-project")); | |||
@@ -201,7 +201,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void simulate_bulk_update_key_do_not_return_disable_components() { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "A").setKey("project")); | |||
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)); | |||
@@ -215,7 +215,7 @@ public class ComponentKeyUpdaterDaoTest { | |||
@Test | |||
public void simulate_bulk_update_key_fails_if_invalid_componentKey() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, "A").setKey("project")); | |||
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)); | |||
@@ -26,6 +26,7 @@ import org.sonar.api.resources.Scopes; | |||
import org.sonar.core.util.Uuids; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import static com.google.common.base.Preconditions.checkArgument; | |||
import static com.google.common.base.Preconditions.checkNotNull; | |||
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR; | |||
@@ -96,15 +97,23 @@ public class ComponentTesting { | |||
return newModuleDto(Uuids.createFast(), subProjectOrProject); | |||
} | |||
public static ComponentDto newProjectDto(OrganizationDto organizationDto) { | |||
return newProjectDto(organizationDto.getUuid(), Uuids.createFast()); | |||
public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto) { | |||
return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), true); | |||
} | |||
public static ComponentDto newProjectDto(OrganizationDto organizationDto, String uuid) { | |||
return newProjectDto(organizationDto.getUuid(), uuid); | |||
public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto, String uuid) { | |||
return newProjectDto(organizationDto.getUuid(), uuid, true); | |||
} | |||
private static ComponentDto newProjectDto(String organizationUuid, String uuid) { | |||
public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto) { | |||
return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), false); | |||
} | |||
public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto, String uuid) { | |||
return newProjectDto(organizationDto.getUuid(), uuid, false); | |||
} | |||
private static ComponentDto newProjectDto(String organizationUuid, String uuid, boolean isPrivate) { | |||
return new ComponentDto() | |||
.setOrganizationUuid(organizationUuid) | |||
.setUuid(uuid) | |||
@@ -120,7 +129,8 @@ public class ComponentTesting { | |||
.setQualifier(Qualifiers.PROJECT) | |||
.setPath(null) | |||
.setLanguage(null) | |||
.setEnabled(true); | |||
.setEnabled(true) | |||
.setPrivate(isPrivate); | |||
} | |||
public static ComponentDto newView(OrganizationDto organizationDto) { | |||
@@ -128,17 +138,18 @@ public class ComponentTesting { | |||
} | |||
public static ComponentDto newView(OrganizationDto organizationDto, String uuid) { | |||
return newProjectDto(organizationDto, uuid) | |||
return newPrivateProjectDto(organizationDto, uuid) | |||
.setUuid(uuid) | |||
.setScope(Scopes.PROJECT) | |||
.setQualifier(Qualifiers.VIEW); | |||
.setQualifier(Qualifiers.VIEW) | |||
.setPrivate(false); | |||
} | |||
private static ComponentDto newView(String organizationUuid, String uuid) { | |||
return newProjectDto(organizationUuid, uuid) | |||
.setUuid(uuid) | |||
.setScope(Scopes.PROJECT) | |||
.setQualifier(Qualifiers.VIEW); | |||
return newProjectDto(organizationUuid, uuid, false) | |||
.setUuid(uuid) | |||
.setScope(Scopes.PROJECT) | |||
.setQualifier(Qualifiers.VIEW); | |||
} | |||
public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) { | |||
@@ -156,6 +167,9 @@ public class ComponentTesting { | |||
} | |||
public static ComponentDto newChildComponent(String uuid, ComponentDto moduleOrProject, ComponentDto parent) { | |||
checkArgument(moduleOrProject.isPrivate() == parent.isPrivate(), | |||
"private flag inconsistent between moduleOrProject (%s) and parent (%s)", | |||
moduleOrProject.isPrivate(), parent.isPrivate()); | |||
return new ComponentDto() | |||
.setOrganizationUuid(parent.getOrganizationUuid()) | |||
.setUuid(uuid) | |||
@@ -165,6 +179,7 @@ public class ComponentTesting { | |||
.setModuleUuid(moduleOrProject.uuid()) | |||
.setModuleUuidPath(moduleOrProject.moduleUuidPath()) | |||
.setCreatedAt(new Date()) | |||
.setEnabled(true); | |||
.setEnabled(true) | |||
.setPrivate(moduleOrProject.isPrivate()); | |||
} | |||
} |
@@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException; | |||
import static java.util.Arrays.asList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN; | |||
import static org.sonar.db.component.ComponentTreeQuery.Strategy.LEAVES; | |||
import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto; | |||
@@ -70,10 +70,10 @@ public class ComponentTreeQueryTest { | |||
@Test | |||
public void test_getUuidPath() throws Exception { | |||
assertThat(ComponentTreeQuery.builder().setBaseUuid(BASE_UUID).setStrategy(CHILDREN) | |||
.build().getUuidPath(newProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID."); | |||
.build().getUuidPath(newPrivateProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID."); | |||
assertThat(ComponentTreeQuery.builder().setBaseUuid(BASE_UUID).setStrategy(LEAVES) | |||
.build().getUuidPath(newProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%"); | |||
.build().getUuidPath(newPrivateProjectDto(newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%"); | |||
} | |||
@Test |
@@ -35,7 +35,7 @@ import org.sonar.db.organization.OrganizationTesting; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static java.util.Collections.emptyList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED; | |||
import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED; | |||
import static org.sonar.db.component.SnapshotQuery.SORT_FIELD.BY_DATE; | |||
@@ -57,7 +57,7 @@ public class SnapshotDaoTest { | |||
@Test | |||
public void test_selectByUuid() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
db.components().insertSnapshot(newAnalysis(project) | |||
.setUuid("ABCD") | |||
.setStatus("P") | |||
@@ -122,12 +122,12 @@ public class SnapshotDaoTest { | |||
@Test | |||
public void selectLastSnapshotsByRootComponentUuids_returns_snapshots_flagged_as_last() { | |||
ComponentDto firstProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_1")); | |||
ComponentDto firstProject = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_1")); | |||
dbClient.snapshotDao().insert(dbSession, newAnalysis(firstProject).setLast(false)); | |||
SnapshotDto lastSnapshotOfFirstProject = dbClient.snapshotDao().insert(dbSession, newAnalysis(firstProject).setLast(true)); | |||
ComponentDto secondProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_2")); | |||
ComponentDto secondProject = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_UUID_2")); | |||
SnapshotDto lastSnapshotOfSecondProject = dbClient.snapshotDao().insert(dbSession, newAnalysis(secondProject).setLast(true)); | |||
db.components().insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization())); | |||
db.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization())); | |||
List<SnapshotDto> result = underTest.selectLastAnalysesByRootComponentUuids(dbSession, newArrayList(firstProject.uuid(), secondProject.uuid())); | |||
@@ -182,7 +182,7 @@ public class SnapshotDaoTest { | |||
@Test | |||
public void select_first_snapshots() throws Exception { | |||
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()); | |||
db.getDbClient().componentDao().insert(dbSession, project); | |||
db.getDbClient().snapshotDao().insert(dbSession, | |||
@@ -200,7 +200,7 @@ public class SnapshotDaoTest { | |||
@Test | |||
public void insert() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
SnapshotDto dto = underTest.insert(db.getSession(), newAnalysis(project) | |||
.setStatus("P") | |||
@@ -229,7 +229,7 @@ public class SnapshotDaoTest { | |||
@Test | |||
public void insert_snapshots() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
underTest.insert(db.getSession(), | |||
newAnalysis(project).setLast(false).setUuid("u5"), | |||
@@ -307,7 +307,7 @@ public class SnapshotDaoTest { | |||
} | |||
private SnapshotDto insertAnalysis(String projectUuid, String uuid, String status, boolean isLastFlag) { | |||
SnapshotDto snapshot = newAnalysis(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid)) | |||
SnapshotDto snapshot = newAnalysis(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid)) | |||
.setLast(isLastFlag) | |||
.setStatus(status) | |||
.setUuid(uuid); |
@@ -29,11 +29,11 @@ import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.SnapshotDto; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.db.event.EventTesting.newEvent; | |||
@@ -51,7 +51,7 @@ public class EventDaoTest { | |||
@Test | |||
public void select_by_uuid() { | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.organizations().insert())); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert())); | |||
dbTester.events().insertEvent(newEvent(analysis).setUuid("A1")); | |||
dbTester.events().insertEvent(newEvent(analysis).setUuid("A2")); | |||
dbTester.events().insertEvent(newEvent(analysis).setUuid("A3")); | |||
@@ -87,7 +87,7 @@ public class EventDaoTest { | |||
@Test | |||
public void select_by_analysis_uuid() { | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
SnapshotDto otherAnalysis = dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); | |||
dbTester.commit(); | |||
@@ -106,7 +106,7 @@ public class EventDaoTest { | |||
@Test | |||
public void select_by_analysis_uuids() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
SnapshotDto a1 = dbTester.components().insertSnapshot(newAnalysis(project)); | |||
SnapshotDto a2 = dbTester.components().insertSnapshot(newAnalysis(project)); | |||
SnapshotDto a42 = dbTester.components().insertSnapshot(newAnalysis(project)); | |||
@@ -156,7 +156,7 @@ public class EventDaoTest { | |||
@Test | |||
public void update_name_and_description() { | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.organizations().insert())); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert())); | |||
dbTester.events().insertEvent(newEvent(analysis).setUuid("E1")); | |||
underTest.update(dbSession, "E1", "New Name", "New Description"); | |||
@@ -178,7 +178,7 @@ public class EventDaoTest { | |||
@Test | |||
public void delete_by_uuid() { | |||
dbTester.events().insertEvent(newEvent(newAnalysis(newProjectDto(dbTester.getDefaultOrganization()))).setUuid("E1")); | |||
dbTester.events().insertEvent(newEvent(newAnalysis(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()))).setUuid("E1")); | |||
underTest.delete(dbTester.getSession(), "E1"); | |||
dbTester.commit(); |
@@ -151,7 +151,7 @@ public class IssueDaoTest { | |||
private void prepareTables() { | |||
dbTester.rules().insertRule(RULE); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto projectDto = dbTester.components().insertProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto projectDto = dbTester.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY)); | |||
dbTester.components().insertComponent(ComponentTesting.newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY)); | |||
underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY1) | |||
.setMessage("the message") |
@@ -73,7 +73,7 @@ public class IssueDbTester { | |||
public IssueDto insertIssue(OrganizationDto organizationDto, Consumer<IssueDto> populateIssueDto) { | |||
RuleDefinitionDto rule = db.rules().insert(); | |||
ComponentDto project = db.components().insertProject(organizationDto); | |||
ComponentDto project = db.components().insertPrivateProject(organizationDto); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
IssueDto issueDto = newIssue(rule, file, project); | |||
populateIssueDto.accept(issueDto); |
@@ -48,7 +48,7 @@ public class IssueMapperTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
project = ComponentTesting.newProjectDto(organizationDto); | |||
project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbTester.getDbClient().componentDao().insert(dbSession, project); | |||
file = ComponentTesting.newFileDto(project, null); | |||
dbTester.getDbClient().componentDao().insert(dbSession, file); |
@@ -71,7 +71,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void test_inserted_and_selected_columns() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true); | |||
db.components().insertComponent(newFileDto(project).setUuid("C4")); | |||
@@ -105,7 +105,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void selectByQuery() { | |||
ComponentDto project1 = db.components().insertProject(); | |||
ComponentDto project1 = db.components().insertPrivateProject(); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(project1)); | |||
db.components().insertComponent(newFileDto(module).setUuid("C1")); | |||
db.components().insertComponent(newFileDto(module).setUuid("C2")); | |||
@@ -113,7 +113,7 @@ public class MeasureDaoTest { | |||
insertAnalysis(OTHER_ANALYSIS_UUID, project1.uuid(), false); | |||
String project2LastAnalysisUuid = "P2_LAST_ANALYSIS"; | |||
ComponentDto project2 = db.components().insertProject(); | |||
ComponentDto project2 = db.components().insertPrivateProject(); | |||
insertAnalysis(project2LastAnalysisUuid, project2.uuid(), true); | |||
// project 1 | |||
@@ -200,7 +200,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void selectSingle() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
db.components().insertComponent(newFileDto(project).setUuid("C1")); | |||
insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true); | |||
insertMeasure("M1", LAST_ANALYSIS_UUID, "C1", NCLOC_METRIC_ID); | |||
@@ -221,7 +221,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void select_tree_by_query() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto module1 = db.components().insertComponent(newModuleDto(project)); | |||
ComponentDto module2 = db.components().insertComponent(newModuleDto(project)); | |||
ComponentDto file1 = db.components().insertComponent(newFileDto(module1).setUuid("C1").setName("File One")); | |||
@@ -272,7 +272,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void select_tree_by_query_use_only_latest_analysis() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file1 = db.components().insertComponent(newFileDto(project).setUuid("C1").setName("File One")); | |||
db.components().insertComponent(newFileDto(project).setUuid("C2").setName("File Two").setQualifier(UNIT_TEST_FILE)); | |||
insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true); | |||
@@ -305,7 +305,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void select_past_measures_with_several_analyses() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
long lastAnalysisDate = parseDate("2017-01-25").getTime(); | |||
long previousAnalysisDate = lastAnalysisDate - 10_000_000_000L; | |||
long oldAnalysisDate = lastAnalysisDate - 100_000_000_000L; | |||
@@ -329,7 +329,7 @@ public class MeasureDaoTest { | |||
@Test | |||
public void selectByComponentsAndMetrics() { | |||
ComponentDto project1 = db.components().insertProject(db.getDefaultOrganization(), "P1"); | |||
ComponentDto project1 = db.components().insertPrivateProject(db.getDefaultOrganization(), "P1"); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(project1)); | |||
db.components().insertComponent(newFileDto(module).setUuid("C1")); | |||
db.components().insertComponent(newFileDto(module).setUuid("C2")); | |||
@@ -337,7 +337,7 @@ public class MeasureDaoTest { | |||
insertAnalysis(OTHER_ANALYSIS_UUID, project1.uuid(), false); | |||
String project2LastAnalysisUuid = "P2_LAST_ANALYSIS"; | |||
ComponentDto project2 = db.components().insertProject(db.getDefaultOrganization(), "P2"); | |||
ComponentDto project2 = db.components().insertPrivateProject(db.getDefaultOrganization(), "P2"); | |||
insertAnalysis(project2LastAnalysisUuid, project2.uuid(), true); | |||
// project 1 |
@@ -81,10 +81,10 @@ public class MeasureTreeQueryTest { | |||
@Test | |||
public void test_getUuidPath() throws Exception { | |||
assertThat(MeasureTreeQuery.builder().setStrategy(CHILDREN) | |||
.build().getUuidPath(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID."); | |||
.build().getUuidPath(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT_UUID."); | |||
assertThat(MeasureTreeQuery.builder().setStrategy(LEAVES) | |||
.build().getUuidPath(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%"); | |||
.build().getUuidPath(ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), "PROJECT_UUID"))).isEqualTo(".PROJECT/_UUID.%"); | |||
} | |||
@Test |
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.SnapshotDto; | |||
import org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures; | |||
import org.sonar.db.metric.MetricDto; | |||
@@ -47,7 +48,7 @@ import static org.sonar.api.measures.Metric.ValueType.DISTRIB; | |||
import static org.sonar.api.measures.Metric.ValueType.INT; | |||
import static org.sonar.api.measures.Metric.ValueType.LEVEL; | |||
import static org.sonar.api.measures.Metric.ValueType.STRING; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
@@ -65,7 +66,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
public void return_project_measure() { | |||
MetricDto metric1 = insertIntMetric("ncloc"); | |||
MetricDto metric2 = insertIntMetric("coverage"); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setKey("Project-Key").setName("Project Name").setTagsString("platform,java"); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasure(project, analysis, metric1, 10d); | |||
insertMeasure(project, analysis, metric2, 20d); | |||
@@ -86,7 +87,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void return_project_measure_having_leak() throws Exception { | |||
MetricDto metric = insertIntMetric("new_lines"); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasureOnLeak(project, analysis, metric, 10d); | |||
@@ -122,7 +123,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void return_language_distribution_measure() throws Exception { | |||
MetricDto metric = insertMetric("ncloc_language_distribution", DATA); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasure(project, analysis, metric, "<null>=2;java=6;xoo=18"); | |||
@@ -136,7 +137,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
MetricDto dataMetric = insertMetric("data", DATA); | |||
MetricDto distribMetric = insertMetric("distrib", DISTRIB); | |||
MetricDto stringMetric = insertMetric("string", STRING); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasure(project, analysis, dataMetric, "dat"); | |||
insertMeasure(project, analysis, distribMetric, "dis"); | |||
@@ -150,7 +151,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void does_not_return_disabled_metrics() throws Exception { | |||
MetricDto disabledMetric = insertMetric("disabled", false, false, INT); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasure(project, analysis, disabledMetric, 10d); | |||
@@ -162,7 +163,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void fail_when_measure_return_no_value() throws Exception { | |||
MetricDto metric = insertIntMetric("new_lines"); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
insertMeasure(project, analysis, metric, 10d); | |||
@@ -172,16 +173,16 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void return_many_project_measures() { | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization())); | |||
assertThat(createResultSetAndReturnDocsById()).hasSize(3); | |||
} | |||
@Test | |||
public void return_project_without_analysis() throws Exception { | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert())); | |||
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert())); | |||
dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setLast(false)); | |||
dbSession.commit(); | |||
@@ -195,9 +196,9 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void does_not_return_non_active_projects() throws Exception { | |||
// Disabled project | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false)); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setEnabled(false)); | |||
// Disabled project with analysis | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()).setEnabled(false)); | |||
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()).setEnabled(false)); | |||
dbClient.snapshotDao().insert(dbSession, newAnalysis(project)); | |||
// A view | |||
@@ -211,10 +212,10 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void return_only_docs_from_given_project() throws Exception { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
SnapshotDto analysis = dbTester.components().insertProjectAndSnapshot(project); | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById(project.uuid()); | |||
@@ -229,7 +230,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
@Test | |||
public void return_nothing_on_unknown_project() throws Exception { | |||
dbTester.components().insertProjectAndSnapshot(newProjectDto(dbTester.getDefaultOrganization())); | |||
dbTester.components().insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization())); | |||
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById("UNKNOWN"); | |||
@@ -271,7 +272,7 @@ public class ProjectMeasuresIndexerIteratorTest { | |||
} | |||
private MeasureDto insertProjectAndMeasure(String projectUuid, MetricDto metric, String value) { | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), projectUuid); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), projectUuid); | |||
SnapshotDto analysis1 = dbTester.components().insertProjectAndSnapshot(project); | |||
return insertMeasure(project, analysis1, metric, value); | |||
} |
@@ -77,7 +77,7 @@ public class AuthorizationDaoTest { | |||
*/ | |||
@Test | |||
public void selectOrganizationPermissions_for_logged_in_user() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertMember(group1, user); | |||
db.users().insertPermissionOnUser(org, user, "perm1"); | |||
db.users().insertProjectPermissionOnUser(user, "perm42", project); | |||
@@ -451,7 +451,7 @@ public class AuthorizationDaoTest { | |||
db.users().insertPermissionOnUser(org3, user, QUALITY_GATE_ADMIN); | |||
// exclude project permission | |||
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, db.components().insertProject()); | |||
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, db.components().insertPrivateProject()); | |||
Set<String> orgUuids = underTest.selectOrganizationUuidsOfUserWithGlobalPermission(dbSession, user.getId(), SCAN_EXECUTION); | |||
@@ -470,10 +470,10 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project); | |||
db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.USER, project); | |||
ComponentDto otherProject = db.components().insertProject(); | |||
ComponentDto otherProject = db.components().insertPrivateProject(); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, otherProject); | |||
assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, project.uuid())).containsOnly(UserRole.CODEVIEWER); | |||
@@ -481,7 +481,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissionsOfAnonymous_returns_empty_set_when_project_does_not_exist() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project); | |||
assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, "does_not_exist")).isEmpty(); | |||
@@ -489,7 +489,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissions_returns_empty_set_when_logged_in_user_and_project_does_not_exist() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project); | |||
assertThat(underTest.selectProjectPermissions(dbSession, "does_not_exist", user.getId())).isEmpty(); | |||
@@ -497,7 +497,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_anonymous_permissions() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, project); | |||
@@ -506,7 +506,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project); | |||
db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.ISSUE_ADMIN, project); | |||
@@ -515,7 +515,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_group_membership() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnGroup(group1, UserRole.CODEVIEWER, project); | |||
db.users().insertProjectPermissionOnGroup(group2, UserRole.ISSUE_ADMIN, project); | |||
db.users().insertMember(group1, user); | |||
@@ -525,7 +525,7 @@ public class AuthorizationDaoTest { | |||
@Test | |||
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project_through_all_possible_configurations() { | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project); | |||
db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, project); | |||
db.users().insertProjectPermissionOnGroup(group1, UserRole.USER, project); |
@@ -31,6 +31,7 @@ import org.sonar.api.web.UserRole; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.db.user.GroupDto; | |||
@@ -45,7 +46,6 @@ import static org.sonar.api.web.UserRole.USER; | |||
import static org.sonar.core.permission.GlobalPermissions.PROVISIONING; | |||
import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION; | |||
import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER; | |||
import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS; | |||
import static org.sonar.db.permission.OrganizationPermission.SCAN; | |||
@@ -72,9 +72,9 @@ public class GroupPermissionDaoTest { | |||
GroupDto group1 = db.users().insertGroup(); | |||
GroupDto group2 = db.users().insertGroup(); | |||
GroupDto group3 = db.users().insertGroup(); | |||
ComponentDto project1 = db.components().insertProject(); | |||
ComponentDto project2 = db.components().insertProject(); | |||
ComponentDto project3 = db.components().insertProject(); | |||
ComponentDto project1 = db.components().insertPrivateProject(); | |||
ComponentDto project2 = db.components().insertPrivateProject(); | |||
ComponentDto project3 = db.components().insertPrivateProject(); | |||
db.users().insertProjectPermissionOnGroup(group1, ISSUE_ADMIN, project1); | |||
db.users().insertProjectPermissionOnGroup(group1, ADMIN, project2); | |||
@@ -135,7 +135,7 @@ public class GroupPermissionDaoTest { | |||
GroupDto group2 = db.users().insertGroup(organizationDto, "Group-2"); | |||
GroupDto group3 = db.users().insertGroup(organizationDto, "Group-3"); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto)); | |||
ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
db.users().insertPermissionOnAnyone(organizationDto, SCAN); | |||
db.users().insertPermissionOnAnyone(organizationDto, PROVISION_PROJECTS); | |||
@@ -159,8 +159,8 @@ public class GroupPermissionDaoTest { | |||
GroupDto group2 = db.users().insertGroup(); | |||
GroupDto group3 = db.users().insertGroup(); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto anotherProject = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto anotherProject = db.components().insertPrivateProject(); | |||
db.users().insertProjectPermissionOnGroup(group1, SCAN_EXECUTION, project); | |||
db.users().insertProjectPermissionOnGroup(group1, PROVISIONING, project); | |||
@@ -217,7 +217,7 @@ public class GroupPermissionDaoTest { | |||
db.users().insertPermissionOnGroup(group1, SCAN); | |||
GroupDto group2 = db.users().insertGroup(organizationDto, "Group-2"); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto)); | |||
ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project); | |||
GroupDto group3 = db.users().insertGroup(organizationDto, "Group-3"); | |||
@@ -255,7 +255,7 @@ public class GroupPermissionDaoTest { | |||
db.users().insertPermissionOnGroup(group1, PROVISION_PROJECTS); | |||
GroupDto group2 = db.users().insertGroup(org, "Group-2"); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(org)); | |||
ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(org)); | |||
db.users().insertProjectPermissionOnGroup(group2, USER, project); | |||
GroupDto group3 = db.users().insertGroup(org, "Group-3"); | |||
@@ -291,7 +291,7 @@ public class GroupPermissionDaoTest { | |||
OrganizationDto org2 = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org1, "group1"); | |||
GroupDto group2 = db.users().insertGroup(org2, "group2"); | |||
ComponentDto project = db.components().insertProject(org1); | |||
ComponentDto project = db.components().insertPrivateProject(org1); | |||
db.users().insertPermissionOnAnyone(org1, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
@@ -313,8 +313,8 @@ public class GroupPermissionDaoTest { | |||
public void selectProjectPermissionsOfGroup() { | |||
OrganizationDto org1 = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org1, "group1"); | |||
ComponentDto project1 = db.components().insertProject(org1); | |||
ComponentDto project2 = db.components().insertProject(org1); | |||
ComponentDto project1 = db.components().insertPrivateProject(org1); | |||
ComponentDto project2 = db.components().insertPrivateProject(org1); | |||
db.users().insertPermissionOnAnyone(org1, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
@@ -337,8 +337,8 @@ public class GroupPermissionDaoTest { | |||
public void selectAllPermissionsByGroupId() throws Exception { | |||
OrganizationDto org1 = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org1, "group1"); | |||
ComponentDto project1 = db.components().insertProject(org1); | |||
ComponentDto project2 = db.components().insertProject(org1); | |||
ComponentDto project1 = db.components().insertPrivateProject(org1); | |||
ComponentDto project2 = db.components().insertPrivateProject(org1); | |||
db.users().insertPermissionOnAnyone(org1, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1); | |||
@@ -358,8 +358,8 @@ public class GroupPermissionDaoTest { | |||
OrganizationDto org = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org); | |||
GroupDto group2 = db.users().insertGroup(org); | |||
ComponentDto project1 = db.components().insertProject(org); | |||
ComponentDto project2 = db.components().insertProject(org); | |||
ComponentDto project1 = db.components().insertPrivateProject(org); | |||
ComponentDto project2 = db.components().insertPrivateProject(org); | |||
db.users().insertPermissionOnGroup(group1, "perm1"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm2", project1); | |||
db.users().insertProjectPermissionOnAnyone("perm3", project1); | |||
@@ -376,7 +376,7 @@ public class GroupPermissionDaoTest { | |||
public void delete_global_permission_from_group() { | |||
OrganizationDto org = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org); | |||
ComponentDto project1 = db.components().insertProject(org); | |||
ComponentDto project1 = db.components().insertPrivateProject(org); | |||
db.users().insertPermissionOnAnyone(org, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1); | |||
@@ -393,7 +393,7 @@ public class GroupPermissionDaoTest { | |||
public void delete_global_permission_from_anyone() { | |||
OrganizationDto org = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org); | |||
ComponentDto project1 = db.components().insertProject(org); | |||
ComponentDto project1 = db.components().insertPrivateProject(org); | |||
db.users().insertPermissionOnAnyone(org, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1); | |||
@@ -410,7 +410,7 @@ public class GroupPermissionDaoTest { | |||
public void delete_project_permission_from_group() { | |||
OrganizationDto org = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org); | |||
ComponentDto project1 = db.components().insertProject(org); | |||
ComponentDto project1 = db.components().insertPrivateProject(org); | |||
db.users().insertPermissionOnAnyone(org, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1); | |||
@@ -427,7 +427,7 @@ public class GroupPermissionDaoTest { | |||
public void delete_project_permission_from_anybody() { | |||
OrganizationDto org = db.organizations().insert(); | |||
GroupDto group1 = db.users().insertGroup(org); | |||
ComponentDto project1 = db.components().insertProject(org); | |||
ComponentDto project1 = db.components().insertPrivateProject(org); | |||
db.users().insertPermissionOnAnyone(org, "perm1"); | |||
db.users().insertPermissionOnGroup(group1, "perm2"); | |||
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1); |
@@ -70,8 +70,8 @@ public class UserPermissionDaoTest { | |||
dbClient.userDao().insert(dbSession, user2); | |||
dbClient.userDao().insert(dbSession, user3); | |||
organizationDto = dbTester.organizations().insert(); | |||
project1 = dbTester.components().insertProject(organizationDto); | |||
project2 = dbTester.components().insertProject(organizationDto); | |||
project1 = dbTester.components().insertPrivateProject(organizationDto); | |||
project2 = dbTester.components().insertPrivateProject(organizationDto); | |||
dbTester.organizations().addMember(organizationDto, user1); | |||
dbTester.organizations().addMember(organizationDto, user2); | |||
dbTester.organizations().addMember(organizationDto, user3); | |||
@@ -236,8 +236,8 @@ public class UserPermissionDaoTest { | |||
public void selectUserIds() { | |||
OrganizationDto org1 = dbTester.organizations().insert(); | |||
OrganizationDto org2 = dbTester.organizations().insert(); | |||
ComponentDto project1 = dbTester.components().insertProject(org1); | |||
ComponentDto project2 = dbTester.components().insertProject(org2); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(org1); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(org2); | |||
addProjectPermission(org1, USER, user1, project1); | |||
addProjectPermission(org1, USER, user2, project1); | |||
@@ -353,7 +353,7 @@ public class UserPermissionDaoTest { | |||
@Test | |||
public void selectProjectPermissionsOfUser() { | |||
OrganizationDto org = dbTester.organizations().insert(); | |||
ComponentDto project3 = dbTester.components().insertProject(org); | |||
ComponentDto project3 = dbTester.components().insertPrivateProject(org); | |||
addGlobalPermission(organizationDto, "perm1", user1); | |||
addProjectPermission(organizationDto, "perm2", user1, project1); | |||
addProjectPermission(organizationDto, "perm3", user1, project1); | |||
@@ -414,7 +414,7 @@ public class UserPermissionDaoTest { | |||
public void delete_permissions_of_an_organization_member() { | |||
OrganizationDto organization1 = dbTester.organizations().insert(); | |||
OrganizationDto organization2 = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(organization1); | |||
ComponentDto project = dbTester.components().insertPrivateProject(organization1); | |||
UserDto user1 = dbTester.users().insertUser(); | |||
UserDto user2 = dbTester.users().insertUser(); | |||
// user 1 permissions | |||
@@ -442,7 +442,7 @@ public class UserPermissionDaoTest { | |||
public void deleteByUserId() { | |||
UserDto user1 = dbTester.users().insertUser(); | |||
UserDto user2 = dbTester.users().insertUser(); | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
dbTester.users().insertPermissionOnUser(user1, SCAN); | |||
dbTester.users().insertPermissionOnUser(user1, ADMINISTER); | |||
dbTester.users().insertProjectPermissionOnUser(user1, ADMINISTER_QUALITY_GATES.getKey(), project); |
@@ -338,7 +338,7 @@ public class PropertiesDaoTest { | |||
@UseDataProvider("allValuesForSelect") | |||
public void selectEnabledDescendantModuleProperties_supports_all_values(String dbValue, String expected) throws SQLException { | |||
String projectUuid = "A"; | |||
ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid); | |||
dbClient.componentDao().insert(session, project); | |||
long projectId = project.getId(); | |||
insertProperty("project.one", dbValue, projectId, null); | |||
@@ -404,7 +404,7 @@ public class PropertiesDaoTest { | |||
@Test | |||
public void select_component_properties_by_keys() throws Exception { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
UserDto user = dbTester.users().insertUser(); | |||
String key = "key"; | |||
@@ -425,8 +425,8 @@ public class PropertiesDaoTest { | |||
@Test | |||
public void select_component_properties_by_ids() throws Exception { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project2 = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(); | |||
UserDto user = UserTesting.newUserDto(); | |||
dbClient.userDao().insert(session, user); | |||
@@ -453,8 +453,8 @@ public class PropertiesDaoTest { | |||
@Test | |||
public void select_properties_by_keys_and_component_ids() throws Exception { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project2 = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(); | |||
UserDto user = UserTesting.newUserDto(); | |||
dbClient.userDao().insert(session, user); | |||
@@ -850,8 +850,8 @@ public class PropertiesDaoTest { | |||
public void delete_by_organization_and_user() throws SQLException { | |||
OrganizationDto organization = dbTester.organizations().insert(); | |||
OrganizationDto anotherOrganization = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(organization); | |||
ComponentDto anotherProject = dbTester.components().insertProject(anotherOrganization); | |||
ComponentDto project = dbTester.components().insertPrivateProject(organization); | |||
ComponentDto anotherProject = dbTester.components().insertPrivateProject(anotherOrganization); | |||
UserDto user = dbTester.users().insertUser(); | |||
UserDto anotherUser = dbTester.users().insertUser(); | |||
insertProperty("KEY_11", "VALUE", project.getId(), user.getId()); | |||
@@ -872,8 +872,8 @@ public class PropertiesDaoTest { | |||
public void delete_by_organization_and_matching_login() throws SQLException { | |||
OrganizationDto organization = dbTester.organizations().insert(); | |||
OrganizationDto anotherOrganization = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(organization); | |||
ComponentDto anotherProject = dbTester.components().insertProject(anotherOrganization); | |||
ComponentDto project = dbTester.components().insertPrivateProject(organization); | |||
ComponentDto anotherProject = dbTester.components().insertPrivateProject(anotherOrganization); | |||
UserDto user = dbTester.users().insertUser(); | |||
UserDto anotherUser = dbTester.users().insertUser(); | |||
insertProperty("KEY_11", user.getLogin(), project.getId(), null); | |||
@@ -892,8 +892,8 @@ public class PropertiesDaoTest { | |||
@Test | |||
public void delete_by_key_and_value() throws SQLException { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto anotherProject = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto anotherProject = dbTester.components().insertPrivateProject(); | |||
insertProperty("KEY", "VALUE", null, null); | |||
insertProperty("KEY", "VALUE", project.getId(), null); | |||
insertProperty("KEY", "VALUE", null, 100); | |||
@@ -1091,7 +1091,7 @@ public class PropertiesDaoTest { | |||
private ComponentDto insertProject(String uuid) { | |||
String key = "project" + uuid; | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), uuid).setKey(key); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setKey(key); | |||
dbClient.componentDao().insert(session, project); | |||
dbTester.commit(); | |||
return project; |
@@ -141,8 +141,8 @@ public class PurgeDaoTest { | |||
@Test | |||
public void delete_project_in_ce_activity_when_deleting_project() { | |||
ComponentDto projectToBeDeleted = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto anotherLivingProject = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto projectToBeDeleted = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
ComponentDto anotherLivingProject = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization()); | |||
dbClient.componentDao().insert(dbSession, projectToBeDeleted, anotherLivingProject); | |||
// Insert 2 rows in CE_ACTIVITY : one for the project that will be deleted, and on on another project | |||
@@ -158,8 +158,8 @@ public class PurgeDaoTest { | |||
@Test | |||
public void delete_tasks_in_ce_queue_when_deleting_project() { | |||
ComponentDto projectToBeDeleted = dbTester.components().insertProject(); | |||
ComponentDto anotherLivingProject = dbTester.components().insertProject(); | |||
ComponentDto projectToBeDeleted = dbTester.components().insertPrivateProject(); | |||
ComponentDto anotherLivingProject = dbTester.components().insertPrivateProject(); | |||
// Insert 3 rows in CE_QUEUE: two for the project that will be deleted (in order to check that status | |||
// is not involved in deletion), and one on another project |
@@ -88,7 +88,7 @@ public class ProjectQgateAssociationDaoTest { | |||
@Test | |||
public void select_qgate_id_is_absent() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
Optional<Long> result = underTest.selectQGateIdByComponentId(dbSession, project.getId()); | |||
@@ -128,7 +128,7 @@ public class QualityProfileDaoTest { | |||
@Test | |||
public void deleteProjectAssociationsByProfileKeys_does_nothing_if_empty_keys() { | |||
QualityProfileDto profile1 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization()); | |||
ComponentDto project1 = dbTester.components().insertProject(); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profile1); | |||
underTest.deleteProjectAssociationsByProfileKeys(dbSession, Collections.emptyList()); | |||
@@ -140,9 +140,9 @@ public class QualityProfileDaoTest { | |||
public void deleteProjectAssociationsByProfileKeys_deletes_rows_from_table_project_profiles() { | |||
QualityProfileDto profile1 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization()); | |||
QualityProfileDto profile2 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization()); | |||
ComponentDto project1 = dbTester.components().insertProject(); | |||
ComponentDto project2 = dbTester.components().insertProject(); | |||
ComponentDto project3 = dbTester.components().insertProject(); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(); | |||
ComponentDto project3 = dbTester.components().insertPrivateProject(); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profile1); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project2, profile1); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project3, profile2); | |||
@@ -304,14 +304,14 @@ public class QualityProfileDaoTest { | |||
public void countProjectsByProfileKey() { | |||
QualityProfileDto profileWithoutProjects = dbTester.qualityProfiles().insert(organization); | |||
QualityProfileDto profileWithProjects = dbTester.qualityProfiles().insert(organization); | |||
ComponentDto project1 = dbTester.components().insertProject(organization); | |||
ComponentDto project2 = dbTester.components().insertProject(organization); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(organization); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(organization); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, profileWithProjects); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(project2, profileWithProjects); | |||
OrganizationDto otherOrg = dbTester.organizations().insert(); | |||
QualityProfileDto profileInOtherOrg = dbTester.qualityProfiles().insert(otherOrg); | |||
ComponentDto projectInOtherOrg = dbTester.components().insertProject(otherOrg); | |||
ComponentDto projectInOtherOrg = dbTester.components().insertPrivateProject(otherOrg); | |||
dbTester.qualityProfiles().associateProjectWithQualityProfile(projectInOtherOrg, profileInOtherOrg); | |||
assertThat(underTest.countProjectsByProfileKey(dbTester.getSession(), organization)).containsOnly( | |||
@@ -357,11 +357,11 @@ public class QualityProfileDaoTest { | |||
@Test | |||
public void select_selected_projects() throws Exception { | |||
ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
OrganizationDto organization2 = dbTester.organizations().insert(); | |||
ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
QualityProfileDto profile1 = newQualityProfileDto(); | |||
qualityProfileDb.insertQualityProfiles(profile1); | |||
@@ -384,11 +384,11 @@ public class QualityProfileDaoTest { | |||
@Test | |||
public void select_deselected_projects() throws Exception { | |||
ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
OrganizationDto organization2 = dbTester.organizations().insert(); | |||
ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
QualityProfileDto profile1 = newQualityProfileDto(); | |||
qualityProfileDb.insertQualityProfiles(profile1); | |||
@@ -410,11 +410,11 @@ public class QualityProfileDaoTest { | |||
@Test | |||
public void select_project_associations() throws Exception { | |||
ComponentDto project1 = dbTester.components().insertProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(t -> t.setName("Project1 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(t -> t.setName("Project2 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
ComponentDto project3 = dbTester.components().insertPrivateProject(t -> t.setName("Project3 name"), t -> t.setOrganizationUuid(organization.getUuid())); | |||
OrganizationDto organization2 = dbTester.organizations().insert(); | |||
ComponentDto project4 = dbTester.components().insertProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
ComponentDto project4 = dbTester.components().insertPrivateProject(t -> t.setName("Project4 name"), t -> t.setOrganizationUuid(organization2.getUuid())); | |||
QualityProfileDto profile1 = newQualityProfileDto(); | |||
qualityProfileDb.insertQualityProfiles(profile1); | |||
@@ -437,7 +437,7 @@ public class QualityProfileDaoTest { | |||
@Test | |||
public void update_project_profile_association() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
QualityProfileDto profile1Language1 = insertQualityProfileDto("profile1", "Profile 1", "xoo"); | |||
QualityProfileDto profile2Language2 = insertQualityProfileDto("profile2", "Profile 2", "xoo2"); | |||
QualityProfileDto profile3Language1 = insertQualityProfileDto("profile3", "Profile 3", "xoo"); |
@@ -53,8 +53,8 @@ public class RoleDaoTest { | |||
public void setUp() throws Exception { | |||
user1 = db.users().insertUser(); | |||
user2 = db.users().insertUser(); | |||
project1 = db.components().insertProject(); | |||
project2 = db.components().insertProject(); | |||
project1 = db.components().insertPrivateProject(); | |||
project2 = db.components().insertPrivateProject(); | |||
} | |||
@Test | |||
@@ -117,7 +117,7 @@ public class RoleDaoTest { | |||
public void delete_all_group_permissions_by_group_id() { | |||
GroupDto group1 = db.users().insertGroup(); | |||
GroupDto group2 = db.users().insertGroup(); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
db.users().insertPermissionOnGroup(group1, "admin"); | |||
db.users().insertProjectPermissionOnGroup(group1, "profileadmin", project); | |||
db.users().insertPermissionOnGroup(group1, "gateadmin"); |
@@ -73,7 +73,7 @@ public class CeQueueImplTest { | |||
@Test | |||
public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() { | |||
ComponentDto componentDto = insertComponent(ComponentTesting.newProjectDto(dbTester.organizations().insert(), "PROJECT_1")); | |||
ComponentDto componentDto = insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "PROJECT_1")); | |||
CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto.uuid(), null); | |||
CeTask task = underTest.submit(taskSubmit); | |||
@@ -116,7 +116,7 @@ public class CeQueueImplTest { | |||
@Test | |||
public void massSubmit_populates_component_name_and_key_of_CeTask_if_component_exists() { | |||
ComponentDto componentDto1 = insertComponent(ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1")); | |||
ComponentDto componentDto1 = insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1")); | |||
CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, componentDto1.uuid(), null); | |||
CeTaskSubmit taskSubmit2 = createTaskSubmit("something", "non existing component uuid", null); | |||
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.api.rules.RuleType.BUG; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.rule.RuleTesting.newRule; | |||
public class IssuesActionTest { | |||
@@ -87,7 +87,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void return_minimal_fields() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY)); | |||
ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath(null)); | |||
db.rules().insert(RULE_DEFINITION); | |||
@@ -126,7 +126,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void issues_from_project() throws Exception { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY)); | |||
ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java")); | |||
db.rules().insert(RULE_DEFINITION); | |||
@@ -162,7 +162,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void issues_from_module() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY)); | |||
ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java")); | |||
db.rules().insert(RULE_DEFINITION); | |||
@@ -198,7 +198,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void issues_from_file() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY)); | |||
ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java")); | |||
db.rules().insert(RULE_DEFINITION); | |||
@@ -235,7 +235,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void issues_attached_on_module() throws Exception { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY)); | |||
db.rules().insert(RULE_DEFINITION); | |||
db.issues().insert(RULE_DEFINITION, project, module, issue -> issue | |||
@@ -270,7 +270,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void project_issues_attached_file_on_removed_module() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
// File and module are removed | |||
ComponentDto module = db.components().insertComponent(newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY).setEnabled(false)); | |||
ComponentDto file = db.components().insertComponent(newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java").setEnabled(false)); | |||
@@ -297,7 +297,7 @@ public class IssuesActionTest { | |||
@Test | |||
public void fail_without_browse_permission_on_file() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
thrown.expect(ForbiddenException.class); |
@@ -87,7 +87,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_settings_with_global_scan_permission() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -111,7 +111,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_settings_with_project_scan_permission() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn("john").addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -135,7 +135,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void not_returned_secured_settings_when_lgged_but_no_scan_permission() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn("john").addProjectPermission(UserRole.USER, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -157,7 +157,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_with_module_settings() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -193,7 +193,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_with_module_settings_inherited_from_project() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -224,7 +224,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_with_module_with_sub_module() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -271,7 +271,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_project_with_two_modules() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -317,7 +317,7 @@ public class ProjectDataLoaderMediumTest { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
// No snapshot attached on the project -> provisioned project | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -338,7 +338,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_sub_module_settings() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
// No project properties | |||
@@ -372,7 +372,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_sub_module_settings_including_settings_from_parent_modules() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -408,7 +408,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_sub_module_settings_only_inherited_from_project() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -442,7 +442,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_sub_module_settings_inherited_from_project_and_module() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -479,7 +479,7 @@ public class ProjectDataLoaderMediumTest { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
@@ -495,7 +495,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void fail_when_not_preview_and_only_browse_permission_without_scan_permission() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
@@ -511,7 +511,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void fail_when_preview_and_only_scan_permission_without_browse_permission() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
@@ -526,7 +526,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_file_data_from_single_project() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -546,7 +546,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_file_data_from_multi_modules() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
userSessionRule.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -575,7 +575,7 @@ public class ProjectDataLoaderMediumTest { | |||
public void return_file_data_from_module() { | |||
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto(); | |||
dbClient.organizationDao().insert(dbSession, organizationDto); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(dbSession, project); | |||
addDefaultProfile(); | |||
@@ -129,7 +129,7 @@ public class ProjectDataLoaderTest { | |||
@Test | |||
public void throw_ForbiddenException_if_no_browse_permission_nor_scan_permission() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn(); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -140,7 +140,7 @@ public class ProjectDataLoaderTest { | |||
@Test | |||
public void throw_ForbiddenException_if_browse_permission_but_not_scan_permission() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn().addProjectPermission(UserRole.USER, project); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -151,7 +151,7 @@ public class ProjectDataLoaderTest { | |||
@Test | |||
public void issues_mode_is_allowed_if_user_has_browse_permission() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn().addProjectPermission(UserRole.USER, project); | |||
ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true)); | |||
@@ -161,7 +161,7 @@ public class ProjectDataLoaderTest { | |||
@Test | |||
public void issues_mode_is_forbidden_if_user_doesnt_have_browse_permission() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn().addProjectPermission(GlobalPermissions.SCAN_EXECUTION, project); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -172,7 +172,7 @@ public class ProjectDataLoaderTest { | |||
@Test | |||
public void scan_permission_on_organization_is_enough_even_without_scan_permission_on_project() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn().addPermission(SCAN, project.getOrganizationUuid()); | |||
userSession.logIn().addProjectPermission(UserRole.USER, project); | |||
@@ -34,6 +34,7 @@ import org.sonar.db.ce.CeActivityDto; | |||
import org.sonar.db.ce.CeQueueDto; | |||
import org.sonar.db.ce.CeTaskTypes; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import org.sonar.server.exceptions.ForbiddenException; | |||
@@ -52,7 +53,6 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonar.api.utils.DateUtils.formatDate; | |||
import static org.sonar.api.utils.DateUtils.formatDateTime; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_QUERY; | |||
@@ -80,9 +80,9 @@ public class ActivityActionTest { | |||
public void get_all_past_activity() { | |||
logInAsSystemAdministrator(); | |||
OrganizationDto org1 = dbTester.organizations().insert(); | |||
dbTester.components().insertProject(org1, "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(org1, "PROJECT_1"); | |||
OrganizationDto org2 = dbTester.organizations().insert(); | |||
dbTester.components().insertProject(org2, "PROJECT_2"); | |||
dbTester.components().insertPrivateProject(org2, "PROJECT_2"); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); | |||
@@ -110,8 +110,8 @@ public class ActivityActionTest { | |||
@Test | |||
public void filter_by_status() { | |||
logInAsSystemAdministrator(); | |||
dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_2"); | |||
dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_2"); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); | |||
insertQueue("T3", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); | |||
@@ -142,7 +142,7 @@ public class ActivityActionTest { | |||
public void filter_by_min_submitted_and_max_executed_at_include_day() { | |||
logInAsSystemAdministrator(); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
dbTester.components().insertProject(organizationDto, "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(organizationDto, "PROJECT_1"); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
String today = formatDate(new Date(EXECUTED_AT)); | |||
@@ -155,7 +155,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void filter_on_current_activities() { | |||
dbTester.components().insertProject(dbTester.organizations().insert(), "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(dbTester.organizations().insert(), "PROJECT_1"); | |||
logInAsSystemAdministrator(); | |||
// T2 is the current activity (the most recent one) | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
@@ -174,8 +174,8 @@ public class ActivityActionTest { | |||
public void limit_results() { | |||
logInAsSystemAdministrator(); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
dbTester.components().insertProject(organizationDto, "PROJECT_1"); | |||
dbTester.components().insertProject(organizationDto, "PROJECT_2"); | |||
dbTester.components().insertPrivateProject(organizationDto, "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(organizationDto, "PROJECT_2"); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); | |||
insertQueue("T3", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); | |||
@@ -210,7 +210,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void project_administrator_can_access_his_project_activity() { | |||
ComponentDto project = dbTester.components().insertProject(dbTester.organizations().insert(), "PROJECT_1"); | |||
ComponentDto project = dbTester.components().insertPrivateProject(dbTester.organizations().insert(), "PROJECT_1"); | |||
// no need to be a system admin | |||
userSession.logIn().addProjectPermission(UserRole.ADMIN, project); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
@@ -226,7 +226,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void return_401_if_user_is_not_logged_in() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.anonymous(); | |||
expectedException.expect(UnauthorizedException.class); | |||
@@ -238,9 +238,9 @@ public class ActivityActionTest { | |||
@Test | |||
public void search_activity_by_component_name() throws IOException { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto struts = newProjectDto(organizationDto).setName("old apache struts").setUuid("P1").setProjectUuid("P1"); | |||
ComponentDto zookeeper = newProjectDto(organizationDto).setName("new apache zookeeper").setUuid("P2").setProjectUuid("P2"); | |||
ComponentDto eclipse = newProjectDto(organizationDto).setName("eclipse").setUuid("P3").setProjectUuid("P3"); | |||
ComponentDto struts = ComponentTesting.newPrivateProjectDto(organizationDto).setName("old apache struts").setUuid("P1").setProjectUuid("P1"); | |||
ComponentDto zookeeper = ComponentTesting.newPrivateProjectDto(organizationDto).setName("new apache zookeeper").setUuid("P2").setProjectUuid("P2"); | |||
ComponentDto eclipse = ComponentTesting.newPrivateProjectDto(organizationDto).setName("eclipse").setUuid("P3").setProjectUuid("P3"); | |||
dbTester.components().insertProjectAndSnapshot(struts); | |||
dbTester.components().insertProjectAndSnapshot(zookeeper); | |||
dbTester.components().insertProjectAndSnapshot(eclipse); | |||
@@ -270,7 +270,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void search_task_id_in_queue_ignoring_other_parameters() throws IOException { | |||
logInAsSystemAdministrator(); | |||
dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
insertQueue("T1", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); | |||
ActivityResponse result = call( | |||
@@ -285,7 +285,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void search_task_id_in_activity() { | |||
logInAsSystemAdministrator(); | |||
dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
ActivityResponse result = call(ws.newRequest().setParam(Param.TEXT_QUERY, "T1")); | |||
@@ -311,7 +311,7 @@ public class ActivityActionTest { | |||
@Test | |||
public void search_task_by_component_id() { | |||
ComponentDto project = dbTester.components().insertProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
ComponentDto project = dbTester.components().insertPrivateProject(dbTester.getDefaultOrganization(), "PROJECT_1"); | |||
insertQueue("T1", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
userSession.logIn().addProjectPermission(UserRole.ADMIN, project); |
@@ -32,6 +32,7 @@ import org.sonar.db.DbTester; | |||
import org.sonar.db.ce.CeActivityDto; | |||
import org.sonar.db.ce.CeQueueDto; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.server.component.ComponentFinder; | |||
import org.sonar.server.exceptions.ForbiddenException; | |||
@@ -43,7 +44,7 @@ import org.sonarqube.ws.WsCe; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.ce.CeQueueTesting.newCeQueueDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_KEY; | |||
@@ -81,9 +82,9 @@ public class ActivityStatusActionTest { | |||
String projectUuid = "project-uuid"; | |||
String anotherProjectUuid = "another-project-uuid"; | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = newProjectDto(organizationDto, projectUuid); | |||
ComponentDto project = newPrivateProjectDto(organizationDto, projectUuid); | |||
db.components().insertComponent(project); | |||
db.components().insertComponent(newProjectDto(organizationDto, anotherProjectUuid)); | |||
db.components().insertComponent(newPrivateProjectDto(organizationDto, anotherProjectUuid)); | |||
userSession.logIn().addProjectPermission(UserRole.ADMIN, project); | |||
// pending tasks returned | |||
insertInQueue(CeQueueDto.Status.PENDING, projectUuid); | |||
@@ -115,7 +116,7 @@ public class ActivityStatusActionTest { | |||
@Test | |||
public void fail_if_component_uuid_and_key_are_provided() { | |||
ComponentDto project = newProjectDto(db.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert()); | |||
db.components().insertComponent(project); | |||
expectedException.expect(IllegalArgumentException.class); | |||
@@ -149,7 +150,7 @@ public class ActivityStatusActionTest { | |||
@Test | |||
public void throw_ForbiddenException_if_not_administrator_of_requested_project() { | |||
userSession.logIn(); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
expectedException.expect(ForbiddenException.class); | |||
expectedException.expectMessage("Insufficient privileges"); |
@@ -39,7 +39,7 @@ import org.sonarqube.ws.MediaTypes; | |||
import org.sonarqube.ws.WsCe; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.ce.ws.ComponentAction.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.ComponentAction.PARAM_COMPONENT_KEY; | |||
@@ -60,7 +60,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void empty_queue_and_empty_activity() { | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert(), "PROJECT_1")); | |||
ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(dbTester.organizations().insert(), "PROJECT_1")); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
WsCe.ProjectResponse response = ws.newRequest() | |||
@@ -74,7 +74,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void project_tasks() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(organizationDto, "PROJECT_1")); | |||
ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(organizationDto, "PROJECT_1")); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); | |||
@@ -99,7 +99,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void search_tasks_by_component_key() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
logInWithBrowsePermission(project); | |||
insertActivity("T1", project.uuid(), CeActivityDto.Status.SUCCESS); | |||
@@ -111,7 +111,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void canceled_tasks_must_not_be_picked_as_current_analysis() { | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1")); | |||
ComponentDto project = dbTester.components().insertComponent(newPrivateProjectDto(dbTester.getDefaultOrganization(), "PROJECT_1")); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); | |||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); | |||
@@ -139,7 +139,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void throw_ForbiddenException_if_user_cant_access_project() { | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
userSession.logIn(); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -153,7 +153,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void fail_when_no_component_parameter() { | |||
expectedException.expect(IllegalArgumentException.class); | |||
logInWithBrowsePermission(dbTester.components().insertProject()); | |||
logInWithBrowsePermission(dbTester.components().insertPrivateProject()); | |||
ws.newRequest().execute(); | |||
} |
@@ -65,7 +65,7 @@ public class TaskActionTest { | |||
@Before | |||
public void setUp() { | |||
organizationDto = dbTester.organizations().insert(); | |||
project = dbTester.components().insertProject(organizationDto); | |||
project = dbTester.components().insertPrivateProject(organizationDto); | |||
} | |||
@Test |
@@ -78,7 +78,7 @@ public class TaskFormatterTest { | |||
public void formatQueue_with_component_and_other_fields() throws IOException { | |||
String uuid = "COMPONENT_UUID"; | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
db.components().insertProject(organizationDto, (t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name")); | |||
db.components().insertPrivateProject(organizationDto, (t) -> t.setUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name")); | |||
CeQueueDto dto = new CeQueueDto(); | |||
dto.setUuid("UUID"); |
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.SnapshotDto; | |||
import org.sonar.db.component.SnapshotTesting; | |||
import org.sonar.db.issue.IssueDto; | |||
@@ -47,7 +48,7 @@ import static org.mockito.Mockito.never; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.when; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
public class ComponentCleanerServiceTest { | |||
@@ -93,7 +94,7 @@ public class ComponentCleanerServiceTest { | |||
@Test | |||
public void fail_with_IAE_if_not_a_project() throws Exception { | |||
mockResourceTypeAsValidProject(); | |||
ComponentDto project = newProjectDto(db.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert()); | |||
dbClient.componentDao().insert(dbSession, project); | |||
ComponentDto file = newFileDto(project, null); | |||
dbClient.componentDao().insert(dbSession, file); | |||
@@ -108,7 +109,7 @@ public class ComponentCleanerServiceTest { | |||
ResourceType resourceType = mock(ResourceType.class); | |||
when(resourceType.getBooleanProperty("deletable")).thenReturn(false); | |||
when(mockResourceTypes.get(anyString())).thenReturn(resourceType); | |||
ComponentDto project = newProjectDto(db.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert()); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
@@ -119,7 +120,7 @@ public class ComponentCleanerServiceTest { | |||
@Test | |||
public void fail_to_delete_null_resource_type() throws Exception { | |||
when(mockResourceTypes.get(anyString())).thenReturn(null); | |||
ComponentDto project = newProjectDto(db.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert()); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
@@ -129,7 +130,7 @@ public class ComponentCleanerServiceTest { | |||
private DbData insertData(int id) { | |||
String suffix = String.valueOf(id); | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid-" + suffix) | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid-" + suffix) | |||
.setKey("project-key-" + suffix); | |||
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("sonarqube", "rule-" + suffix)); | |||
dbClient.ruleDao().insert(dbSession, rule); |
@@ -26,10 +26,11 @@ import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.ID_AND_KEY; | |||
@@ -95,7 +96,7 @@ public class ComponentFinderTest { | |||
@Test | |||
public void get_component_by_uuid() { | |||
db.components().insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
ComponentDto component = underTest.getByUuidOrKey(dbSession, "project-uuid", null, ID_AND_KEY); | |||
@@ -104,7 +105,7 @@ public class ComponentFinderTest { | |||
@Test | |||
public void get_component_by_key() { | |||
db.components().insertComponent(newProjectDto(db.getDefaultOrganization()).setKey("project-key")); | |||
db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key")); | |||
ComponentDto component = underTest.getByUuidOrKey(dbSession, null, "project-key", ID_AND_KEY); | |||
@@ -28,6 +28,7 @@ import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.server.es.ProjectIndexer; | |||
import org.sonar.server.tester.UserSessionRule; | |||
@@ -35,7 +36,6 @@ import static org.assertj.guava.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
public class ComponentServiceTest { | |||
@@ -55,7 +55,7 @@ public class ComponentServiceTest { | |||
@Test | |||
public void bulk_update() { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(dbTester.organizations().insert()).setKey("my_project")); | |||
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")); |
@@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
public class ComponentServiceUpdateKeyTest { | |||
@@ -131,7 +130,7 @@ public class ComponentServiceUpdateKeyTest { | |||
@Test | |||
public void fail_if_old_key_and_new_key_are_the_same() { | |||
ComponentDto project = insertSampleRootProject(); | |||
ComponentDto anotherProject = componentDb.insertProject(); | |||
ComponentDto anotherProject = componentDb.insertPrivateProject(); | |||
logInAsProjectAdministrator(project); | |||
expectedException.expect(IllegalArgumentException.class); | |||
@@ -176,7 +175,7 @@ public class ComponentServiceUpdateKeyTest { | |||
@Test | |||
public void bulk_update_key() { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()).setKey("my_project")); | |||
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")); | |||
@@ -205,7 +204,7 @@ public class ComponentServiceUpdateKeyTest { | |||
} | |||
private ComponentDto insertProject(String key) { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert()).setKey(key)); | |||
ComponentDto project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setKey(key)); | |||
return project; | |||
} | |||
@@ -164,7 +164,7 @@ public class ComponentUpdaterTest { | |||
@Test | |||
public void fail_when_project_key_already_exists() throws Exception { | |||
ComponentDto existing = db.components().insertProject(); | |||
ComponentDto existing = db.components().insertPrivateProject(); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("Could not create Project, key already exists: " + existing.key()); | |||
@@ -180,7 +180,7 @@ public class ComponentUpdaterTest { | |||
@Test | |||
public void fail_when_project_key_already_exists_on_other_organization() throws Exception { | |||
ComponentDto existing = db.components().insertProject(db.organizations().insert()); | |||
ComponentDto existing = db.components().insertPrivateProject(db.organizations().insert()); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("Could not create Project, key already exists: " + existing.key()); |
@@ -112,10 +112,10 @@ public class ComponentIndexScoreTest extends ComponentIndexTest { | |||
@Test | |||
public void should_prefer_favorite_over_recently_browsed() { | |||
ComponentDto recentlyBrowsed = db.components().insertProject(c -> c.setName("File1")); | |||
ComponentDto recentlyBrowsed = db.components().insertPrivateProject(c -> c.setName("File1")); | |||
index(recentlyBrowsed); | |||
ComponentDto favorite = db.components().insertProject(c -> c.setName("File2")); | |||
ComponentDto favorite = db.components().insertPrivateProject(c -> c.setName("File2")); | |||
index(favorite); | |||
ComponentIndexQuery query = ComponentIndexQuery.builder() |
@@ -125,13 +125,13 @@ public abstract class ComponentIndexTest { | |||
protected ComponentDto indexProject(String key, String name) { | |||
return index( | |||
ComponentTesting.newProjectDto(organization, "UUID_" + key) | |||
ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key) | |||
.setKey(key) | |||
.setName(name)); | |||
} | |||
protected ComponentDto newProject(String key, String name) { | |||
return ComponentTesting.newProjectDto(organization, "UUID_" + key) | |||
return ComponentTesting.newPrivateProjectDto(organization, "UUID_" + key) | |||
.setKey(key) | |||
.setName(name); | |||
} |
@@ -78,7 +78,7 @@ public class ComponentIndexerTest { | |||
@Test | |||
public void index_everything() { | |||
insert(ComponentTesting.newProjectDto(organization)); | |||
insert(ComponentTesting.newPrivateProjectDto(organization)); | |||
index(); | |||
assertThat(count()).isEqualTo(1); | |||
@@ -86,7 +86,7 @@ public class ComponentIndexerTest { | |||
@Test | |||
public void index_unexisting_project_while_database_contains_another() { | |||
insert(ComponentTesting.newProjectDto(organization, "UUID-1")); | |||
insert(ComponentTesting.newPrivateProjectDto(organization, "UUID-1")); | |||
index("UUID-2"); | |||
assertThat(count()).isEqualTo(0); | |||
@@ -94,7 +94,7 @@ public class ComponentIndexerTest { | |||
@Test | |||
public void index_one_project() { | |||
ComponentDto project = ComponentTesting.newProjectDto(organization, "UUID-1"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organization, "UUID-1"); | |||
insert(project); | |||
index(project); | |||
@@ -103,7 +103,7 @@ public class ComponentIndexerTest { | |||
@Test | |||
public void index_one_project_containing_a_file() { | |||
ComponentDto projectComponent = ComponentTesting.newProjectDto(organization, "UUID-PROJECT-1"); | |||
ComponentDto projectComponent = ComponentTesting.newPrivateProjectDto(organization, "UUID-PROJECT-1"); | |||
insert(projectComponent); | |||
insert(ComponentTesting.newFileDto(projectComponent)); | |||
@@ -115,7 +115,7 @@ public class ComponentIndexerTest { | |||
public void index_and_update_and_reindex_project() { | |||
// insert | |||
ComponentDto component = ComponentTesting.newProjectDto(organization, "UUID-1").setName("OldName"); | |||
ComponentDto component = ComponentTesting.newPrivateProjectDto(organization, "UUID-1").setName("OldName"); | |||
insert(component); | |||
// verify insert | |||
@@ -136,7 +136,7 @@ public class ComponentIndexerTest { | |||
public void index_and_update_and_reindex_project_with_files() { | |||
// insert | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project).setName("OldFile")); | |||
// verify insert | |||
@@ -157,7 +157,7 @@ public class ComponentIndexerTest { | |||
public void full_reindexing_on_empty_index() { | |||
// insert | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
dbTester.components().insertComponent(ComponentTesting.newFileDto(project).setName("OldFile")); | |||
// verify insert |
@@ -139,7 +139,7 @@ public class AppActionTest { | |||
} | |||
private ComponentDto[] insertComponentsAndAnalysis() { | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.getDefaultOrganization(), PROJECT_UUID) | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.getDefaultOrganization(), PROJECT_UUID) | |||
.setLongName("SonarQube") | |||
.setKey(PROJECT_KEY); | |||
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project) |
@@ -38,7 +38,7 @@ public class ComponentDtoToWsComponentTest { | |||
public void componentDtoToWsComponent_throws_IAE_if_organization_uuid_of_component_does_not_match_organizationDto_uuid() { | |||
OrganizationDto organizationDto1 = OrganizationTesting.newOrganizationDto(); | |||
OrganizationDto organizationDto2 = OrganizationTesting.newOrganizationDto(); | |||
ComponentDto componentDto = ComponentTesting.newProjectDto(organizationDto1); | |||
ComponentDto componentDto = ComponentTesting.newPrivateProjectDto(organizationDto1); | |||
expectedException.expect(IllegalArgumentException.class); | |||
expectedException.expectMessage("OrganizationUuid (" + organizationDto1.getUuid() + ") of ComponentDto to convert " + |
@@ -35,6 +35,7 @@ import org.sonar.api.utils.System2; | |||
import org.sonar.api.web.UserRole; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.ResourceTypesRule; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.db.user.UserDto; | |||
@@ -62,7 +63,7 @@ import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.WsComponents.Component; | |||
@@ -122,8 +123,8 @@ public class SearchActionTest { | |||
@Test | |||
public void search_by_key_query() throws IOException { | |||
insertProjectsAuthorizedForUser( | |||
newProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"), | |||
newProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters")); | |||
ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"), | |||
ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters")); | |||
SearchWsResponse response = call(new SearchWsRequest().setQuery("project-_%-key").setQualifiers(singletonList(PROJECT))); | |||
@@ -132,7 +133,7 @@ public class SearchActionTest { | |||
@Test | |||
public void search_for_files() throws IOException { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()); | |||
ComponentDto file1 = newFileDto(project).setKey("file1"); | |||
ComponentDto file2 = newFileDto(project).setKey("file2"); | |||
db.components().insertComponents(project, file1, file2); | |||
@@ -148,7 +149,7 @@ public class SearchActionTest { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
List<ComponentDto> componentDtoList = new ArrayList<>(); | |||
for (int i = 1; i <= 9; i++) { | |||
componentDtoList.add(newProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i)); | |||
componentDtoList.add(newPrivateProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i)); | |||
} | |||
insertProjectsAuthorizedForUser(componentDtoList.toArray(new ComponentDto[] {})); | |||
@@ -161,8 +162,8 @@ public class SearchActionTest { | |||
public void search_with_language() throws IOException { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
insertProjectsAuthorizedForUser( | |||
newProjectDto(organizationDto).setKey("java-project").setLanguage("java"), | |||
newProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp")); | |||
ComponentTesting.newPrivateProjectDto(organizationDto).setKey("java-project").setLanguage("java"), | |||
ComponentTesting.newPrivateProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp")); | |||
SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT))); | |||
@@ -171,10 +172,10 @@ public class SearchActionTest { | |||
@Test | |||
public void return_only_components_from_projects_on_which_user_has_browse_permission() throws IOException { | |||
ComponentDto project1 = newProjectDto(db.getDefaultOrganization()); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()); | |||
ComponentDto file1 = newFileDto(project1).setKey("file1"); | |||
ComponentDto file2 = newFileDto(project1).setKey("file2"); | |||
ComponentDto project2 = newProjectDto(db.getDefaultOrganization()); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()); | |||
ComponentDto file3 = newFileDto(project2).setKey("file3"); | |||
db.components().insertComponents(project1, file1, file2, project2, file3); | |||
setBrowsePermissionOnUser(project1); | |||
@@ -187,9 +188,9 @@ public class SearchActionTest { | |||
@Test | |||
public void do_not_verify_permissions_if_user_is_root() throws IOException { | |||
OrganizationDto org = db.organizations().insert(); | |||
ComponentDto project1 = newProjectDto(org); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto file1 = newFileDto(project1); | |||
ComponentDto project2 = newProjectDto(org); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto file2 = newFileDto(project2); | |||
db.components().insertComponents(project1, file1, project2, file2); | |||
@@ -222,7 +223,7 @@ public class SearchActionTest { | |||
public void test_json_example() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1"); | |||
db.components().insertComponent(newView(organizationDto)); | |||
ComponentDto project = newProjectDto(organizationDto, "project-uuid").setName("Project Name").setKey("project-key"); | |||
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"); | |||
db.components().insertComponents(project, module, directory, |
@@ -41,6 +41,7 @@ import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.db.property.PropertyDto; | |||
import org.sonar.server.es.EsTester; | |||
@@ -80,7 +81,7 @@ import static org.sonar.core.util.stream.MoreCollectors.toList; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.db.metric.MetricTesting.newMetricDto; | |||
@@ -159,16 +160,16 @@ public class SearchProjectsActionTest { | |||
public void json_example() { | |||
OrganizationDto organization1Dto = db.organizations().insertForKey("my-org-key-1"); | |||
OrganizationDto organization2Dto = db.organizations().insertForKey("my-org-key-2"); | |||
ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(organization1Dto) | |||
ComponentDto project1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1Dto) | |||
.setUuid(Uuids.UUID_EXAMPLE_01) | |||
.setKey(KeyExamples.KEY_PROJECT_EXAMPLE_001) | |||
.setName("My Project 1") | |||
.setTagsString("finance, java")); | |||
insertProjectInDbAndEs(newProjectDto(organization1Dto) | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1Dto) | |||
.setUuid(Uuids.UUID_EXAMPLE_02) | |||
.setKey(KeyExamples.KEY_PROJECT_EXAMPLE_002) | |||
.setName("My Project 2")); | |||
insertProjectInDbAndEs(newProjectDto(organization2Dto) | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2Dto) | |||
.setUuid(Uuids.UUID_EXAMPLE_03) | |||
.setKey(KeyExamples.KEY_PROJECT_EXAMPLE_003) | |||
.setName("My Project 3") | |||
@@ -184,9 +185,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void order_by_name_case_insensitive() { | |||
insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Maven")); | |||
insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Apache")); | |||
insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("guava")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Maven")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Apache")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("guava")); | |||
SearchProjectsWsResponse result = call(request); | |||
@@ -196,7 +197,7 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void paginate_result() { | |||
IntStream.rangeClosed(1, 9).forEach(i -> insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("PROJECT-" + i))); | |||
IntStream.rangeClosed(1, 9).forEach(i -> insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("PROJECT-" + i))); | |||
SearchProjectsWsResponse result = call(request.setPage(2).setPageSize(3)); | |||
@@ -223,7 +224,7 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_only_projects() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project = newProjectDto(organizationDto).setName("SonarQube"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto).setName("SonarQube"); | |||
ComponentDto directory = newDirectory(project, "path"); | |||
insertProjectInDbAndEs(project); | |||
componentDb.insertComponents(newModuleDto(project), newView(organizationDto), directory, newFileDto(project, directory)); | |||
@@ -237,9 +238,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_with_query() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertMetrics(COVERAGE, NCLOC); | |||
request.setFilter("coverage <= 80 and ncloc <= 10000"); | |||
@@ -253,9 +254,9 @@ public class SearchProjectsActionTest { | |||
public void filter_projects_with_query_within_specified_organization() { | |||
OrganizationDto organization1 = db.organizations().insert(); | |||
OrganizationDto organization2 = db.organizations().insert(); | |||
insertProjectInDbAndEs(newProjectDto(organization1).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization1).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization2).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertMetrics(COVERAGE, NCLOC); | |||
assertThat(call(request.setOrganization(null)).getComponentsList()) | |||
@@ -272,9 +273,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_by_quality_gate() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), "OK"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), "OK"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), "ERROR"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), "OK"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), "OK"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), "ERROR"); | |||
insertMetrics(COVERAGE, NCLOC); | |||
request.setFilter("alert_status = OK"); | |||
@@ -286,10 +287,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_by_languages() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo")); | |||
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY); | |||
request.setFilter("languages IN (java, js, <null>)"); | |||
@@ -301,9 +302,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_by_tags() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown").setTags(singletonList("marketing"))); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Markdown").setTags(singletonList("marketing"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
request.setFilter("tags in (finance, offshore)"); | |||
SearchProjectsWsResponse result = call(request); | |||
@@ -314,10 +315,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_by_text_query() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1"); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-java").setName("Sonar Java")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-groovy").setName("Sonar Groovy")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonar-markdown").setName("Sonar Markdown")); | |||
insertProjectInDbAndEs(newProjectDto(organizationDto).setKey("sonarqube").setName("Sonar Qube")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-java").setName("Sonar Java")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-groovy").setName("Sonar Groovy")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("sonar-markdown").setName("Sonar Markdown")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("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", | |||
@@ -334,13 +335,13 @@ public class SearchProjectsActionTest { | |||
OrganizationDto organization4 = db.organizations().insert(); | |||
OrganizationDto organization5 = db.organizations().insert(); | |||
List<Map<String, Object>> someMeasure = singletonList(newMeasure(COVERAGE, 81)); | |||
ComponentDto favourite1_1 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure); | |||
ComponentDto favourite1_2 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure); | |||
ComponentDto nonFavourite1 = insertProjectInDbAndEs(newProjectDto(organization1), someMeasure); | |||
ComponentDto favourite2 = insertProjectInDbAndEs(newProjectDto(organization2), someMeasure); | |||
ComponentDto nonFavourite2 = insertProjectInDbAndEs(newProjectDto(organization2), someMeasure); | |||
ComponentDto favourite3 = insertProjectInDbAndEs(newProjectDto(organization3), someMeasure); | |||
ComponentDto nonFavourite4 = insertProjectInDbAndEs(newProjectDto(organization4), someMeasure); | |||
ComponentDto favourite1_1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure); | |||
ComponentDto favourite1_2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure); | |||
ComponentDto nonFavourite1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization1), someMeasure); | |||
ComponentDto favourite2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2), someMeasure); | |||
ComponentDto nonFavourite2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization2), someMeasure); | |||
ComponentDto favourite3 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization3), someMeasure); | |||
ComponentDto nonFavourite4 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization4), someMeasure); | |||
Stream.of(favourite1_1, favourite1_2, favourite2, favourite3) | |||
.forEach(this::addFavourite); | |||
insertMetrics(COVERAGE, NCLOC); | |||
@@ -377,11 +378,11 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filter_projects_on_favorites() { | |||
userSession.logIn(); | |||
ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), | |||
ComponentDto javaProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), | |||
newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
ComponentDto markDownProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "markdown-id").setName("Sonar Markdown"), | |||
ComponentDto markDownProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "markdown-id").setName("Sonar Markdown"), | |||
newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
addFavourite(javaProject); | |||
addFavourite(markDownProject); | |||
dbSession.commit(); | |||
@@ -395,9 +396,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void filtering_on_favorites_returns_empty_results_if_not_logged_in() { | |||
ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), | |||
ComponentDto javaProject = insertProjectInDbAndEs(newPrivateProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), | |||
newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))); | |||
addFavourite(javaProject); | |||
dbSession.commit(); | |||
request.setFilter("isFavorite"); | |||
@@ -410,7 +411,7 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void do_not_return_isFavorite_if_anonymous_user() { | |||
insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81))); | |||
insertMetrics(COVERAGE); | |||
userSession.anonymous(); | |||
@@ -422,7 +423,7 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void empty_list_if_isFavorite_filter_and_anonymous_user() { | |||
insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81))); | |||
insertMetrics(COVERAGE); | |||
userSession.anonymous(); | |||
request.setFilter("isFavorite"); | |||
@@ -435,10 +436,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_nloc_facet() { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertMetrics(COVERAGE, NCLOC); | |||
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NCLOC))); | |||
@@ -461,10 +462,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_languages_facet() { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo")); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo")); | |||
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY); | |||
SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_LANGUAGES))); | |||
@@ -484,8 +485,8 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_languages_facet_with_language_having_no_project_if_language_is_in_filter() { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java")); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java")); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java")); | |||
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY); | |||
SearchProjectsWsResponse result = call(request.setFilter("languages = xoo").setFacets(singletonList(FILTER_LANGUAGES))); | |||
@@ -504,9 +505,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_tags_facet() { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore"))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_TAGS))); | |||
@@ -525,9 +526,9 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_tags_facet_with_tags_having_no_project_if_tags_is_in_filter() { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore"))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore"))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore"))); | |||
SearchProjectsWsResponse result = call(request.setFilter("tags = marketing").setFacets(singletonList(FILTER_TAGS))); | |||
@@ -546,10 +547,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void default_sort_is_by_ascending_name() throws Exception { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
SearchProjectsWsResponse result = call(request); | |||
@@ -559,10 +560,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void sort_by_name() throws Exception { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
assertThat(call(request.setSort("name").setAsc(true)).getComponentsList()).extracting(Component::getName) | |||
.containsExactly("Sonar Groovy", "Sonar Java", "Sonar Markdown", "Sonar Qube"); | |||
@@ -573,10 +574,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void sort_by_coverage() throws Exception { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d))); | |||
insertMetrics(COVERAGE); | |||
assertThat(call(request.setSort(COVERAGE).setAsc(true)).getComponentsList()).extracting(Component::getName) | |||
@@ -588,10 +589,10 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void sort_by_quality_gate() throws Exception { | |||
OrganizationDto organization = db.getDefaultOrganization(); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), "ERROR"); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), "WARN"); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), "OK"); | |||
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), "OK"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Java"), "ERROR"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Groovy"), "WARN"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Markdown"), "OK"); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organization).setName("Sonar Qube"), "OK"); | |||
dbClient.metricDao().insert(dbSession, newMetricDto().setKey(QUALITY_GATE_STATUS).setValueType(LEVEL.name()).setEnabled(true).setHidden(false)); | |||
db.commit(); | |||
@@ -604,13 +605,13 @@ public class SearchProjectsActionTest { | |||
@Test | |||
public void return_last_analysis_date() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(organizationDto)); | |||
ComponentDto project1 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(10_000_000_000L).setLast(false)); | |||
db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(20_000_000_000L).setLast(true)); | |||
ComponentDto project2 = insertProjectInDbAndEs(newProjectDto(organizationDto)); | |||
ComponentDto project2 = insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
db.components().insertSnapshot(newAnalysis(project2).setCreatedAt(30_000_000_000L).setLast(true)); | |||
// No snapshot on project 3 | |||
insertProjectInDbAndEs(newProjectDto(organizationDto)); | |||
insertProjectInDbAndEs(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
SearchProjectsWsResponse result = call(request.setAdditionalFields(singletonList("analysisDate"))); | |||
@@ -47,7 +47,7 @@ import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT; | |||
@@ -93,7 +93,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_with_browse_permission() { | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
userSession.logIn().addProjectPermission(UserRole.USER, project); | |||
@@ -105,7 +105,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_provided_project() { | |||
userSession.logIn().setRoot(); | |||
componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setEnabled(false)); | |||
componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid").setEnabled(false)); | |||
ShowWsResponse response = newRequest("project-uuid", null); | |||
@@ -115,7 +115,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_with_ancestors_when_not_project() throws Exception { | |||
ComponentDto project = componentDb.insertProject(); | |||
ComponentDto project = componentDb.insertPrivateProject(); | |||
ComponentDto module = componentDb.insertComponent(newModuleDto(project)); | |||
ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir")); | |||
ComponentDto file = componentDb.insertComponent(newFileDto(directory)); | |||
@@ -129,7 +129,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_without_ancestors_when_project() throws Exception { | |||
ComponentDto project = componentDb.insertProject(); | |||
ComponentDto project = componentDb.insertPrivateProject(); | |||
componentDb.insertComponent(newModuleDto(project)); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
@@ -141,7 +141,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_with_last_analysis_date() throws Exception { | |||
ComponentDto project = componentDb.insertProject(); | |||
ComponentDto project = componentDb.insertPrivateProject(); | |||
componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000_000L).setLast(false)); | |||
componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(2_000_000_000L).setLast(false)); | |||
componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true)); | |||
@@ -154,7 +154,7 @@ public class ShowActionTest { | |||
@Test | |||
public void show_with_ancestors_and_analysis_date() throws Exception { | |||
ComponentDto project = componentDb.insertProject(); | |||
ComponentDto project = componentDb.insertPrivateProject(); | |||
componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true)); | |||
ComponentDto module = componentDb.insertComponent(newModuleDto(project)); | |||
ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir")); | |||
@@ -173,7 +173,7 @@ public class ShowActionTest { | |||
userSession.logIn(); | |||
expectedException.expect(ForbiddenException.class); | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
newRequest("project-uuid", null); | |||
} | |||
@@ -199,7 +199,7 @@ public class ShowActionTest { | |||
private void insertJsonExampleComponentsAndSnapshots() { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1"); | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW") | |||
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW") | |||
.setKey("com.sonarsource:java-markdown") | |||
.setName("Java Markdown") | |||
.setDescription("Java Markdown Project") |
@@ -59,13 +59,13 @@ import static org.assertj.core.groups.Tuple.tuple; | |||
import static org.mockito.Mockito.doReturn; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.component.index.ComponentIndexQuery.DEFAULT_LIMIT; | |||
import static org.sonar.server.component.ws.SuggestionsAction.EXTENDED_LIMIT; | |||
import static org.sonar.server.component.ws.SuggestionsAction.SHORT_INPUT_WARNING; | |||
import static org.sonar.server.component.ws.SuggestionsAction.PARAM_MORE; | |||
import static org.sonar.server.component.ws.SuggestionsAction.PARAM_QUERY; | |||
import static org.sonar.server.component.ws.SuggestionsAction.PARAM_RECENTLY_BROWSED; | |||
import static org.sonar.server.component.ws.SuggestionsAction.SHORT_INPUT_WARNING; | |||
import static org.sonarqube.ws.WsComponents.SuggestionsWsResponse.Category; | |||
import static org.sonarqube.ws.WsComponents.SuggestionsWsResponse.Organization; | |||
@@ -113,7 +113,7 @@ public class SuggestionsActionTest { | |||
@Test | |||
public void exact_match_in_one_qualifier() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organization)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
componentIndexer.indexOnStartup(null); | |||
authorizationIndexerTester.allowOnlyAnyone(project); | |||
@@ -138,7 +138,7 @@ public class SuggestionsActionTest { | |||
@Test | |||
public void must_not_search_if_no_valid_tokens_are_provided() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organization).setName("SonarQube")); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("SonarQube")); | |||
componentIndexer.indexOnStartup(null); | |||
authorizationIndexerTester.allowOnlyAnyone(project); | |||
@@ -167,11 +167,11 @@ public class SuggestionsActionTest { | |||
OrganizationDto organization1 = db.organizations().insert(o -> o.setKey("org-1").setName("Organization One")); | |||
OrganizationDto organization2 = db.organizations().insert(o -> o.setKey("org-2").setName("Organization Two")); | |||
ComponentDto project1 = db.components().insertComponent(newProjectDto(organization1).setName("Project1")); | |||
ComponentDto project1 = db.components().insertComponent(newPrivateProjectDto(organization1).setName("Project1")); | |||
componentIndexer.indexProject(project1.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION); | |||
authorizationIndexerTester.allowOnlyAnyone(project1); | |||
ComponentDto project2 = db.components().insertComponent(newProjectDto(organization2).setName("Project2")); | |||
ComponentDto project2 = db.components().insertComponent(newPrivateProjectDto(organization2).setName("Project2")); | |||
componentIndexer.indexProject(project2.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION); | |||
authorizationIndexerTester.allowOnlyAnyone(project2); | |||
@@ -189,7 +189,7 @@ public class SuggestionsActionTest { | |||
@Test | |||
public void should_contain_project_names() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organization)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
db.components().insertComponent(newModuleDto(project).setName("Module1")); | |||
db.components().insertComponent(newModuleDto(project).setName("Module2")); | |||
componentIndexer.indexProject(project.projectUuid(), ProjectIndexer.Cause.PROJECT_CREATION); | |||
@@ -213,7 +213,7 @@ public class SuggestionsActionTest { | |||
@Test | |||
public void should_mark_recently_browsed_items() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organization)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
ComponentDto module1 = newModuleDto(project).setName("Module1"); | |||
db.components().insertComponent(module1); | |||
ComponentDto module2 = newModuleDto(project).setName("Module2"); | |||
@@ -235,7 +235,7 @@ public class SuggestionsActionTest { | |||
@Test | |||
public void should_mark_favorite_items() throws Exception { | |||
ComponentDto project = db.components().insertComponent(newProjectDto(organization)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
ComponentDto favorite = newModuleDto(project).setName("Module1"); | |||
db.components().insertComponent(favorite); | |||
doReturn(singletonList(favorite)).when(favoriteFinder).list(); | |||
@@ -280,7 +280,7 @@ public class SuggestionsActionTest { | |||
String namePrefix = "MyProject"; | |||
List<ComponentDto> projects = range(0, numberOfProjects) | |||
.mapToObj(i -> db.components().insertComponent(newProjectDto(organization).setName(namePrefix + i))) | |||
.mapToObj(i -> db.components().insertComponent(newPrivateProjectDto(organization).setName(namePrefix + i))) | |||
.collect(Collectors.toList()); | |||
componentIndexer.indexOnStartup(null); |
@@ -60,7 +60,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectCopy; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newSubView; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT_ID; | |||
@@ -104,7 +104,7 @@ public class TreeActionTest { | |||
@Test | |||
public void return_children() throws IOException { | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto module = newModuleDto("module-uuid-1", project); | |||
componentDb.insertComponent(module); | |||
@@ -134,7 +134,7 @@ public class TreeActionTest { | |||
@Test | |||
public void return_descendants() throws IOException { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto module = newModuleDto("module-uuid-1", project); | |||
componentDb.insertComponent(module); | |||
@@ -164,7 +164,7 @@ public class TreeActionTest { | |||
@Test | |||
public void filter_descendants_by_qualifier() throws IOException { | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
componentDb.insertComponent(newFileDto(project, 1)); | |||
componentDb.insertComponent(newFileDto(project, 2)); | |||
@@ -182,7 +182,7 @@ public class TreeActionTest { | |||
@Test | |||
public void return_leaves() throws IOException { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto module = newModuleDto("module-uuid-1", project); | |||
componentDb.insertComponent(module); | |||
@@ -206,7 +206,7 @@ public class TreeActionTest { | |||
@Test | |||
public void sort_descendants_by_qualifier() throws IOException { | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
componentDb.insertComponent(newFileDto(project, 1)); | |||
componentDb.insertComponent(newFileDto(project, 2)); | |||
@@ -229,7 +229,7 @@ public class TreeActionTest { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto view = newView(organizationDto, "view-uuid"); | |||
componentDb.insertViewAndSnapshot(view); | |||
ComponentDto project = newProjectDto(organizationDto, "project-uuid-1").setName("project-name").setKey("project-key-1"); | |||
ComponentDto project = newPrivateProjectDto(organizationDto, "project-uuid-1").setName("project-name").setKey("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")); | |||
@@ -248,7 +248,7 @@ public class TreeActionTest { | |||
@Test | |||
public void response_is_empty_on_provisioned_projects() { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
logInWithBrowsePermission(project); | |||
TreeWsResponse response = ws.newRequest() | |||
@@ -263,7 +263,7 @@ public class TreeActionTest { | |||
@Test | |||
public void return_projects_composing_a_view() { | |||
ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.organizations().insert(), "project-uuid"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid"); | |||
componentDb.insertViewAndSnapshot(view); | |||
@@ -280,7 +280,7 @@ public class TreeActionTest { | |||
@Test | |||
public void fail_when_not_enough_privileges() { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
userSession.logIn() | |||
.addProjectPermission(UserRole.CODEVIEWER, project); | |||
db.commit(); | |||
@@ -296,7 +296,7 @@ public class TreeActionTest { | |||
public void fail_when_page_size_above_500() { | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("The 'ps' parameter must be less than 500"); | |||
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
db.commit(); | |||
ws.newRequest() | |||
@@ -309,7 +309,7 @@ public class TreeActionTest { | |||
public void fail_when_search_query_has_less_than_3_characters() { | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("The 'q' parameter must have at least 3 characters"); | |||
componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
db.commit(); | |||
ws.newRequest() | |||
@@ -321,7 +321,7 @@ public class TreeActionTest { | |||
@Test | |||
public void fail_when_sort_is_unknown() { | |||
expectedException.expect(IllegalArgumentException.class); | |||
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
db.commit(); | |||
ws.newRequest() | |||
@@ -333,7 +333,7 @@ public class TreeActionTest { | |||
@Test | |||
public void fail_when_strategy_is_unknown() { | |||
expectedException.expect(IllegalArgumentException.class); | |||
componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
componentDb.insertComponent(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
db.commit(); | |||
ws.newRequest() | |||
@@ -372,7 +372,7 @@ public class TreeActionTest { | |||
private ComponentDto initJsonExampleComponents() throws IOException { | |||
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1"); | |||
ComponentDto project = newProjectDto(organizationDto, "MY_PROJECT_ID") | |||
ComponentDto project = newPrivateProjectDto(organizationDto, "MY_PROJECT_ID") | |||
.setKey("MY_PROJECT_KEY") | |||
.setName("Project Name"); | |||
componentDb.insertProjectAndSnapshot(project); |
@@ -58,7 +58,7 @@ import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.verifyZeroInteractions; | |||
import static org.mockito.Mockito.when; | |||
import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS; | |||
import static org.sonar.db.permission.OrganizationPermission.SCAN; | |||
@@ -103,7 +103,7 @@ public class ReportSubmitterTest { | |||
public void submit_fails_with_organizationKey_does_not_match_organization_of_specified_component() { | |||
userSession.logIn().setRoot(); | |||
OrganizationDto organization = db.organizations().insert(); | |||
ComponentDto project = db.components().insertProject(organization); | |||
ComponentDto project = db.components().insertPrivateProject(organization); | |||
mockSuccessfulPrepareSubmitCall(); | |||
underTest.submit(organization.getKey(), project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}")); | |||
@@ -111,7 +111,7 @@ public class ReportSubmitterTest { | |||
@Test | |||
public void submit_a_report_on_existing_project() { | |||
ComponentDto project = db.components().insertProject(db.getDefaultOrganization()); | |||
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization()); | |||
userSession.logIn().addProjectPermission(SCAN_EXECUTION, project); | |||
mockSuccessfulPrepareSubmitCall(); | |||
@@ -143,7 +143,7 @@ public class ReportSubmitterTest { | |||
.addPermission(PROVISION_PROJECTS, organization); | |||
mockSuccessfulPrepareSubmitCall(); | |||
ComponentDto createdProject = newProjectDto(organization, PROJECT_UUID).setKey(PROJECT_KEY); | |||
ComponentDto createdProject = newPrivateProjectDto(organization, PROJECT_UUID).setKey(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))) | |||
@@ -174,7 +174,7 @@ public class ReportSubmitterTest { | |||
.addPermission(PROVISION_PROJECTS, db.getDefaultOrganization()); | |||
mockSuccessfulPrepareSubmitCall(); | |||
ComponentDto createdProject = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
ComponentDto createdProject = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(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))) | |||
@@ -193,7 +193,7 @@ public class ReportSubmitterTest { | |||
.addPermission(PROVISION_PROJECTS, db.getDefaultOrganization()); | |||
mockSuccessfulPrepareSubmitCall(); | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(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))) | |||
@@ -207,7 +207,7 @@ public class ReportSubmitterTest { | |||
@Test | |||
public void user_with_scan_permission_on_organization_is_allowed_to_submit_a_report_on_existing_project() { | |||
OrganizationDto org = db.organizations().insert(); | |||
ComponentDto project = db.components().insertProject(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
userSession.addPermission(SCAN, org); | |||
mockSuccessfulPrepareSubmitCall(); | |||
@@ -219,7 +219,7 @@ public class ReportSubmitterTest { | |||
@Test | |||
public void submit_a_report_on_existing_project_with_project_scan_permission() { | |||
ComponentDto project = db.components().insertProject(db.getDefaultOrganization()); | |||
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization()); | |||
userSession.addProjectPermission(SCAN_EXECUTION, project); | |||
mockSuccessfulPrepareSubmitCall(); | |||
@@ -238,7 +238,7 @@ public class ReportSubmitterTest { | |||
@Test | |||
public void fail_with_forbidden_exception_on_new_project_when_only_project_scan_permission() { | |||
userSession.addProjectPermission(SCAN_EXECUTION, ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
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)); | |||
@@ -252,12 +252,12 @@ public class ReportSubmitterTest { | |||
*/ | |||
@Test | |||
public void project_branch_must_not_benefit_from_the_scan_permission_on_main_project() { | |||
ComponentDto mainProject = db.components().insertProject(); | |||
ComponentDto mainProject = db.components().insertPrivateProject(); | |||
userSession.addProjectPermission(GlobalPermissions.SCAN_EXECUTION, mainProject); | |||
// user does not have the "scan" permission on the branch, so it can't scan it | |||
String branchName = "branchFoo"; | |||
ComponentDto branchProject = db.components().insertProject(p -> p.setKey(mainProject.getKey() + ":" + branchName)); | |||
ComponentDto branchProject = db.components().insertPrivateProject(p -> p.setKey(mainProject.getKey() + ":" + branchName)); | |||
thrown.expect(ForbiddenException.class); | |||
underTest.submit(defaultOrganizationKey, mainProject.key(), branchName, PROJECT_NAME, IOUtils.toInputStream("{binary}")); |
@@ -76,7 +76,7 @@ public class SettingsRepositoryTest { | |||
@Test | |||
public void get_project_settings_from_db() { | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey()); | |||
dbClient.componentDao().insert(session, project); | |||
dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value")); | |||
session.commit(); |
@@ -276,7 +276,7 @@ public class IntegrateIssuesVisitorTest { | |||
} | |||
private void addBaseIssue(RuleKey ruleKey) { | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY); | |||
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, file); | |||
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.DIRECTORY; | |||
import static org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType.FILE; | |||
@@ -170,7 +170,7 @@ public class BuildComponentTreeStepTest { | |||
@Test | |||
public void return_existing_uuids() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
ComponentDto module = insertComponent(newModuleDto("BCDE", project).setKey(REPORT_MODULE_KEY)); | |||
ComponentDto directory = newDirectory(module, "CDEF", REPORT_DIR_KEY_1); | |||
insertComponent(directory.setKey(REPORT_MODULE_KEY + ":" + REPORT_DIR_KEY_1)); | |||
@@ -250,7 +250,7 @@ public class BuildComponentTreeStepTest { | |||
@Test | |||
public void return_existing_uuids_when_components_were_removed() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
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)); | |||
@@ -281,7 +281,7 @@ public class BuildComponentTreeStepTest { | |||
@Test | |||
public void set_no_base_project_snapshot_when_no_last_snapshot() throws Exception { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
insertSnapshot(newAnalysis(project).setLast(false)); | |||
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY)); | |||
@@ -293,7 +293,7 @@ public class BuildComponentTreeStepTest { | |||
@Test | |||
public void set_base_project_snapshot_when_last_snapshot_exist() throws Exception { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = insertComponent(newProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
ComponentDto project = insertComponent(newPrivateProjectDto(organizationDto, "ABCD").setKey(REPORT_PROJECT_KEY)); | |||
insertSnapshot(newAnalysis(project).setLast(true)); | |||
reportReader.putComponent(componentWithKey(ROOT_REF, PROJECT, REPORT_PROJECT_KEY)); |
@@ -56,7 +56,7 @@ public class EnableAnalysisStepTest { | |||
@Test | |||
public void switch_islast_flag_and_mark_analysis_as_processed() { | |||
OrganizationDto organization = db.organizations().insert(); | |||
ComponentDto project = ComponentTesting.newProjectDto(organization, REPORT_PROJECT.getUuid()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organization, REPORT_PROJECT.getUuid()); | |||
db.getDbClient().componentDao().insert(db.getSession(), project); | |||
insertAnalysis(project, PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true); | |||
insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false); | |||
@@ -72,7 +72,7 @@ public class EnableAnalysisStepTest { | |||
@Test | |||
public void set_islast_flag_and_mark_as_processed_if_no_previous_analysis() { | |||
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), REPORT_PROJECT.getUuid()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), REPORT_PROJECT.getUuid()); | |||
db.getDbClient().componentDao().insert(db.getSession(), project); | |||
insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false); | |||
db.commit(); |
@@ -108,7 +108,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()); | |||
dbClient.componentDao().insert(dbSession, project); | |||
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project); | |||
dbClient.snapshotDao().insert(dbSession, projectSnapshot); | |||
@@ -326,7 +326,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { | |||
} | |||
private ComponentDto createProject(String projectKey) { | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(projectKey); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(projectKey); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
return project; |
@@ -98,7 +98,7 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01")); | |||
dbTester.rules().insert(rule); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
dbClient.componentDao().insert(session, project); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
dbClient.componentDao().insert(session, file); |
@@ -86,7 +86,7 @@ public class ReportComputeMeasureVariationsStepTest { | |||
@Before | |||
public void setUp() { | |||
project = dbTester.components().insertProject(dbTester.organizations().insert(), PROJECT_UUID); | |||
project = dbTester.components().insertPrivateProject(dbTester.organizations().insert(), PROJECT_UUID); | |||
} | |||
@Test |
@@ -99,7 +99,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_analysis() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), projectDto); | |||
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module"); | |||
dbClient.componentDao().insert(dbTester.getSession(), moduleDto); | |||
@@ -141,7 +141,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_snapshots_with_leak_period() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(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); | |||
@@ -165,7 +165,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest { | |||
periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1")); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), projectDto); | |||
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto); | |||
dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot); | |||
@@ -200,7 +200,7 @@ public class ReportPersistAnalysisStepTest extends BaseStepTest { | |||
@Test | |||
public void set_no_period_on_snapshots_when_no_period() { | |||
ComponentDto projectDto = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), projectDto); | |||
SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto); | |||
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto); |
@@ -52,7 +52,7 @@ import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT; | |||
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newModuleDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY; | |||
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.FILE; | |||
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT; | |||
@@ -240,7 +240,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_only_new_components() { | |||
// Project and module already exists | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -394,7 +394,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void nothing_to_persist() { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -469,7 +469,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void update_module_name_and_description() { | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -508,7 +508,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void update_module_path() { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path"); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -535,7 +535,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void update_module_uuid_when_moving_a_module() { | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project) | |||
.setKey("MODULE_A") | |||
@@ -612,7 +612,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void do_not_update_created_at_on_existing_component() { | |||
Date oldDate = DateUtils.parseDate("2015-01-01"); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(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); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -630,7 +630,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_components_that_were_previously_removed() { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project) | |||
.setKey(MODULE_KEY) | |||
@@ -732,7 +732,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void update_module_uuid_when_reactivating_removed_component() { | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(PROJECT_KEY).setName("Project"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), "ABCD").setKey(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); | |||
@@ -798,7 +798,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() { | |||
boolean isRootPrivate = new Random().nextBoolean(); | |||
OrganizationDto organization = dbTester.organizations().insert(); | |||
ComponentDto project = newProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate); | |||
ComponentDto project = newPrivateProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate); | |||
dbTester.components().insertComponent(project); | |||
treeRootHolder.setRoot(createSampleProjectComponentTree(project)); | |||
@@ -814,7 +814,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
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 = newProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate); | |||
ComponentDto project = newPrivateProjectDto(organization, "ABCD").setKey(PROJECT_KEY).setName("Project").setPrivate(isRootPrivate); | |||
dbTester.components().insertComponent(project); | |||
ComponentDto module = newModuleDto(project).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate); | |||
dbTester.components().insertComponent(module); |
@@ -159,7 +159,7 @@ public class ValidateProjectStepTest { | |||
.setKey(MODULE_KEY) | |||
.build()); | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(MODULE_KEY); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(MODULE_KEY); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
dbTester.getSession().commit(); | |||
@@ -192,8 +192,8 @@ public class ValidateProjectStepTest { | |||
.build()); | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY); | |||
ComponentDto anotherProject = ComponentTesting.newProjectDto(organizationDto).setKey(anotherProjectKey); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY); | |||
ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(organizationDto).setKey(anotherProjectKey); | |||
dbClient.componentDao().insert(dbTester.getSession(), project, anotherProject); | |||
ComponentDto module = ComponentTesting.newModuleDto("BCDE", anotherProject).setKey(MODULE_KEY); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -226,7 +226,7 @@ public class ValidateProjectStepTest { | |||
.setKey(MODULE_KEY) | |||
.build()); | |||
ComponentDto anotherProject = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(anotherProjectKey); | |||
ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setKey(anotherProjectKey); | |||
dbClient.componentDao().insert(dbTester.getSession(), anotherProject); | |||
ComponentDto module = ComponentTesting.newModuleDto("ABCD", anotherProject).setKey(PROJECT_KEY); | |||
dbClient.componentDao().insert(dbTester.getSession(), module); | |||
@@ -255,7 +255,7 @@ public class ValidateProjectStepTest { | |||
.addChildRef(2) | |||
.build()); | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1420088400000L)); // 2015-01-01 | |||
dbTester.getSession().commit(); | |||
@@ -276,7 +276,7 @@ public class ValidateProjectStepTest { | |||
.addChildRef(2) | |||
.build()); | |||
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), "ABCD").setKey(PROJECT_KEY); | |||
dbClient.componentDao().insert(dbTester.getSession(), project); | |||
dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project).setCreatedAt(1433131200000L)); // 2015-06-01 | |||
dbTester.getSession().commit(); |
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newSubView; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT_VIEW; | |||
@@ -99,7 +99,7 @@ public class ViewsPersistAnalysisStepTest extends BaseStepTest { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW")); | |||
save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW")); | |||
save(newProjectDto(organizationDto, "proj")); | |||
save(newPrivateProjectDto(organizationDto, "proj")); | |||
dbTester.getSession().commit(); | |||
Component projectView = ViewsComponent.builder(PROJECT_VIEW, "KEY_PROJECT_COPY").setUuid("UUID_PROJECT_COPY").build(); |
@@ -50,7 +50,7 @@ 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.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
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; | |||
@@ -133,7 +133,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_view_with_projectView() { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()); | |||
persistComponents(project); | |||
treeRootHolder.setRoot( | |||
@@ -227,7 +227,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persist_project_view_under_subview() { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()); | |||
persistComponents(project); | |||
treeRootHolder.setRoot( | |||
@@ -273,7 +273,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
public void update_project_view() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto view = newViewDto(organizationDto); | |||
ComponentDto project = newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
persistComponents(view, project); | |||
ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view) | |||
.setOrganizationUuid(ORGANIZATION_UUID) | |||
@@ -302,8 +302,8 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
public void update_copy_component_uuid_of_project_view() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto view = newViewDto(organizationDto); | |||
ComponentDto project1 = newProjectDto(organizationDto, "P1"); | |||
ComponentDto project2 = newProjectDto(organizationDto, "P2"); | |||
ComponentDto project1 = newPrivateProjectDto(organizationDto, "P1"); | |||
ComponentDto project2 = newPrivateProjectDto(organizationDto, "P2"); | |||
persistComponents(view, project1, project2); | |||
// Project view in DB is associated to project1 | |||
@@ -354,7 +354,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persists_new_components_as_public_if_root_does_not_exist_yet_out_of_functional_transaction() { | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert())); | |||
ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert())); | |||
treeRootHolder.setRoot( | |||
createViewBuilder() | |||
.addChildren( | |||
@@ -373,7 +373,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() { | |||
boolean isRootPrivate = new Random().nextBoolean(); | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert())); | |||
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); | |||
dbTester.components().insertComponent(view); | |||
@@ -397,7 +397,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
@Test | |||
public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() { | |||
boolean isRootPrivate = new Random().nextBoolean(); | |||
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert())); | |||
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); | |||
dbTester.components().insertComponent(view); |
@@ -59,7 +59,7 @@ public class DuplicationsJsonWriterTest { | |||
@Before | |||
public void setUp() { | |||
project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto()) | |||
project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto()) | |||
.setId(1L) | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") |
@@ -36,11 +36,11 @@ import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDao; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
public class DuplicationsParserTest { | |||
@@ -66,11 +66,11 @@ public class DuplicationsParserTest { | |||
@Before | |||
public void setUp() { | |||
organizationDto = db.organizations().insert(); | |||
project1 = newProjectDto(organizationDto) | |||
project1 = ComponentTesting.newPrivateProjectDto(organizationDto) | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
.setKey("org.codehaus.sonar:sonar"); | |||
project2 = newProjectDto(organizationDto); | |||
project2 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
componentDao.insert(dbSession, project1, project2); | |||
// Current file | |||
@@ -213,7 +213,7 @@ public class DuplicationsParserTest { | |||
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnSameProject, 5, 2), new DuplicationsParser.Duplication(fileOnDifferentProject, 2, 2))).isEqualTo(-1); | |||
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), new DuplicationsParser.Duplication(fileOnSameProject, 2, 2))).isEqualTo(1); | |||
// Files on 2 different projects | |||
ComponentDto project3 = newProjectDto(organizationDto).setId(3L); | |||
ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto).setId(3L); | |||
assertThat(comparator.compare(new DuplicationsParser.Duplication(fileOnDifferentProject, 5, 2), | |||
new DuplicationsParser.Duplication(project3, 2, 2))).isEqualTo(1); | |||
@@ -79,7 +79,7 @@ public class ShowActionTest { | |||
@Test | |||
public void return_file_with_missing_duplication_data() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js")); | |||
db.components().insertSnapshot(newAnalysis(project)); | |||
@@ -102,7 +102,7 @@ public class ShowActionTest { | |||
@Test | |||
public void return_403_if_user_is_not_allowed_to_access_project() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -115,7 +115,7 @@ public class ShowActionTest { | |||
} | |||
private void verifyCallToFileWithDuplications(Function<ComponentDto, WsTester.TestRequest> requestFactory) throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project).setKey("foo.js")); | |||
SnapshotDto snapshot = db.components().insertSnapshot(newAnalysis(project)); | |||
String xml = "<duplications>\n" + |
@@ -27,17 +27,17 @@ import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationTesting; | |||
import org.sonar.db.property.PropertyQuery; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
public class FavoriteUpdaterTest { | |||
private static final long COMPONENT_ID = 23L; | |||
private static final String COMPONENT_KEY = "K1"; | |||
private static final ComponentDto COMPONENT = newProjectDto(OrganizationTesting.newOrganizationDto()) | |||
private static final ComponentDto COMPONENT = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto()) | |||
.setId(COMPONENT_ID) | |||
.setKey(COMPONENT_KEY); | |||
private static final int USER_ID = 42; |
@@ -46,7 +46,7 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class AddActionTest { | |||
@@ -142,7 +142,7 @@ public class AddActionTest { | |||
} | |||
private ComponentDto insertProject() { | |||
return db.components().insertComponent(newProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
} | |||
private ComponentDto insertProjectAndPermissions() { |
@@ -41,7 +41,7 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class RemoveActionTest { | |||
@@ -112,7 +112,7 @@ public class RemoveActionTest { | |||
} | |||
private ComponentDto insertProject() { | |||
return db.components().insertComponent(newProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
return db.components().insertComponent(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY)); | |||
} | |||
private ComponentDto insertProjectAndPermissions() { |
@@ -31,6 +31,7 @@ import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.db.permission.UserPermissionDto; | |||
import org.sonar.server.exceptions.UnauthorizedException; | |||
@@ -48,7 +49,7 @@ import static org.sonar.api.resources.Qualifiers.FILE; | |||
import static org.sonar.api.resources.Qualifiers.PROJECT; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.WsRequest.Method.POST; | |||
@@ -69,10 +70,10 @@ public class SearchActionTest { | |||
@Test | |||
public void return_favorites() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "P1").setKey("K1").setName("N1"); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "P1").setKey("K1").setName("N1"); | |||
addComponent(project); | |||
addComponent(newFileDto(project).setKey("K11").setName("N11")); | |||
addComponent(newProjectDto(db.getDefaultOrganization(), "P2").setKey("K2").setName("N2")); | |||
addComponent(newPrivateProjectDto(db.getDefaultOrganization(), "P2").setKey("K2").setName("N2")); | |||
SearchResponse result = call(); | |||
@@ -98,8 +99,8 @@ public class SearchActionTest { | |||
@Test | |||
public void filter_authorized_components() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
addComponent(newProjectDto(organizationDto).setKey("K1")); | |||
ComponentDto unauthorizedProject = db.components().insertComponent(newProjectDto(organizationDto)); | |||
addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1")); | |||
ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
db.favorites().add(unauthorizedProject, USER_ID); | |||
SearchResponse result = call(); | |||
@@ -111,8 +112,8 @@ public class SearchActionTest { | |||
@Test | |||
public void paginate_results() { | |||
IntStream.rangeClosed(1, 9) | |||
.forEach(i -> addComponent(newProjectDto(db.getDefaultOrganization()).setKey("K" + i).setName("N" + i))); | |||
ComponentDto unauthorizedProject = db.components().insertComponent(newProjectDto(db.getDefaultOrganization())); | |||
.forEach(i -> addComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setKey("K" + i).setName("N" + i))); | |||
ComponentDto unauthorizedProject = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization())); | |||
db.favorites().add(unauthorizedProject, USER_ID); | |||
SearchResponse result = call(2, 3); | |||
@@ -127,8 +128,8 @@ public class SearchActionTest { | |||
@Test | |||
public void return_only_users_favorite() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
addComponent(newProjectDto(organizationDto).setKey("K1")); | |||
ComponentDto otherUserFavorite = newProjectDto(organizationDto).setKey("K42"); | |||
addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K1")); | |||
ComponentDto otherUserFavorite = ComponentTesting.newPrivateProjectDto(organizationDto).setKey("K42"); | |||
db.components().insertComponent(otherUserFavorite); | |||
db.favorites().add(otherUserFavorite, 42); | |||
dbClient.userPermissionDao().insert(dbSession, new UserPermissionDto(organizationDto.getUuid(), UserRole.USER, 42, otherUserFavorite.getId())); | |||
@@ -142,9 +143,9 @@ public class SearchActionTest { | |||
@Test | |||
public void favorites_ordered_by_name() { | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
addComponent(newProjectDto(organizationDto).setName("N2")); | |||
addComponent(newProjectDto(organizationDto).setName("N3")); | |||
addComponent(newProjectDto(organizationDto).setName("N1")); | |||
addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N2")); | |||
addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N3")); | |||
addComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setName("N1")); | |||
SearchResponse result = call(); | |||
@@ -156,9 +157,9 @@ public class SearchActionTest { | |||
public void json_example() { | |||
OrganizationDto organization1 = db.organizations().insertForKey("my-org"); | |||
OrganizationDto organization2 = db.organizations().insertForKey("openjdk"); | |||
addComponent(newProjectDto(organization1).setKey("K1").setName("Samba")); | |||
addComponent(newProjectDto(organization1).setKey("K2").setName("Apache HBase")); | |||
addComponent(newProjectDto(organization2).setKey("K3").setName("JDK9")); | |||
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")); | |||
String result = ws.newRequest().execute().getInput(); | |||
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED; | |||
import static org.sonar.api.web.UserRole.ISSUE_ADMIN; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.issue.IssueTesting.newDto; | |||
import static org.sonar.db.rule.RuleTesting.newXooX1; | |||
@@ -49,7 +49,7 @@ public class ActionFinderTest { | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone().logIn("arthur"); | |||
private ComponentDto project = newProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
private ComponentDto project = newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID).setKey(PROJECT_KEY); | |||
private IssueDto issue = newDto(newXooX1().setId(10), newFileDto(project, null), project).setKee(ISSUE_KEY); | |||
private ActionFinder underTest = new ActionFinder(userSession); | |||
@@ -61,7 +61,7 @@ public class ActionFinderTest { | |||
@Test | |||
public void return_provided_actions_with_set_severity_and_set_type_when_issue_admin() { | |||
userSession.addProjectPermission(ISSUE_ADMIN, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID)); | |||
userSession.addProjectPermission(ISSUE_ADMIN, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), PROJECT_UUID)); | |||
assertThat(underTest.listAvailableActions(issue)).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "set_severity"); | |||
} | |||
@@ -67,7 +67,7 @@ public class AssignActionTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
issueOrganizationDto = db.organizations().insert(); | |||
project = db.components().insertProject(issueOrganizationDto); | |||
project = db.components().insertPrivateProject(issueOrganizationDto); | |||
context = new BulkChangeAction.ActionContext(issue, issueChangeContext, project); | |||
} | |||
@@ -91,7 +91,7 @@ public class IssueFinderTest { | |||
private IssueDto insertIssue() { | |||
RuleDto rule = ruleDbTester.insertRule(newRuleDto()); | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
ComponentDto file = componentDbTester.insertComponent(newFileDto(project)); | |||
return issueDbTester.insertIssue(newDto(rule, file, project)); | |||
} |
@@ -58,7 +58,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void create_from_parameters() { | |||
OrganizationDto organization = db.organizations().insert(); | |||
ComponentDto project = db.components().insertProject(organization); | |||
ComponentDto project = db.components().insertPrivateProject(organization); | |||
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project)); | |||
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project)); | |||
@@ -176,7 +176,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void fail_if_componentRoots_references_components_with_different_qualifier() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project)); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentRoots(asList(project.key(), file.key())); | |||
@@ -214,7 +214,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void param_componentUuids_enables_search_on_project_tree_by_default() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentUuids(asList(project.uuid())); | |||
@@ -225,7 +225,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void onComponentOnly_restricts_search_to_specified_componentKeys() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentKeys(asList(project.key())) | |||
.setOnComponentOnly(true); | |||
@@ -239,7 +239,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void should_search_in_tree_with_module_uuid() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project)); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentUuids(asList(module.uuid())); | |||
@@ -251,7 +251,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void param_componentUuids_enables_search_in_directory_tree() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto dir = db.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo")); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentUuids(asList(dir.uuid())); | |||
@@ -265,7 +265,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void param_componentUuids_enables_search_by_file() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project)); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentUuids(asList(file.uuid())); | |||
@@ -277,7 +277,7 @@ public class IssueQueryFactoryTest { | |||
@Test | |||
public void param_componentUuids_enables_search_by_test_file() { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setQualifier(Qualifiers.UNIT_TEST_FILE)); | |||
SearchWsRequest request = new SearchWsRequest() | |||
.setComponentUuids(asList(file.uuid())); |
@@ -152,7 +152,7 @@ public class IssueServiceMediumTest { | |||
private ComponentDto newProject() { | |||
OrganizationDto organization = OrganizationTesting.newOrganizationDto(); | |||
tester.get(OrganizationDao.class).insert(session, organization); | |||
ComponentDto project = ComponentTesting.newProjectDto(organization); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organization); | |||
tester.get(ComponentDao.class).insert(session, project); | |||
userSessionRule.logIn().addProjectPermission(UserRole.USER, project); |
@@ -98,7 +98,7 @@ public class IssueUpdaterTest { | |||
@Test | |||
public void verify_notification() throws Exception { | |||
RuleDto rule = ruleDbTester.insertRule(newRuleDto()); | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
ComponentDto file = componentDbTester.insertComponent(newFileDto(project)); | |||
DefaultIssue issue = issueDbTester.insertIssue(newDto(rule, file, project)).setSeverity(MAJOR).toDefaultIssue(); | |||
IssueChangeContext context = IssueChangeContext.createUser(new Date(), "john"); | |||
@@ -123,7 +123,7 @@ public class IssueUpdaterTest { | |||
@Test | |||
public void verify_notification_when_issue_is_linked_on_removed_rule() throws Exception { | |||
RuleDto rule = ruleDbTester.insertRule(newRuleDto().setStatus(RuleStatus.REMOVED)); | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
ComponentDto file = componentDbTester.insertComponent(newFileDto(project)); | |||
DefaultIssue issue = issueDbTester.insertIssue(newDto(rule, file, project)).setSeverity(MAJOR).toDefaultIssue(); | |||
IssueChangeContext context = IssueChangeContext.createUser(new Date(), "john"); | |||
@@ -137,7 +137,7 @@ public class IssueUpdaterTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = ruleDbTester.insertRule(newRuleDto()); | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
ComponentDto file = componentDbTester.insertComponent(newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -122,7 +122,7 @@ public class SetSeverityActionTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = db.rules().insertRule(newRuleDto()); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -129,7 +129,7 @@ public class SetTypeActionTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = db.rules().insertRule(newRuleDto()); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -114,13 +114,13 @@ public class TransitionActionTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = newRuleDto().setId(10); | |||
ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto()); | |||
ComponentDto file = (newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} | |||
private void loginAndAddProjectPermission(String login, String permission) { | |||
userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), issue.projectUuid())); | |||
userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), issue.projectUuid())); | |||
} | |||
} |
@@ -62,7 +62,7 @@ public class TransitionServiceTest { | |||
@Test | |||
public void list_transitions() throws Exception { | |||
IssueDto issue = newIssue().setStatus(STATUS_OPEN).setResolution(null); | |||
userSession.logIn("john").addProjectPermission(ISSUE_ADMIN, ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), issue.getProjectUuid())); | |||
userSession.logIn("john").addProjectPermission(ISSUE_ADMIN, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), issue.getProjectUuid())); | |||
List<Transition> result = underTest.listTransitions(issue.toDefaultIssue()); | |||
@@ -100,7 +100,7 @@ public class TransitionServiceTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = newRuleDto().setId(10); | |||
ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto()); | |||
ComponentDto file = (newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -80,8 +80,8 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_projects() { | |||
OrganizationDto organizationDto = newOrganizationDto(); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto, "EFGH"); | |||
indexIssues( | |||
IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L), | |||
@@ -97,7 +97,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_components() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto(), "A"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto(), "A"); | |||
ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD"); | |||
ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE"); | |||
ComponentDto file3 = ComponentTesting.newFileDto(project, null, "CDEF"); | |||
@@ -118,7 +118,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_directories() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo"); | |||
ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo"); | |||
@@ -134,7 +134,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_severities() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
indexIssues( | |||
@@ -150,7 +150,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_statuses() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
indexIssues( | |||
@@ -166,7 +166,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_resolutions() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
indexIssues( | |||
@@ -182,7 +182,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_languages() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
RuleKey ruleKey = RuleKey.of("repo", "X1"); | |||
@@ -196,7 +196,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_assignees() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
indexIssues( | |||
@@ -213,7 +213,7 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void facets_on_authors() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
indexIssues( | |||
@@ -246,8 +246,8 @@ public class IssueIndexDebtTest { | |||
@Test | |||
public void deprecated_debt_facets() { | |||
OrganizationDto organizationDto = newOrganizationDto(); | |||
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH"); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto, "EFGH"); | |||
indexIssues( | |||
IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L), | |||
@@ -262,7 +262,7 @@ public class IssueIndexDebtTest { | |||
} | |||
protected SearchOptions fixtureForCreatedAtFacet() { | |||
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = ComponentTesting.newFileDto(project, null); | |||
IssueDoc issue0 = IssueDocTesting.newDoc("ISSUE0", file).setFuncCreationDate(DateUtils.parseDateTime("2011-04-25T01:05:13+0100")); |
@@ -72,7 +72,7 @@ import static org.sonar.api.rules.RuleType.BUG; | |||
import static org.sonar.api.utils.DateUtils.parseDate; | |||
import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto; | |||
import static org.sonar.db.user.GroupTesting.newGroupDto; | |||
import static org.sonar.db.user.UserTesting.newUserDto; | |||
@@ -109,7 +109,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void get_by_key() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
IssueDoc issue = newDoc("ISSUE1", file) | |||
.setEffort(100L); | |||
@@ -129,7 +129,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void get_by_key_with_attributes() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
IssueDoc issue = newDoc("ISSUE1", file).setAttributes((KeyValueFormat.format(ImmutableMap.of("jira-issue-key", "SONAR-1234")))); | |||
indexIssues(issue); | |||
@@ -140,7 +140,7 @@ public class IssueIndexTest { | |||
@Test(expected = IllegalStateException.class) | |||
public void comments_field_is_not_available() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
IssueDoc issue = newDoc("ISSUE1", file); | |||
indexIssues(issue); | |||
@@ -151,7 +151,7 @@ public class IssueIndexTest { | |||
@Test(expected = IllegalStateException.class) | |||
public void is_new_field_is_not_available() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
IssueDoc issue = newDoc("ISSUE1", file); | |||
indexIssues(issue); | |||
@@ -162,7 +162,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_keys() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
indexIssues( | |||
newDoc("1", newFileDto(project, null)), | |||
@@ -175,7 +175,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_projects() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto module = ComponentTesting.newModuleDto(project); | |||
ComponentDto subModule = ComponentTesting.newModuleDto(module); | |||
@@ -194,8 +194,8 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_projects() { | |||
OrganizationDto organizationDto = newOrganizationDto(); | |||
ComponentDto project = newProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = newProjectDto(organizationDto, "EFGH"); | |||
ComponentDto project = newPrivateProjectDto(organizationDto, "ABCD"); | |||
ComponentDto project2 = newPrivateProjectDto(organizationDto, "EFGH"); | |||
indexIssues( | |||
newDoc("ISSUE1", newFileDto(project, null)), | |||
@@ -209,7 +209,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_modules() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto module = ComponentTesting.newModuleDto(project); | |||
ComponentDto subModule = ComponentTesting.newModuleDto(module); | |||
ComponentDto file = newFileDto(subModule, null); | |||
@@ -242,7 +242,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_components_on_contextualized_search() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto module = ComponentTesting.newModuleDto(project); | |||
ComponentDto subModule = ComponentTesting.newModuleDto(module); | |||
ComponentDto file1 = newFileDto(project, null); | |||
@@ -277,7 +277,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_components_on_non_contextualized_search() { | |||
ComponentDto project = newProjectDto(newOrganizationDto(), "project"); | |||
ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "project"); | |||
ComponentDto file1 = newFileDto(project, null, "file1"); | |||
ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("module"); | |||
ComponentDto file2 = newFileDto(module, null, "file2"); | |||
@@ -308,7 +308,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_components() { | |||
ComponentDto project = newProjectDto(newOrganizationDto(), "A"); | |||
ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "A"); | |||
ComponentDto file1 = newFileDto(project, null, "ABCD"); | |||
ComponentDto file2 = newFileDto(project, null, "BCDE"); | |||
ComponentDto file3 = newFileDto(project, null, "CDEF"); | |||
@@ -328,7 +328,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_directories() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file1 = newFileDto(project, null).setPath("src/main/xoo/F1.xoo"); | |||
ComponentDto file2 = newFileDto(project, null).setPath("F2.xoo"); | |||
@@ -343,7 +343,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_directories() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file1 = newFileDto(project, null).setPath("src/main/xoo/F1.xoo"); | |||
ComponentDto file2 = newFileDto(project, null).setPath("F2.xoo"); | |||
@@ -359,9 +359,9 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_views() { | |||
OrganizationDto organizationDto = newOrganizationDto(); | |||
ComponentDto project1 = newProjectDto(organizationDto); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
ComponentDto file1 = newFileDto(project1, null); | |||
ComponentDto project2 = newProjectDto(organizationDto); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
indexIssues( | |||
// Project1 has 2 issues (one on a file and one on the project itself) | |||
newDoc("ISSUE1", project1), | |||
@@ -385,7 +385,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_severities() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -399,7 +399,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_severities() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -414,7 +414,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_statuses() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -429,7 +429,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_statuses() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -444,7 +444,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_resolutions() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -461,7 +461,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_resolutions() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -476,7 +476,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_resolved() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -491,7 +491,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_rules() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
RuleKey ruleKey = RuleKey.of("repo", "X1"); | |||
@@ -503,7 +503,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_languages() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
RuleKey ruleKey = RuleKey.of("repo", "X1"); | |||
@@ -516,7 +516,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_languages() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
RuleKey ruleKey = RuleKey.of("repo", "X1"); | |||
@@ -529,7 +529,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_assignees() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -544,7 +544,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_assignees() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -560,7 +560,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_assignees_supports_dashes() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -577,7 +577,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_assigned() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -592,7 +592,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_authors() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -607,7 +607,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void facets_on_authors() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -623,7 +623,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_created_after() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -639,7 +639,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_created_before() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -655,7 +655,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_created_after_and_before() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -701,7 +701,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_create_after_and_before_take_into_account_timezone() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -748,7 +748,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_created_at() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues(newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20"))); | |||
@@ -888,7 +888,7 @@ public class IssueIndexTest { | |||
} | |||
private SearchOptions fixtureForCreatedAtFacet() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
IssueDoc issue0 = newDoc("ISSUE0", file).setFuncCreationDate(parseDateTime("2011-04-25T00:05:13+0000")); | |||
@@ -906,7 +906,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void paging() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
for (int i = 0; i < 12; i++) { | |||
indexIssues(newDoc("ISSUE" + i, file)); | |||
@@ -929,7 +929,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void search_with_max_limit() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
List<IssueDoc> issues = newArrayList(); | |||
for (int i = 0; i < 500; i++) { | |||
@@ -945,7 +945,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_status() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -968,7 +968,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_severity() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -997,7 +997,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_assignee() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -1019,7 +1019,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_creation_date() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -1041,7 +1041,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_update_date() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -1063,7 +1063,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_close_date() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
@@ -1088,7 +1088,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void sort_by_file_and_line() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file1 = newFileDto(project, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo"); | |||
ComponentDto file2 = newFileDto(project, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo"); | |||
@@ -1130,11 +1130,11 @@ public class IssueIndexTest { | |||
@Test | |||
public void default_sort_is_by_creation_date_then_project_then_file_then_line_then_issue_key() { | |||
OrganizationDto organizationDto = newOrganizationDto(); | |||
ComponentDto project1 = newProjectDto(organizationDto, "P1"); | |||
ComponentDto project1 = newPrivateProjectDto(organizationDto, "P1"); | |||
ComponentDto file1 = newFileDto(project1, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo"); | |||
ComponentDto file2 = newFileDto(project1, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo"); | |||
ComponentDto project2 = newProjectDto(organizationDto, "P2"); | |||
ComponentDto project2 = newPrivateProjectDto(organizationDto, "P2"); | |||
ComponentDto file3 = newFileDto(project2, null, "F3").setPath("src/main/xoo/org/sonar/samples/File3.xoo"); | |||
indexIssues( | |||
@@ -1160,9 +1160,9 @@ public class IssueIndexTest { | |||
@Test | |||
public void authorized_issues_on_groups() { | |||
OrganizationDto org = newOrganizationDto(); | |||
ComponentDto project1 = newProjectDto(org); | |||
ComponentDto project2 = newProjectDto(org); | |||
ComponentDto project3 = newProjectDto(org); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto project3 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto file1 = newFileDto(project1, null); | |||
ComponentDto file2 = newFileDto(project2, null); | |||
ComponentDto file3 = newFileDto(project3, null); | |||
@@ -1198,9 +1198,9 @@ public class IssueIndexTest { | |||
@Test | |||
public void authorized_issues_on_user() { | |||
OrganizationDto org = newOrganizationDto(); | |||
ComponentDto project1 = newProjectDto(org); | |||
ComponentDto project2 = newProjectDto(org); | |||
ComponentDto project3 = newProjectDto(org); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto project3 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto file1 = newFileDto(project1, null); | |||
ComponentDto file2 = newFileDto(project2, null); | |||
ComponentDto file3 = newFileDto(project3, null); | |||
@@ -1228,7 +1228,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void root_user_is_authorized_to_access_all_issues() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
indexIssue(newDoc("I1", project)); | |||
userSessionRule.logIn().setRoot(); | |||
@@ -1237,7 +1237,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void search_issues_for_batch_return_needed_fields() { | |||
ComponentDto project = newProjectDto(newOrganizationDto(), "PROJECT"); | |||
ComponentDto project = newPrivateProjectDto(newOrganizationDto(), "PROJECT"); | |||
ComponentDto file = newFileDto(project, null).setPath("src/File.xoo"); | |||
IssueDoc issue = newDoc("ISSUE", file) | |||
@@ -1275,7 +1275,7 @@ public class IssueIndexTest { | |||
@Test | |||
public void search_issues_for_batch() { | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto module = ComponentTesting.newModuleDto(project); | |||
ComponentDto subModule = ComponentTesting.newModuleDto(module); | |||
ComponentDto file = newFileDto(subModule, null); | |||
@@ -1291,7 +1291,7 @@ public class IssueIndexTest { | |||
assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(module))).hasSize(3); | |||
assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(subModule))).hasSize(2); | |||
assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(file))).hasSize(1); | |||
assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(newProjectDto(newOrganizationDto())))).isEmpty(); | |||
assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(ComponentTesting.newPrivateProjectDto(newOrganizationDto())))).isEmpty(); | |||
} | |||
@Test | |||
@@ -1307,8 +1307,8 @@ public class IssueIndexTest { | |||
@Test | |||
public void search_issues_for_batch_return_only_authorized_issues() { | |||
OrganizationDto org = newOrganizationDto(); | |||
ComponentDto project1 = newProjectDto(org); | |||
ComponentDto project2 = newProjectDto(org); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(org); | |||
ComponentDto file1 = newFileDto(project1, null); | |||
ComponentDto file2 = newFileDto(project2, null); | |||
GroupDto allowedGroup = newGroupDto(); | |||
@@ -1336,7 +1336,7 @@ public class IssueIndexTest { | |||
ruleIndexer.indexRuleDefinition(r2.getKey()); | |||
OrganizationDto org = db.organizations().insert(); | |||
ComponentDto project = newProjectDto(newOrganizationDto()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto()); | |||
ComponentDto file = newFileDto(project, null); | |||
indexIssues( | |||
newDoc("ISSUE1", file).setOrganizationUuid(org.getUuid()).setRuleKey(r1.getKey().toString()).setTags(of("convention", "java8", "bug")), | |||
@@ -1355,9 +1355,9 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_organization() { | |||
OrganizationDto org1 = newOrganizationDto(); | |||
ComponentDto projectInOrg1 = newProjectDto(org1); | |||
ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1); | |||
OrganizationDto org2 = newOrganizationDto(); | |||
ComponentDto projectInOrg2 = newProjectDto(org2); | |||
ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2); | |||
indexIssues(newDoc("issueInOrg1", projectInOrg1), newDoc("issue1InOrg2", projectInOrg2), newDoc("issue2InOrg2", projectInOrg2)); | |||
@@ -1369,9 +1369,9 @@ public class IssueIndexTest { | |||
@Test | |||
public void filter_by_organization_and_project() { | |||
OrganizationDto org1 = newOrganizationDto(); | |||
ComponentDto projectInOrg1 = newProjectDto(org1); | |||
ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1); | |||
OrganizationDto org2 = newOrganizationDto(); | |||
ComponentDto projectInOrg2 = newProjectDto(org2); | |||
ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2); | |||
indexIssues(newDoc("issueInOrg1", projectInOrg1), newDoc("issue1InOrg2", projectInOrg2), newDoc("issue2InOrg2", projectInOrg2)); | |||
@@ -81,7 +81,7 @@ public class IssueIndexerTest { | |||
@Test | |||
public void indexOnStartup_loads_and_indexes_all_issues() { | |||
OrganizationDto org = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(org); | |||
ComponentDto project = dbTester.components().insertPrivateProject(org); | |||
ComponentDto dir = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo")); | |||
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project, dir, "F1")); | |||
RuleDto rule = dbTester.rules().insertRule(); | |||
@@ -97,7 +97,7 @@ public class IssueIndexerTest { | |||
@Test | |||
public void index_loads_and_indexes_issues_with_specified_keys() { | |||
OrganizationDto org = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(org); | |||
ComponentDto project = dbTester.components().insertPrivateProject(org); | |||
ComponentDto dir = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "src/main/java/foo")); | |||
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project, dir, "F1")); | |||
RuleDto rule = dbTester.rules().insertRule(); | |||
@@ -124,9 +124,9 @@ public class IssueIndexerTest { | |||
@Test | |||
public void indexProject_loads_and_indexes_issues_with_specified_project_uuid() { | |||
OrganizationDto org = dbTester.organizations().insert(); | |||
ComponentDto project1 = dbTester.components().insertProject(org); | |||
ComponentDto project1 = dbTester.components().insertPrivateProject(org); | |||
ComponentDto file1 = dbTester.components().insertComponent(ComponentTesting.newFileDto(project1)); | |||
ComponentDto project2 = dbTester.components().insertProject(org); | |||
ComponentDto project2 = dbTester.components().insertPrivateProject(org); | |||
ComponentDto file2 = dbTester.components().insertComponent(ComponentTesting.newFileDto(project2)); | |||
RuleDto rule = dbTester.rules().insertRule(); | |||
IssueDto issue1 = dbTester.issues().insertIssue(IssueTesting.newDto(rule, file1, project1)); | |||
@@ -151,7 +151,7 @@ public class IssueIndexerTest { | |||
private void verifyThatProjectIsNotIndexed(ProjectIndexer.Cause cause) { | |||
OrganizationDto org = dbTester.organizations().insert(); | |||
ComponentDto project = dbTester.components().insertProject(org); | |||
ComponentDto project = dbTester.components().insertPrivateProject(org); | |||
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project)); | |||
RuleDto rule = dbTester.rules().insertRule(); | |||
IssueDto issue = dbTester.issues().insertIssue(IssueTesting.newDto(rule, file, project)); |
@@ -123,7 +123,7 @@ public class BulkChangeActionTest { | |||
issueWorkflow.start(); | |||
rule = db.rules().insertRule(newRuleDto()); | |||
organization = db.organizations().insert(); | |||
project = db.components().insertProject(organization); | |||
project = db.components().insertPrivateProject(organization); | |||
file = db.components().insertComponent(newFileDto(project)); | |||
user = db.users().insertUser("john"); | |||
when(system2.now()).thenReturn(NOW); | |||
@@ -346,7 +346,7 @@ public class BulkChangeActionTest { | |||
@Test | |||
public void issues_on_which_user_has_not_browse_permission_are_ignored() throws Exception { | |||
setUserProjectPermissions(USER, ISSUE_ADMIN); | |||
ComponentDto anotherProject = db.components().insertProject(); | |||
ComponentDto anotherProject = db.components().insertPrivateProject(); | |||
ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject)); | |||
IssueDto authorizedIssue = db.issues().insertIssue(newUnresolvedIssue(rule, file, project).setType(BUG)); | |||
// User has not browse permission on these 2 issues | |||
@@ -370,7 +370,7 @@ public class BulkChangeActionTest { | |||
@Test | |||
public void does_not_update_type_when_no_issue_admin_permission() throws Exception { | |||
setUserProjectPermissions(USER, ISSUE_ADMIN); | |||
ComponentDto anotherProject = db.components().insertProject(); | |||
ComponentDto anotherProject = db.components().insertPrivateProject(); | |||
ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject)); | |||
addUserProjectPermissions(anotherProject, USER); | |||
@@ -396,7 +396,7 @@ public class BulkChangeActionTest { | |||
@Test | |||
public void does_not_update_severity_when_no_issue_admin_permission() throws Exception { | |||
setUserProjectPermissions(USER, ISSUE_ADMIN); | |||
ComponentDto anotherProject = db.components().insertProject(); | |||
ComponentDto anotherProject = db.components().insertPrivateProject(); | |||
ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject)); | |||
addUserProjectPermissions(anotherProject, USER); | |||
@@ -70,7 +70,7 @@ public class ChangelogActionTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
project = db.components().insertProject(); | |||
project = db.components().insertPrivateProject(); | |||
file = db.components().insertComponent(newFileDto(project)); | |||
} | |||
@@ -94,7 +94,7 @@ public class ChangelogActionTest { | |||
@Test | |||
public void changelog_of_file_move_contains_file_names() throws Exception { | |||
RuleDto rule = db.rules().insertRule(newRuleDto()); | |||
ComponentDto project = db.components().insertProject(db.organizations().insert()); | |||
ComponentDto project = db.components().insertPrivateProject(db.organizations().insert()); | |||
ComponentDto file1 = db.components().insertComponent(newFileDto(project)); | |||
ComponentDto file2 = db.components().insertComponent(newFileDto(project)); | |||
IssueDto issueDto = db.issues().insertIssue(newDto(rule, file2, project)); |
@@ -111,7 +111,7 @@ public class DoTransitionActionTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
project = componentDbTester.insertProject(); | |||
project = componentDbTester.insertPrivateProject(); | |||
file = componentDbTester.insertComponent(newFileDto(project)); | |||
workflow.start(); | |||
} |
@@ -112,7 +112,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void issues_on_different_projects() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
IssueDto issue = IssueTesting.newDto(rule, file, project) | |||
@@ -123,7 +123,7 @@ public class SearchActionComponentsMediumTest { | |||
.setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100")); | |||
db.issueDao().insert(session, issue); | |||
ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P2").setKey("PK2")); | |||
ComponentDto project2 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P2").setKey("PK2")); | |||
setDefaultProjectPermission(project2); | |||
ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2")); | |||
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2) | |||
@@ -142,7 +142,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void do_not_return_module_key_on_single_module_projects() throws IOException { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1")); | |||
ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1")); | |||
@@ -169,7 +169,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_project_uuid() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"); | |||
@@ -200,7 +200,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_since_leak_period_on_project() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
db.snapshotDao().insert(session, | |||
@@ -228,7 +228,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_since_leak_period_on_file_in_module_project() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto module = insertComponent(newModuleDto(project)); | |||
ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1")); | |||
@@ -257,9 +257,9 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void project_facet_is_sticky() throws Exception { | |||
ComponentDto project1 = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P2").setKey("PK2")); | |||
ComponentDto project3 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P3").setKey("PK3")); | |||
ComponentDto project1 = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project2 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P2").setKey("PK2")); | |||
ComponentDto project3 = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P3").setKey("PK3")); | |||
setDefaultProjectPermission(project1); | |||
setDefaultProjectPermission(project2); | |||
setDefaultProjectPermission(project3); | |||
@@ -283,7 +283,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_file_uuid() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"); | |||
@@ -314,7 +314,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_file_key() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
ComponentDto unitTest = insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2")); | |||
@@ -338,7 +338,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void display_file_facet() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setKey("FK2")); | |||
@@ -360,7 +360,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_directory_path() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
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")); | |||
@@ -392,7 +392,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_directory_path_in_different_modules() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto module1 = insertComponent(newModuleDto("M1", project).setKey("MK1")); | |||
ComponentDto module2 = insertComponent(newModuleDto("M2", project).setKey("MK2")); | |||
@@ -441,7 +441,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void display_module_facet() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1")); | |||
ComponentDto subModule1 = insertComponent(newModuleDto("SUBM1", module).setKey("SUBMK1")); | |||
@@ -466,7 +466,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void display_directory_facet() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
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")); | |||
@@ -485,12 +485,12 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_view_uuid() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); | |||
ComponentDto view = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
indexView(view.uuid(), newArrayList(project.uuid())); | |||
setAnyoneProjectPermission(view, UserRole.USER); | |||
@@ -504,12 +504,12 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_view_uuid_return_only_authorized_view() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); | |||
ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
indexView(view.uuid(), newArrayList(project.uuid())); | |||
setAnyoneProjectPermission(view, UserRole.USER); | |||
@@ -524,14 +524,14 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_sub_view_uuid() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); | |||
ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
indexView(view.uuid(), newArrayList(project.uuid())); | |||
ComponentDto subView = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView")); | |||
ComponentDto subView = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView")); | |||
indexView(subView.uuid(), newArrayList(project.uuid())); | |||
setAnyoneProjectPermission(view, UserRole.USER); | |||
@@ -545,14 +545,14 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_sub_view_uuid_return_only_authorized_view() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
insertIssue(IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); | |||
ComponentDto view = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
ComponentDto view = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "V1").setQualifier(Qualifiers.VIEW).setKey("MyView")); | |||
indexView(view.uuid(), newArrayList(project.uuid())); | |||
ComponentDto subView = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView")); | |||
ComponentDto subView = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "SV1").setQualifier(Qualifiers.SUBVIEW).setKey("MySubView")); | |||
indexView(subView.uuid(), newArrayList(project.uuid())); | |||
setAnyoneProjectPermission(view, UserRole.USER); | |||
@@ -567,7 +567,7 @@ public class SearchActionComponentsMediumTest { | |||
@Test | |||
public void search_by_author() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "P1").setKey("PK1")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1")); | |||
RuleDto newRule = newRule(); |
@@ -129,7 +129,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -158,7 +158,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -195,7 +195,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -230,7 +230,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java")); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js")); | |||
setProjectPermission(project, USER); | |||
@@ -252,7 +252,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java")); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js")); | |||
setProjectPermission(project, USER, ISSUE_ADMIN); | |||
@@ -273,7 +273,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void issue_on_removed_file() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto removedFile = insertComponent(ComponentTesting.newFileDto(project, null).setUuid("REMOVED_FILE_ID") | |||
.setKey("REMOVED_FILE_KEY") | |||
@@ -298,7 +298,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void issue_contains_component_id_for_eclipse() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project); | |||
@@ -314,7 +314,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void apply_paging_with_one_component() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
for (int i = 0; i < SearchOptions.MAX_LIMIT + 1; i++) { | |||
@@ -331,7 +331,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void components_contains_sub_projects() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("ProjectHavingModule")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto module = insertComponent(ComponentTesting.newModuleDto(project).setKey("ModuleHavingFile")); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(module, null, "BCDE").setKey("FileLinkedToModule")); | |||
@@ -347,7 +347,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void display_facets() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -372,7 +372,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void display_facets_in_effort_mode() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -398,7 +398,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void display_zero_valued_facets_for_selected_items() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) | |||
@@ -440,7 +440,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
RuleDto rule = newRule(); | |||
@@ -485,7 +485,7 @@ public class SearchActionMediumTest { | |||
public void filter_by_assigned_to_me_unauthenticated() throws Exception { | |||
userSessionRule.logIn(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
RuleDto rule = newRule(); | |||
@@ -516,7 +516,7 @@ public class SearchActionMediumTest { | |||
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.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
RuleDto rule = newRule(); | |||
@@ -560,7 +560,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void sort_by_updated_at() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
db.issueDao().insert(session, IssueTesting.newDto(rule, file, project) | |||
@@ -586,7 +586,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void paging() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
for (int i = 0; i < 12; i++) { | |||
@@ -608,7 +608,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void paging_with_page_size_to_minus_one() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
for (int i = 0; i < 12; i++) { | |||
@@ -630,7 +630,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void deprecated_paging() throws Exception { | |||
RuleDto rule = newRule(); | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(defaultOrganization, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
for (int i = 0; i < 12; i++) { | |||
@@ -659,7 +659,7 @@ public class SearchActionMediumTest { | |||
@Test | |||
public void display_deprecated_debt_fields() throws Exception { | |||
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY")); | |||
setDefaultProjectPermission(project); | |||
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY")); | |||
IssueDto issue = IssueTesting.newDto(newRule(), file, project) |
@@ -178,7 +178,7 @@ public class SetSeverityActionTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = dbTester.rules().insertRule(newRuleDto()); | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto file = dbTester.components().insertComponent(newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -232,13 +232,13 @@ public class SetTagsActionTest { | |||
private IssueDto newIssue() { | |||
RuleDefinitionDto rule = db.rules().insert(); | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPublicProject(); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
return IssueTesting.newIssue(rule, file, project); | |||
} | |||
private void setUserWithBrowsePermission(IssueDto issueDto) { | |||
logInAndAddProjectPermission(issueDto, USER); | |||
userSession.logIn("john").addProjectPermission(USER, dbClient.componentDao().selectByUuid(db.getSession(), issueDto.getProjectUuid()).get()); | |||
} | |||
private void logInAndAddProjectPermission(IssueDto issueDto, String permission) { |
@@ -175,7 +175,7 @@ public class SetTypeActionTest { | |||
private IssueDto newIssue() { | |||
RuleDto rule = dbTester.rules().insertRule(newRuleDto()); | |||
ComponentDto project = dbTester.components().insertProject(); | |||
ComponentDto project = dbTester.components().insertPrivateProject(); | |||
ComponentDto file = dbTester.components().insertComponent(newFileDto(project)); | |||
return newDto(rule, file, project); | |||
} |
@@ -206,7 +206,7 @@ public class TagsActionTest { | |||
} | |||
private IssueDto insertIssue(RuleDefinitionDto rule, String... tags) { | |||
ComponentDto project = db.components().insertProject(organization); | |||
ComponentDto project = db.components().insertPrivateProject(organization); | |||
ComponentDto file = db.components().insertComponent(newFileDto(project)); | |||
IssueDto issueDto = IssueTesting.newIssue(rule, file, project).setTags(asList(tags)); | |||
return db.issues().insertIssue(issueDto); |
@@ -96,7 +96,7 @@ public class CreateActionTest { | |||
dbSession.commit(); | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
project = ComponentTesting.newProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setKey(DEFAULT_PROJECT_KEY); | |||
project = ComponentTesting.newPrivateProjectDto(organizationDto, DEFAULT_PROJECT_UUID).setKey(DEFAULT_PROJECT_KEY); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); | |||
userSession.logIn("login").addProjectPermission(UserRole.ADMIN, project); |
@@ -63,7 +63,7 @@ public class DeleteActionTest { | |||
@Test | |||
public void project_administrator_can_delete_custom_measures() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
userSession.logIn().addProjectPermission(UserRole.ADMIN, project); | |||
long id = insertCustomMeasure(project); | |||
@@ -81,7 +81,7 @@ public class DeleteActionTest { | |||
@Test | |||
public void throw_ForbiddenException_if_not_system_administrator() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
long id = insertCustomMeasure(project); | |||
userSession.logIn().setNonSystemAdministrator(); | |||
@@ -91,7 +91,7 @@ public class DeleteActionTest { | |||
@Test | |||
public void throw_UnauthorizedException_if_not_logged_in() throws Exception { | |||
ComponentDto project = db.components().insertProject(); | |||
ComponentDto project = db.components().insertPrivateProject(); | |||
long id = insertCustomMeasure(project); | |||
userSession.anonymous(); | |||
@@ -227,7 +227,7 @@ public class MetricsActionTest { | |||
} | |||
private ComponentDto insertProject(String projectUuid, String projectKey) { | |||
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), projectUuid) | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), projectUuid) | |||
.setKey(projectKey); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); |
@@ -265,7 +265,7 @@ public class SearchActionTest { | |||
} | |||
private ComponentDto insertProject(String projectUuid, String projectKey) { | |||
ComponentDto project = ComponentTesting.newProjectDto(db.organizations().insert(), projectUuid) | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert(), projectUuid) | |||
.setKey(projectKey); | |||
dbClient.componentDao().insert(dbSession, project); | |||
dbSession.commit(); |
@@ -90,7 +90,7 @@ public class UpdateActionTest { | |||
@Test | |||
public void update_text_value_and_description_in_db() throws Exception { | |||
MetricDto metric = insertNewMetric(ValueType.STRING); | |||
ComponentDto component = db.components().insertProject(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto component = db.components().insertPrivateProject(db.getDefaultOrganization(), "project-uuid"); | |||
CustomMeasureDto customMeasure = newCustomMeasure(component, metric) | |||
.setDescription("custom-measure-description") | |||
.setTextValue("text-measure-value"); | |||
@@ -117,7 +117,7 @@ public class UpdateActionTest { | |||
public void update_double_value_and_description_in_db() throws Exception { | |||
MetricDto metric = insertNewMetric(ValueType.INT); | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto component = db.components().insertProject(organizationDto, "project-uuid"); | |||
ComponentDto component = db.components().insertPrivateProject(organizationDto, "project-uuid"); | |||
CustomMeasureDto customMeasure = newCustomMeasure(component, metric) | |||
.setDescription("custom-measure-description") | |||
.setValue(42d); | |||
@@ -144,7 +144,7 @@ public class UpdateActionTest { | |||
.setKey("metric-key"); | |||
dbClient.metricDao().insert(dbSession, metric); | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto component = ComponentTesting.newProjectDto(organizationDto, "project-uuid").setKey("project-key"); | |||
ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid").setKey("project-key"); | |||
dbClient.componentDao().insert(dbSession, component); | |||
CustomMeasureDto customMeasure = newCustomMeasure(component, metric) | |||
.setCreatedAt(100_000_000L) | |||
@@ -171,7 +171,7 @@ public class UpdateActionTest { | |||
@Test | |||
public void update_value_only() throws Exception { | |||
MetricDto metric = insertNewMetric(ValueType.STRING); | |||
ComponentDto component = db.components().insertProject(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto component = db.components().insertPrivateProject(db.getDefaultOrganization(), "project-uuid"); | |||
CustomMeasureDto customMeasure = newCustomMeasure(component, metric) | |||
.setDescription("custom-measure-description") | |||
.setTextValue("text-measure-value"); | |||
@@ -197,7 +197,7 @@ public class UpdateActionTest { | |||
public void update_description_only() throws Exception { | |||
MetricDto metric = insertNewMetric(ValueType.STRING); | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto component = db.components().insertProject(organizationDto, "project-uuid"); | |||
ComponentDto component = db.components().insertPrivateProject(organizationDto, "project-uuid"); | |||
CustomMeasureDto customMeasure = newCustomMeasure(component, metric) | |||
.setMetricId(metric.getId()) | |||
.setComponentUuid(component.uuid()) | |||
@@ -249,7 +249,7 @@ public class UpdateActionTest { | |||
userSessionRule.logIn(); | |||
MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(ValueType.STRING.name()); | |||
dbClient.metricDao().insert(dbSession, metric); | |||
ComponentDto component = ComponentTesting.newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto component = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
dbClient.componentDao().insert(dbSession, component); | |||
CustomMeasureDto customMeasure = newCustomMeasureDto() | |||
.setMetricId(metric.getId()) | |||
@@ -276,7 +276,7 @@ public class UpdateActionTest { | |||
MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(ValueType.STRING.name()); | |||
dbClient.metricDao().insert(dbSession, metric); | |||
OrganizationDto organizationDto = db.organizations().insert(); | |||
ComponentDto component = ComponentTesting.newProjectDto(organizationDto, "project-uuid"); | |||
ComponentDto component = ComponentTesting.newPrivateProjectDto(organizationDto, "project-uuid"); | |||
dbClient.componentDao().insert(dbSession, component); | |||
CustomMeasureDto customMeasure = newCustomMeasureDto() | |||
.setMetricId(metric.getId()) |
@@ -32,6 +32,7 @@ import org.junit.rules.ExpectedException; | |||
import org.sonar.api.config.MapSettings; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.db.organization.OrganizationTesting; | |||
import org.sonar.db.user.GroupDto; | |||
@@ -58,7 +59,7 @@ import static org.sonar.api.measures.CoreMetrics.COVERAGE_KEY; | |||
import static org.sonar.api.measures.Metric.Level.ERROR; | |||
import static org.sonar.api.measures.Metric.Level.OK; | |||
import static org.sonar.api.measures.Metric.Level.WARN; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.user.GroupTesting.newGroupDto; | |||
import static org.sonar.db.user.UserTesting.newUserDto; | |||
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_TAGS; | |||
@@ -75,9 +76,9 @@ public class ProjectMeasuresIndexTest { | |||
private static final String LANGUAGES = "languages"; | |||
private static final OrganizationDto ORG = OrganizationTesting.newOrganizationDto(); | |||
private static final ComponentDto PROJECT1 = newProjectDto(ORG).setUuid("Project-1").setName("Project 1").setKey("key-1"); | |||
private static final ComponentDto PROJECT2 = newProjectDto(ORG).setUuid("Project-2").setName("Project 2").setKey("key-2"); | |||
private static final ComponentDto PROJECT3 = newProjectDto(ORG).setUuid("Project-3").setName("Project 3").setKey("key-3"); | |||
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 UserDto USER1 = newUserDto(); | |||
private static final UserDto USER2 = newUserDto(); | |||
private static final GroupDto GROUP1 = newGroupDto(); | |||
@@ -103,10 +104,10 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void default_sort_is_by_ascending_case_insensitive_name_then_by_key() { | |||
ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1"); | |||
ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2"); | |||
ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3"); | |||
ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4"); | |||
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"); | |||
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2)); | |||
assertResults(new ProjectMeasuresQuery(), apache1, apache2, apachee, windows); | |||
@@ -114,9 +115,9 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void sort_by_insensitive_name() { | |||
ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows"); | |||
ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee"); | |||
ComponentDto apache = newProjectDto(ORG).setUuid("apache").setName("Apache"); | |||
ComponentDto windows = ComponentTesting.newPrivateProjectDto(ORG).setUuid("windows").setName("Windows"); | |||
ComponentDto apachee = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apachee").setName("apachee"); | |||
ComponentDto apache = ComponentTesting.newPrivateProjectDto(ORG).setUuid("apache").setName("Apache"); | |||
index(newDoc(windows), newDoc(apachee), newDoc(apache)); | |||
assertResults(new ProjectMeasuresQuery().setSort("name").setAsc(true), apache, apachee, windows); | |||
@@ -136,10 +137,10 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void sort_by_a_metric_then_by_name_then_by_key() { | |||
ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1"); | |||
ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2"); | |||
ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3"); | |||
ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4"); | |||
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"); | |||
index( | |||
newDoc(windows, NCLOC, 10_000d), | |||
newDoc(apachee, NCLOC, 5_000d), | |||
@@ -152,7 +153,7 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void sort_by_quality_gate_status() { | |||
ComponentDto project4 = newProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4"); | |||
ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4"); | |||
index( | |||
newDoc(PROJECT1).setQualityGateStatus(OK.name()), | |||
newDoc(PROJECT2).setQualityGateStatus(ERROR.name()), | |||
@@ -165,10 +166,10 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void sort_by_quality_gate_status_then_by_name_then_by_key() { | |||
ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1"); | |||
ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2"); | |||
ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3"); | |||
ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4"); | |||
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"); | |||
index( | |||
newDoc(windows).setQualityGateStatus(WARN.name()), | |||
newDoc(apachee).setQualityGateStatus(OK.name()), | |||
@@ -182,7 +183,7 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void paginate_results() { | |||
IntStream.rangeClosed(1, 9) | |||
.forEach(i -> index(newDoc(newProjectDto(ORG, "P" + i)))); | |||
.forEach(i -> index(newDoc(newPrivateProjectDto(ORG, "P" + i)))); | |||
SearchIdResult<String> result = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().setPage(2, 3)); | |||
@@ -284,7 +285,7 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void filter_on_languages() { | |||
ComponentDto project4 = newProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4"); | |||
ComponentDto project4 = ComponentTesting.newPrivateProjectDto(ORG).setUuid("Project-4").setName("Project 4").setKey("key-4"); | |||
index( | |||
newDoc(PROJECT1).setLanguages(singletonList("java")), | |||
newDoc(PROJECT2).setLanguages(singletonList("xoo")), | |||
@@ -298,10 +299,10 @@ public class ProjectMeasuresIndexTest { | |||
@Test | |||
public void filter_on_query_text() { | |||
ComponentDto windows = newProjectDto(ORG).setUuid("windows").setName("Windows").setKey("project1"); | |||
ComponentDto apachee = newProjectDto(ORG).setUuid("apachee").setName("apachee").setKey("project2"); | |||
ComponentDto apache1 = newProjectDto(ORG).setUuid("apache-1").setName("Apache").setKey("project3"); | |||
ComponentDto apache2 = newProjectDto(ORG).setUuid("apache-2").setName("Apache").setKey("project4"); | |||
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"); | |||
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2)); | |||
assertResults(new ProjectMeasuresQuery().setQueryText("windows"), windows); | |||
@@ -338,8 +339,8 @@ public class ProjectMeasuresIndexTest { | |||
public void filter_on_organization() { | |||
OrganizationDto org1 = OrganizationTesting.newOrganizationDto(); | |||
OrganizationDto org2 = OrganizationTesting.newOrganizationDto(); | |||
ComponentDto projectInOrg1 = newProjectDto(org1); | |||
ComponentDto projectInOrg2 = newProjectDto(org2); | |||
ComponentDto projectInOrg1 = ComponentTesting.newPrivateProjectDto(org1); | |||
ComponentDto projectInOrg2 = ComponentTesting.newPrivateProjectDto(org2); | |||
index(newDoc(projectInOrg1), newDoc(projectInOrg2)); | |||
ProjectMeasuresQuery query1 = new ProjectMeasuresQuery().setOrganizationUuid(org1.getUuid()); | |||
@@ -1282,7 +1283,7 @@ public class ProjectMeasuresIndexTest { | |||
} | |||
private static ProjectMeasuresDoc newDoc() { | |||
return newDoc(newProjectDto(ORG)); | |||
return newDoc(ComponentTesting.newPrivateProjectDto(ORG)); | |||
} | |||
private static ProjectMeasuresDoc newDoc(ComponentDto project, String metric1, Object value1) { | |||
@@ -1302,15 +1303,15 @@ public class ProjectMeasuresIndexTest { | |||
} | |||
private static ProjectMeasuresDoc newDoc(String metric1, Object value1) { | |||
return newDoc(newProjectDto(ORG), metric1, value1); | |||
return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1); | |||
} | |||
private static ProjectMeasuresDoc newDoc(String metric1, Object value1, String metric2, Object value2) { | |||
return newDoc(newProjectDto(ORG), metric1, value1, metric2, value2); | |||
return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1, metric2, value2); | |||
} | |||
private static ProjectMeasuresDoc newDoc(String metric1, Object value1, String metric2, Object value2, String metric3, Object value3) { | |||
return newDoc(newProjectDto(ORG), metric1, value1, metric2, value2, metric3, value3); | |||
return newDoc(ComponentTesting.newPrivateProjectDto(ORG), metric1, value1, metric2, value2, metric3, value3); | |||
} | |||
private void assertResults(ProjectMeasuresQuery query, ComponentDto... expectedProjects) { |
@@ -28,6 +28,7 @@ import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ComponentDbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.SnapshotDto; | |||
import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.server.es.EsTester; | |||
@@ -41,7 +42,7 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery; | |||
import static org.mockito.Mockito.doNothing; | |||
import static org.mockito.Mockito.spy; | |||
import static org.mockito.Mockito.verify; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ANALYSED_AT; | |||
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_KEY; | |||
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NAME; | |||
@@ -81,9 +82,9 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void index_all_project() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
underTest.indexOnStartup(null); | |||
@@ -95,7 +96,7 @@ public class ProjectMeasuresIndexerTest { | |||
*/ | |||
@Test | |||
public void index_provisioned_projects() { | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
underTest.indexOnStartup(null); | |||
@@ -104,7 +105,7 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void indexProject_indexes_provisioned_project() { | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
underTest.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_CREATION); | |||
@@ -113,7 +114,7 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void indexProject_indexes_project_when_its_key_is_updated() { | |||
ComponentDto project = componentDbTester.insertProject(); | |||
ComponentDto project = componentDbTester.insertPrivateProject(); | |||
underTest.indexProject(project.uuid(), ProjectIndexer.Cause.PROJECT_KEY_UPDATE); | |||
@@ -123,9 +124,9 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void index_one_project() throws Exception { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project = newProjectDto(organizationDto); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
componentDbTester.insertProjectAndSnapshot(project); | |||
componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto)); | |||
componentDbTester.insertProjectAndSnapshot(ComponentTesting.newPrivateProjectDto(organizationDto)); | |||
underTest.indexProject(project.uuid(), ProjectIndexer.Cause.NEW_ANALYSIS); | |||
@@ -141,7 +142,7 @@ public class ProjectMeasuresIndexerTest { | |||
.setName("Old Name") | |||
.setTags(singletonList("old tag")) | |||
.setAnalysedAt(new Date(1_000_000L))); | |||
ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), uuid).setKey("New key").setName("New name").setTagsString("new tag"); | |||
ComponentDto project = newPrivateProjectDto(dbTester.getDefaultOrganization(), uuid).setKey("New key").setName("New name").setTagsString("new tag"); | |||
SnapshotDto analysis = componentDbTester.insertProjectAndSnapshot(project); | |||
underTest.indexProject(project.uuid(), ProjectIndexer.Cause.NEW_ANALYSIS); | |||
@@ -162,11 +163,11 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void delete_project() { | |||
OrganizationDto organizationDto = dbTester.organizations().insert(); | |||
ComponentDto project1 = newProjectDto(organizationDto); | |||
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
componentDbTester.insertProjectAndSnapshot(project1); | |||
ComponentDto project2 = newProjectDto(organizationDto); | |||
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
componentDbTester.insertProjectAndSnapshot(project2); | |||
ComponentDto project3 = newProjectDto(organizationDto); | |||
ComponentDto project3 = ComponentTesting.newPrivateProjectDto(organizationDto); | |||
componentDbTester.insertProjectAndSnapshot(project3); | |||
underTest.indexOnStartup(null); | |||
@@ -177,7 +178,7 @@ public class ProjectMeasuresIndexerTest { | |||
@Test | |||
public void does_nothing_when_deleting_unknown_project() throws Exception { | |||
ComponentDto project = newProjectDto(dbTester.organizations().insert()); | |||
ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()); | |||
componentDbTester.insertProjectAndSnapshot(project); | |||
underTest.indexOnStartup(null); | |||
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectCopy; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.db.measure.MeasureTesting.newMeasureDto; | |||
import static org.sonar.db.metric.MetricTesting.newMetricDto; | |||
@@ -93,7 +93,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void provided_project() { | |||
ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
ComponentDto project = componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
insertNclocMetric(); | |||
@@ -106,7 +106,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void without_additional_fields() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), "project-uuid")); | |||
insertNclocMetric(); | |||
String response = ws.newRequest() | |||
@@ -121,7 +121,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void reference_uuid_in_the_response() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key"); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key"); | |||
componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid"); | |||
componentDb.insertViewAndSnapshot(view); | |||
@@ -140,7 +140,7 @@ public class ComponentActionTest { | |||
expectedException.expect(NotFoundException.class); | |||
expectedException.expectMessage("Component id 'unknown-developer-id' not found"); | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
insertNclocMetric(); | |||
ws.newRequest() | |||
@@ -151,7 +151,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void fail_when_a_metric_is_not_found() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), PROJECT_UUID)); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID)); | |||
insertNclocMetric(); | |||
insertComplexityMetric(); | |||
@@ -163,7 +163,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void fail_when_empty_metric_keys_parameter() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID)); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("At least one metric key must be provided"); | |||
@@ -174,7 +174,7 @@ public class ComponentActionTest { | |||
@Test | |||
public void fail_when_not_enough_permission() { | |||
userSession.logIn(); | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), PROJECT_UUID)); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID)); | |||
insertNclocMetric(); | |||
expectedException.expect(ForbiddenException.class); | |||
@@ -243,7 +243,7 @@ public class ComponentActionTest { | |||
} | |||
private void insertJsonExampleData() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), PROJECT_UUID); | |||
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project) | |||
.setPeriodDate(parseDateTime("2016-01-11T10:49:50+0100").getTime()) | |||
.setPeriodMode("previous_version") |
@@ -60,7 +60,7 @@ import static org.sonar.api.measures.Metric.ValueType.RATING; | |||
import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
import static org.sonar.db.component.ComponentTesting.newDirectory; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.db.measure.MeasureTesting.newMeasureDto; | |||
import static org.sonar.server.measure.ws.ComponentTreeAction.LEAVES_STRATEGY; | |||
@@ -121,7 +121,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void empty_response() { | |||
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
ComponentTreeWsResponse response = ws.newRequest() | |||
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid") | |||
@@ -136,7 +136,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void load_measures_and_periods() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
componentDb.insertComponent(projectDto); | |||
SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession, | |||
newAnalysis(projectDto) | |||
@@ -172,7 +172,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void load_measures_with_best_value() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); | |||
userSession.anonymous().addProjectPermission(UserRole.USER, projectDto); | |||
ComponentDto directoryDto = newDirectory(projectDto, "directory-uuid", "path/to/directory").setName("directory-1"); | |||
@@ -216,7 +216,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void use_best_value_for_rating() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
userSession.anonymous().addProjectPermission(UserRole.USER, projectDto); | |||
componentDb.insertComponent(projectDto); | |||
SnapshotDto projectSnapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(projectDto) | |||
@@ -249,7 +249,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void load_measures_multi_sort_with_metric_key_and_paginated() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); | |||
ComponentDto file9 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-9").setName("file-1")); | |||
ComponentDto file8 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-8").setName("file-1")); | |||
@@ -292,7 +292,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void sort_by_metric_value() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); | |||
ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4")); | |||
ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3")); | |||
@@ -319,7 +319,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void remove_components_without_measure_on_the_metric_sort() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project); | |||
ComponentDto file1 = newFileDto(project, null, "file-uuid-1"); | |||
ComponentDto file2 = newFileDto(project, null, "file-uuid-2"); | |||
@@ -355,7 +355,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void sort_by_metric_period() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); | |||
ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3")); | |||
ComponentDto file1 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-1")); | |||
@@ -381,7 +381,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void remove_components_without_measure_on_the_metric_period_sort() { | |||
ComponentDto projectDto = newProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
ComponentDto projectDto = newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid"); | |||
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(projectDto); | |||
ComponentDto file4 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-4")); | |||
ComponentDto file3 = componentDb.insertComponent(newFileDto(projectDto, null, "file-uuid-3")); | |||
@@ -415,7 +415,7 @@ public class ComponentTreeActionTest { | |||
public void load_measures_when_no_leave_qualifier() { | |||
resourceTypes.setLeavesQualifiers(); | |||
String projectUuid = "project-uuid"; | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), projectUuid); | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), projectUuid); | |||
componentDb.insertProjectAndSnapshot(project); | |||
componentDb.insertComponent(newFileDto(project, null)); | |||
insertNclocMetric(); | |||
@@ -432,7 +432,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_metric_keys_parameter_is_empty() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("The 'metricKeys' parameter must contain at least one metric key"); | |||
@@ -445,7 +445,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_a_metric_is_not_found() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
insertNclocMetric(); | |||
insertNewViolationsMetric(); | |||
expectedException.expect(NotFoundException.class); | |||
@@ -458,7 +458,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_using_DISTRIB_metrics() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
dbClient.metricDao().insert(dbSession, newMetricDto().setKey("distrib1").setValueType(DISTRIB.name())); | |||
dbClient.metricDao().insert(dbSession, newMetricDto().setKey("distrib2").setValueType(DISTRIB.name())); | |||
db.commit(); | |||
@@ -474,7 +474,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_using_DATA_metrics() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
dbClient.metricDao().insert(dbSession, newMetricDto().setKey("data1").setValueType(DISTRIB.name())); | |||
dbClient.metricDao().insert(dbSession, newMetricDto().setKey("data2").setValueType(DISTRIB.name())); | |||
db.commit(); | |||
@@ -490,7 +490,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_setting_more_than_15_metric_keys() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
List<String> metrics = IntStream.range(0, 20) | |||
.mapToObj(i -> "metric" + i) | |||
.collect(MoreCollectors.toList()); | |||
@@ -507,7 +507,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_search_query_have_less_than_3_characters() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
insertNclocMetric(); | |||
insertNewViolationsMetric(); | |||
expectedException.expect(BadRequestException.class); | |||
@@ -523,7 +523,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_insufficient_privileges() { | |||
userSession.logIn(); | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
expectedException.expect(ForbiddenException.class); | |||
ws.newRequest() | |||
@@ -534,7 +534,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_sort_by_metric_and_no_metric_sort_provided() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException | |||
.expectMessage("To sort by a metric, the 's' parameter must contain 'metric' or 'metricPeriod', and a metric key must be provided in the 'metricSort' parameter"); | |||
@@ -549,7 +549,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_sort_by_metric_and_not_in_the_list_of_metric_keys() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("To sort by the 'complexity' metric, it must be in the list of metric keys in the 'metricKeys' parameter"); | |||
@@ -563,7 +563,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_sort_by_metric_period_and_no_metric_period_sort_provided() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("To sort by a metric period, the 's' parameter must contain 'metricPeriod' and the 'metricPeriodSort' must be provided."); | |||
@@ -578,7 +578,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_paging_parameter_is_too_big() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
insertNclocMetric(); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("The 'ps' parameter must be less than 500"); | |||
@@ -592,7 +592,7 @@ public class ComponentTreeActionTest { | |||
@Test | |||
public void fail_when_with_measures_only_and_no_metric_sort() { | |||
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
componentDb.insertProjectAndSnapshot(newPrivateProjectDto(db.getDefaultOrganization(), "project-uuid")); | |||
insertNclocMetric(); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException | |||
@@ -614,7 +614,7 @@ public class ComponentTreeActionTest { | |||
} | |||
private void insertJsonExampleData() { | |||
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-id") | |||
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization(), "project-id") | |||
.setKey("MY_PROJECT") | |||
.setName("My Project") | |||
.setQualifier(Qualifiers.PROJECT); |