Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for an issue #1421 #1446

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}