Skip to content

Commit ef60e8d

Browse files
committed
Add missing test cases to JavaJctFlagBuilderImplTest
1 parent 73e38e1 commit ef60e8d

File tree

1 file changed

+133
-29
lines changed

1 file changed

+133
-29
lines changed

java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/compilers/javac/JavacJctFlagBuilderImplTest.java

Lines changed: 133 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616
package io.github.ascopes.jct.tests.unit.compilers.javac;
1717

18-
import static io.github.ascopes.jct.tests.helpers.Fixtures.someText;
18+
import static io.github.ascopes.jct.tests.helpers.Fixtures.someBoolean;
19+
import static io.github.ascopes.jct.tests.helpers.Fixtures.someRelease;
1920
import static org.assertj.core.api.Assertions.assertThat;
2021
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2122

@@ -73,6 +74,14 @@ void doesNotAddFlagIfFalse() {
7374
// Then
7475
assertThat(flagBuilder.build()).doesNotContain("-verbose");
7576
}
77+
78+
@DisplayName(".verbose(...) returns the flag builder")
79+
@Test
80+
void returnsFlagBuilder() {
81+
// Then
82+
assertThat(flagBuilder.verbose(someBoolean()))
83+
.isSameAs(flagBuilder);
84+
}
7685
}
7786

7887
@DisplayName(".previewFeatures(boolean) tests")
@@ -98,6 +107,14 @@ void doesNotAddFlagIfFalse() {
98107
// Then
99108
assertThat(flagBuilder.build()).doesNotContain("--enable-preview");
100109
}
110+
111+
@DisplayName(".previewFeatures(...) returns the flag builder")
112+
@Test
113+
void returnsFlagBuilder() {
114+
// Then
115+
assertThat(flagBuilder.previewFeatures(someBoolean()))
116+
.isSameAs(flagBuilder);
117+
}
101118
}
102119

103120
@DisplayName(".showWarnings(boolean) tests")
@@ -123,6 +140,14 @@ void addsFlagIfFalse() {
123140
// Then
124141
assertThat(flagBuilder.build()).contains("-nowarn");
125142
}
143+
144+
@DisplayName(".showWarnings(...) returns the flag builder")
145+
@Test
146+
void returnsFlagBuilder() {
147+
// Then
148+
assertThat(flagBuilder.showWarnings(someBoolean()))
149+
.isSameAs(flagBuilder);
150+
}
126151
}
127152

128153
@DisplayName(".failOnWarnings(boolean) tests")
@@ -148,6 +173,14 @@ void doesNotAddFlagIfFalse() {
148173
// Then
149174
assertThat(flagBuilder.build()).doesNotContain("-Werror");
150175
}
176+
177+
@DisplayName(".failOnWarnings(...) returns the flag builder")
178+
@Test
179+
void returnsFlagBuilder() {
180+
// Then
181+
assertThat(flagBuilder.failOnWarnings(someBoolean()))
182+
.isSameAs(flagBuilder);
183+
}
151184
}
152185

153186
@DisplayName(".showDeprecationWarnings(boolean) tests")
@@ -173,6 +206,14 @@ void doesNotAddFlagIfFalse() {
173206
// Then
174207
assertThat(flagBuilder.build()).doesNotContain("-deprecation");
175208
}
209+
210+
@DisplayName(".showDeprecationWarnings(...) returns the flag builder")
211+
@Test
212+
void returnsFlagBuilder() {
213+
// Then
214+
assertThat(flagBuilder.showDeprecationWarnings(someBoolean()))
215+
.isSameAs(flagBuilder);
216+
}
176217
}
177218

178219
@DisplayName(".release(String) tests")
@@ -199,6 +240,14 @@ void doesNotAddFlagIfNotPresent() {
199240
// Then
200241
assertThat(flagBuilder.build()).doesNotContain("--release");
201242
}
243+
244+
@DisplayName(".release(...) returns the flag builder")
245+
@Test
246+
void returnsFlagBuilder() {
247+
// Then
248+
assertThat(flagBuilder.release(someRelease()))
249+
.isSameAs(flagBuilder);
250+
}
202251
}
203252

