Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScoringClassMapBuilder generated the wrong map #376

Open
shenzhaoquan opened this issue Aug 9, 2021 · 0 comments
Open

ScoringClassMapBuilder generated the wrong map #376

shenzhaoquan opened this issue Aug 9, 2021 · 0 comments

Comments

@shenzhaoquan
Copy link

  1. 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;
    }

  2. 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"));
    

    }

  3. result
    Unit test failed. Title is incorrectly mapped to lengthTitle and should be mapped to title first, content is the same

  4. expect result
    Unit test passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant