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
1ebcc297
Verified
Commit
1ebcc297
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: files
parent
10398ee9
No related branches found
No related tags found
1 merge request
!8
F files
Pipeline
#11932
passed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
1
Pipelines
5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+80
-91
80 additions, 91 deletions
test/test_transaction.cpp
with
80 additions
and
91 deletions
test/test_transaction.cpp
+
80
−
91
View file @
1ebcc297
...
@@ -23,10 +23,10 @@
...
@@ -23,10 +23,10 @@
#include
"caosdb/filestreaming/FileWriter.h"
// for FileWriter
#include
"caosdb/filestreaming/FileWriter.h"
// for FileWriter
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
#include
"caosdb/transaction.h"
// for Entity, Transaction,
UniqueRe
...
#include
"caosdb/transaction.h"
// for Entity, Transaction,...
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
<boost/filesystem/path.hpp>
// for path
#include
<boost/filesystem/operations.hpp>
// for remove
#include
<boost/filesystem/operations.hpp>
// for remove
#include
<boost/filesystem/path.hpp>
// for path
#include
<boost/filesystem/path_traits.hpp>
// for filesystem
#include
<boost/filesystem/path_traits.hpp>
// for filesystem
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
...
@@ -44,11 +44,10 @@ using caosdb::entity::Property;
...
@@ -44,11 +44,10 @@ using caosdb::entity::Property;
using
FileExchange
::
FileWriter
;
using
FileExchange
::
FileWriter
;
class
test_transaction
:
public
::
testing
::
Test
{
class
test_transaction
:
public
::
testing
::
Test
{
pr
ivate
:
pr
otected
:
fs
::
path
test_upload_file_1
;
fs
::
path
test_upload_file_1
;
fs
::
path
test_download_file_1
;
fs
::
path
test_download_file_1
;
protected:
void
SetUp
()
override
{
void
SetUp
()
override
{
test_upload_file_1
=
fs
::
path
(
"test_upload_file_1_delete_me.dat"
);
test_upload_file_1
=
fs
::
path
(
"test_upload_file_1_delete_me.dat"
);
test_download_file_1
=
fs
::
path
(
"test_download_file_1_delete_me.dat"
);
test_download_file_1
=
fs
::
path
(
"test_download_file_1_delete_me.dat"
);
...
@@ -69,7 +68,7 @@ protected:
...
@@ -69,7 +68,7 @@ protected:
auto
query_transaction
(
connection
->
CreateTransaction
());
auto
query_transaction
(
connection
->
CreateTransaction
());
query_transaction
->
Query
(
"FIND ENTITY WITH id > 99"
);
query_transaction
->
Query
(
"FIND ENTITY WITH id > 99"
);
query_transaction
->
Execute
();
query_transaction
->
Execute
();
if
(
query_transaction
->
GetResultSet
().
S
ize
()
>
0
)
{
if
(
query_transaction
->
GetResultSet
().
s
ize
()
>
0
)
{
auto
delete_transaction
(
connection
->
CreateTransaction
());
auto
delete_transaction
(
connection
->
CreateTransaction
());
for
(
const
Entity
&
entity
:
query_transaction
->
GetResultSet
())
{
for
(
const
Entity
&
entity
:
query_transaction
->
GetResultSet
())
{
delete_transaction
->
DeleteById
(
entity
.
GetId
());
delete_transaction
->
DeleteById
(
entity
.
GetId
());
...
@@ -93,10 +92,9 @@ TEST_F(test_transaction, DISABLED_retrieve_manufacturer_by_id) {
...
@@ -93,10 +92,9 @@ TEST_F(test_transaction, DISABLED_retrieve_manufacturer_by_id) {
transaction
->
RetrieveById
(
id
);
transaction
->
RetrieveById
(
id
);
transaction
->
Execute
();
transaction
->
Execute
();
const
auto
&
result_set
=
const
auto
&
result_set
=
transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
transaction
->
GetResultSet
());
const
auto
&
entity
=
result_set
.
GetEntity
(
);
const
auto
&
entity
=
result_set
.
at
(
0
);
EXPECT_EQ
(
id
,
entity
.
GetId
());
EXPECT_EQ
(
id
,
entity
.
GetId
());
EXPECT_EQ
(
name
,
entity
.
GetName
());
EXPECT_EQ
(
name
,
entity
.
GetName
());
EXPECT_EQ
(
role
,
entity
.
GetRole
());
EXPECT_EQ
(
role
,
entity
.
GetRole
());
...
@@ -118,14 +116,13 @@ TEST_F(test_transaction, retrieve_non_existing) {
...
@@ -118,14 +116,13 @@ TEST_F(test_transaction, retrieve_non_existing) {
EXPECT_EQ
(
status
.
GetCode
(),
TransactionStatus
::
TRANSACTION_ERROR
().
GetCode
());
EXPECT_EQ
(
status
.
GetCode
(),
TransactionStatus
::
TRANSACTION_ERROR
().
GetCode
());
ASSERT_EQ
(
status
.
GetCode
(),
StatusCode
::
GENERIC_TRANSACTION_ERROR
);
ASSERT_EQ
(
status
.
GetCode
(),
StatusCode
::
GENERIC_TRANSACTION_ERROR
);
const
auto
&
result_set
=
const
auto
&
result_set
=
transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
transaction
->
GetResultSet
());
const
auto
&
entity
=
result_set
.
GetEntity
(
);
const
auto
&
entity
=
result_set
.
at
(
0
);
EXPECT_EQ
(
id
,
entity
.
GetId
());
EXPECT_EQ
(
id
,
entity
.
GetId
());
EXPECT_TRUE
(
entity
.
HasErrors
());
EXPECT_TRUE
(
entity
.
HasErrors
());
ASSERT_EQ
(
entity
.
GetErrors
().
S
ize
(),
1
);
ASSERT_EQ
(
entity
.
GetErrors
().
s
ize
(),
1
);
EXPECT_EQ
(
entity
.
GetErrors
().
A
t
(
0
).
GetCode
(),
EXPECT_EQ
(
entity
.
GetErrors
().
a
t
(
0
).
GetCode
(),
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
}
}
...
@@ -146,16 +143,15 @@ TEST_F(test_transaction, insert_without_delete) {
...
@@ -146,16 +143,15 @@ TEST_F(test_transaction, insert_without_delete) {
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_FALSE
(
insert_status
.
IsError
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
const
auto
&
insert_result_set
=
insert_transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
());
const
auto
&
new_entity
=
insert_result_set
.
GetEntity
(
);
const
auto
&
new_entity
=
insert_result_set
.
at
(
0
);
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
// Should have a warning since it has no properties
// Should have a warning since it has no properties
EXPECT_TRUE
(
new_entity
.
HasWarnings
());
EXPECT_TRUE
(
new_entity
.
HasWarnings
());
EXPECT_EQ
(
new_entity
.
GetWarnings
().
S
ize
(),
1
);
EXPECT_EQ
(
new_entity
.
GetWarnings
().
s
ize
(),
1
);
EXPECT_EQ
(
new_entity
.
GetWarnings
().
A
t
(
0
).
GetCode
(),
EXPECT_EQ
(
new_entity
.
GetWarnings
().
a
t
(
0
).
GetCode
(),
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
}
}
...
@@ -176,16 +172,15 @@ TEST_F(test_transaction, insert_delete) {
...
@@ -176,16 +172,15 @@ TEST_F(test_transaction, insert_delete) {
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_FALSE
(
insert_status
.
IsError
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
const
auto
&
insert_result_set
=
insert_transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
());
const
auto
&
new_entity
=
insert_result_set
.
GetEntity
(
);
const
auto
&
new_entity
=
insert_result_set
.
at
(
0
);
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
// Should have a warning since it has no properties
// Should have a warning since it has no properties
EXPECT_TRUE
(
new_entity
.
HasWarnings
());
EXPECT_TRUE
(
new_entity
.
HasWarnings
());
EXPECT_EQ
(
new_entity
.
GetWarnings
().
S
ize
(),
1
);
EXPECT_EQ
(
new_entity
.
GetWarnings
().
s
ize
(),
1
);
EXPECT_EQ
(
new_entity
.
GetWarnings
().
A
t
(
0
).
GetCode
(),
EXPECT_EQ
(
new_entity
.
GetWarnings
().
a
t
(
0
).
GetCode
(),
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
auto
delete_transaction
(
connection
->
CreateTransaction
());
auto
delete_transaction
(
connection
->
CreateTransaction
());
...
@@ -198,10 +193,10 @@ TEST_F(test_transaction, insert_delete) {
...
@@ -198,10 +193,10 @@ TEST_F(test_transaction, insert_delete) {
ASSERT_TRUE
(
delete_status
.
IsTerminated
());
ASSERT_TRUE
(
delete_status
.
IsTerminated
());
ASSERT_FALSE
(
delete_status
.
IsError
());
ASSERT_FALSE
(
delete_status
.
IsError
());
const
auto
&
delete_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
delete_transaction
->
GetResultSet
());
const
auto
&
deleted_entity
=
delete_result_set
.
GetEntity
();
const
auto
&
delete_result_set
=
delete_transaction
->
GetResultSet
();
const
auto
&
deleted_entity
=
delete_result_set
.
at
(
0
);
EXPECT_EQ
(
deleted_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_EQ
(
deleted_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
}
}
...
@@ -224,9 +219,9 @@ TEST_F(test_transaction, insert_delete_with_parent) {
...
@@ -224,9 +219,9 @@ TEST_F(test_transaction, insert_delete_with_parent) {
ASSERT_FALSE
(
insert_status
.
IsError
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
const
auto
&
insert_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
()
)
;
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_rt
=
insert_result_set
.
GetEntity
(
);
const
auto
&
inserted_rt
=
insert_result_set
.
at
(
0
);
Entity
rec
;
Entity
rec
;
rec
.
SetRole
(
"Record"
);
rec
.
SetRole
(
"Record"
);
...
@@ -246,10 +241,9 @@ TEST_F(test_transaction, insert_delete_with_parent) {
...
@@ -246,10 +241,9 @@ TEST_F(test_transaction, insert_delete_with_parent) {
ASSERT_TRUE
(
rec_insert_status
.
IsTerminated
());
ASSERT_TRUE
(
rec_insert_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_insert_status
.
IsError
());
ASSERT_FALSE
(
rec_insert_status
.
IsError
());
const
auto
&
rec_result_set
=
const
auto
&
rec_result_set
=
rec_transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
rec_transaction
->
GetResultSet
());
const
auto
&
inserted_rec
=
rec_result_set
.
GetEntity
(
);
const
auto
&
inserted_rec
=
rec_result_set
.
at
(
0
);
EXPECT_FALSE
(
inserted_rec
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rec
.
GetId
().
empty
());
...
@@ -263,14 +257,13 @@ TEST_F(test_transaction, insert_delete_with_parent) {
...
@@ -263,14 +257,13 @@ TEST_F(test_transaction, insert_delete_with_parent) {
ASSERT_TRUE
(
rec_retrieve_status
.
IsTerminated
());
ASSERT_TRUE
(
rec_retrieve_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_retrieve_status
.
IsError
());
ASSERT_FALSE
(
rec_retrieve_status
.
IsError
());
const
auto
&
retrieve_result_set
=
const
auto
&
retrieve_result_set
=
retrieve_transaction
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
retrieve_transaction
->
GetResultSet
());
const
auto
&
retrieved_rec
=
retrieve_result_set
.
at
(
0
);
const
auto
&
retrieved_rec
=
retrieve_result_set
.
GetEntity
();
EXPECT_EQ
(
retrieved_rec
.
GetName
(),
rec
.
GetName
());
EXPECT_EQ
(
retrieved_rec
.
GetName
(),
rec
.
GetName
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
S
ize
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
s
ize
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
A
t
(
0
).
GetId
(),
inserted_rt
.
GetId
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
a
t
(
0
).
GetId
(),
inserted_rt
.
GetId
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
A
t
(
0
).
GetName
(),
rt
.
GetName
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
a
t
(
0
).
GetName
(),
rt
.
GetName
());
auto
rec_deletion
(
connection
->
CreateTransaction
());
auto
rec_deletion
(
connection
->
CreateTransaction
());
...
@@ -312,10 +305,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
...
@@ -312,10 +305,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
ASSERT_TRUE
(
prop_insert_status
.
IsTerminated
());
ASSERT_TRUE
(
prop_insert_status
.
IsTerminated
());
ASSERT_FALSE
(
prop_insert_status
.
IsError
());
ASSERT_FALSE
(
prop_insert_status
.
IsError
());
const
auto
&
prop_result_set
=
const
auto
&
prop_result_set
=
prop_insertion
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
prop_insertion
->
GetResultSet
());
const
auto
&
inserted_prop
=
prop_result_set
.
GetEntity
(
);
const
auto
&
inserted_prop
=
prop_result_set
.
at
(
0
);
EXPECT_FALSE
(
inserted_prop
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_prop
.
GetId
().
empty
());
// create and insert record type with the above property
// create and insert record type with the above property
...
@@ -338,10 +330,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
...
@@ -338,10 +330,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
ASSERT_TRUE
(
rt_insert_status
.
IsTerminated
());
ASSERT_TRUE
(
rt_insert_status
.
IsTerminated
());
ASSERT_FALSE
(
rt_insert_status
.
IsError
());
ASSERT_FALSE
(
rt_insert_status
.
IsError
());
const
auto
&
rt_result_set
=
const
auto
&
rt_result_set
=
rt_insertion
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
rt_insertion
->
GetResultSet
());
const
auto
&
inserted_rt
=
rt_result_set
.
GetEntity
(
);
const
auto
&
inserted_rt
=
rt_result_set
.
at
(
0
);
EXPECT_FALSE
(
inserted_rt
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt
.
GetId
().
empty
());
// retrieve inserted rt for testing
// retrieve inserted rt for testing
...
@@ -353,15 +344,14 @@ TEST_F(test_transaction, insert_delete_with_property) {
...
@@ -353,15 +344,14 @@ TEST_F(test_transaction, insert_delete_with_property) {
ASSERT_TRUE
(
rt_retrieve_status
.
IsTerminated
());
ASSERT_TRUE
(
rt_retrieve_status
.
IsTerminated
());
ASSERT_FALSE
(
rt_retrieve_status
.
IsError
());
ASSERT_FALSE
(
rt_retrieve_status
.
IsError
());
const
auto
&
rt_retrieve_results
=
const
auto
&
rt_retrieve_results
=
rt_retrieval
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
rt_retrieval
->
GetResultSet
());
const
auto
&
retrieved_rt
=
rt_retrieve_results
.
GetEntity
(
);
const
auto
&
retrieved_rt
=
rt_retrieve_results
.
at
(
0
);
EXPECT_EQ
(
inserted_rt
.
GetId
(),
retrieved_rt
.
GetId
());
EXPECT_EQ
(
inserted_rt
.
GetId
(),
retrieved_rt
.
GetId
());
EXPECT_EQ
(
rt
.
GetName
(),
retrieved_rt
.
GetName
());
EXPECT_EQ
(
rt
.
GetName
(),
retrieved_rt
.
GetName
());
EXPECT_EQ
(
retrieved_rt
.
GetProperties
().
S
ize
(),
1
);
EXPECT_EQ
(
retrieved_rt
.
GetProperties
().
s
ize
(),
1
);
const
auto
&
retrieved_prop_rt
=
retrieved_rt
.
GetProperties
().
A
t
(
0
);
const
auto
&
retrieved_prop_rt
=
retrieved_rt
.
GetProperties
().
a
t
(
0
);
EXPECT_EQ
(
retrieved_prop_rt
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetDatatype
(),
prop_ent
.
GetDatatype
());
EXPECT_EQ
(
retrieved_prop_rt
.
GetDatatype
(),
prop_ent
.
GetDatatype
());
...
@@ -393,10 +383,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
...
@@ -393,10 +383,9 @@ TEST_F(test_transaction, insert_delete_with_property) {
ASSERT_TRUE
(
rec_insert_status
.
IsTerminated
());
ASSERT_TRUE
(
rec_insert_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_insert_status
.
IsError
());
ASSERT_FALSE
(
rec_insert_status
.
IsError
());
const
auto
&
rec_result_set
=
const
auto
&
rec_result_set
=
rec_insertion
->
GetResultSet
();
dynamic_cast
<
const
UniqueResult
&>
(
rec_insertion
->
GetResultSet
());
const
auto
&
inserted_rec
=
rec_result_set
.
GetEntity
(
);
const
auto
&
inserted_rec
=
rec_result_set
.
at
(
0
);
EXPECT_FALSE
(
inserted_rec
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rec
.
GetId
().
empty
());
// Retrieve the record and verify paretn and property
// Retrieve the record and verify paretn and property
...
@@ -409,19 +398,19 @@ TEST_F(test_transaction, insert_delete_with_property) {
...
@@ -409,19 +398,19 @@ TEST_F(test_transaction, insert_delete_with_property) {
ASSERT_FALSE
(
rec_retrieve_status
.
IsError
());
ASSERT_FALSE
(
rec_retrieve_status
.
IsError
());
const
auto
&
rec_retrieve_results
=
const
auto
&
rec_retrieve_results
=
dynamic_cast
<
const
UniqueResult
&>
(
rec_retrieval
->
GetResultSet
()
)
;
rec_retrieval
->
GetResultSet
();
const
auto
&
retrieved_rec
=
rec_retrieve_results
.
GetEntity
(
);
const
auto
&
retrieved_rec
=
rec_retrieve_results
.
at
(
0
);
EXPECT_EQ
(
rec
.
GetName
(),
retrieved_rec
.
GetName
());
EXPECT_EQ
(
rec
.
GetName
(),
retrieved_rec
.
GetName
());
EXPECT_EQ
(
inserted_rec
.
GetId
(),
retrieved_rec
.
GetId
());
EXPECT_EQ
(
inserted_rec
.
GetId
(),
retrieved_rec
.
GetId
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
S
ize
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
s
ize
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetProperties
().
S
ize
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetProperties
().
s
ize
(),
1
);
const
auto
&
retrieved_parent_rec
=
retrieved_rec
.
GetParents
().
A
t
(
0
);
const
auto
&
retrieved_parent_rec
=
retrieved_rec
.
GetParents
().
a
t
(
0
);
EXPECT_EQ
(
retrieved_parent_rec
.
GetName
(),
rt
.
GetName
());
EXPECT_EQ
(
retrieved_parent_rec
.
GetName
(),
rt
.
GetName
());
EXPECT_EQ
(
retrieved_parent_rec
.
GetId
(),
inserted_rt
.
GetId
());
EXPECT_EQ
(
retrieved_parent_rec
.
GetId
(),
inserted_rt
.
GetId
());
const
auto
&
retrieved_prop_rec
=
retrieved_rec
.
GetProperties
().
A
t
(
0
);
const
auto
&
retrieved_prop_rec
=
retrieved_rec
.
GetProperties
().
a
t
(
0
);
EXPECT_EQ
(
retrieved_prop_rec
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetName
(),
prop_ent
.
GetName
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetId
(),
inserted_prop
.
GetId
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetDatatype
(),
prop_ent
.
GetDatatype
());
EXPECT_EQ
(
retrieved_prop_rec
.
GetDatatype
(),
prop_ent
.
GetDatatype
());
...
@@ -441,18 +430,18 @@ TEST_F(test_transaction, test_multi_retrieve) {
...
@@ -441,18 +430,18 @@ TEST_F(test_transaction, test_multi_retrieve) {
auto
status
=
transaction
->
WaitForIt
();
auto
status
=
transaction
->
WaitForIt
();
ASSERT_TRUE
(
status
.
IsTerminated
());
ASSERT_TRUE
(
status
.
IsTerminated
());
ASSERT_
FALS
E
(
status
.
IsError
());
ASSERT_
TRU
E
(
status
.
IsError
());
const
auto
&
result_set
=
transaction
->
GetResultSet
();
const
auto
&
result_set
=
transaction
->
GetResultSet
();
EXPECT_EQ
(
result_set
.
S
ize
(),
3
);
EXPECT_EQ
(
result_set
.
s
ize
(),
3
);
EXPECT_EQ
(
result_set
.
A
t
(
1
).
GetId
(),
"21"
);
EXPECT_EQ
(
result_set
.
a
t
(
1
).
GetId
(),
"21"
);
EXPECT_EQ
(
result_set
.
A
t
(
1
).
GetName
(),
"unit"
);
EXPECT_EQ
(
result_set
.
a
t
(
1
).
GetName
(),
"unit"
);
EXPECT_FALSE
(
result_set
.
A
t
(
1
).
HasErrors
());
EXPECT_FALSE
(
result_set
.
a
t
(
1
).
HasErrors
());
EXPECT_EQ
(
result_set
.
A
t
(
2
).
GetId
(),
"22"
);
EXPECT_EQ
(
result_set
.
a
t
(
2
).
GetId
(),
"22"
);
EXPECT_TRUE
(
result_set
.
A
t
(
2
).
HasErrors
());
EXPECT_TRUE
(
result_set
.
a
t
(
2
).
HasErrors
());
EXPECT_EQ
(
result_set
.
A
t
(
2
).
GetErrors
().
A
t
(
0
).
GetCode
(),
EXPECT_EQ
(
result_set
.
a
t
(
2
).
GetErrors
().
a
t
(
0
).
GetCode
(),
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
}
}
...
@@ -475,9 +464,9 @@ TEST_F(test_transaction, insert_update_delete) {
...
@@ -475,9 +464,9 @@ TEST_F(test_transaction, insert_update_delete) {
ASSERT_FALSE
(
insert_status
.
IsError
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
const
auto
&
insert_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
()
)
;
insert_transaction
->
GetResultSet
();
const
auto
&
new_entity
=
insert_result_set
.
GetEntity
(
);
const
auto
&
new_entity
=
insert_result_set
.
at
(
0
);
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
...
@@ -488,7 +477,7 @@ TEST_F(test_transaction, insert_update_delete) {
...
@@ -488,7 +477,7 @@ TEST_F(test_transaction, insert_update_delete) {
// UPDATE
// UPDATE
auto
update_transaction
(
connection
->
CreateTransaction
());
auto
update_transaction
(
connection
->
CreateTransaction
());
auto
update_entity
(
retrieve_transaction
->
GetResultSet
().
A
t
(
0
));
auto
update_entity
(
retrieve_transaction
->
GetResultSet
().
a
t
(
0
));
update_entity
.
SetName
(
"RT1-Update"
);
update_entity
.
SetName
(
"RT1-Update"
);
update_transaction
->
UpdateEntity
(
&
update_entity
);
update_transaction
->
UpdateEntity
(
&
update_entity
);
...
@@ -498,8 +487,8 @@ TEST_F(test_transaction, insert_update_delete) {
...
@@ -498,8 +487,8 @@ TEST_F(test_transaction, insert_update_delete) {
ASSERT_TRUE
(
update_status
.
IsTerminated
());
ASSERT_TRUE
(
update_status
.
IsTerminated
());
ASSERT_FALSE
(
update_status
.
IsError
());
ASSERT_FALSE
(
update_status
.
IsError
());
EXPECT_EQ
(
update_transaction
->
GetResultSet
().
S
ize
(),
1
);
EXPECT_EQ
(
update_transaction
->
GetResultSet
().
s
ize
(),
1
);
const
auto
&
updated_entity
=
update_transaction
->
GetResultSet
().
A
t
(
0
);
const
auto
&
updated_entity
=
update_transaction
->
GetResultSet
().
a
t
(
0
);
EXPECT_EQ
(
updated_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_EQ
(
updated_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_FALSE
(
updated_entity
.
HasErrors
());
EXPECT_FALSE
(
updated_entity
.
HasErrors
());
...
@@ -516,9 +505,9 @@ TEST_F(test_transaction, insert_update_delete) {
...
@@ -516,9 +505,9 @@ TEST_F(test_transaction, insert_update_delete) {
ASSERT_FALSE
(
delete_status
.
IsError
());
ASSERT_FALSE
(
delete_status
.
IsError
());
const
auto
&
delete_result_set
=
const
auto
&
delete_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
delete_transaction
->
GetResultSet
()
)
;
delete_transaction
->
GetResultSet
();
const
auto
&
deleted_entity
=
delete_result_set
.
GetEntity
(
);
const
auto
&
deleted_entity
=
delete_result_set
.
at
(
0
);
EXPECT_EQ
(
deleted_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_EQ
(
deleted_entity
.
GetId
(),
new_entity
.
GetId
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
}
}
...
@@ -541,17 +530,17 @@ TEST_F(test_transaction, test_query) {
...
@@ -541,17 +530,17 @@ TEST_F(test_transaction, test_query) {
ASSERT_FALSE
(
insert_status
.
IsError
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
const
auto
&
insert_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
()
)
;
insert_transaction
->
GetResultSet
();
const
auto
&
new_entity
=
insert_result_set
.
GetEntity
(
);
const
auto
&
new_entity
=
insert_result_set
.
at
(
0
);
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
auto
query_transaction
(
connection
->
CreateTransaction
());
auto
query_transaction
(
connection
->
CreateTransaction
());
query_transaction
->
Query
(
"FIND ENTITY WITH id = "
+
new_entity
.
GetId
());
query_transaction
->
Query
(
"FIND ENTITY WITH id = "
+
new_entity
.
GetId
());
query_transaction
->
Execute
();
query_transaction
->
Execute
();
EXPECT_EQ
(
query_transaction
->
GetResultSet
().
S
ize
(),
1
);
EXPECT_EQ
(
query_transaction
->
GetResultSet
().
s
ize
(),
1
);
EXPECT_EQ
(
query_transaction
->
GetResultSet
().
A
t
(
0
).
GetId
(),
EXPECT_EQ
(
query_transaction
->
GetResultSet
().
a
t
(
0
).
GetId
(),
new_entity
.
GetId
());
new_entity
.
GetId
());
// No count query, so no count result should be present
// No count query, so no count result should be present
EXPECT_TRUE
((
query_transaction
->
GetCountResult
()
<
0
));
EXPECT_TRUE
((
query_transaction
->
GetCountResult
()
<
0
));
...
@@ -560,7 +549,7 @@ TEST_F(test_transaction, test_query) {
...
@@ -560,7 +549,7 @@ TEST_F(test_transaction, test_query) {
count_query_trans
->
Query
(
"COUNT ENTITY WITH id = "
+
new_entity
.
GetId
());
count_query_trans
->
Query
(
"COUNT ENTITY WITH id = "
+
new_entity
.
GetId
());
count_query_trans
->
Execute
();
count_query_trans
->
Execute
();
// No result set in a count query
// No result set in a count query
EXPECT_EQ
(
count_query_trans
->
GetResultSet
().
S
ize
(),
0
);
EXPECT_EQ
(
count_query_trans
->
GetResultSet
().
s
ize
(),
0
);
EXPECT_EQ
(
count_query_trans
->
GetCountResult
(),
1
);
EXPECT_EQ
(
count_query_trans
->
GetCountResult
(),
1
);
}
}
...
@@ -583,9 +572,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -583,9 +572,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
ASSERT_FALSE
(
insert_rt1_status
.
IsError
());
ASSERT_FALSE
(
insert_rt1_status
.
IsError
());
const
auto
&
insert_rt1_results
=
const
auto
&
insert_rt1_results
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_rt1_transaction
->
GetResultSet
()
)
;
insert_rt1_transaction
->
GetResultSet
();
const
auto
&
inserted_rt1
=
insert_rt1_results
.
GetEntity
(
);
const
auto
&
inserted_rt1
=
insert_rt1_results
.
at
(
0
);
EXPECT_FALSE
(
inserted_rt1
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt1
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt1
.
HasErrors
());
EXPECT_FALSE
(
inserted_rt1
.
HasErrors
());
...
@@ -604,9 +593,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -604,9 +593,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
ASSERT_FALSE
(
insert_rt2_status
.
IsError
());
ASSERT_FALSE
(
insert_rt2_status
.
IsError
());
const
auto
&
insert_rt2_results
=
const
auto
&
insert_rt2_results
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_rt2_transaction
->
GetResultSet
()
)
;
insert_rt2_transaction
->
GetResultSet
();
const
auto
&
inserted_rt2
=
insert_rt2_results
.
GetEntity
(
);
const
auto
&
inserted_rt2
=
insert_rt2_results
.
at
(
0
);
EXPECT_FALSE
(
inserted_rt2
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt2
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt2
.
HasErrors
());
EXPECT_FALSE
(
inserted_rt2
.
HasErrors
());
...
@@ -625,9 +614,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -625,9 +614,9 @@ TEST_F(test_transaction, test_query_with_retrieve) {
ASSERT_FALSE
(
insert_rt3_status
.
IsError
());
ASSERT_FALSE
(
insert_rt3_status
.
IsError
());
const
auto
&
insert_rt3_results
=
const
auto
&
insert_rt3_results
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_rt3_transaction
->
GetResultSet
()
)
;
insert_rt3_transaction
->
GetResultSet
();
const
auto
&
inserted_rt3
=
insert_rt3_results
.
GetEntity
(
);
const
auto
&
inserted_rt3
=
insert_rt3_results
.
at
(
0
);
EXPECT_FALSE
(
inserted_rt3
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt3
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_rt3
.
HasErrors
());
EXPECT_FALSE
(
inserted_rt3
.
HasErrors
());
...
@@ -642,7 +631,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -642,7 +631,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
ASSERT_FALSE
(
find_status
.
IsError
());
ASSERT_FALSE
(
find_status
.
IsError
());
const
auto
&
find_results
=
find_transaction
->
GetResultSet
();
const
auto
&
find_results
=
find_transaction
->
GetResultSet
();
EXPECT_EQ
(
find_results
.
S
ize
(),
3
);
EXPECT_EQ
(
find_results
.
s
ize
(),
3
);
// only retrieve rt1 and rt2 by id
// only retrieve rt1 and rt2 by id
const
std
::
vector
<
std
::
string
>
ids
=
{
inserted_rt1
.
GetId
(),
const
std
::
vector
<
std
::
string
>
ids
=
{
inserted_rt1
.
GetId
(),
...
@@ -660,7 +649,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -660,7 +649,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
ASSERT_FALSE
(
find_and_retrieve_status
.
IsError
());
ASSERT_FALSE
(
find_and_retrieve_status
.
IsError
());
const
auto
&
result_set_a
=
find_and_retrieve
->
GetResultSet
();
const
auto
&
result_set_a
=
find_and_retrieve
->
GetResultSet
();
EXPECT_EQ
(
result_set_a
.
S
ize
(),
3
);
EXPECT_EQ
(
result_set_a
.
s
ize
(),
3
);
// retrieve rt1 and rt2 by ID and count all TestRTs
// retrieve rt1 and rt2 by ID and count all TestRTs
auto
count_and_retrieve
(
connection
->
CreateTransaction
());
auto
count_and_retrieve
(
connection
->
CreateTransaction
());
...
@@ -675,7 +664,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
...
@@ -675,7 +664,7 @@ TEST_F(test_transaction, test_query_with_retrieve) {
const
auto
&
result_set_b
=
count_and_retrieve
->
GetResultSet
();
const
auto
&
result_set_b
=
count_and_retrieve
->
GetResultSet
();
// TODO(fspreck) Re-enable once we implemented this
// TODO(fspreck) Re-enable once we implemented this
// EXPECT_EQ(result_set_b.
S
ize(), 2);
// EXPECT_EQ(result_set_b.
s
ize(), 2);
EXPECT_EQ
(
count_and_retrieve
->
GetCountResult
(),
3
);
EXPECT_EQ
(
count_and_retrieve
->
GetCountResult
(),
3
);
}
}
...
@@ -698,9 +687,9 @@ TEST_F(test_transaction, test_file_upload) {
...
@@ -698,9 +687,9 @@ TEST_F(test_transaction, test_file_upload) {
EXPECT_EQ
(
insert_status
.
GetCode
(),
StatusCode
::
SUCCESS
);
EXPECT_EQ
(
insert_status
.
GetCode
(),
StatusCode
::
SUCCESS
);
const
auto
&
insert_results
=
const
auto
&
insert_results
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
()
)
;
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_file
=
insert_results
.
GetEntity
(
);
const
auto
&
inserted_file
=
insert_results
.
at
(
0
);
EXPECT_FALSE
(
inserted_file
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_file
.
GetId
().
empty
());
EXPECT_FALSE
(
inserted_file
.
HasErrors
());
EXPECT_FALSE
(
inserted_file
.
HasErrors
());
}
}
...
@@ -720,7 +709,7 @@ TEST_F(test_transaction, test_file_download) {
...
@@ -720,7 +709,7 @@ TEST_F(test_transaction, test_file_download) {
const
auto
&
insert_results
=
insert_transaction
->
GetResultSet
();
const
auto
&
insert_results
=
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_file
=
insert_results
.
A
t
(
0
);
const
auto
&
inserted_file
=
insert_results
.
a
t
(
0
);
ASSERT_FALSE
(
inserted_file
.
GetId
().
empty
());
ASSERT_FALSE
(
inserted_file
.
GetId
().
empty
());
ASSERT_FALSE
(
inserted_file
.
HasErrors
());
ASSERT_FALSE
(
inserted_file
.
HasErrors
());
...
@@ -731,9 +720,9 @@ TEST_F(test_transaction, test_file_download) {
...
@@ -731,9 +720,9 @@ TEST_F(test_transaction, test_file_download) {
download_transaction
->
WaitForIt
();
download_transaction
->
WaitForIt
();
const
auto
&
download_results
=
download_transaction
->
GetResultSet
();
const
auto
&
download_results
=
download_transaction
->
GetResultSet
();
ASSERT_EQ
(
download_results
.
S
ize
(),
1
);
ASSERT_EQ
(
download_results
.
s
ize
(),
1
);
const
auto
&
downloaded_file
=
download_results
.
A
t
(
0
);
const
auto
&
downloaded_file
=
download_results
.
a
t
(
0
);
ASSERT_FALSE
(
downloaded_file
.
GetId
().
empty
());
ASSERT_FALSE
(
downloaded_file
.
GetId
().
empty
());
ASSERT_FALSE
(
downloaded_file
.
HasErrors
());
ASSERT_FALSE
(
downloaded_file
.
HasErrors
());
EXPECT_EQ
(
downloaded_file
.
GetLocalPath
().
string
(),
EXPECT_EQ
(
downloaded_file
.
GetLocalPath
().
string
(),
...
...
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