Skip to content

Commit

Permalink
Merge pull request #1446 from Spikhalskiy/1421-failingTest
Browse files Browse the repository at this point in the history
Add failing test for an issue #1421
  • Loading branch information
cowtowncoder authored Nov 9, 2016
2 parents 0c8642c + 18eee34 commit 7713153
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

public class SingleValueAsArray1421Test
{
private static final String JSON = "[{\"message\":\"messageHere\"}]";

static class A
{
List<B> bs = Collections.emptyList();

@JsonCreator
A(final List<B> bs)
{
this.bs = bs;
}
}

static class B
{
List<C> cs = Collections.emptyList();

@JsonCreator
B(final List<C> cs)
{
this.cs = cs;
}
}

public static class C
{
String message;

@JsonCreator
C(@JsonProperty("message") String message)
{
this.message = message;
}
}

@Test
public void testSuccessfulDeserializationOfObjectWithChainedArrayCreators() throws IOException
{
ObjectMapper om = new ObjectMapper();
om.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
om.readValue(JSON, A.class);
}
}

0 comments on commit 7713153

Please sign in to comment.