String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH);
String projectName = StringUtils.defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey);
- CeTask task;
- try (InputStream report = new BufferedInputStream(wsRequest.paramAsInputStream(PARAM_REPORT_DATA))) {
- task = reportSubmitter.submit(organizationKey, projectKey, projectBranch, projectName, report);
+ try (InputStream report = new BufferedInputStream(wsRequest.mandatoryParamAsPart(PARAM_REPORT_DATA).getInputStream())) {
+ CeTask task = reportSubmitter.submit(organizationKey, projectKey, projectBranch, projectName, report);
+ WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder()
+ .setTaskId(task.getUuid())
+ .setProjectId(task.getComponentUuid())
+ .build();
+ WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
}
-
- WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder()
- .setTaskId(task.getUuid())
- .setProjectId(task.getComponentUuid())
- .build();
- WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
}
}
*/
package org.sonar.server.ce.ws;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.junit.Test;
import org.mockito.Matchers;
WsCe.SubmitResponse submitResponse = tester.newRequest()
.setParam("projectKey", "my_project")
.setParam("projectName", "My Project")
- .setParam("report", "{binary}")
+ .setPart("report", new ByteArrayInputStream("{binary}".getBytes()), "foo.bar")
.setMethod("POST")
.executeProtobuf(WsCe.SubmitResponse.class);
TestResponse wsResponse = tester.newRequest()
.setParam("projectKey", "my_project")
.setParam("projectName", "My Project")
- .setParam("report", "{binary}")
+ .setPart("report", new ByteArrayInputStream("{binary}".getBytes()), "foo.bar")
.setMediaType(MediaTypes.JSON)
.setMethod("POST")
.execute();
tester.newRequest()
.setParam("projectKey", "my_project")
- .setParam("report", "{binary}")
+ .setPart("report", new ByteArrayInputStream("{binary}".getBytes()), "foo.bar")
.setMediaType(MediaTypes.PROTOBUF)
.setMethod("POST")
.execute();