public static B create() { B t = new B(); t.f1 = new TreeMap<>(); t.f2 = new TreeMap<String,A>(){{put("f2a",null);put("f2b",A.create());}}; return t; } }
@Test public void testTrimNullsFromBeans() throws Exception { UrlEncodingSerializerBuilder s = UrlEncodingSerializer.create(); A t1 = A.create(), t2; s.trimNullProperties(false); String r = s.build().serialize(t1); assertEquals("s1=null&s2=s2", r); t2 = p.parse(r, A.class); assertEqualObjects(t1, t2); s.trimNullProperties(true); r = s.build().serialize(t1); assertEquals("s2=s2", r); t2 = p.parse(r, A.class); assertEqualObjects(t1, t2); }
public static D create() { D t = new D(); t.f1 = new A[]{}; t.f2 = new A[]{null, A.create()}; return t; } }
public static C create() { C t = new C(); t.f1 = new AList<>(); t.f2 = new AList<A>().append(null).append(A.create()); return t; } }