Search in sources :

Example 71 with PipelineContinuationBehavior

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

the class RequestContentValidationHandlerTest method doChannelRead_validates_without_validationGroups_if_validationGroups_is_null.

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

Example 72 with PipelineContinuationBehavior

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

the class RequestContentValidationHandlerTest method doChannelRead_does_not_call_request_getContent_method_if_endpoint_is_null.

@Test
public void doChannelRead_does_not_call_request_getContent_method_if_endpoint_is_null() throws Exception {
    // given
    doReturn(null).when(stateMock).getEndpointForExecution();
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msg);
    // then
    verify(requestInfoMock, never()).getContent();
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 73 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_isContentDeserializerSetup_returns_false.

@Test
public void doChannelRead_does_nothing_if_request_isContentDeserializerSetup_returns_false() throws Exception {
    // given
    doReturn(false).when(requestInfoMock).isContentDeserializerSetup();
    // 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 74 with PipelineContinuationBehavior

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

the class RequestContentValidationHandlerTest method doChannelRead_does_not_call_request_getContent_method_if_endpoint_does_not_want_validation.

@Test
public void doChannelRead_does_not_call_request_getContent_method_if_endpoint_does_not_want_validation() throws Exception {
    // given
    doReturn(false).when(endpointMock).isValidateRequestContent(any());
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msg);
    // then
    verify(requestInfoMock, never()).getContent();
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 75 with PipelineContinuationBehavior

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

the class RequestContentValidationHandlerTest method doChannelRead_delegates_to_async_processing_when_requested_by_endpoint.

@Test
public void doChannelRead_delegates_to_async_processing_when_requested_by_endpoint() throws Exception {
    // given
    doReturn(true).when(endpointMock).shouldValidateAsynchronously(requestInfoMock);
    // when
    PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msg);
    // then
    verify(stateMock).addPreEndpointExecutionWorkChainSegment(any(Function.class));
    verifyZeroInteractions(requestValidatorMock);
    assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Function(java.util.function.Function) Test(org.junit.Test)

Aggregations

PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)75 Test (org.junit.Test)73 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)20 RequestInfo (com.nike.riposte.server.http.RequestInfo)5 Span (com.nike.wingtips.Span)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)4 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)4 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)4 RequestAndResponseFilter (com.nike.riposte.server.http.filter.RequestAndResponseFilter)4 ChannelFuture (io.netty.channel.ChannelFuture)4 HttpObject (io.netty.handler.codec.http.HttpObject)4 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)4 Pair (com.nike.internal.util.Pair)3 HttpContent (io.netty.handler.codec.http.HttpContent)3 ChannelAttributes (com.nike.riposte.server.channelpipeline.ChannelAttributes)2 OutboundMessage (com.nike.riposte.server.channelpipeline.message.OutboundMessage)2 OutboundMessageSendHeadersChunkFromResponseInfo (com.nike.riposte.server.channelpipeline.message.OutboundMessageSendHeadersChunkFromResponseInfo)2 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)2 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)2