aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db-repositories
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-requests-db-repositories')
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java33
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationStatusTest.java9
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java4
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/RequestDBConfig.java2
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/SiteStatusTest.java17
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/resources/application-test.yaml2
6 files changed, 38 insertions, 29 deletions
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
index 951f02e5d8..c15c70cd98 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
@@ -21,6 +21,22 @@
package org.onap.so.db.request.data.repository;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NonUniqueResultException;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Order;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -34,23 +50,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
-import javax.persistence.EntityManager;
-import javax.persistence.NonUniqueResultException;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Order;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.logger.MsoLogger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
@Repository
@Transactional(readOnly = true)
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationStatusTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationStatusTest.java
index a10d948b8f..f3be5a154b 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationStatusTest.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationStatusTest.java
@@ -34,6 +34,7 @@ import org.onap.so.TestApplication;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.OperationStatusId;
import org.onap.so.db.request.data.repository.OperationStatusRepository;
+import org.onap.so.db.request.exceptions.NoEntityFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -49,7 +50,7 @@ public class OperationStatusTest {
@Test
@Transactional
- public void timeStampCreated() throws InterruptedException {
+ public void timeStampCreated() throws InterruptedException, NoEntityFoundException {
final String testServiceId = "test-service-id";
final String testOperationId = "test-operation-id";
@@ -61,7 +62,8 @@ public class OperationStatusTest {
status = repository.saveAndFlush(status);
- OperationStatus found = repository.findOne(id);
+ OperationStatus found = repository.findById(id).
+ orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
Date operateAt = found.getOperateAt();
assertNotNull(operateAt);
@@ -72,7 +74,8 @@ public class OperationStatusTest {
Thread.sleep(1000);
repository.saveAndFlush(status);
- OperationStatus foundUpdate = repository.findOne(id);
+ OperationStatus foundUpdate = repository.findById(id).
+ orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
assertEquals(operateAt.toString(), foundUpdate.getOperateAt().toString());
assertNotNull(foundUpdate.getFinishedAt());
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java
index c12d3cbb7b..ef3466278e 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java
@@ -27,6 +27,7 @@ import org.junit.runner.RunWith;
import org.onap.so.TestApplication;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.onap.so.db.request.exceptions.NoEntityFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Example;
@@ -71,7 +72,8 @@ public class OperationalEnvServiceModelStatusTest {
exampleObj.setOperationalEnvId("oper-env-id-1");
exampleObj.setServiceModelVersionId("service-model-ver-id-1");
ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("requestId");
- OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj,matcher));
+ OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj,matcher))
+ .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
if(foundStatus== null)
throw new Exception("No status found");
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/RequestDBConfig.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/RequestDBConfig.java
index 9bcff13699..9026571720 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/RequestDBConfig.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/RequestDBConfig.java
@@ -24,7 +24,7 @@ package org.onap.so.db.request;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/SiteStatusTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/SiteStatusTest.java
index 917f52d4ad..1f99e92d97 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/SiteStatusTest.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/SiteStatusTest.java
@@ -31,6 +31,7 @@ import org.junit.runner.RunWith;
import org.onap.so.TestApplication;
import org.onap.so.db.request.beans.SiteStatus;
import org.onap.so.db.request.data.repository.SiteStatusRepository;
+import org.onap.so.db.request.exceptions.NoEntityFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Example;
@@ -50,8 +51,10 @@ public class SiteStatusTest {
@Test
@Transactional
- public void timeStampCreated() throws InterruptedException {
- SiteStatus found = repository.findOne("test name4");
+ public void timeStampCreated() throws InterruptedException, NoEntityFoundException {
+ SiteStatus found = repository.findById("test name4").
+ orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
+
assertNotNull(found.getCreated());
assertEquals("test name4", found.getSiteName());
}
@@ -72,14 +75,16 @@ public class SiteStatusTest {
}
@Test
- public void updateStatus() {
+ public void updateStatus() throws NoEntityFoundException {
- SiteStatus status = repository.findOne("test name update");
+ SiteStatus status = repository.findById("test name update").
+ orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
status.setStatus(false);
repository.saveAndFlush(status);
-
- assertEquals(false, repository.findOne("test name update").getStatus());
+ status = repository.findById("test name update").
+ orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
+ assertEquals(false, status.getStatus());
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/application-test.yaml b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/application-test.yaml
index c4dd60356b..670d16b6c7 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/application-test.yaml
@@ -16,7 +16,7 @@ mso:
# H2
spring:
datasource:
- url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;
+ jdbc-url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;
username: sa
password: sa
driver-class-name: org.h2.Driver