Skip to content
Snippets Groups Projects
Commit f91e5a0f authored by florian's avatar florian
Browse files

ENH: Add more setters for entities

parent 58940216
No related branches found
No related tags found
1 merge request!4ENH: Allow insertion and deletion of single entities
Pipeline #11109 passed
Pipeline: caosdb-cppinttest

#11111

    This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
    ......@@ -314,6 +314,9 @@ public:
    [[nodiscard]] inline auto GetUnit() const -> const std::string & {
    return wrapped->unit();
    };
    [[nodiscard]] inline auto GetValue() const -> const std::string & {
    return wrapped->value();
    };
    [[nodiscard]] auto GetParents() const -> const Parents &;
    [[nodiscard]] auto GetProperties() const -> const Properties &;
    ......@@ -344,7 +347,6 @@ public:
    auto SetName(const std::string &name) -> void;
    auto SetVersionId(const std::string &id) -> void;
    // TODO(fspreck) ... and also these
    auto SetValue(const std::string &value) -> void;
    auto SetUnit(const std::string &unit) -> void;
    // Currently no references or lists.
    ......
    ......@@ -107,4 +107,16 @@ auto Entity::SetName(const std::string &name) -> void {
    this->wrapped->set_name(name);
    }
    auto Entity::SetValue(const std::string &value) -> void {
    this->wrapped->set_value(value);
    }
    auto Entity::SetUnit(const std::string &unit) -> void {
    this->wrapped->set_unit(unit);
    }
    auto Entity::SetDatatype(const std::string &datatype) -> void {
    this->wrapped->set_datatype(datatype);
    }
    } // namespace caosdb::entity
    ......@@ -73,6 +73,31 @@ TEST(test_entity, test_insert_entity) {
    EXPECT_EQ(entity.GetVersionId(), "version_id");
    }
    // TODO(fspreck) cognitive complexity > 25 (threshold)
    TEST(test_entity, test_insert_with_role) { // NOLINT
    auto transaction = caosdb::transaction::Transaction(
    std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr));
    auto entity = Entity();
    entity.SetId("entity_id");
    entity.SetVersionId("version_id");
    entity.SetRole("Property");
    entity.SetDatatype("DOUBLE");
    entity.SetName("Length");
    entity.SetUnit("m");
    entity.SetValue("5.5");
    transaction.InsertEntity(&entity);
    EXPECT_EQ(entity.GetId(), "entity_id");
    EXPECT_EQ(entity.GetVersionId(), "version_id");
    EXPECT_EQ(entity.GetRole(), "Property");
    EXPECT_EQ(entity.GetDatatype(), "DOUBLE");
    EXPECT_EQ(entity.GetName(), "Length");
    EXPECT_EQ(entity.GetUnit(), "m");
    EXPECT_EQ(entity.GetValue(), "5.5");
    }
    // TODO(tf) cognitive complexity > 25 (threshold)
    TEST(test_entity, test_from_id_response) { // NOLINT
    IdResponse idResponse;
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment