19
19
20
20
package org .elasticsearch .test .rest .yaml .section ;
21
21
22
+ import org .elasticsearch .Version ;
22
23
import org .elasticsearch .common .logging .DeprecationLogger ;
23
24
import org .elasticsearch .common .xcontent .XContent ;
24
25
import org .elasticsearch .common .xcontent .XContentLocation ;
@@ -44,7 +45,7 @@ public void testWarningHeaders() throws IOException {
44
45
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
45
46
46
47
// No warning headers doesn't throw an exception
47
- section .checkWarningHeaders (emptyList ());
48
+ section .checkWarningHeaders (emptyList (), Version . CURRENT );
48
49
}
49
50
50
51
final String testHeader = DeprecationLogger .formatWarning ("test" );
@@ -55,13 +56,12 @@ public void testWarningHeaders() throws IOException {
55
56
{
56
57
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
57
58
58
- final AssertionError one = expectThrows (AssertionError .class , () -> section .checkWarningHeaders (singletonList (testHeader )));
59
+ final AssertionError one = expectThrows (AssertionError .class , () ->
60
+ section .checkWarningHeaders (singletonList (testHeader ), Version .CURRENT ));
59
61
assertEquals ("got unexpected warning header [\n \t " + testHeader + "\n ]\n " , one .getMessage ());
60
62
61
- final AssertionError multiple =
62
- expectThrows (
63
- AssertionError .class ,
64
- () -> section .checkWarningHeaders (Arrays .asList (testHeader , anotherHeader , someMoreHeader )));
63
+ final AssertionError multiple = expectThrows (AssertionError .class , () ->
64
+ section .checkWarningHeaders (Arrays .asList (testHeader , anotherHeader , someMoreHeader ), Version .CURRENT ));
65
65
assertEquals (
66
66
"got unexpected warning headers [\n \t " +
67
67
testHeader + "\n \t " +
@@ -74,39 +74,40 @@ public void testWarningHeaders() throws IOException {
74
74
{
75
75
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
76
76
section .setExpectedWarningHeaders (singletonList ("test" ));
77
- section .checkWarningHeaders (singletonList (testHeader ));
77
+ section .checkWarningHeaders (singletonList (testHeader ), Version . CURRENT );
78
78
}
79
79
{
80
80
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
81
81
section .setExpectedWarningHeaders (Arrays .asList ("test" , "another" , "some more" ));
82
- section .checkWarningHeaders (Arrays .asList (testHeader , anotherHeader , someMoreHeader ));
82
+ section .checkWarningHeaders (Arrays .asList (testHeader , anotherHeader , someMoreHeader ), Version . CURRENT );
83
83
}
84
84
85
85
// But if you don't get some that you did expect, that is an error
86
86
{
87
87
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
88
88
section .setExpectedWarningHeaders (singletonList ("test" ));
89
- final AssertionError e = expectThrows (AssertionError .class , () -> section .checkWarningHeaders (emptyList ()));
89
+ final AssertionError e = expectThrows (AssertionError .class , () -> section .checkWarningHeaders (emptyList (), Version . CURRENT ));
90
90
assertEquals ("did not get expected warning header [\n \t test\n ]\n " , e .getMessage ());
91
91
}
92
92
{
93
93
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
94
94
section .setExpectedWarningHeaders (Arrays .asList ("test" , "another" , "some more" ));
95
95
96
- final AssertionError multiple = expectThrows (AssertionError .class , () -> section .checkWarningHeaders (emptyList ()));
96
+ final AssertionError multiple = expectThrows (AssertionError .class , () ->
97
+ section .checkWarningHeaders (emptyList (), Version .CURRENT ));
97
98
assertEquals ("did not get expected warning headers [\n \t test\n \t another\n \t some more\n ]\n " , multiple .getMessage ());
98
99
99
- final AssertionError one =
100
- expectThrows ( AssertionError . class , () -> section .checkWarningHeaders (Arrays .asList (testHeader , someMoreHeader )));
100
+ final AssertionError one = expectThrows ( AssertionError . class , () ->
101
+ section .checkWarningHeaders (Arrays .asList (testHeader , someMoreHeader ), Version . CURRENT ));
101
102
assertEquals ("did not get expected warning header [\n \t another\n ]\n " , one .getMessage ());
102
103
}
103
104
104
105
// It is also an error if you get some warning you want and some you don't want
105
106
{
106
107
final DoSection section = new DoSection (new XContentLocation (1 , 1 ));
107
108
section .setExpectedWarningHeaders (Arrays .asList ("test" , "another" , "some more" ));
108
- final AssertionError e =
109
- expectThrows ( AssertionError . class , () -> section .checkWarningHeaders (Arrays .asList (testHeader , catHeader )));
109
+ final AssertionError e = expectThrows ( AssertionError . class , () ->
110
+ section .checkWarningHeaders (Arrays .asList (testHeader , catHeader ), Version . CURRENT ));
110
111
assertEquals ("got unexpected warning header [\n \t " +
111
112
catHeader + "\n ]\n " +
112
113
"did not get expected warning headers [\n \t another\n \t some more\n ]\n " ,
0 commit comments