#241 test on adder should be less strict

This commit is contained in:
sjaakd 2014-06-25 20:03:36 +02:00 committed by Gunnar Morling
parent ec977cdbfc
commit 5926e44cee
3 changed files with 8 additions and 6 deletions

View File

@ -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) {

View File

@ -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 );

View File

@ -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;
}
}