summaryrefslogtreecommitdiff
path: root/src/components/utils/test/generated_code_with_sqlite_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/utils/test/generated_code_with_sqlite_test.cc')
-rw-r--r--src/components/utils/test/generated_code_with_sqlite_test.cc93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/components/utils/test/generated_code_with_sqlite_test.cc b/src/components/utils/test/generated_code_with_sqlite_test.cc
index d75d924321..cb319fa0ac 100644
--- a/src/components/utils/test/generated_code_with_sqlite_test.cc
+++ b/src/components/utils/test/generated_code_with_sqlite_test.cc
@@ -62,81 +62,83 @@ const std::string GeneratedCodeTest::kDatabaseName = "test_db";
const std::string GeneratedCodeTest::kEndpointsCreation =
"CREATE TABLE Endpoints ("
- "endpoint_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
- "service_id VARCHAR(45) NOT NULL,"
- "application_id VARCHAR(45),"
- "url VARCHAR(45) NOT NULL,"
- "is_default INTEGER NOT NULL CHECK(is_default>=0))";
+ "endpoint_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "service_id VARCHAR(45) NOT NULL,"
+ "application_id VARCHAR(45),"
+ "url VARCHAR(45) NOT NULL,"
+ "is_default INTEGER NOT NULL CHECK(is_default>=0))";
const std::string GeneratedCodeTest::kEndpointsContent =
"INSERT INTO Endpoints "
- "VALUES (1, '0x07', null, 'http://url.example.com', 1)";
+ "VALUES (1, '0x07', null, 'http://url.example.com', 1)";
const std::string GeneratedCodeTest::kAppPoliciesCreation =
"CREATE TABLE AppPolicies ("
- "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
- "application_id VARCHAR(45),"
- "priority VARCHAR(45),"
- "is_default INTEGER NOT NULL CHECK(is_default>=0))";
+ "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "application_id VARCHAR(45),"
+ "priority VARCHAR(45),"
+ "is_default INTEGER NOT NULL CHECK(is_default>=0))";
-const std::string GeneratedCodeTest::kGroupsCreation = "CREATE TABLE Groups ("
+const std::string GeneratedCodeTest::kGroupsCreation =
+ "CREATE TABLE Groups ("
"id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
"application_id VARCHAR(45) NOT NULL,"
"group_name VARCHAR(45) NOT NULL )";
-TEST_F(GeneratedCodeTest, FindSectionEndpoints_OpenDBSetDefaultUrl_ExpectDefaultUrl) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ FindSectionEndpoints_OpenDBSetDefaultUrl_ExpectDefaultUrl) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
policy_table::ServiceEndpoints ep;
- //assert
+ // assert
EXPECT_TRUE(policy_table::FindSection(&db, ep));
EXPECT_EQ(1u, ep.size());
- //act
+ // act
std::string url = ep["0x07"]["default"].front();
- //assert
+ // assert
EXPECT_EQ("http://url.example.com", url);
}
-TEST_F(GeneratedCodeTest, RemoveSectionEndpoints_RemoveSectionEndpoints_Expect0EndPoints) {
- //arrange
+TEST_F(GeneratedCodeTest,
+ RemoveSectionEndpoints_RemoveSectionEndpoints_Expect0EndPoints) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
policy_table::ServiceEndpoints ep;
- //assert
+ // assert
EXPECT_TRUE(policy_table::RemoveSection(&db, ep));
dbms::SQLQuery sqlquery(&db);
- //act
+ // act
std::string check_query = "select count (*) from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(check_query));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(0, sqlquery.GetInteger(0));
}
-TEST_F(GeneratedCodeTest, UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUrl) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUrl) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
std::string test_url = "http://url.example.com";
policy_table::URL urls;
@@ -148,52 +150,50 @@ TEST_F(GeneratedCodeTest, UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUr
policy_table::ServiceEndpoints ep;
ep["0x07"] = urllist;
- //assert
+ // assert
EXPECT_TRUE(policy_table::UpdateSection(&db, ep));
dbms::SQLQuery sqlquery(&db);
std::string num_of_records_check = "select count (*) from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(num_of_records_check));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(1, sqlquery.GetInteger(0));
EXPECT_TRUE(sqlquery.Reset());
-
- //act
+ // act
std::string url_check_query = "select * from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(url_check_query));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(test_url, sqlquery.GetString(3));
}
-TEST_F(GeneratedCodeTest, UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
policy_table::ApplicationPolicies ap;
const std::string application_id = "12345678";
ap[application_id].groups.push_back("Base-4");
ap[application_id].priority = policy_table::P_NORMAL;
- //assert
+ // assert
EXPECT_TRUE(policy_table::UpdateSection(&db, ap));
- //act
+ // act
dbms::SQLQuery sqlquery(&db);
-
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare("select count (*) from AppPolicies"));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
@@ -206,9 +206,8 @@ TEST_F(GeneratedCodeTest, UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem)
EXPECT_EQ(1, sqlquery.GetInteger(0));
EXPECT_TRUE(sqlquery.Reset());
- EXPECT_TRUE(
- sqlquery.Prepare(
- "select application_id from Groups where group_name='Base-4'"));
+ EXPECT_TRUE(sqlquery.Prepare(
+ "select application_id from Groups where group_name='Base-4'"));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(application_id, sqlquery.GetString(0));