@@ -82,6 +82,21 @@ public void publishEventTest() {
8282 assertTrue (callback .wasCalled );
8383 }
8484
85+ @ Test
86+ public void publishEventNoHotMono () {
87+ SettableFuture <Empty > settableFuture = SettableFuture .create ();
88+ MockCallback <Empty > callback = new MockCallback <Empty >(Empty .newBuilder ().build ());
89+ addCallback (settableFuture , callback , directExecutor ());
90+ when (client .publishEvent (any (DaprProtos .PublishEventEnvelope .class )))
91+ .thenAnswer (c -> {
92+ settableFuture .set (Empty .newBuilder ().build ());
93+ return settableFuture ;
94+ });
95+ adapter .publishEvent ("topic" , "object" );
96+ // Do not call block() on the mono above, so nothing should happen.
97+ assertFalse (callback .wasCalled );
98+ }
99+
85100 @ Test
86101 public void publishEventObjectTest () {
87102 SettableFuture <Empty > settableFuture = SettableFuture .create ();
@@ -145,6 +160,22 @@ public void invokeBindingObjectTest() {
145160 assertTrue (callback .wasCalled );
146161 }
147162
163+ @ Test
164+ public void invokeBindingObjectNoHotMono () {
165+ SettableFuture <Empty > settableFuture = SettableFuture .create ();
166+ MockCallback <Empty > callback = new MockCallback <Empty >(Empty .newBuilder ().build ());
167+ addCallback (settableFuture , callback , directExecutor ());
168+ when (client .invokeBinding (any (DaprProtos .InvokeBindingEnvelope .class )))
169+ .thenAnswer (c -> {
170+ settableFuture .set (Empty .newBuilder ().build ());
171+ return settableFuture ;
172+ });
173+ MyObject event = new MyObject (1 , "Event" );
174+ adapter .invokeBinding ("BindingName" , event );
175+ // Do not call block() on mono above, so nothing should happen.
176+ assertFalse (callback .wasCalled );
177+ }
178+
148179 @ Test (expected = RuntimeException .class )
149180 public void invokeServiceVoidExceptionThrownTest () {
150181 when (client .invokeService (any (DaprProtos .InvokeServiceEnvelope .class )))
@@ -415,6 +446,24 @@ public void invokeServiceNoRequestNoClassBodyTest() throws Exception {
415446 assertTrue (callback .wasCalled );
416447 }
417448
449+ @ Test
450+ public void invokeServiceNoRequestNoHotMono () throws Exception {
451+ String expected = "Value" ;
452+ SettableFuture <DaprProtos .InvokeServiceResponseEnvelope > settableFuture = SettableFuture .create ();
453+ MockCallback <DaprProtos .InvokeServiceResponseEnvelope > callback =
454+ new MockCallback <DaprProtos .InvokeServiceResponseEnvelope >(DaprProtos .InvokeServiceResponseEnvelope .newBuilder ()
455+ .setData (getAny (expected )).build ());
456+ addCallback (settableFuture , callback , directExecutor ());
457+ when (client .invokeService (any (DaprProtos .InvokeServiceEnvelope .class )))
458+ .thenAnswer (c -> {
459+ settableFuture .set (DaprProtos .InvokeServiceResponseEnvelope .newBuilder ().setData (getAny (expected )).build ());
460+ return settableFuture ;
461+ });
462+ adapter .invokeService (Verb .GET , "appId" , "method" , null );
463+ // Do not call block() on mono above, so nothing should happen.
464+ assertFalse (callback .wasCalled );
465+ }
466+
418467 @ Test
419468 public void invokeServiceNoRequestNoClassBodyObjectTest () throws Exception {
420469 MyObject resultObj = new MyObject (1 , "Value" );
@@ -466,13 +515,34 @@ public void getStateStringValueNoOptionsTest() throws IOException {
466515 MockCallback <DaprProtos .GetStateResponseEnvelope > callback = new MockCallback <>(responseEnvelope );
467516 addCallback (settableFuture , callback , directExecutor ());
468517 when (client .getState (any (io .dapr .DaprProtos .GetStateEnvelope .class )))
469- .thenReturn (settableFuture );
518+ .thenReturn (settableFuture );
470519 State <String > keyRequest = buildStateKey (null , key , etag , null );
471520 Mono <State <String >> result = adapter .getState (STATE_STORE_NAME , keyRequest , String .class );
472521 settableFuture .set (responseEnvelope );
473522 assertEquals (expectedState , result .block ());
474523 }
475524
525+ @ Test
526+ public void getStateStringValueNoHotMono () throws IOException {
527+ String etag = "ETag1" ;
528+ String key = "key1" ;
529+ String expectedValue = "Expected state" ;
530+ State <String > expectedState = buildStateKey (expectedValue , key , etag , null );
531+ DaprProtos .GetStateResponseEnvelope responseEnvelope = buildGetStateResponseEnvelope (expectedValue , etag );
532+ SettableFuture <DaprProtos .GetStateResponseEnvelope > settableFuture = SettableFuture .create ();
533+ MockCallback <DaprProtos .GetStateResponseEnvelope > callback = new MockCallback <>(responseEnvelope );
534+ addCallback (settableFuture , callback , directExecutor ());
535+ when (client .getState (any (io .dapr .DaprProtos .GetStateEnvelope .class )))
536+ .thenAnswer (c -> {
537+ settableFuture .set (responseEnvelope );
538+ return settableFuture ;
539+ });
540+ State <String > keyRequest = buildStateKey (null , key , etag , null );
541+ adapter .getState (STATE_STORE_NAME , keyRequest , String .class );
542+ // block() on the mono above is not called, so nothing should happen.
543+ assertFalse (callback .wasCalled );
544+ }
545+
476546 @ Test
477547 public void getStateObjectValueWithOptionsTest () throws IOException {
478548 String etag = "ETag1" ;
@@ -564,20 +634,41 @@ public void deleteStateTest() {
564634 String etag = "ETag1" ;
565635 String key = "key1" ;
566636 StateOptions options = buildStateOptions (StateOptions .Consistency .STRONG , StateOptions .Concurrency .FIRST_WRITE ,
567- Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
637+ Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
568638 SettableFuture <Empty > settableFuture = SettableFuture .create ();
569639 MockCallback <Empty > callback = new MockCallback <>(Empty .newBuilder ().build ());
570640 addCallback (settableFuture , callback , directExecutor ());
571641 when (client .deleteState (any (io .dapr .DaprProtos .DeleteStateEnvelope .class )))
572- .thenReturn (settableFuture );
642+ .thenReturn (settableFuture );
573643 State <String > stateKey = buildStateKey (null , key , etag , options );
574644 Mono <Void > result = adapter .deleteState (STATE_STORE_NAME , stateKey .getKey (), stateKey .getEtag (),
575- stateKey .getOptions ());
645+ stateKey .getOptions ());
576646 settableFuture .set (Empty .newBuilder ().build ());
577647 result .block ();
578648 assertTrue (callback .wasCalled );
579649 }
580650
651+ @ Test
652+ public void deleteStateTestNoHotMono () {
653+ String etag = "ETag1" ;
654+ String key = "key1" ;
655+ StateOptions options = buildStateOptions (StateOptions .Consistency .STRONG , StateOptions .Concurrency .FIRST_WRITE ,
656+ Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
657+ SettableFuture <Empty > settableFuture = SettableFuture .create ();
658+ MockCallback <Empty > callback = new MockCallback <>(Empty .newBuilder ().build ());
659+ addCallback (settableFuture , callback , directExecutor ());
660+ when (client .deleteState (any (io .dapr .DaprProtos .DeleteStateEnvelope .class )))
661+ .thenAnswer (c -> {
662+ settableFuture .set (Empty .newBuilder ().build ());
663+ return settableFuture ;
664+ });
665+ State <String > stateKey = buildStateKey (null , key , etag , options );
666+ Mono <Void > result = adapter .deleteState (STATE_STORE_NAME , stateKey .getKey (), stateKey .getEtag (),
667+ stateKey .getOptions ());
668+ // Do not call result.block(), so nothing should happen.
669+ assertFalse (callback .wasCalled );
670+ }
671+
581672 @ Test
582673 public void deleteStateNoConsistencyTest () {
583674 String etag = "ETag1" ;
@@ -742,13 +833,32 @@ public void saveStateTest() {
742833 addCallback (settableFuture , callback , directExecutor ());
743834 when (client .saveState (any (io .dapr .DaprProtos .SaveStateEnvelope .class ))).thenReturn (settableFuture );
744835 StateOptions options = buildStateOptions (StateOptions .Consistency .STRONG , StateOptions .Concurrency .FIRST_WRITE ,
745- Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
836+ Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
746837 Mono <Void > result = adapter .saveState (STATE_STORE_NAME , key , etag , value , options );
747838 settableFuture .set (Empty .newBuilder ().build ());
748839 result .block ();
749840 assertTrue (callback .wasCalled );
750841 }
751842
843+ @ Test
844+ public void saveStateTestNoHotMono () {
845+ String key = "key1" ;
846+ String etag = "ETag1" ;
847+ String value = "State value" ;
848+ SettableFuture <Empty > settableFuture = SettableFuture .create ();
849+ MockCallback <Empty > callback = new MockCallback <>(Empty .newBuilder ().build ());
850+ addCallback (settableFuture , callback , directExecutor ());
851+ when (client .saveState (any (io .dapr .DaprProtos .SaveStateEnvelope .class ))).thenAnswer (c -> {
852+ settableFuture .set (Empty .newBuilder ().build ());
853+ return settableFuture ;
854+ });
855+ StateOptions options = buildStateOptions (StateOptions .Consistency .STRONG , StateOptions .Concurrency .FIRST_WRITE ,
856+ Duration .ofDays (100 ), 1 , StateOptions .RetryPolicy .Pattern .LINEAR );
857+ Mono <Void > result = adapter .saveState (STATE_STORE_NAME , key , etag , value , options );
858+ // No call to result.block(), so nothing should happen.
859+ assertFalse (callback .wasCalled );
860+ }
861+
752862 @ Test
753863 public void saveStateNoConsistencyTest () {
754864 String key = "key1" ;
0 commit comments