AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection Class Reference

#include <MockHTTP2Connection.h>

Inheritance diagram for alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection:
Collaboration graph
[legend]

Public Member Functions

 MockHTTP2Connection (std::string dURL, std::string pingURL, bool delegateToReal=true)
 
 ~MockHTTP2Connection ()=default
 
std::shared_ptr< HTTP2RequestInterfacecreateAndSendRequestConcrete (const HTTP2RequestConfig &config)
 
bool isRequestQueueEmpty ()
 
std::shared_ptr< MockHTTP2RequestwaitForRequest (std::chrono::milliseconds timeout, unsigned requestNum=1)
 
std::shared_ptr< MockHTTP2RequestdequeRequest ()
 
void setWaitRequestHeader (const std::string &matchString)
 
bool waitForRequestWithHeader (std::chrono::milliseconds timeout)
 
std::shared_ptr< MockHTTP2RequestwaitForPostRequest (const std::chrono::milliseconds timeout)
 
std::shared_ptr< MockHTTP2RequestwaitForPingRequest (const std::chrono::milliseconds timeout)
 
bool respondToDownchannelRequests (long responseCode, bool sendResponseFinished, const std::chrono::milliseconds timeout)
 
void setResponseToPOSTRequests (http::HTTPResponseCode responseCode)
 
