diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-17 10:51:09 +0000 |
---|---|---|
committer | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-01-17 10:51:09 +0000 |
commit | ab3dd55d09241672cdfaf34652b01a593d630fc2 (patch) | |
tree | faa550266edc3290c8c0e04b88f42fb1e73af58f /mso-catalog-db/src/test/java/org | |
parent | 806569f572bf2af202c7f9970fdb85ae1f7da9cd (diff) |
UT improvement for catalog db
UT improvement for catalog db.
Change-Id: Ie1a4554501ebc6e41a9a64b4613d72ae91e5ef03
Issue-ID: SO-360
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/test/java/org')
-rw-r--r-- | mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java | 55 |
1 files changed, 52 insertions, 3 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 d65928f508..2266392d9a 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 @@ -913,9 +913,58 @@ public class CatalogDatabaseTest { ServiceRecipe ht = cd.getServiceRecipe("123","tetwe"); } - @Test(expected = Exception.class) - public void getServiceRecipeByServiceModelUuidTestException() throws Exception{ - ServiceRecipe ht = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); + @Test + public void getServiceRecipeByServiceModelUuidTest() { + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<ServiceRecipe> list() throws Exception { + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setId(1); + return Arrays.asList(serviceRecipe); + } + }; + + 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(); + } + }; + ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); + assertEquals(1, serviceRecipe.getId()); + } + + @Test + public void getServiceRecipeByServiceModelUuidEmptyTest() { + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<ServiceRecipe> 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(); + } + }; + ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); + assertEquals(null, serviceRecipe); } @Test(expected = Exception.class) |