Skip to content

Commit

Permalink
Update unit test to use delegatesTo() with the mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
DNVindhya committed Dec 20, 2024
1 parent 812b902 commit 2fc06df
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions xds/src/test/java/io/grpc/xds/XdsClientMetricReporterImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.grpc.xds;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.AdditionalAnswers.delegatesTo;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -82,14 +83,14 @@ public class XdsClientMetricReporterImplTest {
@Rule
public final MockitoRule mocks = MockitoJUnit.rule();

@Mock
private MetricRecorder mockMetricRecorder;
@Mock
private XdsClient mockXdsClient;
@Mock
private BatchRecorder mockBatchRecorder;
@Captor
private ArgumentCaptor<BatchCallback> gaugeBatchCallbackCaptor;
private MetricRecorder mockMetricRecorder = mock(MetricRecorder.class,
delegatesTo(new MetricRecorderImpl()));
private BatchRecorder mockBatchRecorder = mock(BatchRecorder.class,
delegatesTo(new BatchRecorderImpl()));

private XdsClientMetricReporterImpl reporter;

Expand Down Expand Up @@ -372,6 +373,12 @@ public boolean matches(T instrument) {
});
}

static class MetricRecorderImpl implements MetricRecorder {
}

static class BatchRecorderImpl implements BatchRecorder {
}

static class TestlogHandler extends Handler {
List<LogRecord> logs = new ArrayList<>();

Expand Down

0 comments on commit 2fc06df

Please sign in to comment.