From c3894b6acd5feb6bc0d6a99a48700e98b76bed3a Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 19 Jan 2018 09:10:52 +0000 Subject: Improve UT for catalog db Improve UT for catalog db. Change-Id: I4beee70d0e78fca0d792480477d1010d5faa086d Issue-ID: SO-360 Signed-off-by: subhash kumar singh --- .../mso/db/catalog/test/CatalogDatabaseTest.java | 56 ++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'mso-catalog-db/src/test/java/org') 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 9ea1ef8bd4..b32e705252 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 @@ -1607,9 +1607,59 @@ public class CatalogDatabaseTest { VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); } - @Test(expected = Exception.class) - public void ggetVfModuleCustomizationByModelNameTestException(){ - VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes"); + + @Test + public void ggetVfModuleCustomizationByModelNameTest(){ + MockUp mockUpQuery = new MockUp() { + @Mock + public List list() throws Exception { + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVfModuleModelUuid("123-uuid"); + return Arrays.asList(vfModuleCustomization); + } + }; + + MockUp mockedSession = new MockUp() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + new MockUp() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); + assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid()); + } + + @Test + public void ggetVfModuleCustomizationByModelNameEmptyTest(){ + MockUp mockUpQuery = new MockUp() { + @Mock + public List list() throws Exception { + return Arrays.asList(); + } + }; + + MockUp mockedSession = new MockUp() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + new MockUp() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); + assertEquals(null, vfModuleCustomization); } @Test(expected = Exception.class) -- cgit 1.2.3-korg