use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_quality_gate_error.
@Test
public void should_fail_if_quality_gate_error() {
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.ERROR);
doReturn(qualityGateResponse).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("QUALITY GATE STATUS: FAILED - View details on http://dashboard-url.com");
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_wait_and_then_pass_if_quality_gate_ok.
@Test
public void should_wait_and_then_pass_if_quality_gate_ok() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(10);
MockWsResponse pendingTask = getCeTaskWsResponse(TaskStatus.PENDING);
MockWsResponse successTask = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(pendingTask, successTask).when(wsClient).call(newGetCeTaskRequest());
MockWsResponse qualityGateResponse = getQualityGateWsResponse(Status.OK);
doReturn(qualityGateResponse).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
underTest.await();
assertThat(logTester.logs()).contains("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 QualityGateCheckTest method should_wait_and_then_fail_if_quality_gate_error.
@Test
public void should_wait_and_then_fail_if_quality_gate_error() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(10);
MockWsResponse pendingTask = getCeTaskWsResponse(TaskStatus.PENDING);
MockWsResponse successTask = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(pendingTask, successTask).when(wsClient).call(newGetCeTaskRequest());
MockWsResponse qualityGateResponse = getQualityGateWsResponse(Status.ERROR);
doReturn(qualityGateResponse).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("QUALITY GATE STATUS: FAILED - View details on http://dashboard-url.com");
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_cant_call_ws_for_quality_gate.
@Test
public void should_fail_if_cant_call_ws_for_quality_gate() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(ceTaskWsResponse).when(wsClient).call(newGetCeTaskRequest());
doThrow(new HttpException("quality-gate-url", 400, "content")).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("Failed to get Quality Gate status - HTTP code 400: content");
}
Aggregations