use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class RxClientsTest method testRxFlowableClient.
@Test
public void testRxFlowableClient() throws Exception {
// warmup
target("agent").path("flowable").request().get();
final Response response = target("agent").path("flowable").request().get();
response.bufferEntity();
final AgentResponse agentResponse = response.readEntity(AgentResponse.class);
assertThat(agentResponse.getVisited().size(), is(5));
assertThat(agentResponse.getRecommended().size(), is(5));
assertThat(agentResponse.getProcessingTime() > 850, is(true));
assertThat(agentResponse.getProcessingTime() < 4500, is(true));
System.out.println(response.readEntity(String.class));
System.out.println("Processing Time: " + agentResponse.getProcessingTime());
}
use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class RxClientsTest method testRxObservableClient.
@Test
public void testRxObservableClient() throws Exception {
// warmup
target("agent").path("observable").request().get();
final Response response = target("agent").path("observable").request().get();
response.bufferEntity();
final AgentResponse agentResponse = response.readEntity(AgentResponse.class);
assertThat(agentResponse.getVisited().size(), is(5));
assertThat(agentResponse.getRecommended().size(), is(5));
assertThat(agentResponse.getProcessingTime() > 850, is(true));
assertThat(agentResponse.getProcessingTime() < 4500, is(true));
System.out.println(response.readEntity(String.class));
System.out.println("Processing Time: " + agentResponse.getProcessingTime());
}
use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class RxClientsTest method testSyncClient.
@Test
public void testSyncClient() throws Exception {
// warmup
target("agent").path("sync").request().get();
final Response response = target("agent").path("sync").request().get();
response.bufferEntity();
final AgentResponse agentResponse = response.readEntity(AgentResponse.class);
assertThat(agentResponse.getVisited().size(), is(5));
assertThat(agentResponse.getRecommended().size(), is(5));
assertThat(agentResponse.getProcessingTime() > 4500, is(true));
System.out.println(response.readEntity(String.class));
System.out.println("Processing Time: " + agentResponse.getProcessingTime());
}
use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class RxClientsTest method testRxCompletionStageClient.
@Test
public void testRxCompletionStageClient() throws Exception {
// warmup
target("agent").path("completion").request().get();
final Response response = target("agent").path("completion").request().get();
response.bufferEntity();
final AgentResponse agentResponse = response.readEntity(AgentResponse.class);
assertThat(agentResponse.getVisited().size(), is(5));
assertThat(agentResponse.getRecommended().size(), is(5));
assertThat(agentResponse.getProcessingTime() > 850, is(true));
assertThat(agentResponse.getProcessingTime() < 4500, is(true));
System.out.println(response.readEntity(String.class));
System.out.println("Processing Time: " + agentResponse.getProcessingTime());
}
use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class FlowableAgentResource method flowable.
@GET
public void flowable(@Suspended final AsyncResponse async) {
final long time = System.nanoTime();
final Queue<String> errors = new ConcurrentLinkedQueue<>();
Flowable.just(new AgentResponse()).zipWith(visited(errors), (agentResponse, visited) -> {
agentResponse.setVisited(visited);
return agentResponse;
}).zipWith(recommended(errors), (agentResponse, recommendations) -> {
agentResponse.setRecommended(recommendations);
return agentResponse;
}).observeOn(Schedulers.io()).subscribe(agentResponse -> {
agentResponse.setProcessingTime((System.nanoTime() - time) / 1000000);
async.resume(agentResponse);
}, async::resume);
}
Aggregations