Skip to content

Commit 0469ab7

Browse files
committed
Add a test for #4595
1 parent 5a7704b commit 0469ab7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ public String findTypeName(AnnotatedClass ac) {
207207
return (String) values.get("findTypeName");
208208
}
209209

210+
/*
211+
/******************************************************
212+
/* General member (field, method/constructor) annotations
213+
/******************************************************
214+
*/
215+
216+
@Override
217+
public PropertyName findWrapperName(Annotated ann) {
218+
return (PropertyName) values.get("findWrapperName");
219+
}
220+
210221
/*
211222
/******************************************************
212223
/* Serialization introspection
@@ -386,6 +397,42 @@ public void testFindClassDescription() throws Exception
386397

387398
// // // 3 deprecated methods, skip
388399

400+
/*
401+
/**********************************************************
402+
/* Test methods, general member annotations
403+
/**********************************************************
404+
*/
405+
406+
@Test
407+
public void testFindWrapperName() throws Exception
408+
{
409+
final PropertyName NAME_WITH_NS = PropertyName.construct("simple", "ns");
410+
final PropertyName NAME_NO_NS = PropertyName.construct("other", null);
411+
412+
assertNull(new AnnotationIntrospectorPair(NO_ANNOTATIONS, NO_ANNOTATIONS)
413+
.findClassDescription(null));
414+
415+
// First: basic merging of namespace/localname info
416+
IntrospectorWithMap intr1 = new IntrospectorWithMap()
417+
.add("findWrapperName", NAME_WITH_NS);
418+
IntrospectorWithMap intr2 = new IntrospectorWithMap()
419+
.add("findWrapperName", NAME_NO_NS);
420+
assertSame(NAME_WITH_NS,
421+
new AnnotationIntrospectorPair(intr1, intr2).findWrapperName(null));
422+
assertEquals(PropertyName.construct("other", "ns"),
423+
new AnnotationIntrospectorPair(intr2, intr1).findWrapperName(null));
424+
425+
// [databind#4595]: NO_NAME should be retained, not merged
426+
intr1 = new IntrospectorWithMap()
427+
.add("findWrapperName", PropertyName.NO_NAME);
428+
intr2 = new IntrospectorWithMap()
429+
.add("findWrapperName", NAME_WITH_NS);
430+
assertSame(PropertyName.NO_NAME,
431+
new AnnotationIntrospectorPair(intr1, intr2).findWrapperName(null));
432+
assertSame(NAME_WITH_NS,
433+
new AnnotationIntrospectorPair(intr2, intr1).findWrapperName(null));
434+
}
435+
389436
/*
390437
/**********************************************************
391438
/* Test methods, ser/deser

0 commit comments

Comments
 (0)