use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_last_analysis_date.
@Test
public void return_last_analysis_date() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(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));
db.components().insertSnapshot(newAnalysis(project2).setCreatedAt(30_000_000_000L).setLast(true));
// No snapshot on project 3
insertProjectInDbAndEs(newProjectDto(organizationDto));
SearchProjectsWsResponse result = call(request.setAdditionalFields(singletonList("analysisDate")));
assertThat(result.getComponentsList()).extracting(Component::getAnalysisDate).containsOnly(formatDateTime(new Date(20_000_000_000L)), formatDateTime(new Date(30_000_000_000L)), "");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_text_query.
@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"));
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", "Sonar Qube");
assertThat(call(request.setFilter("query = \"sonar-java\"")).getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ShowActionTest method insertJsonExampleComponentsAndSnapshots.
private void insertJsonExampleComponentsAndSnapshots() {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
ComponentDto project = componentDb.insertComponent(newProjectDto(organizationDto, "AVIF98jgA3Ax6PH2efOW").setKey("com.sonarsource:java-markdown").setName("Java Markdown").setDescription("Java Markdown Project").setQualifier(Qualifiers.PROJECT).setTagsString("language, plugin"));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(project).setCreatedAt(parseDateTime("2017-03-01T11:39:03+0100").getTime()));
ComponentDto directory = newDirectory(project, "AVIF-FfgA3Ax6PH2efPF", "src/main/java/com/sonarsource/markdown/impl").setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl").setName("src/main/java/com/sonarsource/markdown/impl").setQualifier(Qualifiers.DIRECTORY);
componentDb.insertComponent(directory);
componentDb.insertComponent(newFileDto(directory, directory, "AVIF-FffA3Ax6PH2efPD").setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl/Rule.java").setName("Rule.java").setPath("src/main/java/com/sonarsource/markdown/impl/Rule.java").setLanguage("java").setQualifier(Qualifiers.FILE));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class TreeActionTest method return_children_of_a_view.
@Test
public void return_children_of_a_view() {
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");
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"));
db.commit();
logInWithBrowsePermission(view);
TreeWsResponse response = call(ws.newRequest().setParam(PARAM_STRATEGY, "children").setParam(PARAM_COMPONENT_ID, "view-uuid").setParam(Param.TEXT_QUERY, "name"));
assertThat(response.getComponentsList()).extracting("id").containsExactly("project-uuid-1-copy", "sub-view-uuid");
assertThat(response.getComponentsList()).extracting("refId").containsExactly("project-uuid-1", "");
assertThat(response.getComponentsList()).extracting("refKey").containsExactly("project-key-1", "");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ReportSubmitterTest method user_with_scan_permission_on_organization_is_allowed_to_submit_a_report_on_existing_project.
@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);
userSession.addPermission(SCAN, org);
mockSuccessfulPrepareSubmitCall();
underTest.submit(org.getKey(), project.getKey(), null, project.name(), IOUtils.toInputStream("{binary}"));
verify(queue).submit(any(CeTaskSubmit.class));
}
Aggregations