### Question:
CredentialStuffingRegistry implements ApplicationListener<GlobalCredentialStuffingEvent> { public boolean hasHappenDuringCredentialStuffing(long timestamp) { return credentialStuffingWindows.contains(timestamp); } CredentialStuffingRegistry(final Duration credentialStuffingDuration, final NowSource nowSource); boolean hasHappenDuringCredentialStuffing(long timestamp); boolean isCredentialStuffingActive(); @Override void onApplicationEvent(final GlobalCredentialStuffingEvent event);  }### Answer:
@Test void shouldReturnActiveOnEvent() { final long beforeCredentialStuffingExpires = CS_EVENT_OCCURRENCE_TIME.plus(CS_DURATION).minus(1, SECONDS).toEpochMilli(); handleCSEvent(); final boolean isActive = registry.hasHappenDuringCredentialStuffing(beforeCredentialStuffingExpires); assertTrue(isActive); }
@Test void credentialStuffingShouldExpire() { final long afterCredentialStuffingExpired = CS_EVENT_OCCURRENCE_TIME.plus(CS_DURATION).plus(1, SECONDS).toEpochMilli(); handleCSEvent(); final boolean isActive = registry.hasHappenDuringCredentialStuffing(afterCredentialStuffingExpired); assertFalse(isActive); }