Add tests for various scenarios of message conversion

This commit is contained in:
Dave Syer
2018-02-16 10:31:22 +00:00
parent 1b624c3531
commit 8cd2675986
3 changed files with 129 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.cloud.function.context.message;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.springframework.cloud.function.core.FluxWrapper;
@@ -49,6 +50,11 @@ public abstract class MessageUtils {
if (handler instanceof FluxWrapper) {
handler = ((FluxWrapper<?>) handler).getTarget();
}
if (payload instanceof Message) {
headers = new HashMap<>(headers);
headers.putAll(((Message<?>) payload).getHeaders());
payload = ((Message<?>) payload).getPayload();
}
if (!(handler instanceof Isolated)) {
return MessageBuilder.withPayload(payload).copyHeaders(headers).build();
}