Skip to content

Commit

Permalink
Add coverage for #2024 testing, but fix proves elusive.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 5, 2018
1 parent ac82499 commit a50ef5a
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.fasterxml.jackson.annotation.*;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.exc.InvalidNullException;

public class NullConversionWithCreatorTest extends BaseMapTest
{
// [databind#2024]
static class EmptyFromNullViaCreator {
@JsonSetter(nulls=Nulls.AS_EMPTY)
Point p;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand All @@ -18,6 +20,18 @@ public EmptyFromNullViaCreator(@JsonSetter(nulls=Nulls.AS_EMPTY)
}
}

static class FailFromNullViaCreator {
@JsonSetter(nulls=Nulls.AS_EMPTY)
Point p;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public FailFromNullViaCreator(@JsonSetter(nulls=Nulls.FAIL)
@JsonProperty("p") Point p)
{
this.p = p;
}
}

/*
/**********************************************************
/* Test methods
Expand All @@ -33,4 +47,16 @@ public void testEmptyFromNullViaCreator() throws Exception
assertNotNull(result);
assertNotNull(result.p);
}

// [databind#2024]
public void testFailForNullViaCreator() throws Exception
{
try {
/*FailFromNullViaCreator result =*/ MAPPER.readValue(aposToQuotes("{'p':null}"),
FailFromNullViaCreator.class);
fail("Should not pass");
} catch (InvalidNullException e) {
verifyException(e, "property \"p\"");
}
}
}

0 comments on commit a50ef5a

Please sign in to comment.