-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from muehmar/184-make-warnings-configurable-g…
…lobally Make warnings configurable globally
- Loading branch information
Showing
5 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
plugin/src/test/java/com/github/muehmar/gradle/openapi/dsl/WarningsConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.github.muehmar.gradle.openapi.dsl; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
class WarningsConfigTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("commonAndExplicitFlags") | ||
void withCommonWarnings_when_disableWarningsFlag_then_matchExpected( | ||
Boolean common, Boolean explicit, Boolean expected) { | ||
final WarningsConfig commonWarnings = new WarningsConfig(common, false, false); | ||
|
||
final WarningsConfig explicitWarnings = new WarningsConfig(explicit, false, false); | ||
|
||
final WarningsConfig resultingWarnings = explicitWarnings.withCommonWarnings(commonWarnings); | ||
|
||
assertEquals(expected, resultingWarnings.getDisableWarnings()); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("commonAndExplicitFlags") | ||
void withCommonWarnings_when_failOnWarningsFlag_then_matchExpected( | ||
Boolean common, Boolean explicit, Boolean expected) { | ||
final WarningsConfig commonWarnings = new WarningsConfig(false, common, false); | ||
|
||
final WarningsConfig explicitWarnings = new WarningsConfig(false, explicit, false); | ||
|
||
final WarningsConfig resultingWarnings = explicitWarnings.withCommonWarnings(commonWarnings); | ||
|
||
assertEquals(expected, resultingWarnings.getFailOnWarnings()); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("commonAndExplicitFlags") | ||
void withCommonWarnings_when_failOnUnsupportedValidationFlag_then_matchExpected( | ||
Boolean common, Boolean explicit, Boolean expected) { | ||
final WarningsConfig commonWarnings = new WarningsConfig(false, false, common); | ||
|
||
final WarningsConfig explicitWarnings = new WarningsConfig(false, false, explicit); | ||
|
||
final WarningsConfig resultingWarnings = explicitWarnings.withCommonWarnings(commonWarnings); | ||
|
||
assertEquals(expected, resultingWarnings.getFailOnUnsupportedValidation()); | ||
} | ||
|
||
private static Stream<Arguments> commonAndExplicitFlags() { | ||
return Stream.of( | ||
arguments(null, false, false), | ||
arguments(null, true, true), | ||
arguments(null, null, false), | ||
arguments(false, false, false), | ||
arguments(false, true, true), | ||
arguments(false, null, false), | ||
arguments(true, false, false), | ||
arguments(true, true, true), | ||
arguments(true, null, true)); | ||
} | ||
} |