28
28
import com .couchbase .client .core .endpoint .EndpointState ;
29
29
import com .couchbase .client .core .service .ServiceType ;
30
30
import com .couchbase .client .java .Cluster ;
31
+ import com .couchbase .client .java .ReactiveCluster ;
31
32
import org .junit .jupiter .api .Test ;
33
+ import reactor .core .publisher .Mono ;
32
34
33
35
import org .springframework .boot .actuate .health .Health ;
34
36
import org .springframework .boot .actuate .health .Status ;
@@ -53,13 +55,15 @@ void couchbaseClusterIsUp() {
53
55
new EndpointDiagnostics (ServiceType .KV , EndpointState .CONNECTED , "127.0.0.1" , "127.0.0.1" ,
54
56
Optional .empty (), Optional .of (1234L ), Optional .of ("endpoint-1" ), Optional .empty ())));
55
57
DiagnosticsResult diagnostics = new DiagnosticsResult (endpoints , "test-sdk" , "test-id" );
56
- given (cluster .diagnostics ()).willReturn (diagnostics );
58
+ ReactiveCluster reactiveCluster = mock (ReactiveCluster .class );
59
+ given (reactiveCluster .diagnostics ()).willReturn (Mono .just (diagnostics ));
60
+ given (cluster .reactive ()).willReturn (reactiveCluster );
57
61
Health health = healthIndicator .health ().block (Duration .ofSeconds (30 ));
58
62
assertThat (health .getStatus ()).isEqualTo (Status .UP );
59
63
assertThat (health .getDetails ()).containsEntry ("sdk" , "test-sdk" );
60
64
assertThat (health .getDetails ()).containsKey ("endpoints" );
61
65
assertThat ((List <Map <String , Object >>) health .getDetails ().get ("endpoints" )).hasSize (1 );
62
- then (cluster ).should ().diagnostics ();
66
+ then (reactiveCluster ).should ().diagnostics ();
63
67
}
64
68
65
69
@ Test
@@ -74,13 +78,15 @@ void couchbaseClusterIsDown() {
74
78
new EndpointDiagnostics (ServiceType .KV , EndpointState .CONNECTING , "127.0.0.1" , "127.0.0.1" ,
75
79
Optional .empty (), Optional .of (1234L ), Optional .of ("endpoint-2" ), Optional .empty ())));
76
80
DiagnosticsResult diagnostics = new DiagnosticsResult (endpoints , "test-sdk" , "test-id" );
77
- given (cluster .diagnostics ()).willReturn (diagnostics );
81
+ ReactiveCluster reactiveCluster = mock (ReactiveCluster .class );
82
+ given (reactiveCluster .diagnostics ()).willReturn (Mono .just (diagnostics ));
83
+ given (cluster .reactive ()).willReturn (reactiveCluster );
78
84
Health health = healthIndicator .health ().block (Duration .ofSeconds (30 ));
79
85
assertThat (health .getStatus ()).isEqualTo (Status .DOWN );
80
86
assertThat (health .getDetails ()).containsEntry ("sdk" , "test-sdk" );
81
87
assertThat (health .getDetails ()).containsKey ("endpoints" );
82
88
assertThat ((List <Map <String , Object >>) health .getDetails ().get ("endpoints" )).hasSize (2 );
83
- then (cluster ).should ().diagnostics ();
89
+ then (reactiveCluster ).should ().diagnostics ();
84
90
}
85
91
86
92
}
0 commit comments