Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.fasterxml.jackson.annotation.*;
- import com.fasterxml.jackson.core.*;
- import com.fasterxml.jackson.databind.*;
- import com.fasterxml.jackson.databind.deser.*;
- import com.fasterxml.jackson.databind.deser.impl.*;
- import com.fasterxml.jackson.databind.deser.std.*;
- import org.junit.*;
- import java.io.*;
- import static org.junit.Assert.*;
- public class Github1432 {
- @Test
- public void allPropertiesHaveHasParameterReturnTrue() throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.registerModule(new TestModule());
- String json = "{ " +
- "\"p1\": \"NotNull\"," +
- "\"p2\": \"NotNull\"," +
- "\"p3\": \"NotNull\"," +
- "\"p4\": \"NotNull\"," +
- "\"p5\": \"NotNull\"," +
- "\"p6\": \"NotNull\"," +
- "\"p7\": \"NotNull\"," +
- "\"p8\": \"NotNull\"," +
- "\"p9\": \"NotNull\"," +
- "\"p10\": \"NotNull\"," +
- "\"p11\": \"NotNull\"," +
- "\"p12\": \"NotNull\"," +
- "\"p13\": \"NotNull\"," +
- "\"p14\": \"NotNull\"," +
- "\"p15\": \"NotNull\"," +
- "\"p16\": \"NotNull\"," +
- "\"p17\": \"NotNull\"," +
- "\"p18\": \"NotNull\"," +
- "\"p19\": \"NotNull\"," +
- "\"p20\": \"NotNull\"," +
- "\"p21\": \"NotNull\"," +
- "\"p22\": \"NotNull\"," +
- "\"p23\": \"NotNull\"," +
- "\"p24\": \"NotNull\"," +
- "\"p25\": \"NotNull\"," +
- "\"p26\": \"NotNull\"," +
- "\"p27\": \"NotNull\"," +
- "\"p28\": \"NotNull\"," +
- "\"p29\": \"NotNull\"," +
- "\"p30\": \"NotNull\"," +
- "\"p31\": \"NotNull\"," +
- "\"p32\": \"NotNull\" " +
- "}";
- ClassWith32Props classWith32Props = objectMapper.readValue(json, ClassWith32Props.class);
- assertEquals("NotNull", classWith32Props.p1);
- assertEquals("NotNull", classWith32Props.p2);
- assertEquals("NotNull", classWith32Props.p3);
- assertEquals("NotNull", classWith32Props.p4);
- assertEquals("NotNull", classWith32Props.p5);
- assertEquals("NotNull", classWith32Props.p6);
- assertEquals("NotNull", classWith32Props.p7);
- assertEquals("NotNull", classWith32Props.p8);
- assertEquals("NotNull", classWith32Props.p9);
- assertEquals("NotNull", classWith32Props.p10);
- assertEquals("NotNull", classWith32Props.p11);
- assertEquals("NotNull", classWith32Props.p12);
- assertEquals("NotNull", classWith32Props.p13);
- assertEquals("NotNull", classWith32Props.p14);
- assertEquals("NotNull", classWith32Props.p15);
- assertEquals("NotNull", classWith32Props.p16);
- assertEquals("NotNull", classWith32Props.p17);
- assertEquals("NotNull", classWith32Props.p18);
- assertEquals("NotNull", classWith32Props.p19);
- assertEquals("NotNull", classWith32Props.p20);
- assertEquals("NotNull", classWith32Props.p21);
- assertEquals("NotNull", classWith32Props.p22);
- assertEquals("NotNull", classWith32Props.p23);
- assertEquals("NotNull", classWith32Props.p24);
- assertEquals("NotNull", classWith32Props.p25);
- assertEquals("NotNull", classWith32Props.p26);
- assertEquals("NotNull", classWith32Props.p27);
- assertEquals("NotNull", classWith32Props.p28);
- assertEquals("NotNull", classWith32Props.p29);
- assertEquals("NotNull", classWith32Props.p30);
- assertEquals("NotNull", classWith32Props.p31);
- assertEquals("NotNull", classWith32Props.p32);
- }
- public static class ClassWith32Props {
- @JsonCreator
- public ClassWith32Props(
- @JsonProperty("p1") String p1,
- @JsonProperty("p2") String p2,
- @JsonProperty("p3") String p3,
- @JsonProperty("p4") String p4,
- @JsonProperty("p5") String p5,
- @JsonProperty("p6") String p6,
- @JsonProperty("p7") String p7,
- @JsonProperty("p8") String p8,
- @JsonProperty("p9") String p9,
- @JsonProperty("p10") String p10,
- @JsonProperty("p11") String p11,
- @JsonProperty("p12") String p12,
- @JsonProperty("p13") String p13,
- @JsonProperty("p14") String p14,
- @JsonProperty("p15") String p15,
- @JsonProperty("p16") String p16,
- @JsonProperty("p17") String p17,
- @JsonProperty("p18") String p18,
- @JsonProperty("p19") String p19,
- @JsonProperty("p20") String p20,
- @JsonProperty("p21") String p21,
- @JsonProperty("p22") String p22,
- @JsonProperty("p23") String p23,
- @JsonProperty("p24") String p24,
- @JsonProperty("p25") String p25,
- @JsonProperty("p26") String p26,
- @JsonProperty("p27") String p27,
- @JsonProperty("p28") String p28,
- @JsonProperty("p29") String p29,
- @JsonProperty("p30") String p30,
- @JsonProperty("p31") String p31,
- @JsonProperty("p32") String p32) {
- this.p1 = p1;
- this.p2 = p2;
- this.p3 = p3;
- this.p4 = p4;
- this.p5 = p5;
- this.p6 = p6;
- this.p7 = p7;
- this.p8 = p8;
- this.p9 = p9;
- this.p10 = p10;
- this.p11 = p11;
- this.p12 = p12;
- this.p13 = p13;
- this.p14 = p14;
- this.p15 = p15;
- this.p16 = p16;
- this.p17 = p17;
- this.p18 = p18;
- this.p19 = p19;
- this.p20 = p20;
- this.p21 = p21;
- this.p22 = p22;
- this.p23 = p23;
- this.p24 = p24;
- this.p25 = p25;
- this.p26 = p26;
- this.p27 = p27;
- this.p28 = p28;
- this.p29 = p29;
- this.p30 = p30;
- this.p31 = p31;
- this.p32 = p32;
- }
- public final String p1;
- public final String p2;
- public final String p3;
- public final String p4;
- public final String p5;
- public final String p6;
- public final String p7;
- public final String p8;
- public final String p9;
- public final String p10;
- public final String p11;
- public final String p12;
- public final String p13;
- public final String p14;
- public final String p15;
- public final String p16;
- public final String p17;
- public final String p18;
- public final String p19;
- public final String p20;
- public final String p21;
- public final String p22;
- public final String p23;
- public final String p24;
- public final String p25;
- public final String p26;
- public final String p27;
- public final String p28;
- public final String p29;
- public final String p30;
- public final String p31;
- public final String p32;
- }
- public static class TestModule extends Module {
- @Override
- public String getModuleName() {
- return "test";
- }
- @Override
- public Version version() {
- return new Version(0, 0, 0, "Test", null, null);
- }
- @Override
- public void setupModule(SetupContext context) {
- context.addValueInstantiators((config, beanDesc, defaultInstantiator) -> new TestValueInstantiator((StdValueInstantiator) defaultInstantiator));
- }
- }
- public static class TestValueInstantiator extends StdValueInstantiator {
- protected TestValueInstantiator(StdValueInstantiator src) {
- super(src);
- }
- @Override
- public Object createFromObjectWith(DeserializationContext ctxt, SettableBeanProperty[] props, PropertyValueBuffer buffer) throws IOException {
- for (SettableBeanProperty prop : props) {
- assertTrue("prop " + prop.getName() + " was expected to have buffer.hasParameter(prop) be true but was false", buffer.hasParameter(prop));
- }
- return super.createFromObjectWith(ctxt, props, buffer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement