diff options
Diffstat (limited to 'mso-catalog-db/src/test')
-rw-r--r-- | mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java | 56 |
1 files changed, 53 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 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<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<VfModuleCustomization> list() throws Exception { + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVfModuleModelUuid("123-uuid"); + return Arrays.asList(vfModuleCustomization); + } + }; + + 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(); + } + }; + VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); + assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid()); + } + + @Test + public void ggetVfModuleCustomizationByModelNameEmptyTest(){ + MockUp<Query> mockUpQuery = new MockUp<Query>() { + @Mock + public List<VfModuleCustomization> 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(); + } + }; + VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); + assertEquals(null, vfModuleCustomization); } @Test(expected = Exception.class) |