#3678 add before mapping to test

This commit is contained in:
thunderhook 2024-08-22 22:12:07 +02:00
parent b5b94bde46
commit af7b02cb1b
2 changed files with 16 additions and 6 deletions

View File

@ -5,7 +5,11 @@
*/
package org.mapstruct.ap.test.bugs._3678;
import java.util.ArrayList;
import java.util.List;
import org.mapstruct.AfterMapping;
import org.mapstruct.BeforeMapping;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@ -14,15 +18,20 @@ public abstract class Issue3678Mapper {
abstract SimpleDestination sourceToDestination(SimpleSource source);
int afterMappingInvocationCount = 0;
List<String> invocations = new ArrayList<>();
@BeforeMapping
void beforeMapping(SimpleSource simpleSource) {
invocations.add( "beforeMapping" );
}
@AfterMapping
void afterMapping(SimpleSource simpleSource) {
afterMappingInvocationCount++;
invocations.add( "afterMapping" );
}
public int getAfterMappingInvocationCount() {
return afterMappingInvocationCount;
public List<String> getInvocations() {
return invocations;
}
public static class SimpleSource {

View File

@ -26,8 +26,9 @@ public class Issue3678Test {
Issue3678Mapper.SimpleSource source = new Issue3678Mapper.SimpleSource( "name", "description" );
Issue3678Mapper.SimpleDestination simpleDestination = mapper.sourceToDestination( source );
assertThat( mapper.getAfterMappingInvocationCount() )
.isOne();
assertThat( mapper.getInvocations() )
.containsExactly( "beforeMapping", "afterMapping" )
.doesNotHaveDuplicates();
}
}