diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-18 10:17:02 +0000 |
---|---|---|
committer | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-18 10:17:02 +0000 |
commit | 2c83c8aefe45d0dd5a3486482f296de1da67b2dc (patch) | |
tree | 8c9953553bc2e2ea251424357754cd1e026cd553 /mso-catalog-db/src/test/java | |
parent | 89bf0b4f499c7fada8ad221defff5580d12331b6 (diff) |
Improve UT for catalog DB
Impprove UT for catalog DB.
Change-Id: Ifd5c57bdaa39b5965641aab40495f01f16fa6510
Issue-ID: SO-360
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/test/java')
-rw-r--r-- | mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java | 53 |
1 files changed, 51 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 5b595a6720..53ce265709 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 @@ -1277,9 +1277,58 @@ public class CatalogDatabaseTest { ServiceRecipe ht = cd.getServiceRecipe(1001,"3992"); } - @Test(expected = Exception.class) - public void getVnfResourceCustomizationByModelCustomizationNameTestException(){ + @Test + public void getVnfResourceCustomizationByModelCustomizationNameTest(){ + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<VnfResourceCustomization> list() throws Exception { + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setVnfResourceModelUUID("123-uuid"); + return Arrays.asList(vnfResourceCustomization); + } + }; + + 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(); + } + }; + VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); + assertEquals("123-uuid", vnf.getVnfResourceModelUUID()); + } + + @Test + public void getVnfResourceCustomizationByModelCustomizationNameEmptyTest(){ + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<VnfResourceCustomization> list() throws Exception { + return Arrays.asList(); + } + }; + + 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(); + } + }; VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); + assertEquals(null, vnf); } @Test(expected = Exception.class) |