Skip to content

Commit 6100e11

Browse files
committed
Add display name annotation
1 parent d418567 commit 6100e11

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

exercises/practice/rate-limiter/src/test/java/RateLimiterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34
import java.time.Duration;
45
import java.time.Instant;
@@ -9,6 +10,7 @@
910
class RateLimiterTest {
1011

1112
@Test
13+
@DisplayName("Allows up to window limit")
1214
void allowsUpToLimit() {
1315
TimeSource clock = new TimeSource(Instant.EPOCH);
1416
RateLimiter<String> limiter = new RateLimiter<>(3, Duration.ofNanos(10_000L), clock);
@@ -23,6 +25,7 @@ void allowsUpToLimit() {
2325

2426
@Disabled("Remove to run test")
2527
@Test
28+
@DisplayName("Denies requests just before boundary")
2629
void denyCloseToBoundary() {
2730
TimeSource clock = new TimeSource(Instant.EPOCH);
2831
RateLimiter<String> limiter = new RateLimiter<>(2, Duration.ofNanos(10_000L), clock);
@@ -38,6 +41,7 @@ void denyCloseToBoundary() {
3841

3942
@Disabled("Remove to run test")
4043
@Test
44+
@DisplayName("Allows first request at exact boundary")
4145
void allowsNewBoundary() {
4246
TimeSource clock = new TimeSource(Instant.EPOCH);
4347
RateLimiter<String> limiter = new RateLimiter<>(2, Duration.ofNanos(10_000L), clock);
@@ -53,6 +57,7 @@ void allowsNewBoundary() {
5357

5458
@Disabled("Remove to run test")
5559
@Test
60+
@DisplayName("Resets at boundary, then counts within window")
5661
void continuesCountingWithinWindowAfterBoundaryReset() {
5762
TimeSource clock = new TimeSource(Instant.EPOCH);
5863
RateLimiter<String> limiter = new RateLimiter<>(2, Duration.ofNanos(5_000L), clock);
@@ -71,6 +76,7 @@ void continuesCountingWithinWindowAfterBoundaryReset() {
7176

7277
@Disabled("Remove to run test")
7378
@Test
79+
@DisplayName("Independent counters/windows per key")
7480
void separateKeysHaveIndependentCountersAndWindows() {
7581
TimeSource clock = new TimeSource(Instant.EPOCH.plusNanos(42L));
7682
RateLimiter<String> limiter = new RateLimiter<>(1, Duration.ofNanos(100L), clock);
@@ -89,6 +95,7 @@ void separateKeysHaveIndependentCountersAndWindows() {
8995

9096
@Disabled("Remove to run test")
9197
@Test
98+
@DisplayName("Long gaps reset window")
9299
void longGapsResetWindow() {
93100
TimeSource clock = new TimeSource(Instant.EPOCH.plusNanos(1_000L));
94101
RateLimiter<String> limiter = new RateLimiter<>(2, Duration.ofNanos(50L), clock);
@@ -107,6 +114,7 @@ void longGapsResetWindow() {
107114

108115
@Disabled("Remove to run test")
109116
@Test
117+
@DisplayName("Exact boundary starts a new window each time")
110118
void exactBoundaryIsNewWindowEveryTime() {
111119
TimeSource clock = new TimeSource(Instant.EPOCH);
112120
RateLimiter<String> limiter = new RateLimiter<>(1, Duration.ofNanos(10L), clock);
@@ -125,6 +133,7 @@ void exactBoundaryIsNewWindowEveryTime() {
125133

126134
@Disabled("Remove to run test")
127135
@Test
136+
@DisplayName("Supports UUID keys with mixed time units")
128137
void supportsUuidKeys() {
129138
TimeSource clock = new TimeSource(Instant.EPOCH);
130139
// Use a seconds-long window and advance in smaller units to mix Duration usage
@@ -148,6 +157,7 @@ void supportsUuidKeys() {
148157

149158
@Disabled("Remove to run test")
150159
@Test
160+
@DisplayName("Supports Integer keys")
151161
void supportsIntegerKeys() {
152162
TimeSource clock = new TimeSource(Instant.EPOCH);
153163
RateLimiter<Integer> limiter = new RateLimiter<>(1, Duration.ofNanos(100L), clock);
@@ -165,6 +175,7 @@ void supportsIntegerKeys() {
165175

166176
@Disabled("Remove to run test")
167177
@Test
178+
@DisplayName("Supports Long keys")
168179
void supportsLongKeys() {
169180
TimeSource clock = new TimeSource(Instant.EPOCH);
170181
RateLimiter<Long> limiter = new RateLimiter<>(2, Duration.ofNanos(50L), clock);

0 commit comments

Comments
 (0)