21
21
22
22
import static internal .heylogs .URLExtractor .urlOf ;
23
23
import static java .util .Collections .singletonList ;
24
- import static nbbrd .heylogs .Filter .builder ;
25
24
import static nbbrd .heylogs .Heylogs .FIRST_FORMAT_AVAILABLE ;
26
25
import static nbbrd .heylogs .spi .RuleSeverity .ERROR ;
26
+ import static nbbrd .io .function .IOFunction .unchecked ;
27
27
import static org .assertj .core .api .Assertions .*;
28
28
import static org .assertj .core .api .InstanceOfAssertFactories .list ;
29
29
import static tests .heylogs .api .Sample .using ;
@@ -62,13 +62,9 @@ public void testCheckFormat() {
62
62
public void testExtractVersions () {
63
63
Heylogs x = Heylogs .ofServiceLoader ();
64
64
65
- Function <Filter , String > usingMain = extractor -> {
66
- Document doc = using ("/Main.md" );
67
- x .extractVersions (doc , extractor );
68
- return FlexmarkIO .newFormatter ().render (doc );
69
- };
65
+ Function <Filter , String > usingMain = extractor -> extractVersionsToString (x , using ("/Main.md" ), extractor );
70
66
71
- assertThat (builder ().ref ("1.1.0" ).build ())
67
+ assertThat (Filter . builder ().ref ("1.1.0" ).build ())
72
68
.extracting (usingMain , STRING )
73
69
.isEqualTo (
74
70
"## [1.1.0] - 2019-02-15\n " +
@@ -86,14 +82,14 @@ public void testExtractVersions() {
86
82
"\n " +
87
83
"[1.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...v1.1.0\n " );
88
84
89
- assertThat (builder ().ref ("1.1.0" ).ignoreContent (true ).build ())
85
+ assertThat (Filter . builder ().ref ("1.1.0" ).ignoreContent (true ).build ())
90
86
.extracting (usingMain , STRING )
91
87
.isEqualTo (
92
88
"## [1.1.0] - 2019-02-15\n " +
93
89
"\n " +
94
90
"[1.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...v1.1.0\n " );
95
91
96
- assertThat (builder ().ref ("zzz" ).build ())
92
+ assertThat (Filter . builder ().ref ("zzz" ).build ())
97
93
.extracting (usingMain , STRING )
98
94
.isEmpty ();
99
95
}
@@ -260,9 +256,14 @@ public void testFormatStatus() throws IOException {
260
256
);
261
257
}
262
258
259
+ private static String extractVersionsToString (Heylogs heylogs , Document doc , Filter extractor ) {
260
+ heylogs .extractVersions (doc , extractor );
261
+ return unchecked (FlexmarkIO .newTextFormatter ()::formatToString ).apply (doc );
262
+ }
263
+
263
264
private static String releaseChangesToString (Heylogs heylogs , Document doc , Version version ) {
264
265
heylogs .releaseChanges (doc , version , "v" );
265
- return FlexmarkIO .newFormatter (). render (doc );
266
+ return unchecked ( FlexmarkIO .newTextFormatter ():: formatToString ). apply (doc );
266
267
}
267
268
268
269
private static final class MockedRule implements Rule {
0 commit comments