Search in sources :

Example 11 with ComponentLinkDto

use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.

the class CreateActionTest method createAndTest.

private void createAndTest(ComponentDto project, String name, String url, String type) throws IOException {
    InputStream responseStream = ws.newRequest().setMethod("POST").setParam(PARAM_PROJECT_KEY, project.key()).setParam(PARAM_NAME, name).setParam(PARAM_URL, url).setMediaType(PROTOBUF).execute().getInputStream();
    WsProjectLinks.CreateWsResponse response = WsProjectLinks.CreateWsResponse.parseFrom(responseStream);
    long newId = Long.valueOf(response.getLink().getId());
    ComponentLinkDto link = dbClient.componentLinkDao().selectById(dbSession, newId);
    assertThat(link.getName()).isEqualTo(name);
    assertThat(link.getHref()).isEqualTo(url);
    assertThat(link.getType()).isEqualTo(type);
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) InputStream(java.io.InputStream) WsProjectLinks(org.sonarqube.ws.WsProjectLinks)

Example 12 with ComponentLinkDto

use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.

the class DeleteActionTest method no_response.

@Test
public void no_response() {
    ComponentDto project = insertProject();
    ComponentLinkDto link = insertCustomLink(project.uuid());
    logInAsProjectAdministrator(project);
    TestResponse response = deleteLink(link.getId());
    assertThat(response.getStatus()).isEqualTo(204);
    assertThat(response.getInput()).isEmpty();
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) TestResponse(org.sonar.server.ws.TestResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 13 with ComponentLinkDto

use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.

the class DeleteActionTest method fail_if_not_project_admin.

@Test
public void fail_if_not_project_admin() {
    userSession.logIn();
    ComponentDto project = insertProject();
    ComponentLinkDto link = insertCustomLink(project.uuid());
    expectedException.expect(ForbiddenException.class);
    deleteLink(link.getId());
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 14 with ComponentLinkDto

use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.

the class DeleteActionTest method insertCustomLink.

private ComponentLinkDto insertCustomLink(String projectUuid) {
    ComponentLinkDto link = new ComponentLinkDto().setComponentUuid(projectUuid).setName("Custom").setHref("http://example.org/custom");
    insertLink(link);
    return link;
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto)

Example 15 with ComponentLinkDto

use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.

the class DeleteActionTest method actual_removal.

@Test
public void actual_removal() {
    ComponentDto project = insertProject();
    ComponentLinkDto link = insertCustomLink(project.uuid());
    long id = link.getId();
    logInAsProjectAdministrator(project);
    deleteLink(id);
    assertLinkIsDeleted(id);
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)20 ComponentDto (org.sonar.db.component.ComponentDto)14 Test (org.junit.Test)11 DbSession (org.sonar.db.DbSession)3 SnapshotDto (org.sonar.db.component.SnapshotDto)2 SearchWsResponse (org.sonarqube.ws.WsProjectLinks.SearchWsResponse)2 InputStream (java.io.InputStream)1 MeasureDto (org.sonar.db.measure.MeasureDto)1 MeasureQuery (org.sonar.db.measure.MeasureQuery)1 MetricDto (org.sonar.db.metric.MetricDto)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 TestResponse (org.sonar.server.ws.TestResponse)1 WsProjectLinks (org.sonarqube.ws.WsProjectLinks)1