|
19 | 19 | import static com.hedera.block.protos.BlockStreamService.*;
|
20 | 20 | import static com.hedera.block.server.BlockStreamService.buildSingleBlockNotAvailableResponse;
|
21 | 21 | import static com.hedera.block.server.BlockStreamService.buildSingleBlockNotFoundResponse;
|
| 22 | +import static com.hedera.block.server.Constants.*; |
22 | 23 | import static com.hedera.block.server.util.PersistTestUtils.generateBlockItems;
|
23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
24 | 25 | import static org.junit.jupiter.api.Assertions.fail;
|
|
36 | 37 | import com.hedera.block.server.persistence.storage.BlockWriter;
|
37 | 38 | import com.hedera.block.server.producer.ItemAckBuilder;
|
38 | 39 | import com.hedera.block.server.util.TestUtils;
|
| 40 | +import io.grpc.stub.ServerCalls; |
39 | 41 | import io.grpc.stub.StreamObserver;
|
40 | 42 | import io.helidon.config.Config;
|
41 | 43 | import io.helidon.config.MapConfigSource;
|
|
47 | 49 | import java.util.List;
|
48 | 50 | import java.util.Map;
|
49 | 51 | import java.util.Optional;
|
| 52 | +import java.util.function.BiConsumer; |
| 53 | + |
| 54 | +import io.helidon.webserver.Routing; |
| 55 | +import io.helidon.webserver.grpc.GrpcService; |
50 | 56 | import org.junit.jupiter.api.AfterEach;
|
51 | 57 | import org.junit.jupiter.api.BeforeEach;
|
52 | 58 | import org.junit.jupiter.api.Test;
|
@@ -246,6 +252,25 @@ public void testSingleBlockIOExceptionPath() throws IOException {
|
246 | 252 | verify(responseObserver, times(1)).onNext(expectedNotAvailable);
|
247 | 253 | }
|
248 | 254 |
|
| 255 | + @Test |
| 256 | + public void testUpdateInvokesRoutingWithLambdas() { |
| 257 | + |
| 258 | + final BlockStreamService blockStreamService = |
| 259 | + new BlockStreamService( |
| 260 | + TIMEOUT_THRESHOLD_MILLIS, |
| 261 | + itemAckBuilder, |
| 262 | + streamMediator, |
| 263 | + blockPersistenceHandler, |
| 264 | + serviceStatus); |
| 265 | + |
| 266 | + GrpcService.Routing routing = mock(GrpcService.Routing.class); |
| 267 | + blockStreamService.update(routing); |
| 268 | + |
| 269 | + verify(routing, timeout(50).times(1)).bidi(eq(CLIENT_STREAMING_METHOD_NAME), any(ServerCalls.BidiStreamingMethod.class)); |
| 270 | + verify(routing, timeout(50).times(1)).serverStream(eq(SERVER_STREAMING_METHOD_NAME), any(ServerCalls.ServerStreamingMethod.class)); |
| 271 | + verify(routing, timeout(50).times(1)).unary(eq(SINGLE_BLOCK_METHOD_NAME), any(ServerCalls.UnaryMethod.class)); |
| 272 | + } |
| 273 | + |
249 | 274 | private BlockPersistenceHandler<BlockItem, Block> buildBlockPersistenceHandler()
|
250 | 275 | throws IOException {
|
251 | 276 | BlockReader<Block> blockReader = new BlockAsDirReader(JUNIT, testConfig);
|
|
0 commit comments