33
33
import com .datastax .oss .driver .api .testinfra .simulacron .SimulacronRule ;
34
34
import com .datastax .oss .driver .categories .ParallelizableTests ;
35
35
import com .datastax .oss .simulacron .common .cluster .ClusterSpec ;
36
+ import java .util .Objects ;
36
37
import org .junit .Before ;
37
38
import org .junit .BeforeClass ;
38
39
import org .junit .ClassRule ;
@@ -93,18 +94,20 @@ public static void setup() {
93
94
for (Node node : SESSION_RULE .session ().getMetadata ().getNodes ().values ()) {
94
95
// if node is in dc2 it should be ignored, otherwise (dc1, dc3) it should be local.
95
96
NodeDistance expectedDistance =
96
- node .getDatacenter (). equals ( "dc2" ) ? NodeDistance .IGNORED : NodeDistance .LOCAL ;
97
+ Objects . equals ( node .getDatacenter (), "dc2" ) ? NodeDistance .IGNORED : NodeDistance .LOCAL ;
97
98
assertThat (node .getDistance ()).isEqualTo (expectedDistance );
98
99
}
99
100
}
100
101
101
102
@ Test
102
103
public void should_use_policy_from_request_profile () {
103
104
// Since profile1 uses dc3 as localDC, only those nodes should receive these queries.
104
- Statement statement = QUERY .setExecutionProfileName ("profile1" );
105
+ Statement <?> statement = QUERY .setExecutionProfileName ("profile1" );
105
106
for (int i = 0 ; i < 10 ; i ++) {
106
107
ResultSet result = SESSION_RULE .session ().execute (statement );
107
- assertThat (result .getExecutionInfo ().getCoordinator ().getDatacenter ()).isEqualTo ("dc3" );
108
+ Node coordinator = result .getExecutionInfo ().getCoordinator ();
109
+ assertThat (coordinator ).isNotNull ();
110
+ assertThat (coordinator .getDatacenter ()).isEqualTo ("dc3" );
108
111
}
109
112
110
113
assertQueryInDc (0 , 0 );
@@ -115,10 +118,12 @@ public void should_use_policy_from_request_profile() {
115
118
@ Test
116
119
public void should_use_policy_from_config_when_not_configured_in_request_profile () {
117
120
// Since profile2 does not define an lbp config, it should use default which uses dc1.
118
- Statement statement = QUERY .setExecutionProfileName ("profile2" );
121
+ Statement <?> statement = QUERY .setExecutionProfileName ("profile2" );
119
122
for (int i = 0 ; i < 10 ; i ++) {
120
123
ResultSet result = SESSION_RULE .session ().execute (statement );
121
- assertThat (result .getExecutionInfo ().getCoordinator ().getDatacenter ()).isEqualTo ("dc1" );
124
+ Node coordinator = result .getExecutionInfo ().getCoordinator ();
125
+ assertThat (coordinator ).isNotNull ();
126
+ assertThat (coordinator .getDatacenter ()).isEqualTo ("dc1" );
122
127
}
123
128
124
129
assertQueryInDc (0 , 5 );
0 commit comments