@@ -331,7 +331,7 @@ public void stopCollectingGauges_invalidGaugeCollectionFrequency_appInForeground
331331 }
332332
333333 @ Test
334- public void testGaugeCounterStartsAJobToConsumeTheGeneratedMetrics () {
334+ public void testGaugeCounterStartsAJobToConsumeTheGeneratedMetrics () throws InterruptedException {
335335 PerfSession fakeSession = createTestSession (1 );
336336 testGaugeManager .setApplicationProcessState (ApplicationProcessState .FOREGROUND );
337337 testGaugeManager .startCollectingGauges (fakeSession );
@@ -504,23 +504,17 @@ public void testStopCollectingGaugesCreatesOneLastJobToConsumeAnyPendingMetrics(
504504 testGaugeManager .stopCollectingGauges ();
505505 assertThat (fakeScheduledExecutorService .isEmpty ()).isFalse ();
506506
507- CpuMetricReading fakeCpuMetricReading = createFakeCpuMetricReading (200 , 100 );
508- fakeCpuGaugeCollector .cpuMetricReadings .add (fakeCpuMetricReading );
509-
510- AndroidMemoryReading fakeMemoryMetricReading =
511- createFakeAndroidMetricReading (/* currentUsedAppJavaHeapMemoryKb= */ 23454678 );
512- fakeMemoryGaugeCollector .memoryMetricReadings .add (fakeMemoryMetricReading );
507+ generateMetricsAndIncrementCounter (2 );
513508
514509 assertThat (fakeScheduledExecutorService .getDelayToNextTask (TimeUnit .MILLISECONDS ))
515510 .isEqualTo (TIME_TO_WAIT_BEFORE_FLUSHING_GAUGES_QUEUE_MS );
516511
517512 fakeScheduledExecutorService .simulateSleepExecutingAtMostOneTask ();
518513 GaugeMetric recordedGaugeMetric =
519514 getLastRecordedGaugeMetric (ApplicationProcessState .FOREGROUND );
520- assertThatCpuGaugeMetricWasSentToTransport (
521- testSessionId (1 ), recordedGaugeMetric , fakeCpuMetricReading );
522- assertThatMemoryGaugeMetricWasSentToTransport (
523- testSessionId (1 ), recordedGaugeMetric , fakeMemoryMetricReading );
515+ assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (testSessionId (1 ));
516+
517+ assertThat (GaugeCounter .INSTANCE .count ()).isEqualTo (0 );
524518 }
525519
526520 @ Test
@@ -587,6 +581,7 @@ public void testLogGaugeMetadataLogsAfterApplicationContextIsSet() {
587581 GaugeMetadata recordedGaugeMetadata = recordedGaugeMetric .getGaugeMetadata ();
588582
589583 assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (testSessionId (1 ));
584+ assertThat (recordedGaugeMetadata ).isNotEqualTo (GaugeMetadata .getDefaultInstance ());
590585 }
591586
592587 @ Test
@@ -655,20 +650,4 @@ private GaugeMetric getLastRecordedGaugeMetric(
655650 when (mockTransportManager .isInitialized ()).thenReturn (true );
656651 return argMetric .getValue ();
657652 }
658-
659- private void assertThatCpuGaugeMetricWasSentToTransport (
660- String sessionId , GaugeMetric recordedGaugeMetric , CpuMetricReading ... cpuMetricReadings ) {
661- assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (sessionId );
662- assertThat (recordedGaugeMetric .getCpuMetricReadingsList ())
663- .containsAtLeastElementsIn (cpuMetricReadings );
664- }
665-
666- private void assertThatMemoryGaugeMetricWasSentToTransport (
667- String sessionId ,
668- GaugeMetric recordedGaugeMetric ,
669- AndroidMemoryReading ... androidMetricReadings ) {
670- assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (sessionId );
671- assertThat (recordedGaugeMetric .getAndroidMemoryReadingsList ())
672- .containsAtLeastElementsIn (androidMetricReadings );
673- }
674653}
0 commit comments