Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
113a39e1
Commit
113a39e1
authored
3 years ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
okay stopping now, coverage is good
Former-commit-id:
494b62f0
parent
eaa1bb6d
No related branches found
No related tags found
1 merge request
!42
Fixed the query service tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fda-table-service/rest-service/src/test/java/at/tuwien/endpoint/DataEndpointIntegrationTest.java
+47
-3
47 additions, 3 deletions
.../java/at/tuwien/endpoint/DataEndpointIntegrationTest.java
with
47 additions
and
3 deletions
fda-table-service/rest-service/src/test/java/at/tuwien/endpoint/DataEndpointIntegrationTest.java
+
47
−
3
View file @
113a39e1
...
...
@@ -2,6 +2,7 @@ package at.tuwien.endpoint;
import
at.tuwien.BaseUnitTest
;
import
at.tuwien.api.database.table.*
;
import
at.tuwien.config.PostgresConfig
;
import
at.tuwien.config.ReadyConfig
;
import
at.tuwien.endpoints.DataEndpoint
;
import
at.tuwien.exception.*
;
...
...
@@ -30,6 +31,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import
javax.transaction.Transactional
;
import
java.io.File
;
import
java.sql.SQLException
;
import
java.time.Instant
;
import
java.util.*
;
...
...
@@ -124,7 +126,7 @@ public class DataEndpointIntegrationTest extends BaseUnitTest {
@Test
public
void
insertFromTuple_succeeds
()
throws
TableNotFoundException
,
TableMalformedException
,
DatabaseNotFoundException
,
ImageNotSupportedException
{
DatabaseNotFoundException
,
ImageNotSupportedException
,
SQLException
{
final
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>()
{{
put
(
COLUMN_1_NAME
,
4
);
put
(
COLUMN_2_NAME
,
Instant
.
now
());
...
...
@@ -136,17 +138,23 @@ public class DataEndpointIntegrationTest extends BaseUnitTest {
.
data
(
List
.
of
(
map
))
.
build
();
/* mock */
PostgresConfig
.
clearDatabase
();
/* test */
final
ResponseEntity
<?>
response
=
dataEndpoint
.
insertFromTuple
(
DATABASE_1_ID
,
TABLE_1_ID
,
request
);
assertEquals
(
HttpStatus
.
ACCEPTED
,
response
.
getStatusCode
());
}
@Test
public
void
insertFromTuple_empty_fails
()
{
public
void
insertFromTuple_empty_fails
()
throws
SQLException
{
final
TableCsvDto
request
=
TableCsvDto
.
builder
()
.
data
(
List
.
of
())
.
build
();
/* mock */
PostgresConfig
.
clearDatabase
();
/* test */
assertThrows
(
TableMalformedException
.
class
,
()
->
{
dataEndpoint
.
insertFromTuple
(
DATABASE_1_ID
,
TABLE_1_ID
,
request
);
...
...
@@ -154,15 +162,51 @@ public class DataEndpointIntegrationTest extends BaseUnitTest {
}
@Test
public
void
insertFromTuple_empty2_fails
()
{
public
void
insertFromTuple_empty2_fails
()
throws
SQLException
{
final
TableCsvDto
request
=
TableCsvDto
.
builder
()
.
data
(
List
.
of
(
Map
.
of
()))
.
build
();
/* mock */
PostgresConfig
.
clearDatabase
();
/* test */
assertThrows
(
TableMalformedException
.
class
,
()
->
{
dataEndpoint
.
insertFromTuple
(
DATABASE_1_ID
,
TABLE_1_ID
,
request
);
});
}
@Test
public
void
insertFromFile_succeeds
()
throws
TableNotFoundException
,
TableMalformedException
,
DatabaseNotFoundException
,
ImageNotSupportedException
,
FileStorageException
,
SQLException
{
final
TableInsertDto
request
=
TableInsertDto
.
builder
()
.
delimiter
(
','
)
.
skipHeader
(
true
)
.
nullElement
(
"NA"
)
.
csvLocation
(
"test:src/test/resources/csv/csv_01.csv"
)
.
build
();
/* mock */
PostgresConfig
.
clearDatabase
();
/* test */
final
ResponseEntity
<?>
response
=
dataEndpoint
.
insertFromFile
(
DATABASE_1_ID
,
TABLE_1_ID
,
request
);
assertEquals
(
HttpStatus
.
ACCEPTED
,
response
.
getStatusCode
());
}
@Test
public
void
getAll_succeeds
()
throws
TableNotFoundException
,
TableMalformedException
,
DatabaseNotFoundException
,
ImageNotSupportedException
,
SQLException
,
DatabaseConnectionException
{
final
Instant
timestamp
=
Instant
.
now
();
final
Long
page
=
0L
;
final
Long
size
=
1L
;
/* mock */
PostgresConfig
.
clearDatabase
();
/* test */
final
ResponseEntity
<?>
response
=
dataEndpoint
.
getAll
(
DATABASE_1_ID
,
TABLE_1_ID
,
timestamp
,
page
,
size
);
assertEquals
(
HttpStatus
.
OK
,
response
.
getStatusCode
());
}
}
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