1919
2020package org .elasticsearch .test .integration .gateway .local ;
2121
22- import org .elasticsearch .test .hamcrest .ElasticsearchAssertions ;
23-
2422import org .elasticsearch .action .count .CountResponse ;
2523
2624import org .elasticsearch .action .admin .cluster .health .ClusterHealthResponse ;
@@ -98,7 +96,7 @@ public void testX() throws Exception {
9896 .startArray ("appAccountIds" ).value (14 ).endArray ().endObject ()).execute ().actionGet ();
9997
10098 node1 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
101- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("appAccountIds" , 179 )).execute ().actionGet (). getCount (), equalTo ( 2l ) );
99+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("appAccountIds" , 179 )).execute ().actionGet (), 2 );
102100
103101 closeNode ("node1" );
104102 node1 = startNode ("node1" , settingsBuilder ().put ("gateway.type" , "local" ).build ());
@@ -112,7 +110,7 @@ public void testX() throws Exception {
112110 node1 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
113111 CountResponse count = node1 .client ().prepareCount ().setQuery (termQuery ("appAccountIds" , 179 )).execute ().actionGet ();
114112 assertNoFailures (count );
115- assertThat (count . getCount (), equalTo ( 2l ) );
113+ assertHitCount (count , 2 );
116114
117115 closeNode ("node1" );
118116 node1 = startNode ("node1" , settingsBuilder ().put ("gateway.type" , "local" ).build ());
@@ -126,7 +124,7 @@ public void testX() throws Exception {
126124 node1 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
127125 count = node1 .client ().prepareCount ().setQuery (termQuery ("appAccountIds" , 179 )).execute ().actionGet ();
128126 assertNoFailures (count );
129- assertThat (count . getCount (), equalTo ( 2l ) );
127+ assertHitCount (count , 2 );
130128 }
131129
132130 @ Test
@@ -148,10 +146,10 @@ public void testSingleNodeNoFlush() throws Exception {
148146
149147 node1 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
150148 for (int i = 0 ; i < 10 ; i ++) {
151- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
152- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
153- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
154- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
149+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
150+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (), 1 );
151+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (), 1 );
152+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (), 1 );
155153 }
156154
157155 closeNode ("node1" );
@@ -164,10 +162,10 @@ public void testSingleNodeNoFlush() throws Exception {
164162 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .YELLOW ));
165163
166164 for (int i = 0 ; i < 10 ; i ++) {
167- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
168- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
169- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
170- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
165+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
166+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (), 1 );
167+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (), 1 );
168+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (), 1 );
171169 }
172170
173171 closeNode ("node1" );
@@ -180,10 +178,10 @@ public void testSingleNodeNoFlush() throws Exception {
180178 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .YELLOW ));
181179
182180 for (int i = 0 ; i < 10 ; i ++) {
183- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
184- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
185- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
186- assertThat (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (). getCount (), equalTo ( 1l ) );
181+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
182+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value1" )).execute ().actionGet (), 1 );
183+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("field" , "value2" )).execute ().actionGet (), 1 );
184+ assertHitCount (node1 .client ().prepareCount ().setQuery (termQuery ("num" , 179 )).execute ().actionGet (), 1 );
187185 }
188186 }
189187
@@ -199,7 +197,7 @@ public void testSingleNodeWithFlush() throws Exception {
199197 node1 .client ().prepareIndex ("test" , "type1" , "2" ).setSource (jsonBuilder ().startObject ().field ("field" , "value2" ).endObject ()).execute ().actionGet ();
200198 node1 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
201199
202- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
200+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
203201
204202 closeNode ("node1" );
205203 node1 = startNode ("node1" , settingsBuilder ().put ("gateway.type" , "local" ).build ());
@@ -211,7 +209,7 @@ public void testSingleNodeWithFlush() throws Exception {
211209 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .YELLOW ));
212210
213211 for (int i = 0 ; i < 10 ; i ++) {
214- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
212+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
215213 }
216214
217215 closeNode ("node1" );
@@ -224,7 +222,7 @@ public void testSingleNodeWithFlush() throws Exception {
224222 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .YELLOW ));
225223
226224 for (int i = 0 ; i < 10 ; i ++) {
227- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
225+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
228226 }
229227 }
230228
@@ -250,7 +248,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception {
250248 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .GREEN ));
251249
252250 for (int i = 0 ; i < 10 ; i ++) {
253- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
251+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
254252 }
255253
256254 logger .info ("--> closing nodes" );
@@ -271,7 +269,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception {
271269 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .GREEN ));
272270
273271 for (int i = 0 ; i < 10 ; i ++) {
274- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
272+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
275273 }
276274 }
277275
@@ -297,7 +295,7 @@ public void testLatestVersionLoaded() throws Exception {
297295 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .GREEN ));
298296
299297 for (int i = 0 ; i < 10 ; i ++) {
300- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 2l ) );
298+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 2 );
301299 }
302300
303301 logger .info ("--> closing first node, and indexing more data to the second node" );
@@ -307,7 +305,7 @@ public void testLatestVersionLoaded() throws Exception {
307305 node2 .client ().admin ().indices ().prepareRefresh ().execute ().actionGet ();
308306
309307 for (int i = 0 ; i < 10 ; i ++) {
310- assertThat (node2 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 3l ) );
308+ assertHitCount (node2 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 3 );
311309 }
312310
313311 logger .info ("--> add some metadata, additional type and template" );
@@ -340,7 +338,7 @@ public void testLatestVersionLoaded() throws Exception {
340338 assertThat (clusterHealth .getStatus (), equalTo (ClusterHealthStatus .GREEN ));
341339
342340 for (int i = 0 ; i < 10 ; i ++) {
343- assertThat (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 3l ) );
341+ assertHitCount (node1 .client ().prepareCount ().setQuery (matchAllQuery ()).execute ().actionGet (), 3 );
344342 }
345343
346344 ClusterState state = node1 .client ().admin ().cluster ().prepareState ().execute ().actionGet ().getState ();
@@ -459,7 +457,7 @@ public void testRecoveryDifferentNodeOrderStartup() throws Exception {
459457 assertThat (health .isTimedOut (), equalTo (false ));
460458
461459 assertThat (client ("node2" ).admin ().indices ().prepareExists ("test" ).execute ().actionGet ().isExists (), equalTo (true ));
462- assertThat (client ("node2" ).prepareCount ("test" ).setQuery (QueryBuilders .matchAllQuery ()).execute ().actionGet (). getCount (), equalTo ( 1l ) );
460+ assertHitCount (client ("node2" ).prepareCount ("test" ).setQuery (QueryBuilders .matchAllQuery ()).execute ().actionGet (), 1 );
463461 }
464462
465463}
0 commit comments