use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_languages_facet.
@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"));
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_LANGUAGES)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_LANGUAGES.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getProperty()).isEqualTo(FILTER_LANGUAGES);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("xoo", 4L), tuple("java", 3L), tuple("<null>", 2L));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_languages.
@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"));
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
request.setFilter("languages IN (java, js, <null>)");
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Groovy", "Sonar Qube");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_nloc_facet.
@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)));
insertMetrics(COVERAGE, NCLOC);
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NCLOC)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NCLOC.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getProperty()).isEqualTo(NCLOC);
assertThat(facet.getValuesCount()).isEqualTo(5);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("*-1000.0", 2L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 1L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 1L));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_tags_facet_with_tags_having_no_project_if_tags_is_in_filter.
@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")));
SearchProjectsWsResponse result = call(request.setFilter("tags = marketing").setFacets(singletonList(FILTER_TAGS)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_TAGS.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("offshore", 2L), tuple("finance", 1L), tuple("platform", 1L), tuple("marketing", 0L));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method sort_by_quality_gate.
@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");
dbClient.metricDao().insert(dbSession, newMetricDto().setKey(QUALITY_GATE_STATUS).setValueType(LEVEL.name()).setEnabled(true).setHidden(false));
db.commit();
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(true)).getComponentsList()).extracting(Component::getName).containsExactly("Sonar Markdown", "Sonar Qube", "Sonar Groovy", "Sonar Java");
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(false)).getComponentsList()).extracting(Component::getName).containsExactly("Sonar Java", "Sonar Groovy", "Sonar Markdown", "Sonar Qube");
}
Aggregations