diff options
Diffstat (limited to 'mso-api-handlers/mso-requests-db-repositories/src/test/java')
4 files changed, 21 insertions, 11 deletions
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()); } |