From c42e71947301a615bbd4492aa70303bf3ac7414c Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 19 Jan 2018 06:48:20 +0000 Subject: Improve UT for catalog db Improve UT for catalog db. Change-Id: I80eb6d4f58ea9de2d73a92a917dad8f9c98dc88a Issue-ID: SO-360 Signed-off-by: subhash kumar singh --- .../mso/db/catalog/test/CatalogDatabaseTest.java | 55 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'mso-catalog-db/src/test') 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 219e70ea87..2ec75d7582 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 @@ -1443,9 +1443,58 @@ public class CatalogDatabaseTest { VnfResource vnf = cd.getVnfResourceById(19299); } - @Test(expected = Exception.class) - public void getVfModuleModelNameTestException(){ - VfModule vnf = cd.getVfModuleModelName("tetes"); + @Test + public void getVfModuleModelName(){ + MockUp mockUpQuery = new MockUp() { + @Mock + public List list() throws Exception { + VfModule vfModule = new VfModule(); + vfModule.setModelUUID("123-uuid"); + return Arrays.asList(vfModule); + } + }; + + MockUp mockedSession = new MockUp() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + new MockUp() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + VfModule vfModule = cd.getVfModuleModelName("vfmodule"); + assertEquals("123-uuid", vfModule.getModelUUID()); + } + + @Test + public void getVfModuleModelNameExceptionTest(){ + 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(); + } + }; + VfModule vfModule = cd.getVfModuleModelName("vfmodule"); + assertEquals(null, vfModule); } @Test(expected = Exception.class) -- cgit 1.2.3-korg