#729 added unittest for mapping property of collection to primitive

This commit is contained in:
Oliver Ehrenmüller 2016-02-02 09:01:49 +01:00
parent e42788ece2
commit 4101ed86c9
4 changed files with 109 additions and 0 deletions

View File

@ -56,6 +56,21 @@ public class ErroneousCollectionMappingTest {
public void shouldFailToGenerateImplementationBetweenCollectionAndNonCollection() {
}
@Test
@IssueKey("729")
@WithClasses({ ErroneousCollectionToPrimitivePropertyMapper.class, Source.class, Target.class })
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = ErroneousCollectionToPrimitivePropertyMapper.class,
kind = Kind.ERROR,
line = 26,
messageRegExp = "Can't map property \"java.util.List<java.lang.String> strings\" to \"int strings\". Consider to declare/implement a mapping method: \"int map\\(java.util.List<java.lang.String> value\\)\"")
}
)
public void shouldFailToGenerateImplementationBetweenCollectionAndPrimitive() {
}
@Test
@IssueKey("417")
@WithClasses({ EmptyItererableMappingMapper.class })

View File

@ -0,0 +1,28 @@
/**
* Copyright 2012-2016 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.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.collection.erroneous;
import org.mapstruct.Mapper;
@Mapper
public interface ErroneousCollectionToPrimitivePropertyMapper {
Target mapCollectionToNonCollectionAsProperty(Source source);
}

View File

@ -0,0 +1,34 @@
/**
* Copyright 2012-2016 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.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.collection.erroneous;
import java.util.List;
public class Source {
private List<String> strings;
public List<String> getStrings() {
return strings;
}
public void setStrings(List<String> strings) {
this.strings = strings;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2016 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.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.collection.erroneous;
public class Target {
private int strings;
public int getStrings() {
return strings;
}
public void setStrings(int strings) {
this.strings = strings;
}
}