9
9
import java .nio .file .Files ;
10
10
import java .nio .file .Path ;
11
11
import java .util .ArrayList ;
12
+ import java .util .Arrays ;
12
13
import java .util .List ;
13
14
import java .util .Objects ;
14
15
@@ -58,9 +59,8 @@ public void testCatIndexWithFewIndices() throws IOException {
58
59
String responseStr = TestHelper .httpEntityToString (response .getEntity ());
59
60
String toolOutput = extractResult (responseStr );
60
61
String [] actualLines = toolOutput .split ("\\ n" );
61
- // plus 2 as there are one line of header and one line of system agent index, but sometimes the ml-config index will be created
62
- // then there will be one more line.
63
- assert actualLines .length == indices .size () + 2 || actualLines .length == indices .size () + 3 ;
62
+ long testIndexCount = Arrays .stream (actualLines ).filter (x -> x .contains ("test" )).count ();
63
+ assert testIndexCount == indices .size ();
64
64
for (String index : indices ) {
65
65
assert Objects .requireNonNull (toolOutput ).contains (index );
66
66
}
@@ -72,7 +72,8 @@ public void testCatIndexWithMoreThan100Indices() throws IOException {
72
72
String responseStr = TestHelper .httpEntityToString (response .getEntity ());
73
73
String toolOutput = extractResult (responseStr );
74
74
String [] actualLines = toolOutput .split ("\\ n" );
75
- assert actualLines .length == indices .size () + 2 || actualLines .length == indices .size () + 3 ;
75
+ long testIndexCount = Arrays .stream (actualLines ).filter (x -> x .contains ("test" )).count ();
76
+ assert testIndexCount == indices .size ();
76
77
for (String index : indices ) {
77
78
assert Objects .requireNonNull (toolOutput ).contains (index );
78
79
}
0 commit comments