16 #ifndef LEX_COMMON_TEST__TEST_UTILS_H_ 17 #define LEX_COMMON_TEST__TEST_UTILS_H_ 19 #include <gmock/gmock.h> 21 #include <aws/core/utils/Outcome.h> 22 #include <aws/lex/LexRuntimeServiceClient.h> 23 #include <aws/core/utils/memory/AWSMemory.h> 24 #include <aws/lex/model/PostContentRequest.h> 25 #include <aws/core/utils/memory/stl/AWSStreamFwd.h> 42 LexRuntimeService::Model::DialogState::ElicitSlot;
47 LexRuntimeService::Model::MessageFormatType::PlainText;
51 Aws::LexRuntimeService::Model::PostContentResult & example_result)
53 example_result.SetContentType(content_type.c_str());
54 example_result.SetDialogState(dialog_state);
55 example_result.SetIntentName(intent_name.c_str());
56 example_result.SetMessage(message.c_str());
57 example_result.SetSlots(
"");
58 example_result.SetSlotToElicit(slot_to_elicit.c_str());
59 example_result.SetMessageFormat(message_format);
60 example_result.SetSessionAttributes(session_attributes.c_str());
61 auto io_stream =
new Aws::StringStream();
62 example_result.ReplaceBody(io_stream);
69 using Aws::LexRuntimeService::Model::DialogStateMapper::GetNameForDialogState;
70 std::string dialog_state_name =
71 GetNameForDialogState(dialog_state).c_str();
73 using Aws::LexRuntimeService::Model::MessageFormatTypeMapper::GetNameForMessageFormatType;
74 std::string message_format_name =
75 GetNameForMessageFormatType(message_format).c_str();
78 EXPECT_TRUE(response.
slots.empty());
83 namespace LexRuntimeService
88 using Aws::LexRuntimeService::Model::PostContentRequest;
92 std::streampos audio_size = io_stream->seekg(0, std::ios_base::end).tellg();
93 std::vector<uint8_t> vec(audio_size);
94 io_stream->seekg(0, std::ios_base::beg);
95 io_stream->readsome(reinterpret_cast<char *>(&vec[0]), audio_size);
96 io_stream->seekg(0, std::ios_base::beg);
100 inline bool operator==(
const PostContentRequest & left,
const PostContentRequest & right)
102 std::cout <<
"Checking equals" << std::endl;
103 bool is_equal =
true;
104 std::string left_user_id = left.GetUserId().c_str();
105 std::string right_user_id = right.GetUserId().c_str();
106 is_equal &=
static_cast<bool>(left_user_id == right_user_id);
107 is_equal &=
static_cast<bool>(left.GetBotAlias() == right.GetBotAlias());
108 is_equal &=
static_cast<bool>(left.GetBotName() == right.GetBotName());
109 is_equal &=
static_cast<bool>(left.GetContentType() == right.GetContentType());
110 is_equal &=
static_cast<bool>(left.GetSessionAttributes() == right.GetSessionAttributes());
111 is_equal &=
static_cast<bool>(left.GetAccept() == right.GetAccept());
121 #endif // LEX_COMMON_TEST__TEST_UTILS_H_ std::string slot_to_elicit
std::string session_attributes
bool operator==(const PostContentRequest &left, const PostContentRequest &right)
LexRuntimeService::Model::DialogState dialog_state
std::vector< uint8_t > GetVectorFromStream(std::shared_ptr< Aws::IOStream > io_stream)
std::string message_format_type
std::string session_attributes
std::unordered_map< std::string, std::string > slots
std::string text_response
void ConfigureExampleResult(Aws::LexRuntimeService::Model::PostContentResult &example_result)
LexRuntimeService::Model::MessageFormatType message_format
void ExpectEq(const LexResponse &response)