Search in sources :

Example 6 with Request

use of com.spotify.apollo.Request in project apollo by spotify.

the class ClientDecoratorTest method shouldBindDecoratedClient.

@Test
public void shouldBindDecoratedClient() throws Exception {
    try (Service.Instance i = service.build().start()) {
        Client client = ApolloEnvironmentModule.environment(i).environment().client();
        Request request = Request.forUri("http://example.com/");
        Request withService = request.withService("ping");
        client.send(request);
        verify(mockClient).send(eq(withService), eq(empty()));
    } catch (IOException e) {
        fail();
    }
}
Also used : Request(com.spotify.apollo.Request) Service(com.spotify.apollo.core.Service) IOException(java.io.IOException) Client(com.spotify.apollo.Client) Test(org.junit.Test)

Example 7 with Request

use of com.spotify.apollo.Request in project apollo by spotify.

the class RequestStepdefs method aRequestToFromHasBeenCompleted.

@And("^a request to \"([^\"]*)\" from \"([^\"]*)\" has been completed$")
public void aRequestToFromHasBeenCompleted(String uri, String callingService) throws Throwable {
    Request request = Request.forUri(uri).withService(callingService);
    assertThat(ServiceStepdefs.serviceHelper.request(request).toCompletableFuture().get(), hasStatus(withCode(OK)));
}
Also used : Request(com.spotify.apollo.Request) And(cucumber.api.java.en.And)

Example 8 with Request

use of com.spotify.apollo.Request in project apollo by spotify.

the class StubClient method formatRequestNotMatchedExceptionMessage.

private String formatRequestNotMatchedExceptionMessage(final Request request) {
    final AnyOf<Request> anyOfMatcher = Matchers.anyOf(mappings.stream().map(p -> p.requestMatcher).collect(toList()));
    final Description description = new StringDescription();
    anyOfMatcher.describeTo(description);
    final Description mismatchDescription = new StringDescription();
    anyOfMatcher.describeMismatch(request, mismatchDescription);
    return "Could not find any mapping for " + request.uri() + "\n" + "Expected: " + description + "\n" + "but: " + mismatchDescription.toString();
}
Also used : StringDescription(org.hamcrest.StringDescription) Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) Request(com.spotify.apollo.Request)

Example 9 with Request

use of com.spotify.apollo.Request in project apollo by spotify.

the class OutgoingCallsGatheringClientTest method shouldGatherCallsWithServiceFromAuthority.

@Test
public void shouldGatherCallsWithServiceFromAuthority() throws Exception {
    Request request = Request.forUri("http://bowman/path/to/file");
    client.send(request, empty());
    verify(delegate).send(eq(request), eq(empty()));
    verify(callsGatherer).gatherOutgoingCall(eq("bowman"), eq(request));
}
Also used : Request(com.spotify.apollo.Request) Test(org.junit.Test)

Example 10 with Request

use of com.spotify.apollo.Request in project apollo by spotify.

the class RuleRouterTest method shouldThrowInvalidUriExceptionForBadPlaylistMosaicUri.

@Test
public void shouldThrowInvalidUriExceptionForBadPlaylistMosaicUri() throws Exception {
    Rule<Integer> rule = Rule.fromUri("/user/<baz>/playlist/<boo>", "GET", TARGET);
    final RuleRouter<Integer> router = RuleRouter.of(ImmutableList.of(rule));
    final Request message = Request.forUri("/user/%c3%a8hYh%ae%8d%c9%21%d4A%c4%bd8+7/playlist/56S6B5rXio3Q2MQltr7ZJk", "GET");
    thrown.expect(InvalidUriException.class);
    router.match(message);
}
Also used : Request(com.spotify.apollo.Request) Test(org.junit.Test)

Aggregations

Request (com.spotify.apollo.Request)33 Test (org.junit.Test)21 ByteString (okio.ByteString)14 Client (com.spotify.apollo.Client)3 Response (com.spotify.apollo.Response)3 IOException (java.io.IOException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 RequestContext (com.spotify.apollo.RequestContext)2 Album (com.spotify.apollo.example.data.Album)2 Artist (com.spotify.apollo.example.data.Artist)2 AsyncHandler (com.spotify.apollo.route.AsyncHandler)2 JsonSerializerMiddlewares (com.spotify.apollo.route.JsonSerializerMiddlewares)2 Route (com.spotify.apollo.route.Route)2 ArrayList (java.util.ArrayList)2 CompletionStage (java.util.concurrent.CompletionStage)2 Stream (java.util.stream.Stream)2 Before (org.junit.Before)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1