use of com.tngtech.java.junit.dataprovider.DataProvider in project riposte by Nike-Inc.
the class RequestFilterHandlerTest method handleFilterLogic_executes_all_filters_and_uses_original_request_when_filters_are_mixed_type_and_return_null.
@DataProvider(value = { "true", "false" }, splitBy = "\\|")
@Test
public void handleFilterLogic_executes_all_filters_and_uses_original_request_when_filters_are_mixed_type_and_return_null(boolean isFirstChunk) {
// given
HandleFilterLogicMethodCallArgs args = new HandleFilterLogicMethodCallArgs(isFirstChunk);
doReturn(true).when(filtersList.get(0)).isShortCircuitRequestFilter();
doReturn(false).when(filtersList.get(1)).isShortCircuitRequestFilter();
// when
PipelineContinuationBehavior result = handlerSpy.handleFilterLogic(ctxMock, args.msg, args.normalFilterCall, args.shortCircuitFilterCall);
// then
assertThat(result).isEqualTo(CONTINUE);
filtersList.forEach(filter -> {
boolean shortCircuiting = filter.isShortCircuitRequestFilter();
if (isFirstChunk) {
if (shortCircuiting)
verify(filter).filterRequestFirstChunkWithOptionalShortCircuitResponse(requestInfoMock, ctxMock);
else
verify(filter).filterRequestFirstChunkNoPayload(requestInfoMock, ctxMock);
} else {
if (shortCircuiting)
verify(filter).filterRequestLastChunkWithOptionalShortCircuitResponse(requestInfoMock, ctxMock);
else
verify(filter).filterRequestLastChunkWithFullPayload(requestInfoMock, ctxMock);
}
});
assertThat(state.getRequestInfo()).isSameAs(requestInfoMock);
}
use of com.tngtech.java.junit.dataprovider.DataProvider in project riposte by Nike-Inc.
the class HttpServletResponseWrapperForResponseInfoTest method getContentType_delegates_to_responseInfo.
@DataProvider(value = { "null | null | null", "text/plain | null | text/plain", "text/plain | ISO-8859-1 | text/plain; charset=ISO-8859-1", "application/json | UTF-8 | application/json; charset=UTF-8" }, splitBy = "\\|")
@Test
public void getContentType_delegates_to_responseInfo(String contentWriterMimeType, String contentWriterEncodingName, String expectedResult) {
// given
doReturn(contentWriterMimeType).when(responseInfoMock).getDesiredContentWriterMimeType();
Charset contentWriterEncoding = (contentWriterEncodingName == null) ? null : Charset.forName(contentWriterEncodingName);
doReturn(contentWriterEncoding).when(responseInfoMock).getDesiredContentWriterEncoding();
// when
String result = wrapper.getContentType();
// expect
assertThat(result).isEqualTo(expectedResult);
}
Aggregations