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();
}
}
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)));
}
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();
}
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));
}
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);
}
Aggregations