1 package de.juplo.facebook.errors;
4 import de.juplo.facebook.errors.GraphApiException.Type;
5 import java.time.Duration;
6 import okhttp3.mockwebserver.MockResponse;
7 import okhttp3.mockwebserver.MockWebServer;
8 import org.junit.After;
9 import static org.junit.Assert.assertEquals;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14 import org.springframework.http.client.reactive.JettyClientHttpConnector;
15 import org.springframework.web.reactive.function.client.WebClient;
16 import reactor.core.publisher.Mono;
17 import reactor.test.StepVerifier;
24 public class GraphApiExchangeFilterFunctionIntegrationTest
26 private static final Logger LOG =
27 LoggerFactory.getLogger(GraphApiExchangeFilterFunctionIntegrationTest.class);
29 private MockWebServer server;
30 private WebClient webClient;
36 server = new MockWebServer();
40 .clientConnector(new JettyClientHttpConnector())
41 .baseUrl(server.url("/").toString())
42 .filter(GraphApiExchangeFilterFunction.INSTANCE)
47 public void shutdown() throws Exception
49 this.server.shutdown();
54 public void testValidError()
56 LOG.info("testValidError");
60 .enqueue(new MockResponse()
62 .setHeader("Content-Type", "application/json")
67 " \"message\": \"(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.\",\n" +
68 " \"type\": \"OAuthException\",\n" +
79 .bodyToMono(String.class);
83 .expectErrorSatisfies(throwable ->
85 assertEquals(RateLimitExceededException.class, throwable.getClass());
86 RateLimitExceededException e = (RateLimitExceededException)throwable;
87 LOG.debug("{}", e.toString());
88 assertEquals(new Integer(613), e.getCode());
89 assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage());
90 assertEquals(Type.OAuthException, e.getType());
92 .verify(Duration.ofSeconds(3));