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);
}
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();
}
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());
}
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;
}
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);
}
Aggregations