diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Mapper.java new file mode 100644 index 000000000..67a88ba36 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Mapper.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 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._537; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * @author Christian Bandowski + */ +@Mapper(uses = ReferenceMapper.class, config = Issue537MapperConfig.class) +public interface Issue537Mapper { + Issue537Mapper INSTANCE = Mappers.getMapper( Issue537Mapper.class ); + + Target mapDto(Source source); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537MapperConfig.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537MapperConfig.java new file mode 100644 index 000000000..21c81318e --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537MapperConfig.java @@ -0,0 +1,29 @@ +/** + * Copyright 2012-2017 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._537; + +import org.mapstruct.MapperConfig; + +/** + * @author Christian Bandowski + */ +@MapperConfig(uses = ReferenceMapper.class) +public interface Issue537MapperConfig { + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Test.java new file mode 100644 index 000000000..22d9d3913 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Issue537Test.java @@ -0,0 +1,50 @@ +/** + * Copyright 2012-2017 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._537; + +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; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Christian Bandowski + */ +@RunWith(AnnotationProcessorTestRunner.class) +@IssueKey("537") +@WithClasses({ + Issue537Mapper.class, + Issue537MapperConfig.class, + ReferenceMapper.class, + Source.class, + Target.class +}) +public class Issue537Test { + + @Test + public void testThatReferencedMapperWillBeUsed() { + Target target = Issue537Mapper.INSTANCE.mapDto( new Source( "abc" ) ); + + assertThat( target ).isNotNull(); + assertThat( target.getValue() ).isEqualTo( 3 ); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/ReferenceMapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/ReferenceMapper.java new file mode 100644 index 000000000..db3b91f92 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/ReferenceMapper.java @@ -0,0 +1,28 @@ +/** + * Copyright 2012-2017 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._537; + +/** + * @author Christian Bandowski + */ +public class ReferenceMapper { + public Integer stringLength(String source) { + return source == null ? null : source.length(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Source.java new file mode 100644 index 000000000..753c6a47c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Source.java @@ -0,0 +1,41 @@ +/** + * Copyright 2012-2017 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._537; + +/** + * @author Christian Bandowski + */ +public class Source { + private String value; + + public Source() { + } + + public Source(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Target.java new file mode 100644 index 000000000..afe1fb35b --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_537/Target.java @@ -0,0 +1,41 @@ +/** + * Copyright 2012-2017 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._537; + +/** + * @author Christian Bandowski + */ +public class Target { + private Integer value; + + public Target() { + } + + public Target(Integer value) { + this.value = value; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } +}