Skip to content

Commit be0c03e

Browse files
committed
Add more tests; now works for delegating and properties-based Creators (without annotations)
1 parent 01a2c0c commit be0c03e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/test/java/com/fasterxml/jackson/databind/introspect/CanonicalCreator4584Test.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
7676
List<PotentialCreator> declaredFactories)
7777
{
7878
if (valueClass.getRawType() != POJO4584.class) {
79-
System.err.println("findCanonicalCreator SKIPPED for: "+valueClass.getRawType());
8079
return null;
8180
}
82-
System.err.println("findCanonicalCreator DONE for: "+valueClass.getRawType());
8381
List<PotentialCreator> combo = new ArrayList<>(declaredConstructors);
8482
combo.addAll(declaredFactories);
8583
final int argCount = _argTypes.length;
@@ -92,13 +90,11 @@ public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
9290
}
9391
}
9492
if (i == argCount) {
95-
System.err.println("MATCH! "+ctor);
9693
ctor.overrideMode(_mode);
9794
return ctor;
9895
}
9996
}
10097
}
101-
System.err.println("No MATCH! ");
10298
return null;
10399
}
104100
}
@@ -109,16 +105,25 @@ public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
109105
/**********************************************************************
110106
*/
111107

112-
/*
113108
@Test
114-
public void testCanonicalConstructorPropertiesCreator() throws Exception
109+
public void testCanonicalConstructor1ArgPropertiesCreator() throws Exception
115110
{
116-
assertEquals(POJO4584.factoryString("List[0]"),
111+
// Instead of delegating, try denoting List-taking 1-arg one:
112+
assertEquals(POJO4584.factoryString("List[2]"),
117113
readerWith(new PrimaryCreatorFindingIntrospector(JsonCreator.Mode.PROPERTIES,
118114
List.class))
119-
.readValue(a2q("{'x':[ ]}")));
115+
.readValue(a2q("{'list':[ 1, 2]}")));
116+
}
117+
118+
@Test
119+
public void testCanonicalConstructor2ArgPropertiesCreator() throws Exception
120+
{
121+
// Mark the "true" canonical
122+
assertEquals(POJO4584.factoryString("abc"),
123+
readerWith(new PrimaryCreatorFindingIntrospector(JsonCreator.Mode.PROPERTIES,
124+
String.class, Integer.TYPE))
125+
.readValue(a2q("{'bogus':12, 'v':'abc' }")));
120126
}
121-
*/
122127

123128
/*
124129
/**********************************************************************

0 commit comments

Comments
 (0)