@Test public void onPOSTInitThenItSynchronouslyInitRaftService() throws Exception { CompletableFuture<Raft.StateType> future = CompletableFuture.completedFuture(Raft.StateType.START); when(raftService.init()).thenReturn(future); assertThat(client().target("/init").request().post(Entity.json("")).readEntity(Raft.StateType.class)).isEqualTo( Raft.StateType.START); }
@Path("/init") @POST public Raft.StateType init() { try { return raft.init().get(); } catch (Exception e) { throw new RuntimeException(e); } }
BargeResource { @Path("/init") @POST public Raft.StateType init() { try { return raft.init().get(); } catch (Exception e) { throw new RuntimeException(e); } } }
BargeResource { @Path("/init") @POST public Raft.StateType init() { try { return raft.init().get(); } catch (Exception e) { throw new RuntimeException(e); } } @Inject  BargeResource(Raft raft, ClusterConfig clusterConfig); }
BargeResource { @Path("/init") @POST public Raft.StateType init() { try { return raft.init().get(); } catch (Exception e) { throw new RuntimeException(e); } } @Inject  BargeResource(Raft raft, ClusterConfig clusterConfig); @Path("/init") @POST Raft.StateType init(); @Path("/config") @GET ClusterConfig config(); @Path("/state") @GET Raft.StateType state(); @Path("/vote") @POST RequestVoteResponse requestVote(RequestVote vote); @Path("/entries") @POST AppendEntriesResponse appendEntries(AppendEntries appendEntries); @Path("/commit") @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response commit(byte[] operation); }
BargeResource { @Path("/init") @POST public Raft.StateType init() { try { return raft.init().get(); } catch (Exception e) { throw new RuntimeException(e); } } @Inject  BargeResource(Raft raft, ClusterConfig clusterConfig); @Path("/init") @POST Raft.StateType init(); @Path("/config") @GET ClusterConfig config(); @Path("/state") @GET Raft.StateType state(); @Path("/vote") @POST RequestVoteResponse requestVote(RequestVote vote); @Path("/entries") @POST AppendEntriesResponse appendEntries(AppendEntries appendEntries); @Path("/commit") @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response commit(byte[] operation);  }