Skip to content

Commit 7e4a244

Browse files
committed
Add test case for incorrect unmapped target properties for enum mapping
Closes #42
1 parent a1e2848 commit 7e4a244

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright MapStruct Authors.
3+
*
4+
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
package org.mapstruct.intellij.bugs._42;
7+
8+
import java.util.List;
9+
10+
import com.intellij.codeInsight.intention.IntentionAction;
11+
import org.jetbrains.annotations.NotNull;
12+
import org.mapstruct.intellij.inspection.BaseInspectionTest;
13+
import org.mapstruct.intellij.inspection.UnmappedTargetPropertiesInspection;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
/**
18+
* @author Filip Hrisafov
19+
*/
20+
public class UnmappedTargetPropertyForEnumWithStaticMethodTest extends BaseInspectionTest {
21+
22+
@Override
23+
protected String getTestDataPath() {
24+
return "testData/bugs/_42";
25+
}
26+
27+
@NotNull
28+
@Override
29+
protected Class<UnmappedTargetPropertiesInspection> getInspection() {
30+
return UnmappedTargetPropertiesInspection.class;
31+
}
32+
33+
@Override
34+
protected void setUp() throws Exception {
35+
super.setUp();
36+
}
37+
38+
public void testUnmappedTargetPropertyForEnumWithStaticMethod() {
39+
doTest();
40+
List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes();
41+
42+
assertThat( allQuickFixes )
43+
.extracting( IntentionAction::getText )
44+
.as( "Intent Text" )
45+
.isEmpty();
46+
}
47+
}

src/test/java/org/mapstruct/intellij/inspection/BaseInspectionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ protected void setUp() throws Exception {
2525
}
2626

2727
@NotNull
28-
abstract Class<? extends LocalInspectionTool> getInspection();
28+
protected abstract Class<? extends LocalInspectionTool> getInspection();
2929

30-
void doTest() {
30+
protected void doTest() {
3131
String testName = getTestName( false );
3232
configureByFile( testName + ".java" );
3333
myFixture.enableInspections( getInspection() );
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright MapStruct Authors.
3+
*
4+
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
7+
import org.mapstruct.Mapper;
8+
9+
@Mapper
10+
public interface UnmappedTargetPropertyForEnumWithStaticMethod {
11+
12+
CheeseType map(OtherCheeseType cheese);
13+
14+
enum CheeseType {
15+
BRIE,
16+
ROQUEFORT;
17+
18+
public String getValue() {
19+
return null;
20+
}
21+
22+
public static CheeseType fromString(String value) {
23+
return null;
24+
}
25+
}
26+
27+
enum OtherCheeseType {
28+
BRIE,
29+
ROQUEFORT
30+
}
31+
}

0 commit comments

Comments
 (0)