use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method fail_to_update_condition_on_invalid_metric.
@Test
@UseDataProvider("invalid_metrics")
public void fail_to_update_condition_on_invalid_metric(String metricKey, Metric.ValueType valueType, boolean hidden) {
MetricDto metricDto = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(metricKey).setValueType(valueType.name()).setHidden(hidden));
QualityGateConditionDto condition = insertCondition(metricDto.getId(), "LT", null, "80", null);
dbSession.commit();
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Metric '" + metricKey + "' cannot be used to define a condition.");
underTest.updateCondition(dbSession, condition.getId(), metricDto.getKey(), "GT", "60", null, 1);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project riposte by Nike-Inc.
the class ExceptionHandlingHandlerTest method doExceptionCaught_should_setForceConnectionCloseAfterResponseSent_to_true_on_request_when_exception_matches_certain_types.
@UseDataProvider("exceptionsThatShouldForceCloseConnection")
@Test
public void doExceptionCaught_should_setForceConnectionCloseAfterResponseSent_to_true_on_request_when_exception_matches_certain_types(Throwable exThatShouldForceCloseConnection) throws Exception {
// given
ExceptionHandlingHandler handlerSpy = spy(handler);
ResponseInfo<ErrorResponseBody> errorResponseMock = mock(ResponseInfo.class);
doReturn(errorResponseMock).when(handlerSpy).processError(state, null, exThatShouldForceCloseConnection);
assertThat(state.getResponseInfo(), nullValue());
// when
PipelineContinuationBehavior result = handlerSpy.doExceptionCaught(ctxMock, exThatShouldForceCloseConnection);
// then
verify(errorResponseMock).setForceConnectionCloseAfterResponseSent(true);
verify(handlerSpy).getStateAndCreateIfNeeded(ctxMock, exThatShouldForceCloseConnection);
verify(handlerSpy).processError(state, null, exThatShouldForceCloseConnection);
assertThat(state.getResponseInfo(), is(errorResponseMock));
assertThat(result, is(PipelineContinuationBehavior.CONTINUE));
}
Aggregations