mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#241 test on adder should be less strict
This commit is contained in:
parent
ec977cdbfc
commit
5926e44cee
@ -72,12 +72,10 @@ public class Executables {
|
||||
public static boolean isAdderMethod(ExecutableElement method) {
|
||||
String name = method.getSimpleName().toString();
|
||||
|
||||
if ( isPublic( method ) && name.startsWith( "add" ) && name.length() > 3 && method.getParameters()
|
||||
.size() == 1 && method.getReturnType().getKind() == TypeKind.VOID ) {
|
||||
return true;
|
||||
}
|
||||
return isPublic( method ) &&
|
||||
name.startsWith( "add" ) && name.length() > 3 &&
|
||||
method.getParameters().size() == 1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isPublic(ExecutableElement method) {
|
||||
|
@ -41,6 +41,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
|
||||
/**
|
||||
* @author Sjaak Derksen
|
||||
@ -69,6 +70,7 @@ import static org.junit.Assert.assertTrue;
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class AdderTest {
|
||||
|
||||
@IssueKey("241")
|
||||
@Test
|
||||
public void testAdd() throws DogException {
|
||||
AdderUsageObserver.setUsed( false );
|
||||
@ -103,6 +105,7 @@ public class AdderTest {
|
||||
SourceTargetMapper.INSTANCE.toTarget( source );
|
||||
}
|
||||
|
||||
@IssueKey("241")
|
||||
@Test
|
||||
public void testAddwithExistingTarget() throws DogException {
|
||||
AdderUsageObserver.setUsed( false );
|
||||
|
@ -48,11 +48,12 @@ public class Target {
|
||||
// dummy method to test selection mechanims
|
||||
}
|
||||
|
||||
public void addPet(Long pet) {
|
||||
public Long addPet(Long pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( pets == null ) {
|
||||
pets = new ArrayList<Long>();
|
||||
}
|
||||
pets.add( pet );
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user