Browse Source

SONAR-10134 Remove 'organization' parameter from project_status ws

tags/7.0-RC1
Julien Lancelot 6 years ago
parent
commit
bc027f57cd

+ 2
- 7
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java View File

@@ -37,7 +37,6 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.measure.LiveMeasureDto;
import org.sonar.db.measure.MeasureDto;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.component.ComponentFinder.ParamNames;
import org.sonar.server.exceptions.BadRequestException;
@@ -105,8 +104,6 @@ public class ProjectStatusAction implements QualityGatesWsAction {
.setSince("5.4")
.setDescription("Project key")
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);

wsSupport.createOrganizationParam(action);
}

@Override
@@ -121,15 +118,13 @@ public class ProjectStatusAction implements QualityGatesWsAction {
MSG_ONE_PARAMETER_ONLY);

try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = wsSupport.getOrganization(dbSession, request);
ProjectStatusResponse projectStatusResponse = doHandle(dbSession, organization, analysisId, projectId, projectKey);
ProjectStatusResponse projectStatusResponse = doHandle(dbSession, analysisId, projectId, projectKey);
writeProtobuf(projectStatusResponse, request, response);
}
}

private ProjectStatusResponse doHandle(DbSession dbSession, OrganizationDto organization, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
private ProjectStatusResponse doHandle(DbSession dbSession, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
ProjectAndSnapshot projectAndSnapshot = getProjectAndSnapshot(dbSession, analysisId, projectId, projectKey);
wsSupport.checkProjectBelongsToOrganization(organization, projectAndSnapshot.project);
checkPermission(projectAndSnapshot.project);
Optional<String> measureData = loadQualityGateDetails(dbSession, projectAndSnapshot, analysisId != null);


+ 1
- 31
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java View File

@@ -85,8 +85,7 @@ public class ProjectStatusActionTest {
.containsExactlyInAnyOrder(
tuple("analysisId", false),
tuple("projectKey", false),
tuple("projectId", false),
tuple("organization", false));
tuple("projectId", false));
}

@Test
@@ -107,7 +106,6 @@ public class ProjectStatusActionTest {

String response = ws.newRequest()
.setParam("analysisId", snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();

assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -139,7 +137,6 @@ public class ProjectStatusActionTest {

String response = ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, pastAnalysis.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();

assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -162,7 +159,6 @@ public class ProjectStatusActionTest {

String response = ws.newRequest()
.setParam(PARAM_PROJECT_ID, project.uuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();

assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -185,7 +181,6 @@ public class ProjectStatusActionTest {

String response = ws.newRequest()
.setParam(PARAM_PROJECT_KEY, project.getKey())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute().getInput();

assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -201,7 +196,6 @@ public class ProjectStatusActionTest {

ProjectStatusResponse result = ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);

assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
@@ -216,7 +210,6 @@ public class ProjectStatusActionTest {

ProjectStatusResponse result = ws.newRequest()
.setParam(PARAM_PROJECT_ID, project.uuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);

assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
@@ -233,7 +226,6 @@ public class ProjectStatusActionTest {

ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}

@@ -247,7 +239,6 @@ public class ProjectStatusActionTest {

ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}

@@ -264,24 +255,6 @@ public class ProjectStatusActionTest {
assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
}

@Test
public void fail_when_project_does_not_not_belong_to_organization() {
OrganizationDto organization = db.organizations().insert();
OrganizationDto otherOrganization = db.organizations().insert();
ComponentDto project = db.components().insertPrivateProject(otherOrganization);
SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
dbSession.commit();
userSession.addProjectPermission(UserRole.ADMIN, project);

expectedException.expect(NotFoundException.class);
expectedException.expectMessage(String.format("Project '%s' doesn't exist in organization '%s'", project.getKey(), organization.getKey()));

ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}

@Test
public void fail_if_no_snapshot_id_found() {
OrganizationDto organization = db.organizations().insert();
@@ -292,7 +265,6 @@ public class ProjectStatusActionTest {

ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, ANALYSIS_ID)
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}

@@ -308,7 +280,6 @@ public class ProjectStatusActionTest {

ws.newRequest()
.setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.executeProtobuf(ProjectStatusResponse.class);
}

@@ -370,7 +341,6 @@ public class ProjectStatusActionTest {

ws.newRequest()
.setParam("projectId", branch.uuid())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute();
}


+ 0
- 13
sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java View File

@@ -31,7 +31,6 @@ import javax.annotation.Generated;
public class ProjectStatusRequest {

private String analysisId;
private String organization;
private String projectId;
private String projectKey;

@@ -47,18 +46,6 @@ public class ProjectStatusRequest {
return analysisId;
}

/**
* Example value: "my-org"
*/
public ProjectStatusRequest setOrganization(String organization) {
this.organization = organization;
return this;
}

public String getOrganization() {
return organization;
}

/**
* Example value: "AU-Tpxb--iU5OvuD2FLy"
*/

+ 0
- 1
sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java View File

@@ -185,7 +185,6 @@ public class QualitygatesService extends BaseService {
return call(
new GetRequest(path("project_status"))
.setParam("analysisId", request.getAnalysisId())
.setParam("organization", request.getOrganization())
.setParam("projectId", request.getProjectId())
.setParam("projectKey", request.getProjectKey()),
ProjectStatusResponse.parser());

Loading…
Cancel
Save