use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_visibility_flag.
@Test
public void return_visibility_flag() {
userSession.logIn();
ComponentDto privateProject = db.components().insertPublicProject();
authorizationIndexerTester.allowOnlyAnyone(privateProject);
ComponentDto publicProject = db.components().insertPrivateProject();
authorizationIndexerTester.allowOnlyAnyone(publicProject);
index();
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getVisibility).containsExactly(tuple(privateProject.getDbKey(), privateProject.isPrivate() ? "private" : "public"), tuple(publicProject.getDbKey(), publicProject.isPrivate() ? "private" : "public"));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_last_analysis_date.
@Test
public void return_last_analysis_date() {
userSession.logIn();
ComponentDto project1 = db.components().insertPublicProject();
db.components().insertSnapshot(project1, snapshot -> snapshot.setCreatedAt(10_000_000_000L).setLast(false));
db.components().insertSnapshot(project1, snapshot -> snapshot.setCreatedAt(20_000_000_000L).setLast(true));
authorizationIndexerTester.allowOnlyAnyone(project1);
ComponentDto project2 = db.components().insertPublicProject();
db.components().insertSnapshot(project2, snapshot -> snapshot.setCreatedAt(30_000_000_000L).setLast(true));
authorizationIndexerTester.allowOnlyAnyone(project2);
// No snapshot on project 3
ComponentDto project3 = db.components().insertPublicProject();
authorizationIndexerTester.allowOnlyAnyone(project3);
index();
SearchProjectsWsResponse result = call(request.setAdditionalFields(singletonList("analysisDate")));
assertThat(result.getComponentsList()).extracting(Component::getKey, Component::hasAnalysisDate, Component::getAnalysisDate).containsOnly(tuple(project1.getDbKey(), true, formatDateTime(new Date(20_000_000_000L))), tuple(project2.getDbKey(), true, formatDateTime(new Date(30_000_000_000L))), tuple(project3.getDbKey(), false, ""));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method do_not_return_isFavorite_if_anonymous_user.
@Test
public void do_not_return_isFavorite_if_anonymous_user() {
userSession.anonymous();
insertProject();
index();
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsList()).extracting(Component::hasIsFavorite).containsExactlyInAnyOrder(false);
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_new_duplications_facet.
@Test
public void return_new_duplications_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(NEW_DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
insertProject();
insertProject(new Measure(coverage, c -> c.setVariation(10d)));
insertProject(new Measure(coverage, c -> c.setVariation(15d)));
insertProject(new Measure(coverage, c -> c.setVariation(5d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NEW_DUPLICATED_LINES_DENSITY_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NEW_DUPLICATED_LINES_DENSITY_KEY.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("NO_DATA", 1L), tuple("*-3.0", 0L), tuple("3.0-5.0", 0L), tuple("5.0-10.0", 1L), tuple("10.0-20.0", 2L), tuple("20.0-*", 0L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_tags_facet.
@Test
public void return_tags_facet() {
userSession.logIn();
insertProject(defaults(), p -> p.setTags(asList("finance", "platform")));
insertProject(defaults(), p -> p.setTags(singletonList("offshore")));
insertProject(defaults(), p -> p.setTags(singletonList("offshore")));
index();
SearchProjectsWsResponse result = call(request.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));
}
Aggregations