Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cppinttest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cppinttest
Commits
50955570
Verified
Commit
50955570
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: consolidation
parent
7ff53664
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
F consolidation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+20
-41
20 additions, 41 deletions
test/test_transaction.cpp
with
20 additions
and
41 deletions
test/test_transaction.cpp
+
20
−
41
View file @
50955570
...
...
@@ -19,6 +19,7 @@
*
*/
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/data_type.h"
// for AtomicDataType
#include
"caosdb/entity.h"
// for Entity, Messages, Message
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
...
...
@@ -31,6 +32,9 @@
#include
<string>
// for string
#include
<vector>
// for vector
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
Importance
;
using
caosdb
::
entity
::
Role
;
using
caosdb
::
entity
::
AtomicDataType
;
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
MessageCode
;
using
caosdb
::
entity
::
Parent
;
...
...
@@ -56,31 +60,6 @@ protected:
}
};
TEST_F
(
test_transaction
,
DISABLED_retrieve_manufacturer_by_id
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
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
());
transaction
->
RetrieveById
(
id
);
transaction
->
Execute
();
const
auto
&
result_set
=
dynamic_cast
<
const
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
.
GetVersionId
());
}
TEST_F
(
test_transaction
,
retrieve_non_existing
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
...
...
@@ -113,7 +92,7 @@ TEST_F(test_transaction, insert_without_delete) {
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
entity
;
entity
.
SetRole
(
"RecordType"
);
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"RT1"
);
insert_transaction
->
InsertEntity
(
&
entity
);
insert_transaction
->
ExecuteAsynchronously
();
...
...
@@ -143,7 +122,7 @@ TEST_F(test_transaction, insert_delete) {
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
entity
;
entity
.
SetRole
(
"RecordType"
);
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"RT1"
);
insert_transaction
->
InsertEntity
(
&
entity
);
insert_transaction
->
ExecuteAsynchronously
();
...
...
@@ -190,7 +169,7 @@ TEST_F(test_transaction, insert_delete_with_parent) {
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
rt
;
rt
.
SetRole
(
"RecordType"
);
rt
.
SetRole
(
Role
::
RECORD_TYPE
);
rt
.
SetName
(
"TestRT"
);
insert_transaction
->
InsertEntity
(
&
rt
);
insert_transaction
->
ExecuteAsynchronously
();
...
...
@@ -206,7 +185,7 @@ TEST_F(test_transaction, insert_delete_with_parent) {
const
auto
&
inserted_rt
=
insert_result_set
.
GetEntity
();
Entity
rec
;
rec
.
SetRole
(
"Record"
);
rec
.
SetRole
(
Role
::
RECORD
);
rec
.
SetName
(
"TestRec"
);
Parent
parent
;
...
...
@@ -276,9 +255,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
// Create and insert property
Entity
prop_ent
;
prop_ent
.
SetRole
(
"Property"
);
prop_ent
.
SetRole
(
Role
::
PROPERTY
);
prop_ent
.
SetName
(
"TestProperty"
);
prop_ent
.
SetData
t
ype
(
"
TEXT
"
);
prop_ent
.
SetData
T
ype
(
AtomicDataType
::
TEXT
);
auto
prop_insertion
(
connection
->
CreateTransaction
());
prop_insertion
->
InsertEntity
(
&
prop_ent
);
...
...
@@ -299,10 +278,10 @@ TEST_F(test_transaction, insert_delete_with_property) {
Property
prop_rt
;
prop_rt
.
SetName
(
prop_ent
.
GetName
());
prop_rt
.
SetId
(
inserted_prop
.
GetId
());
prop_rt
.
SetImportance
(
"
SUGGESTED
"
);
prop_rt
.
SetImportance
(
Importance
::
SUGGESTED
);
Entity
rt
;
rt
.
SetRole
(
"RecordType"
);
rt
.
SetRole
(
Role
::
RECORD_TYPE
);
rt
.
SetName
(
"TestRT"
);
rt
.
AppendProperty
(
prop_rt
);
...
...
@@ -341,7 +320,7 @@ TEST_F(test_transaction, insert_delete_with_property) {
const
auto
&
retrieved_prop_rt
=
retrieved_rt
.
GetProperties
().
At
(
0
);
EXPECT_EQ
(
retrieved_prop_rt
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetData
t
ype
(),
prop_ent
.
GetData
t
ype
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetData
T
ype
(),
prop_ent
.
GetData
T
ype
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetImportance
(),
prop_rt
.
GetImportance
());
// create and insert record of the above record type with a property
...
...
@@ -357,7 +336,7 @@ TEST_F(test_transaction, insert_delete_with_property) {
Entity
rec
;
rec
.
SetName
(
"TestRec"
);
rec
.
SetRole
(
"Record"
);
rec
.
SetRole
(
Role
::
RECORD
);
rec
.
AppendParent
(
parent
);
rec
.
AppendProperty
(
prop_rec
);
...
...
@@ -401,7 +380,7 @@ TEST_F(test_transaction, insert_delete_with_property) {
const
auto
&
retrieved_prop_rec
=
retrieved_rec
.
GetProperties
().
At
(
0
);
EXPECT_EQ
(
retrieved_prop_rec
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetData
t
ype
(),
prop_ent
.
GetData
t
ype
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetData
T
ype
(),
prop_ent
.
GetData
T
ype
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetValue
(),
prop_rec
.
GetValue
());
}
...
...
@@ -441,7 +420,7 @@ TEST_F(test_transaction, insert_update_delete) {
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
entity
;
entity
.
SetRole
(
"RecordType"
);
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"RT1"
);
insert_transaction
->
InsertEntity
(
&
entity
);
insert_transaction
->
ExecuteAsynchronously
();
...
...
@@ -507,7 +486,7 @@ TEST_F(test_transaction, test_query) {
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
entity
;
entity
.
SetRole
(
"RecordType"
);
entity
.
SetRole
(
Role
::
RECORD_TYPE
);
entity
.
SetName
(
"RT1"
);
insert_transaction
->
InsertEntity
(
&
entity
);
insert_transaction
->
ExecuteAsynchronously
();
...
...
@@ -547,7 +526,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
// rt1
Entity
rt1
;
rt1
.
SetRole
(
"RecordType"
);
rt1
.
SetRole
(
Role
::
RECORD_TYPE
);
rt1
.
SetName
(
"TestRT1"
);
auto
insert_rt1_transaction
(
connection
->
CreateTransaction
());
...
...
@@ -568,7 +547,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
// rt2
Entity
rt2
;
rt2
.
SetRole
(
"RecordType"
);
rt2
.
SetRole
(
Role
::
RECORD_TYPE
);
rt2
.
SetName
(
"TestRT2"
);
auto
insert_rt2_transaction
(
connection
->
CreateTransaction
());
...
...
@@ -589,7 +568,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
// rt3
Entity
rt3
;
rt3
.
SetRole
(
"RecordType"
);
rt3
.
SetRole
(
Role
::
RECORD_TYPE
);
rt3
.
SetName
(
"TestRT3"
);
auto
insert_rt3_transaction
(
connection
->
CreateTransaction
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment