ScoringClassMapBuilder generated the wrong map
shenzhaoquan opened this issue · 0 comments
shenzhaoquan commented
-
I defined two entities as shown below
public static class A {
public String title;
public String content;
}public static class B {
public String title;
public Integer lengthTitle;
public String content;
public Integer lengthContent;
} -
Add test case
@test
public void testScoringMatchingBug() throws Throwable {
MapperFactory factory = new DefaultMapperFactory.Builder().classMapBuilderFactory(new ScoringClassMapBuilder.Factory()).build();ClassMap<A, B> map = factory.classMap(A.class, B.class).byDefault().toClassMap(); Map<String, String> mapping = new HashMap<>(); for (FieldMap f : map.getFieldsMapping()) { mapping.put(f.getSource().getExpression(), f.getDestination().getExpression()); } /* * Check that properties we expect were mapped */ Assert.assertEquals("title", mapping.get("title")); Assert.assertEquals("content", mapping.get("content"));
}
-
result
Unit test failed. Title is incorrectly mapped to lengthTitle and should be mapped to title first, content is the same -
expect result
Unit test passed.