aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenu Kumari <renu.kumari@bell.ca>2021-07-24 03:10:10 -0400
committerRenu Kumari <renu.kumari@bell.ca>2021-07-26 11:04:55 -0400
commitb0abffa28253d49d2b901521977a9e512d1bd281 (patch)
tree4dc43c10d80f6fe941ead11104f6f2aaa40bf436
parentbc5644f4b972f4f000043dd6c99ec828bde39730 (diff)
Kafka Configuration is not loaded when testing DB integration
Issue-ID: CPS-518 Signed-off-by: Renu Kumari <renu.kumari@bell.ca> Change-Id: I673e8b0d4fb70dcdd2024c15e04940996023b4f8
-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 5fe30b0..bb74c28 100755
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -26,6 +26,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 3ac13a9..8d024c5 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -25,6 +25,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