AlexaClientSDK  1.26.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_
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::type
Type type
Definition: TestExceptionEncounteredSender.h:81
ExceptionEncounteredSenderInterface.h
test
Definition: AmdMetricWrapperTest.cpp:24
DirectiveHandlerInterface.h
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::exceptionMessage
std::string exceptionMessage
Definition: TestExceptionEncounteredSender.h:89
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams
Definition: TestExceptionEncounteredSender.h:63
AttachmentManager.h
alexaClientSDK::avsCommon::avs::ExceptionErrorType
ExceptionErrorType
Definition: ExceptionErrorType.h:28
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::integration::test::TestExceptionEncounteredSender
Definition: TestExceptionEncounteredSender.h:43
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::exceptionUnparsedDirective
std::string exceptionUnparsedDirective
Definition: TestExceptionEncounteredSender.h:85
JSONUtils.h
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::Type
Type
Definition: TestExceptionEncounteredSender.h:71
alexaClientSDK::avsCommon
Definition: MockHTTP2Connection.cpp:19
alexaClientSDK::avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface
Definition: ExceptionEncounteredSenderInterface.h:28
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::exceptionError
avsCommon::avs::ExceptionErrorType exceptionError
Definition: TestExceptionEncounteredSender.h:87
alexaClientSDK::integration::test::TestExceptionEncounteredSender::ExceptionParams::directive
std::shared_ptr< avsCommon::avs::AVSDirective > directive
Definition: TestExceptionEncounteredSender.h:83

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