4545#include < olp/core/logging/Log.h>
4646#include < olp/core/porting/make_unique.h>
4747#include < olp/core/utils/Dir.h>
48+ #include < olp/dataservice/read/CatalogClient.h>
49+ #include < olp/dataservice/read/CatalogRequest.h>
50+ #include < olp/dataservice/read/CatalogVersionRequest.h>
51+ #include < olp/dataservice/read/DataRequest.h>
52+ #include < olp/dataservice/read/PartitionsRequest.h>
4853#include < olp/dataservice/read/PrefetchTilesRequest.h>
49-
50- #include " olp/dataservice/read/CatalogClient.h"
51- #include " olp/dataservice/read/CatalogRequest.h"
52- #include " olp/dataservice/read/CatalogVersionRequest.h"
53- #include " olp/dataservice/read/DataRequest.h"
54- #include " olp/dataservice/read/PartitionsRequest.h"
55- #include " olp/dataservice/read/model/Catalog.h"
54+ #include < olp/dataservice/read/model/Catalog.h>
55+ #include " Utils.h"
5656
5757using namespace olp ::dataservice::read;
5858using namespace testing ;
@@ -119,14 +119,6 @@ class CatalogClientTest : public ::testing::TestWithParam<CacheType> {
119119 return CustomParameters::getArgument (" dataservice_read_test_catalog" );
120120 }
121121
122- std::string PrintError (const olp::client::ApiError& error) {
123- std::ostringstream result_stream;
124- result_stream << " ERROR: code: " << static_cast <int >(error.GetErrorCode ())
125- << " , status: " << error.GetHttpStatusCode ()
126- << " , message: " << error.GetMessage ();
127- return result_stream.str ();
128- }
129-
130122 template <typename T>
131123 T GetExecutionTime (std::function<T()> func) {
132124 auto start_time = std::chrono::high_resolution_clock::now ();
@@ -157,8 +149,7 @@ TEST_P(CatalogClientTest, GetCatalog) {
157149 return future.GetFuture ().get ();
158150 });
159151
160- ASSERT_TRUE (catalog_response.IsSuccessful ())
161- << PrintError (catalog_response.GetError ());
152+ EXPECT_SUCCESS (catalog_response);
162153}
163154
164155TEST_P (CatalogClientTest, GetPartitionsWithInvalidHrn) {
@@ -193,8 +184,7 @@ TEST_P(CatalogClientTest, GetPartitions) {
193184 return future.GetFuture ().get ();
194185 });
195186
196- ASSERT_TRUE (partitions_response.IsSuccessful ())
197- << PrintError (partitions_response.GetError ());
187+ EXPECT_SUCCESS (partitions_response);
198188 ASSERT_EQ (4u , partitions_response.GetResult ().GetPartitions ().size ());
199189}
200190
@@ -213,7 +203,7 @@ TEST_P(CatalogClientTest, GetPartitionsForInvalidLayer) {
213203 });
214204
215205 ASSERT_FALSE (partitions_response.IsSuccessful ())
216- << PrintError (partitions_response.GetError ());
206+ << ErrorMessage (partitions_response.GetError ());
217207 ASSERT_EQ (olp::client::ErrorCode::InvalidArgument,
218208 partitions_response.GetError ().GetErrorCode ());
219209}
@@ -252,8 +242,7 @@ TEST_P(CatalogClientTest, GetDataWithHandle) {
252242 return future.GetFuture ().get ();
253243 });
254244
255- ASSERT_TRUE (data_response.IsSuccessful ())
256- << PrintError (data_response.GetError ());
245+ EXPECT_SUCCESS (data_response);
257246 ASSERT_LT (0 , data_response.GetResult ()->size ());
258247 std::string data_string (data_response.GetResult ()->begin (),
259248 data_response.GetResult ()->end ());
@@ -311,8 +300,7 @@ TEST_P(CatalogClientTest, GetDataWithPartitionId) {
311300 return future.GetFuture ().get ();
312301 });
313302
314- ASSERT_TRUE (data_response.IsSuccessful ())
315- << PrintError (data_response.GetError ());
303+ EXPECT_SUCCESS (data_response);
316304 ASSERT_LT (0 , data_response.GetResult ()->size ());
317305 std::string data_string (data_response.GetResult ()->begin (),
318306 data_response.GetResult ()->end ());
@@ -333,8 +321,7 @@ TEST_P(CatalogClientTest, GetDataWithPartitionIdVersion2) {
333321 return future.GetFuture ().get ();
334322 });
335323
336- ASSERT_TRUE (data_response.IsSuccessful ())
337- << PrintError (data_response.GetError ());
324+ EXPECT_SUCCESS (data_response);
338325 ASSERT_LT (0 , data_response.GetResult ()->size ());
339326 std::string data_string (data_response.GetResult ()->begin (),
340327 data_response.GetResult ()->end ());
@@ -386,8 +373,7 @@ TEST_P(CatalogClientTest, GetPartitionsVersion2) {
386373 return future.GetFuture ().get ();
387374 });
388375
389- ASSERT_TRUE (partitions_response.IsSuccessful ())
390- << PrintError (partitions_response.GetError ());
376+ EXPECT_SUCCESS (partitions_response);
391377 ASSERT_LT (0 , partitions_response.GetResult ().GetPartitions ().size ());
392378}
393379
@@ -437,8 +423,7 @@ TEST_P(CatalogClientTest, GetDataWithNonExistentPartitionId) {
437423 return future.GetFuture ().get ();
438424 });
439425
440- ASSERT_TRUE (data_response.IsSuccessful ())
441- << PrintError (data_response.GetError ());
426+ EXPECT_SUCCESS (data_response);
442427 ASSERT_FALSE (data_response.GetResult ());
443428}
444429
@@ -475,8 +460,7 @@ TEST_P(CatalogClientTest, GetDataWithInlineField) {
475460 return future.GetFuture ().get ();
476461 });
477462
478- ASSERT_TRUE (data_response.IsSuccessful ())
479- << PrintError (data_response.GetError ());
463+ EXPECT_SUCCESS (data_response);
480464 ASSERT_LT (0 , data_response.GetResult ()->size ());
481465 std::string data_string (data_response.GetResult ()->begin (),
482466 data_response.GetResult ()->end ());
@@ -497,8 +481,7 @@ TEST_P(CatalogClientTest, GetDataWithEmptyField) {
497481 return future.GetFuture ().get ();
498482 });
499483
500- ASSERT_TRUE (data_response.IsSuccessful ())
501- << PrintError (data_response.GetError ());
484+ EXPECT_SUCCESS (data_response);
502485 ASSERT_FALSE (data_response.GetResult ());
503486}
504487
@@ -516,8 +499,7 @@ TEST_P(CatalogClientTest, GetDataCompressed) {
516499 return future.GetFuture ().get ();
517500 });
518501
519- ASSERT_TRUE (data_response.IsSuccessful ())
520- << PrintError (data_response.GetError ());
502+ EXPECT_SUCCESS (data_response);
521503 ASSERT_LT (0u , data_response.GetResult ()->size ());
522504
523505 auto request_compressed = olp::dataservice::read::DataRequest ();
@@ -529,8 +511,7 @@ TEST_P(CatalogClientTest, GetDataCompressed) {
529511 return future.GetFuture ().get ();
530512 });
531513
532- ASSERT_TRUE (data_response_compressed.IsSuccessful ())
533- << PrintError (data_response_compressed.GetError ());
514+ EXPECT_SUCCESS (data_response_compressed);
534515 ASSERT_LT (0u , data_response_compressed.GetResult ()->size ());
535516 ASSERT_EQ (data_response.GetResult ()->size (),
536517 data_response_compressed.GetResult ()->size ());
@@ -576,8 +557,7 @@ TEST_P(CatalogClientTest, Prefetch) {
576557
577558 auto data_response = future.GetFuture ().get ();
578559
579- ASSERT_TRUE (data_response.IsSuccessful ())
580- << PrintError (data_response.GetError ());
560+ EXPECT_SUCCESS (data_response);
581561 ASSERT_LT (0 , data_response.GetResult ()->size ());
582562 }
583563 // The parent of 5904591 should be fetched too
@@ -590,8 +570,7 @@ TEST_P(CatalogClientTest, Prefetch) {
590570
591571 auto data_response = future.GetFuture ().get ();
592572
593- ASSERT_TRUE (data_response.IsSuccessful ())
594- << PrintError (data_response.GetError ());
573+ EXPECT_SUCCESS (data_response);
595574 ASSERT_LT (0 , data_response.GetResult ()->size ());
596575 }
597576}
0 commit comments