Skip to content

Commit 257644d

Browse files
Fix consul tests (#249)
* Add alreadyLimited to the request context * Fix getRateException
1 parent 63b854e commit 257644d

File tree

1 file changed

+5
-1
lines changed
  • spring-cloud-zuul-ratelimit-core/src/test/java/com/marcosbarbero/cloud/autoconfigure/zuul/ratelimit/config/repository

1 file changed

+5
-1
lines changed

spring-cloud-zuul-ratelimit-core/src/test/java/com/marcosbarbero/cloud/autoconfigure/zuul/ratelimit/config/repository/ConsulRateLimiterTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import com.fasterxml.jackson.databind.ObjectMapper;
1515
import com.google.common.collect.Maps;
1616
import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.Rate;
17+
1718
import java.io.IOException;
1819
import java.util.Base64;
1920
import java.util.Map;
21+
2022
import org.junit.Before;
2123
import org.junit.Test;
2224
import org.mockito.Mock;
@@ -58,7 +60,9 @@ public void testGetRateException() throws IOException {
5860
GetValue getValue = new GetValue();
5961
getValue.setValue("");
6062
when(consulClient.getKVValue(any())).thenReturn(new Response<>(getValue, 1L, true, 1L));
61-
when(objectMapper.readValue(anyString(), eq(Rate.class))).thenThrow(new IOException());
63+
when(objectMapper.readValue(anyString(), eq(Rate.class))).thenAnswer(invocation -> {
64+
throw new IOException();
65+
});
6266
ConsulRateLimiter consulRateLimiter = new ConsulRateLimiter(rateLimiterErrorHandler, consulClient, objectMapper);
6367

6468
Rate rate = consulRateLimiter.getRate("");

0 commit comments

Comments
 (0)