Skip to content

Commit 6eabc21

Browse files
author
Liubov Didkivska
authored
Add CatalogClient functional tests (#912)
* Add CatalogClient functional tests Add versions list CatalogClient tests. Change functional CatalogClient tests to use mock server. Add helper functionality for mock server. Relates-To: OLPEDGE-1606 Signed-off-by: Liubov Didkivska <[email protected]>
1 parent 924e9b6 commit 6eabc21

File tree

12 files changed

+378
-204
lines changed

12 files changed

+378
-204
lines changed

olp-cpp-sdk-dataservice-write/src/generated/BlobApi.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include <olp/core/client/HttpResponse.h>
2626

27-
using namespace olp::client;
27+
namespace client = olp::client;
2828

2929
namespace {
3030
const std::string kQueryParamBillingTag = "billingTag";
@@ -34,8 +34,8 @@ namespace olp {
3434
namespace dataservice {
3535
namespace write {
3636

37-
CancellationToken BlobApi::PutBlob(
38-
const OlpClient& client, const std::string& layer_id,
37+
client::CancellationToken BlobApi::PutBlob(
38+
const client::OlpClient& client, const std::string& layer_id,
3939
const std::string& content_type, const std::string& data_handle,
4040
const std::shared_ptr<std::vector<unsigned char>>& data,
4141
const boost::optional<std::string>& billing_tag, PutBlobCallback callback) {
@@ -56,19 +56,19 @@ CancellationToken BlobApi::PutBlob(
5656
put_blob_uri, "PUT", query_params, header_params, form_params, data,
5757
content_type, [callback](client::HttpResponse http_response) {
5858
if (http_response.status != 200 && http_response.status != 204) {
59-
callback(PutBlobResponse(
60-
ApiError(http_response.status, http_response.response.str())));
59+
callback(PutBlobResponse(client::ApiError(
60+
http_response.status, http_response.response.str())));
6161
return;
6262
}
6363

64-
callback(PutBlobResponse(ApiNoResult()));
64+
callback(PutBlobResponse(client::ApiNoResult()));
6565
});
6666

6767
return cancel_token;
6868
}
6969

7070
PutBlobResponse BlobApi::PutBlob(
71-
const OlpClient& client, const std::string& layer_id,
71+
const client::OlpClient& client, const std::string& layer_id,
7272
const std::string& content_type, const std::string& data_handle,
7373
const std::shared_ptr<std::vector<unsigned char>>& data,
7474
const boost::optional<std::string>& billing_tag,
@@ -94,13 +94,13 @@ PutBlobResponse BlobApi::PutBlob(
9494
if (http_response.status != olp::http::HttpStatusCode::OK &&
9595
http_response.status != olp::http::HttpStatusCode::NO_CONTENT) {
9696
return PutBlobResponse(
97-
ApiError(http_response.status, http_response.response.str()));
97+
client::ApiError(http_response.status, http_response.response.str()));
9898
}
9999

100-
return PutBlobResponse(ApiNoResult());
100+
return PutBlobResponse(client::ApiNoResult());
101101
}
102102

103-
CancellationToken BlobApi::deleteBlob(
103+
client::CancellationToken BlobApi::deleteBlob(
104104
const client::OlpClient& client, const std::string& layer_id,
105105
const std::string& data_handle,
106106
const boost::optional<std::string>& billing_tag,
@@ -121,16 +121,16 @@ CancellationToken BlobApi::deleteBlob(
121121
delete_blob_uri, "DELETE", query_params, header_params, form_params,
122122
nullptr, "", [callback](client::HttpResponse http_response) {
123123
if (http_response.status != 200 && http_response.status != 202) {
124-
callback(PutBlobResponse(
125-
ApiError(http_response.status, http_response.response.str())));
124+
callback(PutBlobResponse(client::ApiError(
125+
http_response.status, http_response.response.str())));
126126
return;
127127
}
128-
callback(DeleteBlobRespone(ApiNoResult()));
128+
callback(DeleteBlobRespone(client::ApiNoResult()));
129129
});
130130
return cancel_token;
131131
}
132132

133-
CancellationToken BlobApi::checkBlobExists(
133+
client::CancellationToken BlobApi::checkBlobExists(
134134
const client::OlpClient& client, const std::string& layer_id,
135135
const std::string& data_handle,
136136
const boost::optional<std::string>& billing_tag,
@@ -154,8 +154,8 @@ CancellationToken BlobApi::checkBlobExists(
154154
callback(CheckBlobRespone(http_response.status));
155155
return;
156156
} else {
157-
callback(CheckBlobRespone(
158-
ApiError(http_response.status, http_response.response.str())));
157+
callback(CheckBlobRespone(client::ApiError(
158+
http_response.status, http_response.response.str())));
159159
}
160160
});
161161
return cancel_token;

olp-cpp-sdk-dataservice-write/src/generated/ConfigApi.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
namespace olp {
3535
namespace dataservice {
3636
namespace write {
37-
using namespace olp::client;
3837

39-
CancellationToken ConfigApi::GetCatalog(
40-
std::shared_ptr<OlpClient> client, const std::string& catalog_hrn,
38+
namespace client = olp::client;
39+
40+
client::CancellationToken ConfigApi::GetCatalog(
41+
std::shared_ptr<client::OlpClient> client, const std::string& catalog_hrn,
4142
boost::optional<std::string> billing_tag,
4243
const CatalogCallback& catalogCallback) {
4344
std::multimap<std::string, std::string> headerParams;
@@ -50,7 +51,7 @@ CancellationToken ConfigApi::GetCatalog(
5051

5152
std::string catalogUri = "/catalogs/" + catalog_hrn;
5253

53-
NetworkAsyncCallback callback =
54+
client::NetworkAsyncCallback callback =
5455
[catalogCallback](client::HttpResponse response) {
5556
if (response.status != 200) {
5657
catalogCallback(CatalogResponse(
@@ -65,7 +66,7 @@ CancellationToken ConfigApi::GetCatalog(
6566
formParams, nullptr, "", callback);
6667
}
6768

68-
CatalogResponse ConfigApi::GetCatalog(const OlpClient& client,
69+
CatalogResponse ConfigApi::GetCatalog(const client::OlpClient& client,
6970
const std::string& catalog_hrn,
7071
boost::optional<std::string> billing_tag,
7172
client::CancellationContext context) {

olp-cpp-sdk-dataservice-write/src/generated/IngestApi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <olp/core/generated/parser/JsonParser.h>
3636
// clang-format on
3737

38-
using namespace olp::client;
38+
namespace client = olp::client;
3939

4040
namespace {
4141
const std::string kHeaderParamChecksum = "X-HERE-Checksum";
@@ -164,7 +164,7 @@ IngestSdiiResponse IngestApi::IngestSdii(
164164

165165
if (response.status != olp::http::HttpStatusCode::OK) {
166166
return IngestSdiiResponse(
167-
ApiError(response.status, response.response.str()));
167+
client::ApiError(response.status, response.response.str()));
168168
}
169169

170170
return IngestSdiiResponse(

olp-cpp-sdk-dataservice-write/src/generated/MetadataApi.cpp

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ std::string concatStringArray(const std::vector<std::string>& strings,
5353
namespace olp {
5454
namespace dataservice {
5555
namespace write {
56-
using namespace olp::client;
56+
namespace client = olp::client;
5757

58-
CancellationToken MetadataApi::GetLayerVersions(
59-
const OlpClient& client, int64_t version,
58+
client::CancellationToken MetadataApi::GetLayerVersions(
59+
const client::OlpClient& client, int64_t version,
6060
boost::optional<std::string> billingTag,
6161
const LayerVersionsCallback& layerVersionsCallback) {
6262
std::multimap<std::string, std::string> headerParams;
@@ -72,22 +72,23 @@ CancellationToken MetadataApi::GetLayerVersions(
7272

7373
std::string metadataUri = "/layerVersions";
7474

75-
NetworkAsyncCallback callback = [layerVersionsCallback](
76-
client::HttpResponse response) {
77-
if (response.status != 200) {
78-
layerVersionsCallback(ApiError(response.status, response.response.str()));
79-
} else {
80-
layerVersionsCallback(
81-
olp::parser::parse<model::LayerVersions>(response.response));
82-
}
83-
};
75+
client::NetworkAsyncCallback callback =
76+
[layerVersionsCallback](client::HttpResponse response) {
77+
if (response.status != 200) {
78+
layerVersionsCallback(
79+
client::ApiError(response.status, response.response.str()));
80+
} else {
81+
layerVersionsCallback(
82+
olp::parser::parse<model::LayerVersions>(response.response));
83+
}
84+
};
8485

8586
return client.CallApi(metadataUri, "GET", queryParams, headerParams,
8687
formParams, nullptr, "", callback);
8788
}
8889

89-
CancellationToken MetadataApi::GetPartitions(
90-
const OlpClient& client, const std::string& layerId,
90+
client::CancellationToken MetadataApi::GetPartitions(
91+
const client::OlpClient& client, const std::string& layerId,
9192
boost::optional<int64_t> version,
9293
boost::optional<std::vector<std::string>> additionalFields,
9394
boost::optional<std::string> range, boost::optional<std::string> billingTag,
@@ -114,22 +115,23 @@ CancellationToken MetadataApi::GetPartitions(
114115

115116
std::string metadataUri = "/layers/" + layerId + "/partitions";
116117

117-
NetworkAsyncCallback callback = [partitionsCallback](
118-
client::HttpResponse response) {
119-
if (response.status != 200) {
120-
partitionsCallback(ApiError(response.status, response.response.str()));
121-
} else {
122-
partitionsCallback(
123-
olp::parser::parse<model::Partitions>(response.response));
124-
}
125-
};
118+
client::NetworkAsyncCallback callback =
119+
[partitionsCallback](client::HttpResponse response) {
120+
if (response.status != 200) {
121+
partitionsCallback(
122+
client::ApiError(response.status, response.response.str()));
123+
} else {
124+
partitionsCallback(
125+
olp::parser::parse<model::Partitions>(response.response));
126+
}
127+
};
126128

127129
return client.CallApi(metadataUri, "GET", queryParams, headerParams,
128130
formParams, nullptr, "", callback);
129131
}
130132

131-
CancellationToken MetadataApi::GetLatestCatalogVersion(
132-
const OlpClient& client, int64_t startVersion,
133+
client::CancellationToken MetadataApi::GetLatestCatalogVersion(
134+
const client::OlpClient& client, int64_t startVersion,
133135
boost::optional<std::string> billingTag,
134136
const CatalogVersionCallback& catalogVersionCallback) {
135137
std::multimap<std::string, std::string> headerParams;
@@ -146,11 +148,11 @@ CancellationToken MetadataApi::GetLatestCatalogVersion(
146148

147149
std::string metadataUri = "/versions/latest";
148150

149-
NetworkAsyncCallback callback =
151+
client::NetworkAsyncCallback callback =
150152
[catalogVersionCallback](client::HttpResponse response) {
151153
if (response.status != 200) {
152154
catalogVersionCallback(
153-
ApiError(response.status, response.response.str()));
155+
client::ApiError(response.status, response.response.str()));
154156
} else {
155157
catalogVersionCallback(
156158
olp::parser::parse<model::VersionResponse>(response.response));

0 commit comments

Comments
 (0)