@@ -121,20 +121,14 @@ public void testToXContentForIndexingStats() throws IOException {
121
121
* This ensures that aggregation (add) always surfaces the maximum value, even across multiple adds and random values.
122
122
*/
123
123
public void testMaxLastIndexRequestTimestampAggregation () throws Exception {
124
- IndexingStats .Stats stats1 = new IndexingStats .Stats ();
125
- IndexingStats .Stats stats2 = new IndexingStats .Stats ();
126
- IndexingStats .Stats stats3 = new IndexingStats .Stats ();
127
- java .lang .reflect .Field tsField = IndexingStats .Stats .class .getDeclaredField ("maxLastIndexRequestTimestamp" );
128
- tsField .setAccessible (true );
129
-
130
- // Use random values for robustness
124
+ // Use explicit values for all fields except the timestamp
125
+ IndexingStats .Stats .DocStatusStats docStatusStats = new IndexingStats .Stats .DocStatusStats ();
131
126
long ts1 = randomLongBetween (0 , 1000000 );
132
127
long ts2 = randomLongBetween (0 , 1000000 );
133
128
long ts3 = randomLongBetween (0 , 1000000 );
134
-
135
- tsField .set (stats1 , ts1 );
136
- tsField .set (stats2 , ts2 );
137
- tsField .set (stats3 , ts3 );
129
+ IndexingStats .Stats stats1 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts1 );
130
+ IndexingStats .Stats stats2 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts2 );
131
+ IndexingStats .Stats stats3 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts3 );
138
132
139
133
// Aggregate stats1 + stats2
140
134
stats1 .add (stats2 );
@@ -145,15 +139,14 @@ public void testMaxLastIndexRequestTimestampAggregation() throws Exception {
145
139
assertEquals (Math .max (Math .max (ts1 , ts2 ), ts3 ), stats1 .getMaxLastIndexRequestTimestamp ());
146
140
147
141
// Test with zero and negative values
148
- tsField .set (stats1 , 0L );
149
- tsField .set (stats2 , -100L );
150
- stats1 .add (stats2 );
151
- assertEquals (0L , stats1 .getMaxLastIndexRequestTimestamp ());
152
-
153
- tsField .set (stats1 , -50L );
154
- tsField .set (stats2 , -100L );
155
- stats1 .add (stats2 );
156
- assertEquals (-50L , stats1 .getMaxLastIndexRequestTimestamp ());
142
+ IndexingStats .Stats statsZero = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , 0L );
143
+ IndexingStats .Stats statsNeg = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , -100L );
144
+ statsZero .add (statsNeg );
145
+ assertEquals (0L , statsZero .getMaxLastIndexRequestTimestamp ());
146
+
147
+ IndexingStats .Stats statsNeg2 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , -50L );
148
+ statsNeg .add (statsNeg2 );
149
+ assertEquals (-50L , statsNeg .getMaxLastIndexRequestTimestamp ());
157
150
}
158
151
159
152
private IndexingStats createTestInstance () {
0 commit comments