divijvaidya commented on code in PR #13705: URL: https://github.com/apache/kafka/pull/13705#discussion_r1199022749
########## core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala: ########## @@ -369,9 +369,12 @@ class ReplicaManagerTest { // Use the second instance of metrics group that is constructed. The first instance is constructed by // ReplicaManager constructor > BrokerTopicStats > BrokerTopicMetrics. val mockMetricsGroup = mockMetricsGroupCtor.constructed.get(1) - verify(mockMetricsGroup, times(9)).newGauge(anyString(), any()) - verify(mockMetricsGroup, times(3)).newMeter(anyString(), anyString(), any(classOf[TimeUnit])) - verify(mockMetricsGroup, times(12)).removeMetric(anyString()) + verify(mockMetricsGroup, times(ReplicaManager.GaugeMetricNames.size)).newGauge(anyString(), any()) + ReplicaManager.GaugeMetricNames.foreach(metricName => verify(mockMetricsGroup).newGauge(ArgumentMatchers.eq(metricName), any())) + verify(mockMetricsGroup, times(ReplicaManager.MeterMetricNames.size)).newMeter(anyString(), anyString(), any(classOf[TimeUnit])) Review Comment: ditto ########## core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala: ########## @@ -369,9 +369,12 @@ class ReplicaManagerTest { // Use the second instance of metrics group that is constructed. The first instance is constructed by // ReplicaManager constructor > BrokerTopicStats > BrokerTopicMetrics. val mockMetricsGroup = mockMetricsGroupCtor.constructed.get(1) - verify(mockMetricsGroup, times(9)).newGauge(anyString(), any()) - verify(mockMetricsGroup, times(3)).newMeter(anyString(), anyString(), any(classOf[TimeUnit])) - verify(mockMetricsGroup, times(12)).removeMetric(anyString()) + verify(mockMetricsGroup, times(ReplicaManager.GaugeMetricNames.size)).newGauge(anyString(), any()) Review Comment: This line could be removed. The line below is verifying that all entries in `GaugeMetricNames` are having a function invocation. ########## core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala: ########## @@ -369,9 +369,12 @@ class ReplicaManagerTest { // Use the second instance of metrics group that is constructed. The first instance is constructed by // ReplicaManager constructor > BrokerTopicStats > BrokerTopicMetrics. val mockMetricsGroup = mockMetricsGroupCtor.constructed.get(1) - verify(mockMetricsGroup, times(9)).newGauge(anyString(), any()) - verify(mockMetricsGroup, times(3)).newMeter(anyString(), anyString(), any(classOf[TimeUnit])) - verify(mockMetricsGroup, times(12)).removeMetric(anyString()) + verify(mockMetricsGroup, times(ReplicaManager.GaugeMetricNames.size)).newGauge(anyString(), any()) + ReplicaManager.GaugeMetricNames.foreach(metricName => verify(mockMetricsGroup).newGauge(ArgumentMatchers.eq(metricName), any())) + verify(mockMetricsGroup, times(ReplicaManager.MeterMetricNames.size)).newMeter(anyString(), anyString(), any(classOf[TimeUnit])) + ReplicaManager.MeterMetricNames.foreach(metricName => verify(mockMetricsGroup).newMeter(ArgumentMatchers.eq(metricName), anyString(), any(classOf[TimeUnit]))) + verify(mockMetricsGroup, times(ReplicaManager.MetricNames.size)).removeMetric(anyString()) Review Comment: ditto -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org