Search in sources :

Example 41 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class RequestContentValidationHandlerTest method doChannelRead_validates_with_validationGroups_if_validationGroups_is_not_null.

@Test
public void doChannelRead_validates_with_validationGroups_if_validationGroups_is_not_null() throws Exception {
    // given
    Class<?>[] validationGroups = new Class[] {};
    doReturn(validationGroups).when(endpointMock).validationGroups(any());
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msg);
    // then
    verify(requestValidatorMock).validateRequestContent(requestInfoMock, validationGroups);
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 42 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class RequestContentValidationHandlerTest method doChannelRead_does_nothing_if_msg_is_not_LastHttpContent.

@Test
public void doChannelRead_does_nothing_if_msg_is_not_LastHttpContent() throws Exception {
    // given
    HttpContent notLastContentMsg = mock(HttpContent.class);
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, notLastContentMsg);
    // then
    verifyNoInteractions(requestInfoMock);
    verifyNoInteractions(endpointMock);
    verifyNoInteractions(stateMock);
    verifyNoInteractions(requestValidatorMock);
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) LastHttpContent(io.netty.handler.codec.http.LastHttpContent) HttpContent(io.netty.handler.codec.http.HttpContent) Test(org.junit.Test)

Example 43 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class RequestContentValidationHandlerTest method doChannelRead_does_nothing_if_request_isCompleteRequestWithAllChunks_returns_false.

@Test
public void doChannelRead_does_nothing_if_request_isCompleteRequestWithAllChunks_returns_false() throws Exception {
    // given
    doReturn(false).when(requestInfoMock).isCompleteRequestWithAllChunks();
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msg);
    // then
    verifyNoMoreInteractions(requestValidatorMock);
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 44 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class DTraceEndHandlerTest method doExceptionCaught_calls_endDtrace_and_returns_CONTINUE.

@Test
public void doExceptionCaught_calls_endDtrace_and_returns_CONTINUE() throws Exception {
    // when
    PipelineContinuationBehavior result = handlerSpy.doExceptionCaught(ctxMock, null);
    // then
    verify(handlerSpy).endDtrace(ctxMock);
    assertThat(result, is(PipelineContinuationBehavior.CONTINUE));
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 45 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class ChannelPipelineFinalizerHandlerTest method doChannelInactive_completes_metrics_if_necessary_and_HttpProcessingState_is_not_null.

@DataProvider(value = { "true", "false" })
@Test
public void doChannelInactive_completes_metrics_if_necessary_and_HttpProcessingState_is_not_null(boolean stateIsNull) throws Exception {
    // given
    ChannelPipelineFinalizerHandler handlerSpy = spy(handler);
    if (stateIsNull) {
        doReturn(null).when(stateAttributeMock).get();
    }
    // when
    PipelineContinuationBehavior result = handlerSpy.doChannelInactive(ctxMock);
    // then
    if (stateIsNull) {
        verify(handlerSpy, never()).handleMetricsForCompletedRequestIfNotAlreadyDone(any(HttpProcessingState.class));
    } else {
        verify(handlerSpy).handleMetricsForCompletedRequestIfNotAlreadyDone(state);
    }
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Aggregations

PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)92 Test (org.junit.Test)90 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)26 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)11 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)9 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 RequestInfo (com.nike.riposte.server.http.RequestInfo)7 Span (com.nike.wingtips.Span)6 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)5 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)5 ErrorResponseBody (com.nike.riposte.server.error.handler.ErrorResponseBody)5 RequestAndResponseFilter (com.nike.riposte.server.http.filter.RequestAndResponseFilter)5 HttpRequest (io.netty.handler.codec.http.HttpRequest)5 Pair (com.nike.internal.util.Pair)4 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)4 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)4 ChannelFuture (io.netty.channel.ChannelFuture)4 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)4 InvalidRipostePipelineException (com.nike.riposte.server.error.exception.InvalidRipostePipelineException)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3