@Test public void getLobby() throws Exception { LobbyBalancer info = (LobbyBalancer) Await.result(Patterns.ask(balancer, RequestInformation.INSTANCE, 1000), FiniteDuration.create("1 second")); for (Map.Entry<ActorRef, Lobby> entry : info.getLobbies().entrySet()) { assertEquals(entry.getValue().getId(), controller.lobby(entry.getValue().getId()).toCompletableFuture().get().getId()); } }
public CompletionStage<Lobby> lobby(String id) { final HttpRequest request = HttpRequest.create() .withUri(client.getBaseUri().addPathSegment("lobbies").addPathSegment(id)) .withMethod(HttpMethods.GET); return client.http().singleRequest(request, client.materializer()) .thenCompose(res -> Jackson.unmarshaller(mapper, Lobby.class) .unmarshall(res.entity(), client.materializer().executionContext(), client.materializer()) ); }
LobbyBalancerController { public CompletionStage<Lobby> lobby(String id) { final HttpRequest request = HttpRequest.create() .withUri(client.getBaseUri().addPathSegment("lobbies").addPathSegment(id)) .withMethod(HttpMethods.GET); return client.http().singleRequest(request, client.materializer()) .thenCompose(res -> Jackson.unmarshaller(mapper, Lobby.class) .unmarshall(res.entity(), client.materializer().executionContext(), client.materializer()) ); } }
LobbyBalancerController { public CompletionStage<Lobby> lobby(String id) { final HttpRequest request = HttpRequest.create() .withUri(client.getBaseUri().addPathSegment("lobbies").addPathSegment(id)) .withMethod(HttpMethods.GET); return client.http().singleRequest(request, client.materializer()) .thenCompose(res -> Jackson.unmarshaller(mapper, Lobby.class) .unmarshall(res.entity(), client.materializer().executionContext(), client.materializer()) ); } LobbyBalancerController(Client client); }
LobbyBalancerController { public CompletionStage<Lobby> lobby(String id) { final HttpRequest request = HttpRequest.create() .withUri(client.getBaseUri().addPathSegment("lobbies").addPathSegment(id)) .withMethod(HttpMethods.GET); return client.http().singleRequest(request, client.materializer()) .thenCompose(res -> Jackson.unmarshaller(mapper, Lobby.class) .unmarshall(res.entity(), client.materializer().executionContext(), client.materializer()) ); } LobbyBalancerController(Client client); CompletionStage<Set<Lobby>> lobbies(); CompletionStage<Set<LobbyController>> controllers(); CompletionStage<Lobby> lobby(String id); CompletionStage<LobbyController> controller(String id); LobbyController controller(Lobby lobby); CompletionStage<LobbyController> find(); }
LobbyBalancerController { public CompletionStage<Lobby> lobby(String id) { final HttpRequest request = HttpRequest.create() .withUri(client.getBaseUri().addPathSegment("lobbies").addPathSegment(id)) .withMethod(HttpMethods.GET); return client.http().singleRequest(request, client.materializer()) .thenCompose(res -> Jackson.unmarshaller(mapper, Lobby.class) .unmarshall(res.entity(), client.materializer().executionContext(), client.materializer()) ); } LobbyBalancerController(Client client); CompletionStage<Set<Lobby>> lobbies(); CompletionStage<Set<LobbyController>> controllers(); CompletionStage<Lobby> lobby(String id); CompletionStage<LobbyController> controller(String id); LobbyController controller(Lobby lobby); CompletionStage<LobbyController> find();  }