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

NullPointerException in Annotation.fillMappedField #76

Open
reyleo opened this issue Oct 16, 2017 · 0 comments
Open

NullPointerException in Annotation.fillMappedField #76

reyleo opened this issue Oct 16, 2017 · 0 comments

Comments

@reyleo
Copy link

reyleo commented Oct 16, 2017

Issues happens when creating mapper with API and attribute has custom accessor annotation.
Here is minimal Test class

import com.googlecode.jmapper.JMapper;
import com.googlecode.jmapper.annotations.JMapAccessor;
import com.googlecode.jmapper.api.JMapperAPI;
import org.junit.Assert;
import org.junit.Test;

import static com.googlecode.jmapper.api.JMapperAPI.*;
public class MinimalTest {

    public static class Source {
        String srcText;

        public String getSrcText() {
            return srcText;
        }

        public void setSrcText(String srcText) {
            this.srcText = srcText;
        }
    }

    public static class Destination {

        @JMapAccessor(set = "customSet")
        String dstText;

        public void customSet(String text) {
            this.dstText = text + " custom";
        }
        public String getDstText() {
            return dstText;
        }

        public void setDstText(String dstText) {
            this.dstText = dstText;
        }
    }

    @Test
    public void minimal_test() {

        JMapperAPI api = new JMapperAPI();
        api.add(mappedClass(Source.class)
                .add(attribute("srcText").value("dstText")));
        JMapper<Destination, Source> mapper = new JMapper<>(Destination.class, Source.class, api);
        Source src = new Source();
        src.setSrcText("A");
        Destination dst = mapper.getDestination(src);

        Assert.assertEquals("A custom", dst.getDstText());

    }
}
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