You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to configure a custom converter for mapping between two types. I want to stick to the programmatic API and not resort to XML. But it seems Dozer is not calling my custom converter. Here is a small unit test that reproduces the problem:
@Test
public void test() {
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setCustomConverters(singletonList(new ABConverter()));
A a = new A("001");
B b = mapper.map(a, B.class);
System.out.println("b = " + b);
}
public static class ABConverter extends DozerConverter<A, B> {
public ABConverter() {
super(A.class, B.class);
}
@Override
public B convertTo(A source, B destination) {
return new B(source.val1);
}
@Override
public A convertFrom(B source, A destination) {
return new A(source.val2);
}
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class A {
private String val1;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class B {
private String val2;
}
Observed Results:
The above code prints b = B(val2=null). I also added print statements in the converter and verified the methods are not being called.
Expected Results:
Looking at the setCustomConverters method, I expected that my custom converter will be called but that is not the case
The text was updated successfully, but these errors were encountered:
Whats your runtime?
Whats the problem?
I am trying to configure a custom converter for mapping between two types. I want to stick to the programmatic API and not resort to XML. But it seems Dozer is not calling my custom converter. Here is a small unit test that reproduces the problem:
Observed Results:
The above code prints b = B(val2=null). I also added print statements in the converter and verified the methods are not being called.
Expected Results:
Looking at the setCustomConverters method, I expected that my custom converter will be called but that is not the case
The text was updated successfully, but these errors were encountered: