-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added test for documented properties * resolved autocompletion clash
- Loading branch information
1 parent
0c92439
commit 6049fa0
Showing
16 changed files
with
88 additions
and
26 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
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
60 changes: 60 additions & 0 deletions
60
doc/src/test/java/com/mastercard/test/flow/doc/PropertyTest.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,60 @@ | ||
package com.mastercard.test.flow.doc; | ||
|
||
import static org.junit.Assert.fail; | ||
import static org.junit.jupiter.api.DynamicTest.dynamicTest; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.DynamicTest; | ||
import org.junit.jupiter.api.TestFactory; | ||
|
||
import com.mastercard.test.flow.assrt.AssertionOptions; | ||
import com.mastercard.test.flow.assrt.filter.FilterOptions; | ||
import com.mastercard.test.flow.report.QuietFiles; | ||
|
||
/** | ||
* Checks the correctness of things that look like system properties in our | ||
* documentation | ||
*/ | ||
@SuppressWarnings("static-method") | ||
class PropertyTest { | ||
|
||
private static final Pattern PROPERTY = Pattern.compile( "(mctf\\.[a-z._]+)" ); | ||
|
||
/** | ||
* @return per-file tests that throw a wobbler if we find an invalid property | ||
*/ | ||
@TestFactory | ||
Stream<DynamicTest> markdown() { | ||
|
||
Set<String> validProperties = new TreeSet<>(); | ||
Stream.of( AssertionOptions.values() ).forEach( o -> validProperties.add( o.property() ) ); | ||
Stream.of( FilterOptions.values() ).forEach( o -> validProperties.add( o.property() ) ); | ||
|
||
return Util.markdownFiles() | ||
.map( mdFile -> dynamicTest( | ||
mdFile.toString(), | ||
() -> checkProperties( mdFile, validProperties ) ) ); | ||
} | ||
|
||
private static void checkProperties( Path file, Set<String> validProperties ) { | ||
QuietFiles.lines( file ) | ||
.forEach( line -> { | ||
Matcher mtch = PROPERTY.matcher( line ); | ||
while( mtch.find() ) { | ||
if( !validProperties.contains( mtch.group( 1 ) ) ) { | ||
fail( String.format( | ||
"Line\n '%s'\ncontains unknown property '%s'. Valid values are\n %s", | ||
line, mtch.group( 1 ), | ||
validProperties.stream().collect( Collectors.joining( "\n " ) ) ) ); | ||
} | ||
} | ||
} ); | ||
} | ||
} |
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
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