204253
@DisplayName(".source(String) tests")
@@ -225,6 +274,15 @@ void doesNotAddFlagIfNotPresent() {
225274
// Then
226275
assertThat(flagBuilder.build()).doesNotContain("-source");
227276
}
277+
278+
279+
@DisplayName(".source(...) returns the flag builder")
280+
@Test
281+
void returnsFlagBuilder() {
282+
// Then
283+
assertThat(flagBuilder.source(someRelease()))
284+
.isSameAs(flagBuilder);
285+
}
228286
}
229287

230288
@DisplayName(".target(String) tests")
@@ -251,42 +309,88 @@ void doesNotAddFlagIfNotPresent() {
251309
// Then
252310
assertThat(flagBuilder.build()).doesNotContain("-target");
253311
}
312+
313+
@DisplayName(".target(...) returns the flag builder")
314+
@Test
315+
void returnsFlagBuilder() {
316+
// Then
317+
assertThat(flagBuilder.target(someRelease()))
318+
.isSameAs(flagBuilder);
319+
}
254320
}
255321

256-
@DisplayName("Setting .annotationProcessorOptions(List<String>) adds the options")
257-
@Test
258-
void addsAnnotationProcessorOptions() {
259-
// Given
260-
var options = Stream
261-
.generate(Fixtures::someText)
262-
.limit(5)
263-
.collect(Collectors.toList());
322+
@DisplayName(".addAnnotationProcessorOptions(List<String>) tests")
323+
@Nested
324+
class AnnotationProcessorOptionsTest {
264325

265-
// When
266-
flagBuilder.annotationProcessorOptions(options);
326+
@DisplayName("Setting .annotationProcessorOptions(List<String>) adds the options")
327+
@Test
328+
void addsAnnotationProcessorOptions() {
329+
// Given
330+
var options = Stream
331+
.generate(Fixtures::someText)
332+
.limit(5)
333+
.collect(Collectors.toList());
267334

268-
// Then
269-
assertThat(flagBuilder.build())
270-
.containsSequence(options.stream()
271-
.map("-A"::concat)
272-
.collect(Collectors.toList()));
335+
// When
336+
flagBuilder.annotationProcessorOptions(options);
337+
338+
// Then
339+
assertThat(flagBuilder.build())
340+
.containsSequence(options.stream()
341+
.map("-A"::concat)
342+
.collect(Collectors.toList()));
343+
}
344+
345+
@DisplayName(".annotationProcessorOptions(...) returns the flag builder")
346+
@Test
347+
void returnsFlagBuilder() {
348+
// Given
349+
var options = Stream
350+
.generate(Fixtures::someText)
351+
.limit(5)
352+
.collect(Collectors.toList());
353+
354+
// Then
355+
assertThat(flagBuilder.annotationProcessorOptions(options))
356+
.isSameAs(flagBuilder);
357+
}
273358
}
274359

275-
@DisplayName("Setting .compilerOptions(List<String>) adds the options")
276-
@Test
277-
void addsCompilerOptions() {
278-
// Given
279-
var options = Stream
280-
.generate(Fixtures::someText)
281-
.limit(5)
282-
.collect(Collectors.toList());
360+
@DisplayName(".compilerOptions(List<String>) tests")
361+
@Nested
362+
class CompilerOptionsTest {
283363

284-
// When
285-
flagBuilder.compilerOptions(options);
364+
@DisplayName("Setting .compilerOptions(List<String>) adds the options")
365+
@Test
366+
void addsCompilerOptions() {
367+
// Given
368+
var options = Stream
369+
.generate(Fixtures::someText)
370+
.limit(5)
371+
.collect(Collectors.toList());
286372

287-
// Then
288-
assertThat(flagBuilder.build())
289-
.containsSequence(options);
373+
// When
374+
flagBuilder.compilerOptions(options);
375+
376+
// Then
377+
assertThat(flagBuilder.build())
378+
.containsSequence(options);
379+
}
380+
381+
@DisplayName(".compilerOptions(...) returns the flag builder")
382+
@Test
383+
void returnsFlagBuilder() {
384+
// Given
385+
var options = Stream
386+
.generate(Fixtures::someText)
387+
.limit(5)
388+
.collect(Collectors.toList());
389+
390+
// Then
391+
assertThat(flagBuilder.compilerOptions(options))
392+
.isSameAs(flagBuilder);
393+
}
290394
}
291395

292396
@Order(Integer.MAX_VALUE - 1)

0 commit comments

Comments
 (0)