Skip to content

Commit d55d422

Browse files
committed
Unit tests for #1533
1 parent 1971732 commit d55d422

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/jsontype/TestPolymorphicWithDefaultImpl.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ static class BaseWrapper {
129129
public BaseClass value;
130130
}
131131

132+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY,
133+
property = "type")
134+
static class AsProperty {
135+
136+
}
137+
138+
static class AsPropertyWrapper {
139+
public AsProperty value;
140+
}
141+
132142
/*
133143
/**********************************************************
134144
/* Unit tests, deserialization
@@ -247,6 +257,24 @@ public void testUnknownClassAsSubtype() throws Exception
247257
assertNull(w.value);
248258
}
249259

260+
public void testWithoutEmptyStringAsNullObject1533() throws Exception
261+
{
262+
ObjectMapper mapper = new ObjectMapper().disable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
263+
try {
264+
mapper.readValue("{ \"value\": \"\" }", AsPropertyWrapper.class);
265+
fail("Expected " + JsonMappingException.class);
266+
} catch (JsonMappingException e) {
267+
// expected
268+
}
269+
}
270+
271+
public void testWithEmptyStringAsNullObject1533() throws Exception
272+
{
273+
ObjectMapper mapper = new ObjectMapper().enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
274+
AsPropertyWrapper wrapper = mapper.readValue("{ \"value\": \"\" }", AsPropertyWrapper.class);
275+
assertNull(wrapper.value);
276+
}
277+
250278
/*
251279
/**********************************************************
252280
/* Unit tests, serialization

0 commit comments

Comments
 (0)