|
19 | 19 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
20 | 20 |
|
21 | 21 | import io.github.ascopes.jct.assertions.JavaFileObjectKindAssert; |
| 22 | +import javax.tools.JavaFileObject; |
22 | 23 | import javax.tools.JavaFileObject.Kind; |
| 24 | +import org.assertj.core.api.AbstractStringAssert; |
23 | 25 | import org.junit.jupiter.api.DisplayName; |
24 | 26 | import org.junit.jupiter.api.Nested; |
25 | 27 | import org.junit.jupiter.api.Test; |
@@ -151,4 +153,33 @@ void isOtherSucceedsIfTheKindIsOther() { |
151 | 153 | .isSameAs(assertions); |
152 | 154 | } |
153 | 155 | } |
| 156 | + |
| 157 | + @DisplayName("JavaFileObjectKindAssert#extension tests") |
| 158 | + @Nested |
| 159 | + class ExtensionTest { |
| 160 | + @DisplayName(".extension() fails if the kind is null") |
| 161 | + @Test |
| 162 | + @SuppressWarnings("ResultOfMethodCallIgnored") |
| 163 | + void extensionFailsIfKindIsNull() { |
| 164 | + // Given |
| 165 | + var assertions = new JavaFileObjectKindAssert(null); |
| 166 | + |
| 167 | + // Then |
| 168 | + assertThatThrownBy(assertions::extension) |
| 169 | + .isInstanceOf(AssertionError.class); |
| 170 | + } |
| 171 | + |
| 172 | + @DisplayName(".extension() returns assertions on the extension") |
| 173 | + @EnumSource(JavaFileObject.Kind.class) |
| 174 | + @ParameterizedTest(name = "for {0}") |
| 175 | + void extensionReturnsAssertionsOnExtension(Kind kind) { |
| 176 | + // Given |
| 177 | + var assertions = new JavaFileObjectKindAssert(kind); |
| 178 | + |
| 179 | + // Then |
| 180 | + assertThat(assertions.extension()) |
| 181 | + .isInstanceOf(AbstractStringAssert.class) |
| 182 | + .satisfies(extensionAssertion -> extensionAssertion.isEqualTo(kind.extension)); |
| 183 | + } |
| 184 | + } |
154 | 185 | } |
0 commit comments