Skip to content

Commit ffd082d

Browse files
authored
[BAEL-117568] Moving some article links in Mapstruct (#17474)
1 parent 9502463 commit ffd082d

File tree

6 files changed

+56
-56
lines changed

6 files changed

+56
-56
lines changed

mapstruct-2/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ This module contains articles about MapStruct.
66
- [Mapping Enum to String Using MapStruct](https://www.baeldung.com/mapstruct-enum-string)
77
- [Map LocalDateTime to Instant in MapStruct](https://www.baeldung.com/java-mapstruct-localdatetime-instant)
88
- [Using MapStruct With Lombok](https://www.baeldung.com/java-mapstruct-lombok)
9+
- [Throw Exception for Unexpected Input for Enum With MapStruct](https://www.baeldung.com/java-mapstruct-enum-unexpected-input-exception)

mapstruct/src/main/java/com/baeldung/enums/InputLevel.java renamed to mapstruct-2/src/main/java/com/baeldung/enums/InputLevel.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.baeldung.enums;
2-
3-
enum InputLevel {
4-
5-
LOW, MEDIUM, HIGH
6-
7-
}
1+
package com.baeldung.enums;
2+
3+
enum InputLevel {
4+
5+
LOW, MEDIUM, HIGH
6+
7+
}

mapstruct/src/main/java/com/baeldung/enums/LevelMapper.java renamed to mapstruct-2/src/main/java/com/baeldung/enums/LevelMapper.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package com.baeldung.enums;
2-
3-
import org.mapstruct.Mapper;
4-
import org.mapstruct.MappingConstants;
5-
import org.mapstruct.ValueMapping;
6-
7-
@Mapper
8-
interface LevelMapper {
9-
10-
@ValueMapping(source = MappingConstants.ANY_REMAINING, target = MappingConstants.THROW_EXCEPTION)
11-
OutputLevel inputLevelToOutputLevel(InputLevel inputLevel);
12-
13-
}
1+
package com.baeldung.enums;
2+
3+
import org.mapstruct.Mapper;
4+
import org.mapstruct.MappingConstants;
5+
import org.mapstruct.ValueMapping;
6+
7+
@Mapper
8+
interface LevelMapper {
9+
10+
@ValueMapping(source = MappingConstants.ANY_REMAINING, target = MappingConstants.THROW_EXCEPTION)
11+
OutputLevel inputLevelToOutputLevel(InputLevel inputLevel);
12+
13+
}

mapstruct/src/main/java/com/baeldung/enums/OutputLevel.java renamed to mapstruct-2/src/main/java/com/baeldung/enums/OutputLevel.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.baeldung.enums;
2-
3-
enum OutputLevel {
4-
5-
LOW, HIGH
6-
7-
}
1+
package com.baeldung.enums;
2+
3+
enum OutputLevel {
4+
5+
LOW, HIGH
6+
7+
}

mapstruct/src/test/java/com/baeldung/enums/LevelMapperUnitTest.java renamed to mapstruct-2/src/test/java/com/baeldung/enums/LevelMapperUnitTest.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
package com.baeldung.enums;
2-
3-
import org.junit.jupiter.api.Test;
4-
import org.mapstruct.factory.Mappers;
5-
6-
import static org.junit.jupiter.api.Assertions.assertEquals;
7-
import static org.junit.jupiter.api.Assertions.assertThrows;
8-
9-
class LevelMapperUnitTest {
10-
11-
LevelMapper levelMapper = Mappers.getMapper(LevelMapper.class);
12-
13-
@Test
14-
void givenHighInputLevel_WhenInputLevelToOutputLevel_ThenHighOutputLevel() {
15-
assertEquals(OutputLevel.HIGH, levelMapper.inputLevelToOutputLevel(InputLevel.HIGH));
16-
}
17-
18-
@Test
19-
void givenMediumInputLevel_WhenInputLevelToOutputLevel_ThenThrows() {
20-
assertThrows(IllegalArgumentException.class, () -> levelMapper.inputLevelToOutputLevel(InputLevel.MEDIUM));
21-
}
22-
23-
@Test
24-
void givenLowInputLevel_WhenInputLevelToOutputLevel_ThenLowOutputLevel() {
25-
assertEquals(OutputLevel.LOW, levelMapper.inputLevelToOutputLevel(InputLevel.LOW));
26-
}
27-
28-
}
1+
package com.baeldung.enums;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.mapstruct.factory.Mappers;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertThrows;
8+
9+
class LevelMapperUnitTest {
10+
11+
LevelMapper levelMapper = Mappers.getMapper(LevelMapper.class);
12+
13+
@Test
14+
void givenHighInputLevel_WhenInputLevelToOutputLevel_ThenHighOutputLevel() {
15+
assertEquals(OutputLevel.HIGH, levelMapper.inputLevelToOutputLevel(InputLevel.HIGH));
16+
}
17+
18+
@Test
19+
void givenMediumInputLevel_WhenInputLevelToOutputLevel_ThenThrows() {
20+
assertThrows(IllegalArgumentException.class, () -> levelMapper.inputLevelToOutputLevel(InputLevel.MEDIUM));
21+
}
22+
23+
@Test
24+
void givenLowInputLevel_WhenInputLevelToOutputLevel_ThenLowOutputLevel() {
25+
assertEquals(OutputLevel.LOW, levelMapper.inputLevelToOutputLevel(InputLevel.LOW));
26+
}
27+
28+
}

mapstruct/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ This module contains articles about MapStruct.
1010
- [Ignoring Unmapped Properties with MapStruct](https://www.baeldung.com/mapstruct-ignore-unmapped-properties)
1111
- [Mapping Collections with MapStruct](https://www.baeldung.com/java-mapstruct-mapping-collections)
1212
- [Use Mapper in Another Mapper with Mapstruct and Java](https://www.baeldung.com/java-mapstruct-nested-mapping)
13-
- [Throw Exception for Unexpected Input for Enum With MapStruct](https://www.baeldung.com/java-mapstruct-enum-unexpected-input-exception)
1413
- [How to Use Conditional Mapping With MapStruct](https://www.baeldung.com/java-mapstruct-bean-types-conditional)
1514
- [Mapping Enum With MapStruct](https://www.baeldung.com/java-mapstruct-enum)
1615
- [Using MapStruct With Inheritance](https://www.baeldung.com/java-mapstruct-inheritance)

0 commit comments

Comments
 (0)