@Test public void wholeAttributes() { Message message = Message.builder().nullValue().attributes(new TypedValue<>(EMPTY_JSON, JSON_STRING)).build(); assertThat(message.getAttributes().getValue(), equalTo(EMPTY_JSON)); assertThat(message.getAttributes().getDataType().getType(), equalTo(String.class)); assertThat(message.getAttributes().getDataType().getMediaType(), is(APPLICATION_JSON)); }
@Test public void regularToString() { Message message = Message.builder() .payload(TypedValue.of("test")) .attributes(new TypedValue<>("{}", JSON_STRING)) .mediaType(TEXT) .build(); assertThat(message.toString(), is(equalToIgnoringLineBreaks("\n" + "org.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementation\n" + "{\n" + " payload=test\n" + " mediaType=text/plain\n" + " attributes={}\n" + " attributesMediaType=application/json\n" + "}"))); }
@Test public void wholeAttributes() { Message message = Message.builder().nullValue().attributes(new TypedValue<>(EMPTY_JSON, JSON_STRING)).build(); assertThat(message.getAttributes().getValue(), equalTo(EMPTY_JSON)); assertThat(message.getAttributes().getDataType().getType(), equalTo(String.class)); assertThat(message.getAttributes().getDataType().getMediaType(), is(APPLICATION_JSON)); }
@Override public void process(Object payload, Object attributes, Consumer<Result> onSuccess, BiConsumer<Throwable, Result> onError) { CoreEvent customEvent = CoreEvent.builder(originalEvent) .message(Message.builder() .payload(TypedValue.of(payload)) .attributes(TypedValue.of(attributes)) .build()) .build(); doProcess(customEvent, onSuccess, onError); }
@Override public void process(Object payload, Object attributes, Consumer<Result> onSuccess, BiConsumer<Throwable, Result> onError) { CoreEvent customEvent = CoreEvent.builder(originalEvent) .message(Message.builder() .payload(TypedValue.of(payload)) .attributes(TypedValue.of(attributes)) .build()) .build(); doProcess(customEvent, onSuccess, onError); }
@Override public TestLegacyMessageBuilder attributes(TypedValue<?> typedValue) { builder.attributes(typedValue); return this; }