Skip to content

Commit 1491397

Browse files
Fix VersionedLayerClientProtectTest test (#1540)
Mock server required support for additional fields, and cache size should be tuned to accommodate increased data size Relates-To: DATASDK-38 Signed-off-by: Andrey Kashcheev <ext-andrey.kashcheev@here.com>
1 parent d59fc01 commit 1491397

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

tests/functional/olp-cpp-sdk-dataservice-read/VersionedLayerClientProtectTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ class VersionedLayerClientProtectTest : public ::testing::Test {
5050
cache_settings.eviction_policy =
5151
olp::cache::EvictionPolicy::kLeastRecentlyUsed;
5252
cache_settings.max_disk_storage =
53-
46484u / 0.85; // eviction trashold is (0.8500000238F)
53+
55000u / 0.85; // eviction threshold is (0.8500000238F)
5454
settings_->cache =
5555
olp::client::OlpClientSettingsFactory::CreateDefaultCache(
5656
cache_settings);

tests/functional/utils/MockServerHelper.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,12 +80,14 @@ void MockServerHelper::MockGetResponse(const std::string& layer,
8080
void MockServerHelper::MockGetResponse(const std::string& layer,
8181
olp::geo::TileKey tile, int64_t version,
8282
const std::string& tree) {
83-
mock_server_client_.MockResponse("GET",
84-
"/query/v1/catalogs/" + catalog_ +
85-
"/layers/" + layer + "/versions/" +
86-
std::to_string(version) + "/quadkeys/" +
87-
tile.ToHereTile() + "/depths/4",
88-
tree);
83+
mock_server_client_.MockResponse(
84+
"GET",
85+
"/query/v1/catalogs/" + catalog_ + "/layers/" + layer + "/versions/" +
86+
std::to_string(version) + "/quadkeys/" + tile.ToHereTile() +
87+
"/depths/4",
88+
tree, olp::http::HttpStatusCode::OK, false, boost::none,
89+
std::vector<Expectation::QueryStringParameter>{
90+
{"additionalFields", {"checksum,crc,dataSize,compressedDataSize"}}});
8991
}
9092

9193
bool MockServerHelper::Verify() {

tests/utils/mock-server-client/Client.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,12 +45,13 @@ class Client {
4545
public:
4646
explicit Client(olp::client::OlpClientSettings settings);
4747

48-
void MockResponse(const std::string& method_matcher,
49-
const std::string& path_matcher,
50-
const std::string& response_body,
51-
int https_status = olp::http::HttpStatusCode::OK,
52-
bool unlimited = false,
53-
boost::optional<int32_t> delay_ms = boost::none);
48+
void MockResponse(
49+
const std::string& method_matcher, const std::string& path_matcher,
50+
const std::string& response_body,
51+
int https_status = olp::http::HttpStatusCode::OK, bool unlimited = false,
52+
boost::optional<int32_t> delay_ms = boost::none,
53+
boost::optional<std::vector<Expectation::QueryStringParameter>>
54+
query_params = boost::none);
5455

5556
void MockBinaryResponse(const std::string& method_matcher,
5657
const std::string& path_matcher,
@@ -77,14 +78,16 @@ inline Client::Client(olp::client::OlpClientSettings settings) {
7778
http_client_->SetBaseUrl(kBaseUrl);
7879
}
7980

80-
inline void Client::MockResponse(const std::string& method_matcher,
81-
const std::string& path_matcher,
82-
const std::string& response_body,
83-
int https_status, bool unlimited,
84-
boost::optional<int32_t> delay_ms) {
81+
inline void Client::MockResponse(
82+
const std::string& method_matcher, const std::string& path_matcher,
83+
const std::string& response_body, int https_status, bool unlimited,
84+
boost::optional<int32_t> delay_ms,
85+
boost::optional<std::vector<Expectation::QueryStringParameter>>
86+
query_params) {
8587
auto expectation = Expectation{};
8688
expectation.request.path = path_matcher;
8789
expectation.request.method = method_matcher;
90+
expectation.request.query_string_parameters = std::move(query_params);
8891

8992
boost::optional<Expectation::ResponseAction> action =
9093
Expectation::ResponseAction{};

tests/utils/mock-server-client/Expectation.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,9 +29,15 @@
2929
namespace mockserver {
3030

3131
struct Expectation {
32+
struct QueryStringParameter {
33+
std::string name;
34+
std::vector<std::string> values;
35+
};
3236
struct RequestMatcher {
3337
boost::optional<std::string> path = boost::none;
3438
boost::optional<std::string> method = boost::none;
39+
boost::optional<std::vector<QueryStringParameter>> query_string_parameters =
40+
boost::none;
3541
};
3642

3743
struct ResponseDelay {
@@ -64,6 +70,9 @@ struct Expectation {
6470

6571
void to_json(const Expectation& x, rapidjson::Value& value,
6672
rapidjson::Document::AllocatorType& allocator);
73+
void to_json(const Expectation::QueryStringParameter& x,
74+
rapidjson::Value& value,
75+
rapidjson::Document::AllocatorType& allocator);
6776
void to_json(const Expectation::RequestMatcher& x, rapidjson::Value& value,
6877
rapidjson::Document::AllocatorType& allocator);
6978
void to_json(const Expectation::BinaryResponse& x, rapidjson::Value& value,
@@ -90,12 +99,22 @@ inline void to_json(const Expectation& x, rapidjson::Value& value,
9099
}
91100
}
92101

102+
inline void to_json(const Expectation::QueryStringParameter& x,
103+
rapidjson::Value& value,
104+
rapidjson::Document::AllocatorType& allocator) {
105+
value.SetObject();
106+
serialize("name", x.name, value, allocator);
107+
serialize("values", x.values, value, allocator);
108+
}
109+
93110
inline void to_json(const Expectation::RequestMatcher& x,
94111
rapidjson::Value& value,
95112
rapidjson::Document::AllocatorType& allocator) {
96113
value.SetObject();
97114
serialize("path", x.path, value, allocator);
98115
serialize("method", x.method, value, allocator);
116+
serialize("queryStringParameters", x.query_string_parameters, value,
117+
allocator);
99118
}
100119

101120
inline void to_json(const Expectation::BinaryResponse& x,

0 commit comments

Comments
 (0)