diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Mapper.java new file mode 100644 index 000000000..c22fbe7b2 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Mapper.java @@ -0,0 +1,41 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._306; + +import java.util.Set; + +import org.mapstruct.Mapper; +import org.mapstruct.TargetType; +import org.mapstruct.factory.Mappers; + +@Mapper +public abstract class Issue306Mapper { + + public static final Issue306Mapper INSTANCE = Mappers.getMapper( Issue306Mapper.class ); + + public abstract Source targetToSource(Target target); + + protected void dummy1( Set arg ) { + throw new RuntimeException(); + } + + protected Set dummy2( Object object, @TargetType Class clazz ) { + throw new RuntimeException(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Test.java new file mode 100644 index 000000000..e6f69ff96 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Issue306Test.java @@ -0,0 +1,40 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._306; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; + +/** + * Reproducer for https://github.com/mapstruct/mapstruct/issues/306. + * + * @author Sjaak Derksen + */ +@IssueKey( "306" ) +@RunWith(AnnotationProcessorTestRunner.class) +public class Issue306Test { + + @Test + @WithClasses( { Issue306Mapper.class, Source.class, Target.class } ) + public void shouldForgeNewIterableMappingMethod() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Source.java new file mode 100644 index 000000000..59e812ae8 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Source.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._306; + +import java.util.Set; + + +public class Source { + + private Set fooSet; + + public Set getFooSet() { + return fooSet; + } + + public void setFooSet(Set fooSet) { + this.fooSet = fooSet; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Target.java new file mode 100644 index 000000000..d3c45074a --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_306/Target.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.bugs._306; + +import java.util.Set; + +public class Target { + + private Set fooSet; + + public Set getFooSet() { + return fooSet; + } + + public void setFooSet(Set fooSet) { + this.fooSet = fooSet; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMapper.java index fc52c88cb..7462a4f19 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMapper.java @@ -18,27 +18,14 @@ */ package org.mapstruct.ap.test.collection.forged; -import java.util.Set; import org.mapstruct.Mapper; -import org.mapstruct.TargetType; import org.mapstruct.factory.Mappers; @Mapper -public abstract class CollectionMapper { +public interface CollectionMapper { - public static final CollectionMapper INSTANCE = Mappers.getMapper( CollectionMapper.class ); + CollectionMapper INSTANCE = Mappers.getMapper( CollectionMapper.class ); - public abstract Target sourceToTarget(Source source); - public abstract Source targetToSource(Target target); - - - // this method is added to reproduce issue 306 - protected void dummy1( Set arg ) { - throw new RuntimeException(); - } - - // this method is added to reproduce issue 306 - protected Set dummy2( Object object, @TargetType Class clazz ) { - throw new RuntimeException(); - } + Target sourceToTarget(Source source); + Source targetToSource(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java index 13a2073f2..828f1b6b6 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java @@ -34,11 +34,10 @@ import org.mapstruct.ap.util.Collections; * * @author Sjaak Derksen */ -@IssueKey("4, 306") +@IssueKey( "4" ) @RunWith(AnnotationProcessorTestRunner.class) public class CollectionMappingTest { - @Test @WithClasses({ CollectionMapper.class, Source.class, Target.class }) public void shouldForgeNewIterableMappingMethod() { @@ -59,13 +58,13 @@ public class CollectionMappingTest { @WithClasses({ CollectionMapper.class, Source.class, Target.class }) public void shouldForgeNewMapMappingMethod() { - Map sourceMap = ImmutableMap.builder().put( "rabbit", 1L ).build(); + Map sourceMap = ImmutableMap.builder().put( "rabbit", 1L ).build(); Source source = new Source(); source.setBarMap( sourceMap ); Target target = CollectionMapper.INSTANCE.sourceToTarget( source ); assertThat( target ).isNotNull(); - Map targetMap = ImmutableMap.builder().put( "rabbit", "1" ).build(); + Map targetMap = ImmutableMap.builder().put( "rabbit", "1" ).build(); assertThat( target.getBarMap() ).isEqualTo( targetMap ); Source source2 = CollectionMapper.INSTANCE.targetToSource( target );