From 71ac7c3a4d7f4597ba49bf4e3efc1ab5ef9c5759 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 19 Sep 2024 09:40:47 -0700 Subject: [PATCH] Remove dup test for #639 --- .../tofix/ObjectIdWithInjectables639Test.java | 93 ------------------- 1 file changed, 93 deletions(-) delete mode 100644 src/test/java/com/fasterxml/jackson/databind/tofix/ObjectIdWithInjectables639Test.java diff --git a/src/test/java/com/fasterxml/jackson/databind/tofix/ObjectIdWithInjectables639Test.java b/src/test/java/com/fasterxml/jackson/databind/tofix/ObjectIdWithInjectables639Test.java deleted file mode 100644 index 46453617d0..0000000000 --- a/src/test/java/com/fasterxml/jackson/databind/tofix/ObjectIdWithInjectables639Test.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.fasterxml.jackson.databind.tofix; - -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.annotation.*; - -import com.fasterxml.jackson.databind.InjectableValues; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; -import com.fasterxml.jackson.databind.testutil.failure.JacksonTestFailureExpected; - -// This is probably impossible to handle, in general case, since -// there is a cycle for Parent2/Child2... unless special handling -// could be made to ensure that -class ObjectIdWithInjectables639Test extends DatabindTestUtil { - public static final class Context { - } - - @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) - public static final class Parent1 { - public Child1 child; - - public Parent1() { - } - } - - @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) - public static final class Child1 { - - @JsonProperty - private final Parent1 parent; - - @JsonCreator - public Child1(@JsonProperty("parent") Parent1 parent) { - this.parent = parent; - } - } - - @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) - public static final class Parent2 { - - protected final Context context; - - public Child2 child; - - @JsonCreator - public Parent2(@JacksonInject Context context) { - this.context = context; - } - } - - @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) - public static final class Child2 { - - protected final Context context; - - @JsonProperty - protected Parent2 parent; - - @JsonCreator - public Child2(@JacksonInject Context context, - @JsonProperty("parent") Parent2 parent) { - this.context = context; - this.parent = parent; - } - } - - @JacksonTestFailureExpected - @Test - void objectIdWithInjectables() throws Exception { - ObjectMapper mapper = new ObjectMapper(); - Context context = new Context(); - InjectableValues iv = new InjectableValues.Std(). - addValue(Context.class, context); - mapper.setInjectableValues(iv); - - Parent1 parent1 = new Parent1(); - Child1 child1 = new Child1(parent1); - parent1.child = child1; - - Parent2 parent2 = new Parent2(context); - Child2 child2 = new Child2(context, parent2); - parent2.child = child2; - - String json = mapper.writeValueAsString(parent1); - parent1 = mapper.readValue(json, Parent1.class); -// System.out.println("This works: " + json); - - json = mapper.writeValueAsString(parent2); -//System.out.println("This fails: " + json); - parent2 = mapper.readValue(json, Parent2.class); - } -}