@@ -179,7 +179,6 @@ public final class AWSLambdaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resultPayload != null) {
|
if (resultPayload != null) {
|
||||||
System.out.println(new String(resultPayload));
|
|
||||||
MessageBuilder<byte[]> messageBuilder = MessageBuilder.withPayload(resultPayload);
|
MessageBuilder<byte[]> messageBuilder = MessageBuilder.withPayload(resultPayload);
|
||||||
if (lastMessage != null) {
|
if (lastMessage != null) {
|
||||||
messageBuilder.copyHeaders(lastMessage.getHeaders());
|
messageBuilder.copyHeaders(lastMessage.getHeaders());
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public abstract class JsonMapper {
|
|||||||
|
|
||||||
public static boolean isJsonStringRepresentsCollection(Object value) {
|
public static boolean isJsonStringRepresentsCollection(Object value) {
|
||||||
boolean isJson = false;
|
boolean isJson = false;
|
||||||
if (value instanceof Iterable && !value.getClass().getPackage().getName().startsWith("reactor.util.function")) {
|
if (value instanceof Collection && !value.getClass().getPackage().getName().startsWith("reactor.util.function")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (value instanceof byte[]) {
|
if (value instanceof byte[]) {
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
@@ -42,6 +45,28 @@ public class JsonMapperTests {
|
|||||||
return Stream.of(new GsonMapper(new Gson()), new JacksonMapper(new ObjectMapper()));
|
return Stream.of(new GsonMapper(new Gson()), new JacksonMapper(new ObjectMapper()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void objectNode_isJsonStringRepresentsCollection() {
|
||||||
|
ObjectNode node = JsonNodeFactory.instance.objectNode();
|
||||||
|
node.put("id", "1234ab");
|
||||||
|
node.put("foo", "bar");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passing the ObjectNode directly results in a positive identification as
|
||||||
|
* a collection, as its distant parent JsonNode implements Iterable.
|
||||||
|
*/
|
||||||
|
assertThat(JsonMapper.isJsonStringRepresentsCollection(node)).isFalse();
|
||||||
|
|
||||||
|
String nodeAsString = node.toString();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sending the node as a string returns false, however, as the line
|
||||||
|
* isJsonString(value) && str.startsWith("[") && str.endsWith("]")
|
||||||
|
* will not be true.
|
||||||
|
*/
|
||||||
|
assertThat(JsonMapper.isJsonStringRepresentsCollection(nodeAsString)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("params")
|
@MethodSource("params")
|
||||||
public void vanillaArray(JsonMapper mapper) {
|
public void vanillaArray(JsonMapper mapper) {
|
||||||
|
|||||||
Reference in New Issue
Block a user