|
10 | 10 | import org.jetbrains.annotations.NotNull;
|
11 | 11 | import org.jetbrains.annotations.Nullable;
|
12 | 12 | import org.junit.jupiter.api.Test;
|
| 13 | +import org.junit.jupiter.params.ParameterizedTest; |
| 14 | +import org.junit.jupiter.params.provider.MethodSource; |
13 | 15 |
|
14 | 16 | import java.io.File;
|
15 | 17 | import java.io.IOException;
|
16 | 18 | import java.lang.reflect.Field;
|
17 | 19 | import java.util.List;
|
18 | 20 |
|
19 | 21 | import static org.junit.jupiter.api.Assertions.*;
|
| 22 | +import static org.mockito.ArgumentMatchers.any; |
20 | 23 | import static org.mockito.Mockito.mock;
|
| 24 | +import static org.mockito.Mockito.when; |
21 | 25 |
|
22 | 26 | class WrapperParserTest {
|
23 | 27 |
|
24 |
| - @Test |
25 |
| - void testLoadNull() throws IOException { |
26 |
| - List<Wrapper> actual = load(getFile("wrapper"), "wrapper", Wrapper.class); |
27 |
| - assertNotNull(actual); |
28 |
| - for (Wrapper w : actual) assertNull(w); |
| 28 | + private static Object[] invalidSaves() { |
| 29 | + return new Object[]{null, "", " "}; |
| 30 | + } |
| 31 | + |
| 32 | + @ParameterizedTest |
| 33 | + @MethodSource("invalidSaves") |
| 34 | + void testLoadNull(String save) throws Exception { |
| 35 | + IConfiguration configuration = mock(IConfiguration.class); |
| 36 | + when(configuration.getString(any())).thenReturn(save); |
| 37 | + assertNull(new WrapperParser<>(Enchantment.class).getLoader().apply(configuration, "path")); |
29 | 38 | }
|
30 | 39 |
|
31 |
| - @SuppressWarnings({"rawtypes", "unchecked"}) |
32 | 40 | @Test
|
33 | 41 | void testSaveNull() {
|
34 |
| - assertDoesNotThrow(() -> new WrapperParser(Enchantment.class).getDumper() |
| 42 | + assertDoesNotThrow(() -> new WrapperParser<>(Enchantment.class).getDumper() |
35 | 43 | .accept(mock(IConfiguration.class), "enchantment", null));
|
36 | 44 | }
|
37 | 45 |
|
|
0 commit comments