Select Git revision
authentication.h
-
Joscha Schmiedt authoredJoscha Schmiedt authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_list_properties.cpp 9.78 KiB
/*
* This file is a part of the LinkAhead Project.
*
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "linkahead/connection.h" // for Connection, ConnectionManager
#include "linkahead/data_type.h" // for AtomicDataType
#include "linkahead/entity.h" // for Entity, Messages, Message
#include "linkahead/transaction.h" // for Entity, Transaction,...
#include "linkahead/transaction_status.h" // for TransactionStatus, StatusCode
#include "linkahead/value.h" // for value
#include <cstdint> // for int64_t
#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver
#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, AssertionResult
#include <iostream> // for cout
#include <memory> // for unique_ptr, allocator, __shar...
#include <string> // for string
#include <vector> // for vector
namespace linkahead::entity {
class test_list_properties : public ::testing::Test {
protected:
void SetUp() override { DeleteEntities(); }
void TearDown() override { DeleteEntities(); }
static void DeleteEntities() {
const auto &connection = linkahead::connection::ConnectionManager::GetDefaultConnection();
auto query_transaction(connection->CreateTransaction());
query_transaction->Query("FIND ENTITY WITH id > 99");
query_transaction->Execute();
if (query_transaction->GetResultSet().size() > 0) {
auto delete_transaction(connection->CreateTransaction());
for (const Entity &entity : query_transaction->GetResultSet()) {
delete_transaction->DeleteById(entity.GetId());
}
delete_transaction->Execute();
}
}
};
TEST_F(test_list_properties, insert_list_of_text) {
const auto &connection = linkahead::connection::ConnectionManager::GetDefaultConnection();
auto insertion_prop(connection->CreateTransaction());
Entity abstract_list_property;
abstract_list_property.SetRole(Role::PROPERTY);
abstract_list_property.SetName("TestProp");
abstract_list_property.SetDataType(DataType::ListOf(AtomicDataType::TEXT));
abstract_list_property.SetValue(std::vector<std::string>{"item1", "item2", "item3"});
insertion_prop->InsertEntity(&abstract_list_property);