DefaultInterceptorContext implements InterceptorContext { public JsonEnvelope inputEnvelope() { return input.getEnvelope().orElseThrow(() -> new IllegalStateException("No input envelope set.")); } DefaultInterceptorContext(final ContextPayload input, final ContextPayload output); InterceptorContext copyWithInput(final JsonEnvelope inputEnvelope); InterceptorContext copyWithOutput(final JsonEnvelope outputEnvelope); JsonEnvelope inputEnvelope(); Optional<JsonEnvelope> outputEnvelope(); Optional<Object> getInputParameter(final String name); void setInputParameter(final String name, final Object parameter); Optional<Object> getOutputParameter(final String name); void setOutputParameter(final String name, final Object parameter); ContextPayload inputContext(); ContextPayload outputContext(); @Override String getComponentName();  }
@Test(expected = IllegalStateException.class) public void shouldThrowExceptionIfInputNotSet() throws Exception { interceptorContextWithInput(null).inputEnvelope(); }