@@ -12,11 +12,16 @@ public class PollScaleReportHandleTest {
1212 public void handleResourceExhaustedError () {
1313 // Mock dependencies
1414 Functions .Proc1 <Integer > mockScaleCallback = Mockito .mock (Functions .Proc1 .class );
15+ ScalingTask mockTask = Mockito .mock (ScalingTask .class );
16+ ScalingTask .ScalingDecision mockDecision = Mockito .mock (ScalingTask .ScalingDecision .class );
17+ Mockito .when (mockTask .getScalingDecision ()).thenReturn (mockDecision );
18+ Mockito .when (mockDecision .getPollRequestDeltaSuggestion ()).thenReturn (0 );
1519 PollScaleReportHandle <ScalingTask > handle =
1620 new PollScaleReportHandle <>(1 , 10 , 8 , mockScaleCallback );
1721
1822 // Simulate RESOURCE_EXHAUSTED error
1923 StatusRuntimeException exception = new StatusRuntimeException (Status .RESOURCE_EXHAUSTED );
24+ handle .report (mockTask , null );
2025 handle .report (null , exception );
2126
2227 // Verify target poller count is halved and callback is invoked
@@ -27,10 +32,15 @@ public void handleResourceExhaustedError() {
2732 public void handleGenericError () {
2833 // Mock dependencies
2934 Functions .Proc1 <Integer > mockScaleCallback = Mockito .mock (Functions .Proc1 .class );
35+ ScalingTask mockTask = Mockito .mock (ScalingTask .class );
36+ ScalingTask .ScalingDecision mockDecision = Mockito .mock (ScalingTask .ScalingDecision .class );
37+ Mockito .when (mockTask .getScalingDecision ()).thenReturn (mockDecision );
38+ Mockito .when (mockDecision .getPollRequestDeltaSuggestion ()).thenReturn (0 );
3039 PollScaleReportHandle <ScalingTask > handle =
3140 new PollScaleReportHandle <>(1 , 10 , 5 , mockScaleCallback );
3241
3342 // Simulate a generic error
43+ handle .report (mockTask , null );
3444 handle .report (null , new RuntimeException ("Generic error" ));
3545
3646 // Verify target poller count is decremented and callback is invoked
0 commit comments