Skip to content

Instantly share code, notes, and snippets.

@mgodave
Created November 18, 2024 16:57
Show Gist options
  • Save mgodave/dcff4574f0b70cb39c3bd97a859565ac to your computer and use it in GitHub Desktop.
Save mgodave/dcff4574f0b70cb39c3bd97a859565ac to your computer and use it in GitHub Desktop.
339a340,352
> }
>
> /**
> * Create a new instance.
> *
> * @param service a service to handle incoming requests
> */
> public ServiceFactory(final BlockingTesterService service) {
> this(new Builder().testBlocking(service).testBiDiStreamBlocking(service).testResponseStreamBlocking(service).testRequestStreamBlocking(service));
> }
>
> private ServiceFactory(final Builder builder) {
> super(builder);
387,395d399
< */
< public ServiceFactory(final BlockingTesterService service) {
< this(new Builder().testBlocking(service).testBiDiStreamBlocking(service).testResponseStreamBlocking(service).testRequestStreamBlocking(service));
< }
<
< /**
< * Create a new instance.
< *
< * @param service a service to handle incoming requests
431,434d434
< }
<
< private ServiceFactory(final Builder builder) {
< super(builder);
438,439d437
< private final List<ContentCodec> supportedMessageCodings;
<
443a442,443
> private final List<ContentCodec> supportedMessageCodings;
>
805,810d804
< return this;
< }
<
< public Builder addService(final TesterService service) {
< Objects.requireNonNull(service);
< registerRoutes(service);
825a820,828
> public Builder addService(final TesterService service) {
> Objects.requireNonNull(service);
> test(service);
> testBiDiStream(service);
> testResponseStream(service);
> testRequestStream(service);
> return this;
> }
>
858,861c861,864
< test = routes.routeFor(TestRpc.PATH);
< testBiDiStream = routes.streamingRouteFor(TestBiDiStreamRpc.PATH);
< testResponseStream = routes.responseStreamingRouteFor(TestResponseStreamRpc.PATH);
< testRequestStream = routes.requestStreamingRouteFor(TestRequestStreamRpc.PATH);
---
> test = routes.routeFor(TestRpc.methodDescriptor().httpPath());
> testBiDiStream = routes.streamingRouteFor(TestBiDiStreamRpc.methodDescriptor().httpPath());
> testResponseStream = routes.responseStreamingRouteFor(TestResponseStreamRpc.methodDescriptor().httpPath());
> testRequestStream = routes.requestStreamingRouteFor(TestRequestStreamRpc.methodDescriptor().httpPath());
920,923d922
< public TestMetadata(final ContentCodec requestEncoding) {
< super(TestRpc.PATH, requestEncoding);
< }
<
931a931,934
> public TestMetadata(final ContentCodec requestEncoding) {
> super(TestRpc.PATH, requestEncoding);
> }
>
962,965d964
< public TestBiDiStreamMetadata(final ContentCodec requestEncoding) {
< super(TestBiDiStreamRpc.PATH, requestEncoding);
< }
<
973a973,976
> public TestBiDiStreamMetadata(final ContentCodec requestEncoding) {
> super(TestBiDiStreamRpc.PATH, requestEncoding);
> }
>
1004,1007d1006
< public TestResponseStreamMetadata(final ContentCodec requestEncoding) {
< super(TestResponseStreamRpc.PATH, requestEncoding);
< }
<
1015a1015,1018
> public TestResponseStreamMetadata(final ContentCodec requestEncoding) {
> super(TestResponseStreamRpc.PATH, requestEncoding);
> }
>
1046,1049d1048
< public TestRequestStreamMetadata(final ContentCodec requestEncoding) {
< super(TestRequestStreamRpc.PATH, requestEncoding);
< }
<
1057a1057,1060
> public TestRequestStreamMetadata(final ContentCodec requestEncoding) {
> super(TestRequestStreamRpc.PATH, requestEncoding);
> }
>
1077d1079
< * @deprecated Use {@link #test(GrpcClientMetadata,TestRequest)}.
1082,1084c1084,1085
< @Deprecated
< default Single<TestResponse> test(TestMetadata metadata, TestRequest request) {
< return Single.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating to an alternative method or implement this method if it's required temporarily."));
---
> default Single<TestResponse> test(GrpcClientMetadata metadata, TestRequest request) {
> return test(new TestMetadata(metadata), request);
1087a1089
> * @deprecated Use {@link #test(GrpcClientMetadata,TestRequest)}.
1092,1093c1094,1096
< default Single<TestResponse> test(GrpcClientMetadata metadata, TestRequest request) {
< return test(new TestMetadata(metadata), request);
---
> @Deprecated
> default Single<TestResponse> test(TestMetadata metadata, TestRequest request) {
> return Single.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating Consider migrating to an alternative method or implement this method if it's required temporarily."));
1103d1105
< * @deprecated Use {@link #testBiDiStream(GrpcClientMetadata,Publisher)}.
1108,1109c1110
< @Deprecated
< default Publisher<TestResponse> testBiDiStream(TestBiDiStreamMetadata metadata,
---
> default Publisher<TestResponse> testBiDiStream(GrpcClientMetadata metadata,
1111c1112
< return Publisher.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating to an alternative method or implement this method if it's required temporarily."));
---
> return testBiDiStream(new TestBiDiStreamMetadata(metadata), request);
1114a1116
> * @deprecated Use {@link #testBiDiStream(GrpcClientMetadata,Publisher)}.
1119c1121,1122
< default Publisher<TestResponse> testBiDiStream(GrpcClientMetadata metadata,
---
> @Deprecated
> default Publisher<TestResponse> testBiDiStream(TestBiDiStreamMetadata metadata,
1121c1124
< return testBiDiStream(new TestBiDiStreamMetadata(metadata), request);
---
> return Publisher.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating Consider migrating to an alternative method or implement this method if it's required temporarily."));
1131d1133
< * @deprecated Use {@link #testResponseStream(GrpcClientMetadata,TestRequest)}.
1136,1137c1138
< @Deprecated
< default Publisher<TestResponse> testResponseStream(TestResponseStreamMetadata metadata,
---
> default Publisher<TestResponse> testResponseStream(GrpcClientMetadata metadata,
1139c1140
< return Publisher.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating to an alternative method or implement this method if it's required temporarily."));
---
> return testResponseStream(new TestResponseStreamMetadata(metadata), request);
1142a1144
> * @deprecated Use {@link #testResponseStream(GrpcClientMetadata,TestRequest)}.
1147c1149,1150
< default Publisher<TestResponse> testResponseStream(GrpcClientMetadata metadata,
---
> @Deprecated
> default Publisher<TestResponse> testResponseStream(TestResponseStreamMetadata metadata,
1149c1152
< return testResponseStream(new TestResponseStreamMetadata(metadata), request);
---
> return Publisher.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating Consider migrating to an alternative method or implement this method if it's required temporarily."));
1159d1161
< * @deprecated Use {@link #testRequestStream(GrpcClientMetadata,Publisher)}.
1164,1165c1166
< @Deprecated
< default Single<TestResponse> testRequestStream(TestRequestStreamMetadata metadata,
---
> default Single<TestResponse> testRequestStream(GrpcClientMetadata metadata,
1167c1168
< return Single.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating to an alternative method or implement this method if it's required temporarily."));
---
> return testRequestStream(new TestRequestStreamMetadata(metadata), request);
1170a1172
> * @deprecated Use {@link #testRequestStream(GrpcClientMetadata,Publisher)}.
1175c1177,1178
< default Single<TestResponse> testRequestStream(GrpcClientMetadata metadata,
---
> @Deprecated
> default Single<TestResponse> testRequestStream(TestRequestStreamMetadata metadata,
1177c1180
< return testRequestStream(new TestRequestStreamMetadata(metadata), request);
---
> return Single.failed(new UnsupportedOperationException("This method is not implemented by " + getClass() + ". Consider migrating Consider migrating to an alternative method or implement this method if it's required temporarily."));
1351d1353
< @Deprecated
1353,1354c1355,1356
< public TestResponse test(final TestMetadata metadata, final TestRequest request) throws
< Exception {
---
> public TestResponse test(final GrpcClientMetadata metadata, final TestRequest request)
> throws Exception {
1357a1360
> @Deprecated
1359,1360c1362,1363
< public TestResponse test(final GrpcClientMetadata metadata, final TestRequest request)
< throws Exception {
---
> public TestResponse test(final TestMetadata metadata, final TestRequest request) throws
> Exception {
1370d1372
< @Deprecated
1372c1374
< public BlockingIterable<TestResponse> testBiDiStream(final TestBiDiStreamMetadata metadata,
---
> public BlockingIterable<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
1376a1379
> @Deprecated
1378c1381
< public BlockingIterable<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
---
> public BlockingIterable<TestResponse> testBiDiStream(final TestBiDiStreamMetadata metadata,
1389d1391
< @Deprecated
1391,1393c1393,1394
< public BlockingIterable<TestResponse> testResponseStream(
< final TestResponseStreamMetadata metadata, final TestRequest request) throws
< Exception {
---
> public BlockingIterable<TestResponse> testResponseStream(final GrpcClientMetadata metadata,
> final TestRequest request) throws Exception {
1396a1398
> @Deprecated
1398,1399c1400,1402
< public BlockingIterable<TestResponse> testResponseStream(final GrpcClientMetadata metadata,
< final TestRequest request) throws Exception {
---
> public BlockingIterable<TestResponse> testResponseStream(
> final TestResponseStreamMetadata metadata, final TestRequest request) throws
> Exception {
1409d1411
< @Deprecated
1411c1413
< public TestResponse testRequestStream(final TestRequestStreamMetadata metadata,
---
> public TestResponse testRequestStream(final GrpcClientMetadata metadata,
1415a1418
> @Deprecated
1417c1420
< public TestResponse testRequestStream(final GrpcClientMetadata metadata,
---
> public TestResponse testRequestStream(final TestRequestStreamMetadata metadata,
1437,1438d1439
< private final List<ContentCodec> supportedMessageCodings;
<
1440a1442,1443
> private final List<ContentCodec> supportedMessageCodings;
>
1452d1454
< this.factory = factory;
1453a1456
> this.factory = factory;
1518,1524c1521
< public Single<TestResponse> test(final TestRequest request) {
< return test(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestMetadata(), request);
< }
<
< @Deprecated
< @Override
< public Single<TestResponse> test(final TestMetadata metadata,
---
> public Single<TestResponse> test(final GrpcClientMetadata metadata,
1530a1528
> @Deprecated
1532c1530
< public Single<TestResponse> test(final GrpcClientMetadata metadata,
---
> public Single<TestResponse> test(final TestMetadata metadata,
1540,1541c1538,1539
< public Publisher<TestResponse> testBiDiStream(final Publisher<TestRequest> request) {
< return testBiDiStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestBiDiStreamMetadata(), request);
---
> public Single<TestResponse> test(final TestRequest request) {
> return test(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestMetadata(), request);
1544d1541
< @Deprecated
1546c1543
< public Publisher<TestResponse> testBiDiStream(final TestBiDiStreamMetadata metadata,
---
> public Publisher<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
1552a1550
> @Deprecated
1554c1552
< public Publisher<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
---
> public Publisher<TestResponse> testBiDiStream(final TestBiDiStreamMetadata metadata,
1562,1563c1560,1561
< public Publisher<TestResponse> testResponseStream(final TestRequest request) {
< return testResponseStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestResponseStreamMetadata(), request);
---
> public Publisher<TestResponse> testBiDiStream(final Publisher<TestRequest> request) {
> return testBiDiStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestBiDiStreamMetadata(), request);
1566d1563
< @Deprecated
1568,1569c1565,1566
< public Publisher<TestResponse> testResponseStream(
< final TestResponseStreamMetadata metadata, final TestRequest request) {
---
> public Publisher<TestResponse> testResponseStream(final GrpcClientMetadata metadata,
> final TestRequest request) {
1574a1572
> @Deprecated
1576,1577c1574,1575
< public Publisher<TestResponse> testResponseStream(final GrpcClientMetadata metadata,
< final TestRequest request) {
---
> public Publisher<TestResponse> testResponseStream(
> final TestResponseStreamMetadata metadata, final TestRequest request) {
1584,1585c1582,1583
< public Single<TestResponse> testRequestStream(final Publisher<TestRequest> request) {
< return testRequestStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestRequestStreamMetadata(), request);
---
> public Publisher<TestResponse> testResponseStream(final TestRequest request) {
> return testResponseStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestResponseStreamMetadata(), request);
1588d1585
< @Deprecated
1590c1587
< public Single<TestResponse> testRequestStream(final TestRequestStreamMetadata metadata,
---
> public Single<TestResponse> testRequestStream(final GrpcClientMetadata metadata,
1596a1594
> @Deprecated
1598c1596
< public Single<TestResponse> testRequestStream(final GrpcClientMetadata metadata,
---
> public Single<TestResponse> testRequestStream(final TestRequestStreamMetadata metadata,
1603a1602,1606
>
> @Override
> public Single<TestResponse> testRequestStream(final Publisher<TestRequest> request) {
> return testRequestStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestRequestStreamMetadata(), request);
> }
1609,1610d1611
< private final List<ContentCodec> supportedMessageCodings;
<
1612a1614,1615
> private final List<ContentCodec> supportedMessageCodings;
>
1624d1626
< this.factory = factory;
1625a1628
> this.factory = factory;
1670,1671c1673,1677
< public TestResponse test(final TestRequest request) throws Exception {
< return test(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestMetadata(), request);
---
> public TestResponse test(final GrpcClientMetadata metadata, final TestRequest request)
> throws Exception {
> Objects.requireNonNull(metadata);
> Objects.requireNonNull(request);
> return testCall.request(metadata, request);
1684,1688c1690,1691
< public TestResponse test(final GrpcClientMetadata metadata, final TestRequest request)
< throws Exception {
< Objects.requireNonNull(metadata);
< Objects.requireNonNull(request);
< return testCall.request(metadata, request);
---
> public TestResponse test(final TestRequest request) throws Exception {
> return test(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestMetadata(), request);
1692c1695
< public BlockingIterable<TestResponse> testBiDiStream(
---
> public BlockingIterable<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
1694c1697,1699
< return testBiDiStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestBiDiStreamMetadata(), request);
---
> Objects.requireNonNull(metadata);
> Objects.requireNonNull(request);
> return testBiDiStreamCall.request(metadata, request);
1708c1713
< public BlockingIterable<TestResponse> testBiDiStream(final GrpcClientMetadata metadata,
---
> public BlockingIterable<TestResponse> testBiDiStream(
1710,1712c1715
< Objects.requireNonNull(metadata);
< Objects.requireNonNull(request);
< return testBiDiStreamCall.request(metadata, request);
---
> return testBiDiStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestBiDiStreamMetadata(), request);
1716,1722d1718
< public BlockingIterable<TestResponse> testResponseStream(final TestRequest request)
< throws Exception {
< return testResponseStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestResponseStreamMetadata(), request);
< }
<
< @Deprecated
< @Override
1724,1725c1720
< final TestResponseStreamMetadata metadata, final TestRequest request) throws
< Exception {
---
> final GrpcClientMetadata metadata, final TestRequest request) throws Exception {
1730a1726
> @Deprecated
1733c1729,1730
< final GrpcClientMetadata metadata, final TestRequest request) throws Exception {
---
> final TestResponseStreamMetadata metadata, final TestRequest request) throws
> Exception {
1740,1742c1737,1739
< public TestResponse testRequestStream(final Iterable<TestRequest> request) throws
< Exception {
< return testRequestStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestRequestStreamMetadata(), request);
---
> public BlockingIterable<TestResponse> testResponseStream(final TestRequest request)
> throws Exception {
> return testResponseStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestResponseStreamMetadata(), request);
1745d1741
< @Deprecated
1747c1743
< public TestResponse testRequestStream(final TestRequestStreamMetadata metadata,
---
> public TestResponse testRequestStream(final GrpcClientMetadata metadata,
1753a1750
> @Deprecated
1755c1752
< public TestResponse testRequestStream(final GrpcClientMetadata metadata,
---
> public TestResponse testRequestStream(final TestRequestStreamMetadata metadata,
1760a1758,1763
>
> @Override
> public TestResponse testRequestStream(final Iterable<TestRequest> request) throws
> Exception {
> return testRequestStream(supportedMessageCodings.isEmpty() ? new DefaultGrpcClientMetadata() : new TestRequestStreamMetadata(), request);
> }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment