19 #include <gtest/gtest.h> 20 #include <gmock/gmock.h> 22 #include <aws/core/utils/Outcome.h> 23 #include <aws/lex/LexRuntimeServiceClient.h> 24 #include <aws/core/utils/memory/AWSMemory.h> 25 #include <aws/lex/model/PostContentResult.h> 44 Aws::LexRuntimeService::Model::PostContentResult
result;
54 auto io_stream =
new Aws::StringStream();
55 *io_stream <<
"test_text";
56 result.ReplaceBody(io_stream);
58 std::string invalid_json =
"This causes failure not valid json";
59 const unsigned char * json =
reinterpret_cast<const unsigned char *
>(
60 invalid_json.c_str());
61 Aws::Utils::ByteBuffer bb(json, invalid_json.size());
62 result.SetSlots(Aws::Utils::HashingUtils::Base64Encode(bb));
69 auto io_stream =
new Aws::StringStream();
70 *io_stream <<
"test_text";
71 result.ReplaceBody(io_stream);
73 Aws::Utils::Json::JsonValue value;
74 value.WithString(
"key",
"value");
75 auto value_str = value.View().WriteReadable();
76 const unsigned char * json =
reinterpret_cast<const unsigned char *
>(
78 Aws::Utils::ByteBuffer bb(json, value_str.size());
79 result.SetSlots(Aws::Utils::HashingUtils::Base64Encode(bb));
82 EXPECT_EQ(1, response.
slots.size());
83 EXPECT_EQ(
"value", response.
slots[
"key"]);
88 auto io_stream =
new Aws::StringStream();
89 *io_stream <<
"test_text";
90 result.ReplaceBody(io_stream);
98 auto param_mock = std::make_shared<Aws::Client::ParameterReaderMock>();
100 AwsError::AWS_ERR_OK,
101 AwsError::AWS_ERR_NOT_FOUND,
110 auto param_mock = std::make_shared<Aws::Client::ParameterReaderMock>();
112 AwsError::AWS_ERR_OK,
113 AwsError::AWS_ERR_OK,
115 ::testing::DefaultValue<AwsError>::Set(AwsError::AWS_ERR_OK);
void SetupMockReader(AwsError user_id_error, AwsError bot_name_error, AwsError bot_alias_error, ParameterReaderMock &mock_reader)
Aws::LexRuntimeService::Model::PostContentResult result
ErrorCode BuildLexInteractor(std::shared_ptr< Client::ParameterReaderInterface > params, LexInteractor &lex_interactor)
Utility function to configure a LexInteractor.
ErrorCode CopyResult(Aws::LexRuntimeService::Model::PostContentResult &result, LexResponse &response)
Copy the PostContentRestult to a LexResponse.
TEST_F(LexCommonTestFixture, CopyResultFailureInvalidJson)
std::unordered_map< std::string, std::string > slots
TEST(BuildLexInteractor, TestBuildInteractorError)
void ConfigureExampleResult(Aws::LexRuntimeService::Model::PostContentResult &example_result)
void ExpectEq(const LexResponse &response)