mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#3678 add before mapping to test
This commit is contained in:
parent
b5b94bde46
commit
af7b02cb1b
@ -5,7 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.bugs._3678;
|
package org.mapstruct.ap.test.bugs._3678;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
|
import org.mapstruct.BeforeMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
@ -14,15 +18,20 @@ public abstract class Issue3678Mapper {
|
|||||||
|
|
||||||
abstract SimpleDestination sourceToDestination(SimpleSource source);
|
abstract SimpleDestination sourceToDestination(SimpleSource source);
|
||||||
|
|
||||||
int afterMappingInvocationCount = 0;
|
List<String> invocations = new ArrayList<>();
|
||||||
|
|
||||||
|
@BeforeMapping
|
||||||
|
void beforeMapping(SimpleSource simpleSource) {
|
||||||
|
invocations.add( "beforeMapping" );
|
||||||
|
}
|
||||||
|
|
||||||
@AfterMapping
|
@AfterMapping
|
||||||
void afterMapping(SimpleSource simpleSource) {
|
void afterMapping(SimpleSource simpleSource) {
|
||||||
afterMappingInvocationCount++;
|
invocations.add( "afterMapping" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAfterMappingInvocationCount() {
|
public List<String> getInvocations() {
|
||||||
return afterMappingInvocationCount;
|
return invocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SimpleSource {
|
public static class SimpleSource {
|
||||||
|
@ -26,8 +26,9 @@ public class Issue3678Test {
|
|||||||
Issue3678Mapper.SimpleSource source = new Issue3678Mapper.SimpleSource( "name", "description" );
|
Issue3678Mapper.SimpleSource source = new Issue3678Mapper.SimpleSource( "name", "description" );
|
||||||
Issue3678Mapper.SimpleDestination simpleDestination = mapper.sourceToDestination( source );
|
Issue3678Mapper.SimpleDestination simpleDestination = mapper.sourceToDestination( source );
|
||||||
|
|
||||||
assertThat( mapper.getAfterMappingInvocationCount() )
|
assertThat( mapper.getInvocations() )
|
||||||
.isOne();
|
.containsExactly( "beforeMapping", "afterMapping" )
|
||||||
|
.doesNotHaveDuplicates();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user