std::shared_ptr< MockHTTP2RequestgetDownchannelRequest (std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
 
bool isPauseOnSendReceived (std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
 
std::size_t getPostRequestsNum ()
 
std::size_t getRequestsNum ()
 
std::size_t getDownchannelRequestsNum ()
 
std::shared_ptr< MockHTTP2RequestdequePostRequest (const std::chrono::milliseconds timeout)
 
std::shared_ptr< MockHTTP2RequestdequePostRequest ()
 
std::shared_ptr< MockHTTP2RequestdequePingRequest ()
 
std::size_t getMaxPostRequestsEnqueud ()
 
HTTP2ConnectionInterface methods
 MOCK_METHOD1 (createAndSendRequest, std::shared_ptr< HTTP2RequestInterface >(const HTTP2RequestConfig &config))
 
 MOCK_METHOD0 (disconnect, void())
 
void addObserver (std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionObserverInterface > observer)
 
void removeObserver (std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionObserverInterface > observer)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::http2::HTTP2ConnectionInterface
virtual ~HTTP2ConnectionInterface ()=default
 
virtual std::shared_ptr< HTTP2RequestInterfacecreateAndSendRequest (const HTTP2RequestConfig &config)=0
 
virtual void disconnect ()=0
 
virtual void addObserver (std::shared_ptr< HTTP2ConnectionObserverInterface > observer)=0
 
virtual void removeObserver (std::shared_ptr< HTTP2ConnectionObserverInterface > observer)=0
 

Detailed Description

A mock class of HTTP2ConnectionInterface.

Constructor & Destructor Documentation

◆ MockHTTP2Connection()

alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::MockHTTP2Connection ( std::string  dURL,
std::string  pingURL,
bool  delegateToReal = true 
)

Constructor

Parameters
dURLThe URL for downchannel requests.
pingURLThe URL for ping requests.
delegateToRealWhether the mock should delegate to real methods when possible. If false, all methods will need expectations set.

◆ ~MockHTTP2Connection()

alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::~MockHTTP2Connection ( )
default

Member Function Documentation

◆ addObserver()

void alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::addObserver ( std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionObserverInterface observer)

◆ createAndSendRequestConcrete()

std::shared_ptr< HTTP2RequestInterface > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::createAndSendRequestConcrete ( const HTTP2RequestConfig config)

A concrete implementation that performs a createAndSendRequest call.

Parameters
configThe HTTP2RequestConfig.
Returns
The request that was created with the provided config.

◆ dequePingRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::dequePingRequest ( )

◆ dequePostRequest() [1/2]

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::dequePostRequest ( )

◆ dequePostRequest() [2/2]

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::dequePostRequest ( const std::chrono::milliseconds  timeout)

◆ dequeRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::dequeRequest ( )

Pop the latest HTTP2 Request from queue.

Returns
The oldest HTTP2 Request in the queue.

◆ getDownchannelRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::getDownchannelRequest ( std::chrono::milliseconds  timeout = std::chrono::milliseconds(0))

Retrieve the first HTTP2 request made on the downchannel.

Returns
The first downchannel request or nullptr if none found

◆ getDownchannelRequestsNum()

std::size_t alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::getDownchannelRequestsNum ( )

◆ getMaxPostRequestsEnqueud()

std::size_t alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::getMaxPostRequestsEnqueud ( )

◆ getPostRequestsNum()

std::size_t alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::getPostRequestsNum ( )

◆ getRequestsNum()

std::size_t alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::getRequestsNum ( )

◆ isPauseOnSendReceived()

bool alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::isPauseOnSendReceived ( std::chrono::milliseconds  timeout = std::chrono::milliseconds(0))

Check if a pause is received while sending data.

Returns
True if a pause is received, false otherwise

◆ isRequestQueueEmpty()

bool alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::isRequestQueueEmpty ( )

Check whether there are any HTTP requests sent.

Returns
True if there are no HTTP requests sent by HTTP2Transport.

◆ MOCK_METHOD0()

alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::MOCK_METHOD0 ( disconnect  ,
void()   
)

◆ MOCK_METHOD1()

alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::MOCK_METHOD1 ( createAndSendRequest  ,
std::shared_ptr< HTTP2RequestInterface const HTTP2RequestConfig &config 
)

◆ removeObserver()

void alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::removeObserver ( std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionObserverInterface observer)

◆ respondToDownchannelRequests()

bool alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::respondToDownchannelRequests ( long  responseCode,
bool  sendResponseFinished,
const std::chrono::milliseconds  timeout 
)

Respond to downchannel requests with a response code and notify onResponseFinished() if needed.

Parameters
responseCodeThe HTTP response code to reply.
sendResponseFinishedTrue if needed to notify onResponseFinished(), otherwise false.
timeoutTimeout for wating for downchannel HTTP2 requests.
Returns
True if a response has been sent to the downchannel request before timeout, otherwise false.

◆ setResponseToPOSTRequests()

void alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::setResponseToPOSTRequests ( http::HTTPResponseCode  responseCode)

Set the response code for POST requests that will be immediately replied when an HTTP POST request is sent.

Parameters
responseCodeThe HTTP response code to reply to the request. If set to HTTPResponseCode::HTTP_RESPONSE_CODE_UNDEFINED, a response code will not be sent.

◆ setWaitRequestHeader()

void alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::setWaitRequestHeader ( const std::string &  matchString)

Set the Header content to be matched by waitForRequestWithHeader.

Parameters
matchStringThe contents of the header to match.

◆ waitForPingRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::waitForPingRequest ( const std::chrono::milliseconds  timeout)

Wait for a Ping HTTP2request.

Parameters
timeoutThe wait timeout in milliseconds.
Returns
A pointer to the Ping request if there is one before the timeout occurs, otherwise nullptr

◆ waitForPostRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::waitForPostRequest ( const std::chrono::milliseconds  timeout)

Wait for a POST HTTP2request.

Parameters
timeoutThe wait timeout in milliseconds.
Returns
A pointer to the POST request if there is one before the timeout occurs, otherwise nullptr

◆ waitForRequest()

std::shared_ptr< MockHTTP2Request > alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::waitForRequest ( std::chrono::milliseconds  timeout,
unsigned  requestNum = 1 
)

Wait for an HTTP request to be sent.

Parameters
timeoutWait timeout in milliseconds.
requestNumThe number of HTTP2 requests to wait for.
Returns
A pointer to the request if there is one before the timeout occurs, otherwise nullptr

◆ waitForRequestWithHeader()

bool alexaClientSDK::avsCommon::utils::http2::test::MockHTTP2Connection::waitForRequestWithHeader ( std::chrono::milliseconds  timeout)

Wait for a request with a particular Header content.

Parameters
timeoutThe wait timeout in milliseconds
matchStringThe contents of the header that it is waiting for
Returns
True if a match occurred before timeout

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

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0