diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-15 11:46:46 +0000 |
---|---|---|
committer | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-15 11:46:46 +0000 |
commit | 91293d4807d0f2946971dd066b1a5cb0f1d0e06e (patch) | |
tree | 2ed069e92511738a4cc5d905bcef59cd56c7a14f /mso-catalog-db/src | |
parent | 8954cade997f94979ea69c2bd463e0f4714dc5c5 (diff) |
Improve TC for catalog database
Improve TC for catalog database class.
Change-Id: I5f4044e2e4151ba0382e914287ab03381962743f
Issue-ID: SO-360
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src')
-rw-r--r-- | mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java | 83 |
1 files changed, 81 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 f59dc5db2d..84e697b20c 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 @@ -384,9 +384,88 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); } + @Test + public void getParametersForHeatTemplateTest(){ + + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<HeatTemplate> list() { + HeatTemplate heatTemplate = new HeatTemplate(); + heatTemplate.setAsdcUuid("1234-uuid"); + return Arrays.asList(heatTemplate); + } + }; + + 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(); + } + }; + + List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); + assertEquals(1, htList.size()); + } + + @Test(expected = HibernateException.class) + public void getParametersForHeatTemplateHibernateExceptionTest(){ + + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<HeatTemplate> list() { + 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(); + } + }; + + List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); + } + @Test(expected = Exception.class) - public void getParametersForHeatTemplateTestException(){ - List<HeatTemplateParam> ht = cd.getParametersForHeatTemplate("123"); + public void getParametersForHeatTemplateExceptionTest(){ + + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<HeatTemplate> list() 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(); + } + }; + + List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); } @Test(expected = Exception.class) |