|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.jayway.jsonpath; |
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator; |
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode; |
|
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory; |
|
|
|
@ -9,6 +11,7 @@ import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
|
import static com.jayway.jsonpath.JsonPath.using; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
@ -111,6 +114,14 @@ public class JacksonJsonNodeJsonProviderTest extends BaseTest {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
// https://github.com/json-path/JsonPath/issues/364
|
|
|
|
|
public void setPropertyWithPOJO() { |
|
|
|
|
DocumentContext context = JsonPath.using(JACKSON_JSON_NODE_CONFIGURATION).parse("{}"); |
|
|
|
|
UUID uuid = UUID.randomUUID(); |
|
|
|
|
context.put("$", "data", new Data(uuid)); |
|
|
|
|
String id = context.read("$.data.id", String.class); |
|
|
|
|
assertThat(id).isEqualTo(uuid.toString()); |
|
|
|
|
} |
|
|
|
|
// https://github.com/json-path/JsonPath/issues/366
|
|
|
|
|
public void empty_array_check_works() throws IOException { |
|
|
|
|
String json = "[" + |
|
|
|
@ -151,4 +162,14 @@ public class JacksonJsonNodeJsonProviderTest extends BaseTest {
|
|
|
|
|
public String eric; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static final class Data { |
|
|
|
|
@JsonProperty("id") |
|
|
|
|
UUID id; |
|
|
|
|
|
|
|
|
|
@JsonCreator |
|
|
|
|
Data(@JsonProperty("id") final UUID id) { |
|
|
|
|
this.id = id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|