@@ -390,6 +390,120 @@ private void shouldGetOnlineFeaturesRangeWithClient(FeastClient client) {
390390 assertEquals (new HashMap <String , List <FieldStatus >>() {}, rows .get (0 ).getStatuses ());
391391 }
392392
393+ @ Test
394+ public void shouldCreateClientWithStub () throws Exception {
395+ String serverName = InProcessServerBuilder .generateName ();
396+ this .grpcRule .register (
397+ InProcessServerBuilder .forName (serverName )
398+ .directExecutor ()
399+ .addService (this .servingMock )
400+ .build ()
401+ .start ());
402+
403+ ManagedChannel channel =
404+ this .grpcRule .register (
405+ InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
406+
407+ feast .proto .serving .ServingServiceGrpc .ServingServiceBlockingStub stub =
408+ feast .proto .serving .ServingServiceGrpc .newBlockingStub (channel );
409+
410+ FeastClient client = FeastClient .createWithStub (stub );
411+ shouldGetOnlineFeaturesFeatureRef (client );
412+ client .close ();
413+ }
414+
415+ @ Test
416+ public void shouldCreateClientWithStubAndTimeout () throws Exception {
417+ String serverName = InProcessServerBuilder .generateName ();
418+ this .grpcRule .register (
419+ InProcessServerBuilder .forName (serverName )
420+ .directExecutor ()
421+ .addService (this .servingMock )
422+ .build ()
423+ .start ());
424+
425+ ManagedChannel channel =
426+ this .grpcRule .register (
427+ InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
428+
429+ feast .proto .serving .ServingServiceGrpc .ServingServiceBlockingStub stub =
430+ feast .proto .serving .ServingServiceGrpc .newBlockingStub (channel );
431+
432+ FeastClient client = FeastClient .createWithStub (stub , TIMEOUT_MILLIS );
433+ shouldGetOnlineFeaturesFeatureService (client );
434+ client .close ();
435+ }
436+
437+ @ Test
438+ public void shouldCreateClientWithStubAndCredentials () throws Exception {
439+ String serverName = InProcessServerBuilder .generateName ();
440+ this .grpcRule .register (
441+ InProcessServerBuilder .forName (serverName )
442+ .directExecutor ()
443+ .addService (this .servingMock )
444+ .build ()
445+ .start ());
446+
447+ ManagedChannel channel =
448+ this .grpcRule .register (
449+ InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
450+
451+ feast .proto .serving .ServingServiceGrpc .ServingServiceBlockingStub stub =
452+ feast .proto .serving .ServingServiceGrpc .newBlockingStub (channel );
453+
454+ FeastClient client = FeastClient .createWithStub (stub , Optional .empty (), TIMEOUT_MILLIS );
455+ shouldGetOnlineFeaturesWithoutStatus (client );
456+ client .close ();
457+ }
458+
459+ @ Test
460+ public void shouldGetOnlineFeaturesRangeWithStub () throws Exception {
461+ String serverName = InProcessServerBuilder .generateName ();
462+ this .grpcRule .register (
463+ InProcessServerBuilder .forName (serverName )
464+ .directExecutor ()
465+ .addService (this .servingMock )
466+ .build ()
467+ .start ());
468+
469+ ManagedChannel channel =
470+ this .grpcRule .register (
471+ InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
472+
473+ feast .proto .serving .ServingServiceGrpc .ServingServiceBlockingStub stub =
474+ feast .proto .serving .ServingServiceGrpc .newBlockingStub (channel );
475+
476+ FeastClient client = FeastClient .createWithStub (stub );
477+ shouldGetOnlineFeaturesRangeWithClient (client );
478+ client .close ();
479+ }
480+
481+ @ Test
482+ public void shouldThrowExceptionForNegativeTimeout () {
483+ String serverName = InProcessServerBuilder .generateName ();
484+ try {
485+ this .grpcRule .register (
486+ InProcessServerBuilder .forName (serverName )
487+ .directExecutor ()
488+ .addService (this .servingMock )
489+ .build ()
490+ .start ());
491+
492+ ManagedChannel channel =
493+ this .grpcRule .register (
494+ InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
495+
496+ feast .proto .serving .ServingServiceGrpc .ServingServiceBlockingStub stub =
497+ feast .proto .serving .ServingServiceGrpc .newBlockingStub (channel );
498+
499+ IllegalArgumentException exception =
500+ assertThrows (IllegalArgumentException .class , () -> FeastClient .createWithStub (stub , -1 ));
501+ assertEquals ("Request timeout can't be negative" , exception .getMessage ());
502+ } catch (Exception e ) {
503+ throw new RuntimeException (e );
504+ }
505+ }
506+
393507 private static GetOnlineFeaturesRequest getFakeOnlineFeaturesRefRequest () {
394508 // setup mock serving service stub
395509 return GetOnlineFeaturesRequest .newBuilder ()
0 commit comments