osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

Bean copy - missing map inner structure when filter applied #202

Closed greenlaw110 closed 5 years ago

greenlaw110 commented 5 years ago

Sample code:

public class Gh202 extends TestBase {

    public static class Bean {
        public Map<String, Object> map;
        public String name;
    }

    @Test
    public void test() {
        Bean bean = new Bean();
        Map<String, Object> innerMap = C.Map("count", 1);
        bean.map = C.Map("foo", "bar", "inner", innerMap);
        bean.name = S.random();

        Bean target = $.deepCopy(bean).filter("map").to(Bean.class);
        Map<String, Object> innerMap2 = $.cast(target.map.get("inner"));
        notNull(innerMap2);
        eq(1, innerMap2.get("count"));
    }

}

Running the above code and the test fail at the eq(1, innerMap2.get("count")); line:

image