mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1454 add more tests for builder lifecycle methods
This commit is contained in:
parent
eeddc17de4
commit
db851701ef
@ -58,10 +58,13 @@ public class BuilderLifecycleCallbacksTest {
|
||||
|
||||
assertThat( context.getInvokedMethods() )
|
||||
.contains(
|
||||
"beforeWithoutParameters",
|
||||
"beforeWithBuilderTargetType",
|
||||
"beforeWithBuilderTarget",
|
||||
"afterWithoutParameters",
|
||||
"afterWithBuilderTargetType",
|
||||
"afterWithBuilderTarget"
|
||||
"afterWithBuilderTarget",
|
||||
"afterWithBuilderTargetReturningTarget"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,11 @@ public class MappingContext {
|
||||
|
||||
private final List<String> invokedMethods = new ArrayList<String>();
|
||||
|
||||
@BeforeMapping
|
||||
public void beforeWithoutParameters() {
|
||||
invokedMethods.add( "beforeWithoutParameters" );
|
||||
}
|
||||
|
||||
@BeforeMapping
|
||||
public void beforeWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
||||
invokedMethods.add( "beforeWithTargetType" );
|
||||
@ -53,6 +58,11 @@ public class MappingContext {
|
||||
invokedMethods.add( "beforeWithBuilderTarget" );
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
public void afterWithoutParameters() {
|
||||
invokedMethods.add( "afterWithoutParameters" );
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
public void afterWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
||||
invokedMethods.add( "afterWithTargetType" );
|
||||
@ -73,6 +83,13 @@ public class MappingContext {
|
||||
invokedMethods.add( "afterWithBuilderTarget" );
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
public Order afterWithBuilderTargetReturningTarget(@MappingTarget Order.Builder orderBuilder) {
|
||||
invokedMethods.add( "afterWithBuilderTargetReturningTarget" );
|
||||
|
||||
return orderBuilder.create();
|
||||
}
|
||||
|
||||
public List<String> getInvokedMethods() {
|
||||
return invokedMethods;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user