MySQL 8.4.2
Source Code Documentation
MockServerRestClient Class Reference

#include <mock_server_rest_client.h>

Public Member Functions

 MockServerRestClient (const uint16_t http_port, const std::string &http_hostname="127.0.0.1")
 Constructor. More...
 
void set_globals (const std::string &globals_json)
 Sets values of the all globals in the server mock via http interface. More...
 
std::string get_globals_as_json_string ()
 Gets all the mock server globals as a json string. More...
 
int get_int_global (const std::string &global_name)
 Gets a selected mock server int global value. More...
 
bool get_bool_global (const std::string &global_name)
 Gets a selected mock server bool global value. More...
 
void send_delete (const std::string &uri)
 Sends Delete request to the mock server on the selected URI. More...
 
bool wait_for_rest_endpoint_ready (std::chrono::milliseconds max_wait_time=kMockServerDefaultRestEndpointTimeout) const noexcept
 Wait until a REST endpoint returns !404. More...
 

Private Attributes

const std::string http_hostname_
 
const uint16_t http_port_
 

Static Private Attributes

static constexpr std::chrono::milliseconds kMockServerMaxRestEndpointStepTime
 
static constexpr std::chrono::milliseconds kMockServerDefaultRestEndpointTimeout {1000}
 

Constructor & Destructor Documentation

◆ MockServerRestClient()

MockServerRestClient::MockServerRestClient ( const uint16_t  http_port,
const std::string &  http_hostname = "127.0.0.1" 
)

Constructor.

Parameters
http_portport on which http server handles the http requests
http_hostnamehostname of the http server that handles the http requests

Member Function Documentation

◆ get_bool_global()

bool MockServerRestClient::get_bool_global ( const std::string &  global_name)

Gets a selected mock server bool global value.

Parameters
global_namename of the global

◆ get_globals_as_json_string()

std::string MockServerRestClient::get_globals_as_json_string ( )

Gets all the mock server globals as a json string.

◆ get_int_global()

int MockServerRestClient::get_int_global ( const std::string &  global_name)

Gets a selected mock server int global value.

Parameters
global_namename of the global

◆ send_delete()

void MockServerRestClient::send_delete ( const std::string &  uri)

Sends Delete request to the mock server on the selected URI.

Parameters
uriuri for the Delete request

◆ set_globals()

void MockServerRestClient::set_globals ( const std::string &  globals_json)

Sets values of the all globals in the server mock via http interface.

Example: set_globals("{\"secondary_removed": true}");

Parameters
globals_jsonjson string with the globals names and values to set

◆ wait_for_rest_endpoint_ready()

bool MockServerRestClient::wait_for_rest_endpoint_ready ( std::chrono::milliseconds  max_wait_time = kMockServerDefaultRestEndpointTimeout) const
noexcept

Wait until a REST endpoint returns !404.

at mock startup the socket starts to listen before the REST endpoint gets registered. As long as it returns 404 Not Found we should wait and retry.

Parameters
max_wait_timemax time to wait for endpoint being ready
Returns
true once endpoint doesn't return 404 anymore, fails otherwise

Member Data Documentation

◆ http_hostname_

const std::string MockServerRestClient::http_hostname_
private

◆ http_port_

const uint16_t MockServerRestClient::http_port_
private

◆ kMockServerDefaultRestEndpointTimeout

constexpr std::chrono::milliseconds MockServerRestClient::kMockServerDefaultRestEndpointTimeout {1000}
staticconstexprprivate

◆ kMockServerMaxRestEndpointStepTime

constexpr std::chrono::milliseconds MockServerRestClient::kMockServerMaxRestEndpointStepTime
staticconstexprprivate
Initial value:
{
100}

The documentation for this class was generated from the following files: