use of com.hazelcast.jet.grpc.greeter.GreeterOuterClass.HelloReply in project hazelcast by hazelcast.
the class GrpcServiceTest method when_bidirectionalStreaming_distributed.
@Test
public void when_bidirectionalStreaming_distributed() throws IOException {
// Given
server = createServer(new GreeterServiceImpl());
final int port = server.getPort();
List<String> items = IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString).collect(toList());
Pipeline p = Pipeline.create();
BatchStageWithKey<String, String> stage = p.readFrom(TestSources.items(items)).groupingKey(i -> i);
// When
BatchStage<String> mapped = stage.mapUsingServiceAsync(bidirectionalStreaming(port), (service, key, item) -> {
HelloRequest req = HelloRequest.newBuilder().setName(item).build();
return service.call(req).thenApply(HelloReply::getMessage);
});
// Then
mapped.writeTo(AssertionSinks.assertCollected(e -> {
assertEquals("unexpected number of items received", ITEM_COUNT, e.size());
}));
instance().getJet().newJob(p).join();
}
use of com.hazelcast.jet.grpc.greeter.GreeterOuterClass.HelloReply in project hazelcast by hazelcast.
the class GrpcServiceTest method when_bidirectionalStreaming.
@Test
public void when_bidirectionalStreaming() throws IOException {
// Given
server = createServer(new GreeterServiceImpl());
final int port = server.getPort();
Pipeline p = Pipeline.create();
BatchStage<String> stage = p.readFrom(TestSources.items("one", "two", "three", "four"));
// When
BatchStage<String> mapped = stage.mapUsingServiceAsync(bidirectionalStreaming(port), (service, item) -> {
HelloRequest req = HelloRequest.newBuilder().setName(item).build();
return service.call(req).thenApply(HelloReply::getMessage);
});
// Then
List<String> expected = Arrays.asList("Hello one", "Hello two", "Hello three", "Hello four");
mapped.writeTo(AssertionSinks.assertAnyOrder(expected));
instance().getJet().newJob(p).join();
}
use of com.hazelcast.jet.grpc.greeter.GreeterOuterClass.HelloReply in project hazelcast by hazelcast.
the class GrpcServiceTest method whenNotAsync_unary_distributed.
@Test
public void whenNotAsync_unary_distributed() throws IOException {
// Given
server = createServer(new GreeterServiceImpl());
final int port = server.getPort();
List<String> items = IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString).collect(toList());
Pipeline p = Pipeline.create();
BatchStageWithKey<String, String> stage = p.readFrom(TestSources.items(items)).groupingKey(i -> i);
// When
BatchStage<String> mapped = stage.mapUsingService(unary(port), (service, key, item) -> {
HelloRequest req = HelloRequest.newBuilder().setName(item).build();
return service.call(req).thenApply(HelloReply::getMessage).get();
});
// Then
mapped.writeTo(AssertionSinks.assertCollected(e -> {
assertEquals("unexpected number of items received", ITEM_COUNT, e.size());
}));
instance().getJet().newJob(p).join();
}
Aggregations