use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method getCeTaskWsResponse.
private MockWsResponse getCeTaskWsResponse(TaskStatus status) {
MockWsResponse submitMockResponse = new MockWsResponse();
submitMockResponse.setContent(Ce.TaskResponse.newBuilder().setTask(Ce.Task.newBuilder().setStatus(status)).build().toByteArray());
return submitMockResponse;
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method getQualityGateWsResponse.
private MockWsResponse getQualityGateWsResponse(Status status) {
MockWsResponse qualityGateWsResponse = new MockWsResponse();
qualityGateWsResponse.setContent(Qualitygates.ProjectStatusResponse.newBuilder().setProjectStatus(Qualitygates.ProjectStatusResponse.ProjectStatus.newBuilder().setStatus(status).build()).build().toByteArray());
return qualityGateWsResponse;
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_pass_if_quality_gate_ok.
@Test
public void should_pass_if_quality_gate_ok() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(ceTaskWsResponse).when(wsClient).call(newGetCeTaskRequest());
MockWsResponse qualityGateResponse = getQualityGateWsResponse(Status.OK);
doReturn(qualityGateResponse).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
underTest.await();
underTest.stop();
assertThat(logTester.logs()).containsOnly("Waiting for the analysis report to be processed (max 5s)", "QUALITY GATE STATUS: PASSED - View details on http://dashboard-url.com");
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class ReportPublisherTest method use_30s_write_timeout.
@Test
public void use_30s_write_timeout() {
MockWsResponse submitMockResponse = new MockWsResponse();
submitMockResponse.setContent(Ce.SubmitResponse.newBuilder().setTaskId("task-1234").build().toByteArray());
when(wsClient.call(any())).thenReturn(submitMockResponse);
underTest.start();
underTest.execute();
verify(wsClient).call(argThat(req -> req.getWriteTimeOutInMs().orElse(0) == 30_000));
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class ReportPublisherTest method should_upload_and_dump_information.
@Test
public void should_upload_and_dump_information() {
when(reportMetadataHolder.getDashboardUrl()).thenReturn("https://publicserver/sonarqube/dashboard?id=org.sonarsource.sonarqube%3Asonarqube");
when(reportMetadataHolder.getCeTaskUrl()).thenReturn("https://publicserver/sonarqube/api/ce/task?id=TASK-123");
MockWsResponse submitMockResponse = new MockWsResponse();
submitMockResponse.setContent(Ce.SubmitResponse.newBuilder().setTaskId("task-1234").build().toByteArray());
when(wsClient.call(any())).thenReturn(submitMockResponse);
underTest.start();
underTest.execute();
assertThat(properties.metadataFilePath()).exists();
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Report metadata written to " + properties.metadataFilePath());
assertThat(logTester.logs(LoggerLevel.INFO)).contains("ANALYSIS SUCCESSFUL, you can find the results at: https://publicserver/sonarqube/dashboard?id=org.sonarsource.sonarqube%3Asonarqube").contains("More about the report processing at https://publicserver/sonarqube/api/ce/task?id=TASK-123");
}
Aggregations