#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) { public static boolean isAdderMethod(ExecutableElement method) {
String name = method.getSimpleName().toString(); String name = method.getSimpleName().toString();
if ( isPublic( method ) && name.startsWith( "add" ) && name.length() > 3 && method.getParameters() return isPublic( method ) &&
.size() == 1 && method.getReturnType().getKind() == TypeKind.VOID ) { name.startsWith( "add" ) && name.length() > 3 &&
return true; method.getParameters().size() == 1;
}
return false;
} }
private static boolean isPublic(ExecutableElement method) { 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.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.mapstruct.ap.testutil.IssueKey;
/** /**
* @author Sjaak Derksen * @author Sjaak Derksen
@ -69,6 +70,7 @@ import static org.junit.Assert.assertTrue;
@RunWith(AnnotationProcessorTestRunner.class) @RunWith(AnnotationProcessorTestRunner.class)
public class AdderTest { public class AdderTest {
@IssueKey("241")
@Test @Test
public void testAdd() throws DogException { public void testAdd() throws DogException {
AdderUsageObserver.setUsed( false ); AdderUsageObserver.setUsed( false );
@ -103,6 +105,7 @@ public class AdderTest {
SourceTargetMapper.INSTANCE.toTarget( source ); SourceTargetMapper.INSTANCE.toTarget( source );
} }
@IssueKey("241")
@Test @Test
public void testAddwithExistingTarget() throws DogException { public void testAddwithExistingTarget() throws DogException {
AdderUsageObserver.setUsed( false ); AdderUsageObserver.setUsed( false );

View File

@ -48,11 +48,12 @@ public class Target {
// dummy method to test selection mechanims // dummy method to test selection mechanims
} }
public void addPet(Long pet) { public Long addPet(Long pet) {
AdderUsageObserver.setUsed( true ); AdderUsageObserver.setUsed( true );
if ( pets == null ) { if ( pets == null ) {
pets = new ArrayList<Long>(); pets = new ArrayList<Long>();
} }
pets.add( pet ); pets.add( pet );
return pet;
} }
} }