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() )
|
assertThat( context.getInvokedMethods() )
|
||||||
.contains(
|
.contains(
|
||||||
|
"beforeWithoutParameters",
|
||||||
"beforeWithBuilderTargetType",
|
"beforeWithBuilderTargetType",
|
||||||
"beforeWithBuilderTarget",
|
"beforeWithBuilderTarget",
|
||||||
|
"afterWithoutParameters",
|
||||||
"afterWithBuilderTargetType",
|
"afterWithBuilderTargetType",
|
||||||
"afterWithBuilderTarget"
|
"afterWithBuilderTarget",
|
||||||
|
"afterWithBuilderTargetReturningTarget"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ public class MappingContext {
|
|||||||
|
|
||||||
private final List<String> invokedMethods = new ArrayList<String>();
|
private final List<String> invokedMethods = new ArrayList<String>();
|
||||||
|
|
||||||
|
@BeforeMapping
|
||||||
|
public void beforeWithoutParameters() {
|
||||||
|
invokedMethods.add( "beforeWithoutParameters" );
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeMapping
|
@BeforeMapping
|
||||||
public void beforeWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
public void beforeWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
||||||
invokedMethods.add( "beforeWithTargetType" );
|
invokedMethods.add( "beforeWithTargetType" );
|
||||||
@ -53,6 +58,11 @@ public class MappingContext {
|
|||||||
invokedMethods.add( "beforeWithBuilderTarget" );
|
invokedMethods.add( "beforeWithBuilderTarget" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterMapping
|
||||||
|
public void afterWithoutParameters() {
|
||||||
|
invokedMethods.add( "afterWithoutParameters" );
|
||||||
|
}
|
||||||
|
|
||||||
@AfterMapping
|
@AfterMapping
|
||||||
public void afterWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
public void afterWithTargetType(OrderDto source, @TargetType Class<Order> orderClass) {
|
||||||
invokedMethods.add( "afterWithTargetType" );
|
invokedMethods.add( "afterWithTargetType" );
|
||||||
@ -73,6 +83,13 @@ public class MappingContext {
|
|||||||
invokedMethods.add( "afterWithBuilderTarget" );
|
invokedMethods.add( "afterWithBuilderTarget" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterMapping
|
||||||
|
public Order afterWithBuilderTargetReturningTarget(@MappingTarget Order.Builder orderBuilder) {
|
||||||
|
invokedMethods.add( "afterWithBuilderTargetReturningTarget" );
|
||||||
|
|
||||||
|
return orderBuilder.create();
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getInvokedMethods() {
|
public List<String> getInvokedMethods() {
|
||||||
return invokedMethods;
|
return invokedMethods;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user