Newer
Older
/*
* This file is a part of the CaosDB 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 <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
#include <memory> // for allocator, static_pointer_cast
#include "caosdb/connection.h" // for CaosDBConnection
#include "caosdb/entity.h" // for Entity, EntityID
#include "caosdb/transaction.h" // for Transaction, UniqueResult, Entity
#include "gtest/gtest_pred_impl.h" // for Test, TestInfo, EXPECT_EQ, TEST
#include "test_connection.h" // for get_test_connection
TEST(test_transaction, retrieve_manufacturer_by_id) {
const auto &connection = caosdb::connection::get_test_connection();
const auto *id = "107";
const auto *role = "RecordType";
const auto *name = "Manufacturer";
const auto *description = "A generic manufacturer of all kinds of products";
const auto *version = "0bea8f7b17f0130fa5701a6c3849b9f8bfa0651b";
auto transaction(connection->CreateTransaction());
const auto &result_set =
dynamic_cast<const caosdb::transaction::UniqueResult &>(
transaction->GetResultSet());
const auto &entity = result_set.GetEntity();
EXPECT_EQ(id, entity.GetId());
EXPECT_EQ(name, entity.GetName());
EXPECT_EQ(role, entity.GetRole());
EXPECT_EQ(description, entity.GetDescription());
EXPECT_EQ(version, entity.GetVersion());