aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruno Sakoto <bruno.sakoto@bell.ca>2021-07-28 22:04:17 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-28 22:04:17 +0000
commit704b80f4948499e0d6ff1c537825ed08fff6227f (patch)
tree81e168512b0643e88bc84bb79a9ced44b6edf930 /src
parentec80c5e31596c36168abca86b5ccb07e4021eb66 (diff)
parentb0abffa28253d49d2b901521977a9e512d1bd281 (diff)
Merge "Kafka Configuration is not loaded when testing DB integration"
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/resources/application.yml1
-rw-r--r--src/test/groovy/org/onap/cps/temporal/repository/NetworkDataRepositorySpec.groovy11
-rw-r--r--src/test/resources/application.yml1
3 files changed, 10 insertions, 3 deletions
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0b41a07..eed24dc 100755
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -32,6 +32,7 @@ spring:
liquibase:
change-log: classpath:/db/changelog/changelog-master.xml
jpa:
+ open-in-view: false
properties:
hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.format_sql: true
diff --git a/src/test/groovy/org/onap/cps/temporal/repository/NetworkDataRepositorySpec.groovy b/src/test/groovy/org/onap/cps/temporal/repository/NetworkDataRepositorySpec.groovy
index c23015c..41f3f42 100644
--- a/src/test/groovy/org/onap/cps/temporal/repository/NetworkDataRepositorySpec.groovy
+++ b/src/test/groovy/org/onap/cps/temporal/repository/NetworkDataRepositorySpec.groovy
@@ -22,8 +22,11 @@ package org.onap.cps.temporal.repository
import org.onap.cps.temporal.domain.NetworkData
import org.onap.cps.temporal.repository.containers.TimescaleContainer
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.testcontainers.spock.Testcontainers
+import org.springframework.test.annotation.Rollback
+import org.springframework.test.context.transaction.TestTransaction
import spock.lang.Shared
import spock.lang.Specification
@@ -32,15 +35,16 @@ import java.time.OffsetDateTime
/**
* Test specification for network data repository.
*/
-@SpringBootTest
@Testcontainers
+@DataJpaTest @Rollback(false)
+@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class NetworkDataRepositorySpec extends Specification {
def observedTimestamp = OffsetDateTime.now()
def dataspaceName = 'TEST_DATASPACE'
def schemaSetName = 'TEST_SCHEMA_SET'
def anchorName = 'TEST_ANCHOR'
- def payload = '{ \"message\": \"Hello World!\" }'
+ def payload = '{ "message": "Hello World!" }'
@Autowired
NetworkDataRepository networkDataRepository
@@ -54,6 +58,7 @@ class NetworkDataRepositorySpec extends Specification {
def 'Store latest network data in timeseries database.'() {
when: 'a new Network Data is stored'
NetworkData savedData = networkDataRepository.save(networkData)
+ TestTransaction.end()
then: ' the saved Network Data is returned'
savedData.getDataspace() == networkData.getDataspace()
savedData.getSchemaSet() == networkData.getSchemaSet()
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index fb38742..b2b8f00 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -31,6 +31,7 @@ spring:
liquibase:
change-log: classpath:/db/changelog/changelog-master.xml
jpa:
+ open-in-view: false
properties:
hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.format_sql: true