@Test public void shouldHaveLimitGreaterThanZero() { assertThatThrownBy(() -> RequestLimitRule.of(Duration.ofSeconds(1), -1).withName("boom")).isInstanceOf(IllegalArgumentException.class); }
DefaultRequestLimitRulesSupplierTest() { allRules.add(RequestLimitRule.of(Duration.ofSeconds(1), 10).withName("localhostPerSeconds") .matchingKeys("localhost", "127.0.0.1")); allRules.add(RequestLimitRule.of(Duration.ofHours(1), 2000).withName("localhostPerHours") .matchingKeys("localhost", "127.0.0.1")); allRules.add(RequestLimitRule.of(Duration.ofSeconds(1), 5).withName("perSeconds")); allRules.add(RequestLimitRule.of(Duration.ofHours(1), 1000).withName("perHours")); requestLimitRulesSupplier = new DefaultRequestLimitRulesSupplier(allRules); }
@Test void shouldHaveNameOfBoom() { RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5).withName("boom"); assertThat(requestLimitRule.getName()).isEqualTo("boom"); }