|
3 | 3 | *
|
4 | 4 | * The use of this file is governed by the Business Source License,
|
5 | 5 | * as detailed in the file "/LICENSE.S3Stream" included in this repository.
|
| 6 | + * |
6 | 7 | * As of the Change Date specified in that file, in accordance with
|
7 | 8 | * the Business Source License, use of this software will be governed
|
8 | 9 | * by the Apache License, Version 2.0
|
9 | 10 | */
|
| 11 | + |
10 | 12 | package com.automq.stream.s3.operator;
|
11 | 13 |
|
12 | 14 | import com.google.common.collect.EvictingQueue;
|
|
18 | 20 | import java.lang.reflect.Field;
|
19 | 21 |
|
20 | 22 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
21 |
| -import static org.mockito.Mockito.*; |
| 23 | +import static org.mockito.Mockito.mock; |
| 24 | +import static org.mockito.Mockito.verify; |
| 25 | +import static org.mockito.Mockito.when; |
22 | 26 |
|
23 | 27 | @Tag("S3Unit")
|
24 | 28 | class TrafficRegulatorTest {
|
@@ -184,8 +188,13 @@ void testRegulateFailureDoesNotRecordSuccess() {
|
184 | 188 | assertTrue(queue.isEmpty(), "Queue should be empty as failure occurred");
|
185 | 189 | }
|
186 | 190 |
|
| 191 | + @SuppressWarnings("unchecked") |
187 | 192 | private EvictingQueue<Double> getSuccessRateQueue() {
|
188 |
| - return (EvictingQueue<Double>) getField(regulator, "successRateQueue"); |
| 193 | + Object field = getField(regulator, "successRateQueue"); |
| 194 | + if (field instanceof EvictingQueue) { |
| 195 | + return (EvictingQueue<Double>) field; |
| 196 | + } |
| 197 | + throw new IllegalStateException("Field 'successRateQueue' is not of expected type EvictingQueue<Double>"); |
189 | 198 | }
|
190 | 199 |
|
191 | 200 | /**
|
|
0 commit comments