### Question:
DutyMetrics { public void onAttestationPublished(final UInt64 slot) { final UInt64 currentTime = timeProvider.getTimeInMillis(); final UInt64 expectedTime = calculateExpectedAttestationTimeInMillis(slot); if (currentTime.isGreaterThanOrEqualTo(expectedTime)) { attestationHistogram.recordValue(currentTime.minus(expectedTime).longValue()); } else { attestationHistogram.recordValue(0); } } @VisibleForTesting  DutyMetrics(
      final TimeProvider timeProvider,
      final RecentChainData recentChainData,
      final MetricsHistogram attestationHistogram); static DutyMetrics create(
      final MetricsSystem metricsSystem,
      final TimeProvider timeProvider,
      final RecentChainData recentChainData); void onAttestationPublished(final UInt64 slot);  }### Answer:
@Test void shouldRecordDelayWhenAttestationIsPublishedLate() { final UInt64 slotNumber = UInt64.valueOf(30); final UInt64 expectedAttestationTime = expectedAttestationTime(slotNumber); final int publicationDelay = 575; timeProvider.advanceTimeByMillis(expectedAttestationTime.plus(publicationDelay).longValue()); metrics.onAttestationPublished(UInt64.valueOf(30)); verify(attestationHistogram).recordValue(publicationDelay); }
@Test void shouldRecordZeroDelayWhenAttestationIsPublishedEarly() { final UInt64 slotNumber = UInt64.valueOf(30); final UInt64 expectedAttestationTime = expectedAttestationTime(slotNumber); timeProvider.advanceTimeByMillis(expectedAttestationTime.minus(50).longValue()); metrics.onAttestationPublished(UInt64.valueOf(30)); verify(attestationHistogram).recordValue(0); }