Skip to content

Commit d44487e

Browse files
committed
#235: Add a regression test for an enum implementing an interface
1 parent c7f77a4 commit d44487e

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
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 https://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
package org.mapstruct.intellij.bugs._235;
7+
8+
import org.jetbrains.annotations.NotNull;
9+
import org.mapstruct.intellij.inspection.BaseInspectionTest;
10+
import org.mapstruct.intellij.inspection.MapstructReferenceInspection;
11+
12+
/**
13+
* @author Oliver Erhart
14+
*/
15+
public class EnumImplementingInterfaceTest extends BaseInspectionTest {
16+
17+
@Override
18+
protected String getTestDataPath() {
19+
return "testData/bugs/_235";
20+
}
21+
22+
@NotNull
23+
@Override
24+
protected Class<MapstructReferenceInspection> getInspection() {
25+
return MapstructReferenceInspection.class;
26+
}
27+
28+
public void testEnumImplementingInterface() {
29+
doTest();
30+
}
31+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright MapStruct Authors.
3+
*
4+
* Licensed under the Apache License version 2.0, available at https://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
7+
import org.mapstruct.Mapper;
8+
9+
interface DbEnum<T> {
10+
T getDbValue();
11+
}
12+
13+
@Mapper
14+
abstract class MyMapper {
15+
16+
enum CheeseType implements DbEnum<Integer> {
17+
BRIE(1),
18+
ROQUEFORT(2);
19+
20+
private final Integer dbValue;
21+
22+
CheeseType(Integer dbValue) {
23+
this.dbValue = dbValue;
24+
}
25+
26+
@Override
27+
public Integer getDbValue() {
28+
return dbValue;
29+
}
30+
}
31+
32+
public enum OtherCheeseType {
33+
BRIE,
34+
ROQUEFORT
35+
}
36+
37+
public abstract CheeseType map(OtherCheeseType cheese);
38+
}

0 commit comments

Comments
 (0)