use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_quality_gate_timeout_exceeded.
@Test
public void should_fail_if_quality_gate_timeout_exceeded() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(1);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(TaskStatus.PENDING);
doReturn(ceTaskWsResponse).when(wsClient).call(newGetCeTaskRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("Quality Gate check timeout exceeded - 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_invalid_response_from_ws_task.
@Test
public void should_fail_if_invalid_response_from_ws_task() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse getCeTaskRequest = new MockWsResponse();
getCeTaskRequest.setRequestUrl("ce-task-url");
getCeTaskRequest.setContent("blabla");
when(wsClient.call(newGetCeTaskRequest())).thenReturn(getCeTaskRequest);
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(IllegalStateException.class).hasMessage("Failed to parse response from ce-task-url");
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_invalid_response_from_quality_gate_ws.
@Test
public void should_fail_if_invalid_response_from_quality_gate_ws() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(ceTaskWsResponse).when(wsClient).call(newGetCeTaskRequest());
MockWsResponse qualityGateResponse = new MockWsResponse();
qualityGateResponse.setRequestUrl("quality-gate-url");
qualityGateResponse.setContent("blabla");
doReturn(qualityGateResponse).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(IllegalStateException.class).hasMessage("Failed to parse response from quality-gate-url");
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_task_not_succeeded.
@Test
@UseDataProvider("ceTaskNotSucceededStatuses")
public void should_fail_if_task_not_succeeded(TaskStatus taskStatus) {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(taskStatus);
when(wsClient.call(newGetCeTaskRequest())).thenReturn(ceTaskWsResponse);
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessageContaining("CE Task finished abnormally with status: " + taskStatus.name());
}
use of org.sonarqube.ws.client.MockWsResponse in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_quality_gate_none.
@Test
public void should_fail_if_quality_gate_none() {
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");
}
Aggregations