AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
TestExceptionEncounteredSender.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTEXCEPTIONENCOUNTEREDSENDER_H_
17 #define ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTEXCEPTIONENCOUNTEREDSENDER_H_
18 
19 #include <condition_variable>
20 #include <string>
21 #include <future>
22 #include <fstream>
23 #include <chrono>
24 #include <deque>
25 #include <mutex>
26 #include <unordered_map>
27 
32 
33 using namespace alexaClientSDK::avsCommon;
34 
35 namespace alexaClientSDK {
36 namespace integration {
37 namespace test {
38 
44 public:
45  void sendExceptionEncountered(
46  const std::string& unparsedDirective,
48  const std::string& message) override;
56  std::shared_ptr<avs::AVSDirective> parseDirective(
57  const std::string& rawJSON,
58  std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager);
59 
64  public:
69 
70  // Enum for the way the directive was passed.
71  enum class Type {
72  // Not yet set.
73  UNSET,
74  // Set when sendExceptionEncountered is called.
75  EXCEPTION,
76  // Set when waitForNext times out waiting for a directive.
77  TIMEOUT
78  };
79 
80  // Type of how the directive was passed.
82  // AVSDirective passed from the Directive Sequencer.
83  std::shared_ptr<avsCommon::avs::AVSDirective> directive;
84  // Unparsed directive string passed to sendExceptionEncountered.
86  // Error type passed to sendExceptionEncountered.
88  // Additional information passed to sendExceptionEncountered.
89  std::string exceptionMessage;
90  };
91 
96  ExceptionParams waitForNext(const std::chrono::seconds duration);
97 
98 private:
100  std::mutex m_mutex;
102  std::condition_variable m_wakeTrigger;
104  std::deque<ExceptionParams> m_queue;
105 };
106 
107 } // namespace test
108 } // namespace integration
109 } // namespace alexaClientSDK
110 
111 #endif // ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTEXCEPTIONENCOUNTEREDSENDER_H_
Definition: MockHTTP2Connection.cpp:19
avsCommon::avs::ExceptionErrorType exceptionError
Definition: TestExceptionEncounteredSender.h:87
ExceptionErrorType
Definition: ExceptionErrorType.h:28
std::string exceptionUnparsedDirective
Definition: TestExceptionEncounteredSender.h:85
Definition: TestExceptionEncounteredSender.h:43
std::shared_ptr< avsCommon::avs::AVSDirective > directive
Definition: TestExceptionEncounteredSender.h:83
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Definition: ExceptionEncounteredSenderInterface.h:28
std::string exceptionMessage
Definition: TestExceptionEncounteredSender.h:89

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