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
Compare revisions
f638ff399c151d7b8a67776a80ea3020e0b72f25 to 8f310e43419729603a749508ec83421c59d71737
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
caosdb/src/caosdb-cppinttest
Select target project
No results found
8f310e43419729603a749508ec83421c59d71737
Select Git revision
Swap
Target
caosdb/src/caosdb-cppinttest
Select target project
caosdb/src/caosdb-cppinttest
1 result
f638ff399c151d7b8a67776a80ea3020e0b72f25
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
workflow test
· bd017725
Henrik tom Wörden
authored
3 years ago
bd017725
STY: ws + todo assigned
· 8f310e43
Henrik tom Wörden
authored
3 years ago
8f310e43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+127
-0
127 additions, 0 deletions
test/test_transaction.cpp
with
127 additions
and
0 deletions
test/test_transaction.cpp
View file @
8f310e43
...
@@ -776,4 +776,131 @@ TEST_F(test_transaction, test_file_up_n_download) {
...
@@ -776,4 +776,131 @@ TEST_F(test_transaction, test_file_up_n_download) {
}
}
}
}
/*
* Test a small worklfow
*/
TEST_F
(
test_transaction
,
test_full_workflow
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
// ###### Create Data Model ######
Entity
dataRT
;
dataRT
.
SetRole
(
Role
::
RECORD_TYPE
);
dataRT
.
SetName
(
"DataRT"
);
Entity
voltage
;
voltage
.
SetRole
(
Role
::
PROPERTY
);
voltage
.
SetName
(
"voltage"
);
voltage
.
SetUnit
(
"V"
);
voltage
.
SetDataType
(
AtomicDataType
::
DOUBLE
);
Entity
notes
;
notes
.
SetRole
(
Role
::
PROPERTY
);
notes
.
SetName
(
"notes"
);
notes
.
SetDataType
(
AtomicDataType
::
TEXT
);
Entity
participants
;
participants
.
SetRole
(
Role
::
PROPERTY
);
participants
.
SetName
(
"participants"
);
participants
.
SetDataType
(
AtomicDataType
::
INTEGER
);
// participants.SetDataType(ListDataType::);
Entity
success
;
success
.
SetRole
(
Role
::
PROPERTY
);
success
.
SetName
(
"success"
);
success
.
SetDataType
(
AtomicDataType
::
BOOLEAN
);
Entity
experiment
;
experiment
.
SetRole
(
Role
::
RECORD_TYPE
);
experiment
.
SetName
(
"Experiment"
);
// TODO(henrik): creating this extra Property (additionally to the Entity
// above) is VERY clumsy
Property
volt_for_rt
;
volt_for_rt
.
SetName
(
voltage
.
GetName
());
volt_for_rt
.
SetImportance
(
Importance
::
RECOMMENDED
);
experiment
.
AppendProperty
(
volt_for_rt
);
Property
notes_for_rt2
;
notes_for_rt2
.
SetName
(
notes
.
GetName
());
notes_for_rt2
.
SetImportance
(
Importance
::
RECOMMENDED
);
experiment
.
AppendProperty
(
notes_for_rt2
);
Property
part_for_rt3
;
part_for_rt3
.
SetName
(
participants
.
GetName
());
part_for_rt3
.
SetImportance
(
Importance
::
SUGGESTED
);
experiment
.
AppendProperty
(
part_for_rt3
);
Property
succ_for_rt
;
succ_for_rt
.
SetName
(
success
.
GetName
());
succ_for_rt
.
SetImportance
(
Importance
::
SUGGESTED
);
experiment
.
AppendProperty
(
succ_for_rt
);
auto
insert_transaction
(
connection
->
CreateTransaction
());
insert_transaction
->
InsertEntity
(
&
dataRT
);
auto
insert_status
=
insert_transaction
->
Execute
();
const
auto
&
insert_results
=
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_ent
=
insert_results
.
at
(
0
);
ASSERT_FALSE
(
inserted_ent
.
GetId
().
empty
());
ASSERT_FALSE
(
inserted_ent
.
HasErrors
());
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
voltage
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
notes
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
participants
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
success
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
experiment
);
insert_status
=
insert_transaction
->
Execute
();
auto
retr_transaction
(
connection
->
CreateTransaction
());
retr_transaction
->
Query
(
"FIND Experiment"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
1
);
Parent
experiment_parent
;
experiment_parent
.
SetName
(
"Experiment"
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
Entity
experiment_rec
;
experiment_rec
.
SetRole
(
Role
::
RECORD
);
experiment_rec
.
AppendParent
(
experiment_parent
);
volt_for_rt
.
SetValue
(
1.6
);
experiment_rec
.
AppendProperty
(
volt_for_rt
);
notes_for_rt2
.
SetValue
(
"This is important!"
);
experiment_rec
.
AppendProperty
(
notes_for_rt2
);
part_for_rt3
.
SetValue
(
static_cast
<
int64_t
>
(
6
));
experiment_rec
.
AppendProperty
(
part_for_rt3
);
succ_for_rt
.
SetValue
(
true
);
experiment_rec
.
AppendProperty
(
succ_for_rt
);
auto
rec_insert_transaction
(
connection
->
CreateTransaction
());
rec_insert_transaction
->
InsertEntity
(
&
experiment_rec
);
std
::
cout
<<
"before ..."
<<
std
::
endl
;
insert_status
=
rec_insert_transaction
->
Execute
();
std
::
cout
<<
"after ..."
<<
std
::
endl
;
}
retr_transaction
=
connection
->
CreateTransaction
();
retr_transaction
->
Query
(
"FIND Record Experiment"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
8
);
auto
to_be_updated
=
retr_transaction
->
GetResultSet
().
at
(
0
);
// TODO(henrik) using the index for deletion is very inconvenient
to_be_updated
.
RemoveProperty
(
0
);
to_be_updated
.
SetName
(
"changedone"
);
auto
update_transaction
(
connection
->
CreateTransaction
());
update_transaction
->
UpdateEntity
(
&
to_be_updated
);
update_transaction
->
Execute
();
retr_transaction
=
connection
->
CreateTransaction
();
retr_transaction
->
Query
(
"FIND Record Experiment with name=changedone"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
1
);
}
}
// namespace caosdb::transaction
}
// namespace caosdb::transaction
This diff is collapsed.
Click to expand it.