aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-15 12:12:09 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-15 12:12:09 +0000
commitbecadde04b85e4d4c7df4a7e957fcff8aa8448a8 (patch)
tree64e64e6550efd2c9374a62e4b3ac0b931c7a2571 /mso-catalog-db/src/test
parent91293d4807d0f2946971dd066b1a5cb0f1d0e06e (diff)
Improve test case for catalog database
Improve test case for catalog database. Change-Id: I9938ca12edf2927368a79bffc21b199651f77879 Issue-ID: SO-360 Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/test')
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java86
1 files changed, 84 insertions, 2 deletions
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
index 84e697b20c..705f64c8cb 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
@@ -468,9 +468,91 @@ public class CatalogDatabaseTest {
List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
}
+ @Test
+ public void getHeatEnvironmentByArtifactUuidTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ heatEnvironment.setArtifactUuid("123-uuid");
+ return heatEnvironment;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
+ assertEquals("123-uuid", he.getArtifactUuid());
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getHeatEnvironmentByArtifactUuidHibernateExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
+ }
+
@Test(expected = Exception.class)
- public void getHeatEnvironmentByArtifactUuidTestException(){
- HeatEnvironment ht = cd.getHeatEnvironmentByArtifactUuid("123");
+ public void getHeatEnvironmentByArtifactUuidExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
}
@Test(expected = Exception.class)