@Override
    public Message buildMessageContent(
            final TestContext context,
            final String messageType,
            final MessageDirection direction) {
        final Object payload = buildMessagePayload(context, messageType);

        try {
            Message message = new DefaultMessage(payload, buildMessageHeaders(context, messageType));
            message.setName(messageName);

            if (payload != null) {
                for (final MessageConstructionInterceptor interceptor: context.getGlobalMessageConstructionInterceptors().getMessageConstructionInterceptors()) {
                    if (direction.equals(MessageDirection.UNBOUND)
                            || interceptor.getDirection().equals(MessageDirection.UNBOUND)
                            || direction.equals(interceptor.getDirection())) {
                        message = interceptor.interceptMessageConstruction(message, messageType, context);
                    }
                }

                if (dataDictionary != null) {
                    message = dataDictionary.interceptMessageConstruction(message, messageType, context);
                }

                for (final MessageConstructionInterceptor interceptor : messageInterceptors) {
                    if (direction.equals(MessageDirection.UNBOUND)
                            || interceptor.getDirection().equals(MessageDirection.UNBOUND)
                            || direction.equals(interceptor.getDirection())) {
                        message = interceptor.interceptMessageConstruction(message, messageType, context);
                    }
                }
            }

            message.getHeaderData().addAll(buildMessageHeaderData(context));

            return message;
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            throw new CitrusRuntimeException("Failed to build message content", e);
        }

    }
@ Override public Message buildMessageContent ( final TestContext context , final String messageType , final MessageDirection direction ) { final Object payload = buildMessagePayload ( context , messageType ) ; try { Message message = new DefaultMessage ( payload , buildMessageHeaders ( context , messageType ) ) ; message . setName ( messageName ) ; if ( payload != null ) { for ( final MessageConstructionInterceptor interceptor : context . getGlobalMessageConstructionInterceptors ( ) . getMessageConstructionInterceptors ( ) ) { if ( direction . equals ( MessageDirection . UNBOUND ) || interceptor . getDirection ( ) . equals ( MessageDirection . UNBOUND ) || direction . equals ( interceptor . getDirection ( ) ) ) { message = interceptor . interceptMessageConstruction ( message , messageType , context ) ; } } if ( dataDictionary != null ) { message = dataDictionary . interceptMessageConstruction ( message , messageType , context ) ; } for ( final MessageConstructionInterceptor interceptor : messageInterceptors ) { if ( direction . equals ( MessageDirection . UNBOUND ) || interceptor . getDirection ( ) . equals ( MessageDirection . UNBOUND ) || direction . equals ( interceptor . getDirection ( ) ) ) { message = interceptor . interceptMessageConstruction ( message , messageType , context ) ; } } } message . getHeaderData ( ) . addAll ( buildMessageHeaderData ( context ) ) ; return message ; } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { throw new CitrusRuntimeException ( "Failed to build message content" , e ) ; } }
Constructs the control message with headers and payload coming from
subclass implementation.