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.web.reactive.function.client.WebClient;
15 import reactor.core.publisher.Mono;
16 import reactor.test.StepVerifier;
23 public class GraphApiExchangeFilterFunctionIntegrationTest
25 private static final Logger LOG =
26 LoggerFactory.getLogger(GraphApiExchangeFilterFunctionIntegrationTest.class);
28 private MockWebServer server;
29 private WebClient webClient;
35 server = new MockWebServer();
39 .baseUrl(server.url("/").toString())
40 .filter(GraphApiExchangeFilterFunction.INSTANCE)
45 public void shutdown() throws Exception
47 this.server.shutdown();
52 public void testValidError()
54 LOG.info("testValidError");
58 .enqueue(new MockResponse()
60 .setHeader("Content-Type", "application/json")
65 " \"message\": \"(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.\",\n" +
66 " \"type\": \"OAuthException\",\n" +
77 .bodyToMono(String.class);
81 .expectErrorSatisfies(throwable ->
83 assertEquals(RateLimitExceededException.class, throwable.getClass());
84 RateLimitExceededException e = (RateLimitExceededException)throwable;
85 LOG.debug("{}", e.toString());
86 assertEquals(new Integer(613), e.getCode());
87 assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage());
88 assertEquals(Type.OAuthException, e.getType());
90 .verify(Duration.ofSeconds(3));