AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
StubMiscStorage.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_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_STORAGE_STUBMISCSTORAGE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_STORAGE_STUBMISCSTORAGE_H_
18 
19 #include <gmock/gmock.h>
20 
21 #include <memory>
22 #include <mutex>
23 #include <unordered_map>
24 #include <unordered_set>
25 
27 
28 namespace alexaClientSDK {
29 namespace avsCommon {
30 namespace sdkInterfaces {
31 namespace storage {
32 namespace test {
33 
38 public:
39  static std::shared_ptr<StubMiscStorage> create();
40 
43 
44  bool createDatabase() override;
45 
46  bool open() override;
47 
48  bool isOpened() override;
49 
50  void close() override;
51 
52  bool createTable(
54  const std::string& tableName,
55  KeyType keyType,
56  ValueType valueType) override;
57 
58  bool clearTable(const std::string& componentName, const std::string& tableName) override;
59 
60  bool deleteTable(const std::string& componentName, const std::string& tableName) override;
61 
62  bool get(const std::string& componentName, const std::string& tableName, const std::string& key, std::string* value)
63  override;
64 
65  bool add(
66  const std::string& componentName,
67  const std::string& tableName,
68  const std::string& key,
69  const std::string& value) override;
70 
71  bool update(
72  const std::string& componentName,
73  const std::string& tableName,
74  const std::string& key,
75  const std::string& value) override;
76 
77  bool put(
78  const std::string& componentName,
79  const std::string& tableName,
80  const std::string& key,
81  const std::string& value) override;
82 
83  bool remove(const std::string& componentName, const std::string& tableName, const std::string& key) override;
84 
85  bool tableEntryExists(
86  const std::string& componentName,
87  const std::string& tableName,
88  const std::string& key,
89  bool* tableEntryExistsValue) override;
90 
91  bool tableExists(const std::string& componentName, const std::string& tableName, bool* tableExistsValue) override;
92 
93  bool load(
94  const std::string& componentName,
95  const std::string& tableName,
96  std::unordered_map<std::string, std::string>* valueContainer) override;
98 
99 private:
101  StubMiscStorage();
102 
112  bool clearTableLocked(const std::string& componentName, const std::string& tableName);
113 
114  // Mutex.
115  std::mutex m_mutex;
116 
118  std::unordered_map<std::string, std::string> m_storage;
119 
121  std::unordered_set<std::string> m_tables;
122 
124  bool m_isOpened;
125 };
126 
127 } // namespace test
128 } // namespace storage
129 } // namespace sdkInterfaces
130 } // namespace avsCommon
131 } // namespace alexaClientSDK
132 
133 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_STORAGE_STUBMISCSTORAGE_H_
ValueType
The type of the value column in Misc DB.
Definition: MiscStorageInterface.h:44
Definition: AmdMetricWrapperTest.cpp:24
::std::string string
Definition: gtest-port.h:1097
bool tableEntryExists(const std::string &componentName, const std::string &tableName, const std::string &key, bool *tableEntryExistsValue) override
bool clearTable(const std::string &componentName, const std::string &tableName) override
bool tableExists(const std::string &componentName, const std::string &tableName, bool *tableExistsValue) override
bool load(const std::string &componentName, const std::string &tableName, std::unordered_map< std::string, std::string > *valueContainer) override
bool put(const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
static const std::string tableName
Definition: SmartScreenCaptionStateManagerTest.cpp:30
bool add(const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
KeyType
The type of the key column in Misc DB.
Definition: MiscStorageInterface.h:36
bool createTable(const std::string &componentName, const std::string &tableName, KeyType keyType, ValueType valueType) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool deleteTable(const std::string &componentName, const std::string &tableName) override
static const std::string componentName
Definition: SmartScreenCaptionStateManagerTest.cpp:29
bool update(const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
static const std::string key
The database key to be used by the protocol given the METADATA object.
Definition: SharedAVSSettingProtocolTest.cpp:58

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