Skip to content

Commit eeddc17

Browse files
chris922filiphr
authored andcommitted
mapstruct#537 add unit test
1 parent 6fbc4cf commit eeddc17

6 files changed

Lines changed: 221 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
import org.mapstruct.Mapper;
22+
import org.mapstruct.factory.Mappers;
23+
24+
/**
25+
* @author Christian Bandowski
26+
*/
27+
@Mapper(uses = ReferenceMapper.class, config = Issue537MapperConfig.class)
28+
public interface Issue537Mapper {
29+
Issue537Mapper INSTANCE = Mappers.getMapper( Issue537Mapper.class );
30+
31+
Target mapDto(Source source);
32+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
import org.mapstruct.MapperConfig;
22+
23+
/**
24+
* @author Christian Bandowski
25+
*/
26+
@MapperConfig(uses = ReferenceMapper.class)
27+
public interface Issue537MapperConfig {
28+
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
import org.junit.Test;
22+
import org.junit.runner.RunWith;
23+
import org.mapstruct.ap.testutil.IssueKey;
24+
import org.mapstruct.ap.testutil.WithClasses;
25+
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
26+
27+
import static org.assertj.core.api.Assertions.assertThat;
28+
29+
/**
30+
* @author Christian Bandowski
31+
*/
32+
@RunWith(AnnotationProcessorTestRunner.class)
33+
@IssueKey("537")
34+
@WithClasses({
35+
Issue537Mapper.class,
36+
Issue537MapperConfig.class,
37+
ReferenceMapper.class,
38+
Source.class,
39+
Target.class
40+
})
41+
public class Issue537Test {
42+
43+
@Test
44+
public void testThatReferencedMapperWillBeUsed() {
45+
Target target = Issue537Mapper.INSTANCE.mapDto( new Source( "abc" ) );
46+
47+
assertThat( target ).isNotNull();
48+
assertThat( target.getValue() ).isEqualTo( 3 );
49+
}
50+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
/**
22+
* @author Christian Bandowski
23+
*/
24+
public class ReferenceMapper {
25+
public Integer stringLength(String source) {
26+
return source == null ? null : source.length();
27+
}
28+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
/**
22+
* @author Christian Bandowski
23+
*/
24+
public class Source {
25+
private String value;
26+
27+
public Source() {
28+
}
29+
30+
public Source(String value) {
31+
this.value = value;
32+
}
33+
34+
public String getValue() {
35+
return value;
36+
}
37+
38+
public void setValue(String value) {
39+
this.value = value;
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._537;
20+
21+
/**
22+
* @author Christian Bandowski
23+
*/
24+
public class Target {
25+
private Integer value;
26+
27+
public Target() {
28+
}
29+
30+
public Target(Integer value) {
31+
this.value = value;
32+
}
33+
34+
public Integer getValue() {
35+
return value;
36+
}
37+
38+
public void setValue(Integer value) {
39+
this.value = value;
40+
}
41+
}

0 commit comments

Comments
 (0)