Search in sources :

Example 6 with ListWsResponse

use of org.sonarqube.ws.ProjectBranches.ListWsResponse in project sonarqube by SonarSource.

the class ListActionTest method test_project_with_branches.

@Test
public void test_project_with_branches() {
    ComponentDto project = db.components().insertPrivateProject();
    db.components().insertProjectBranch(project, b -> b.setKey("feature/bar"));
    db.components().insertProjectBranch(project, b -> b.setKey("feature/foo"));
    userSession.logIn().addProjectPermission(USER, project);
    ListWsResponse response = ws.newRequest().setParam("project", project.getDbKey()).executeProtobuf(ListWsResponse.class);
    assertThat(response.getBranchesList()).extracting(Branch::getName, Branch::getType).containsExactlyInAnyOrder(tuple("master", BranchType.BRANCH), tuple("feature/foo", BranchType.BRANCH), tuple("feature/bar", BranchType.BRANCH));
}
Also used : ListWsResponse(org.sonarqube.ws.ProjectBranches.ListWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ComponentDto (org.sonar.db.component.ComponentDto)6 ListWsResponse (org.sonarqube.ws.ProjectBranches.ListWsResponse)6 String.format (java.lang.String.format)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)2 Assertions.tuple (org.assertj.core.api.Assertions.tuple)2 Before (org.junit.Before)2 Rule (org.junit.Rule)2 Mockito.mock (org.mockito.Mockito.mock)2 ALERT_STATUS_KEY (org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY)2 PROJECT (org.sonar.api.resources.Qualifiers.PROJECT)2 ResourceTypes (org.sonar.api.resources.ResourceTypes)2 BUG (org.sonar.api.rules.RuleType.BUG)2 WebService (org.sonar.api.server.ws.WebService)2 DateUtils.dateToLong (org.sonar.api.utils.DateUtils.dateToLong)2 DateUtils.parseDateTime (org.sonar.api.utils.DateUtils.parseDateTime)2 System2 (org.sonar.api.utils.System2)2 USER (org.sonar.api.web.UserRole.USER)2 SCAN_EXECUTION (org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION)2