summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test/java
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-19 09:05:02 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-19 09:05:02 +0000
commit0bff9b79e7481f039db4b75734f9b6a363c4a612 (patch)
tree5d1f7b59e92efbe7ccf2283676d44c8c2f374830 /mso-catalog-db/src/test/java
parentc42e71947301a615bbd4492aa70303bf3ac7414c (diff)
Improve UT for catalog db
Improve UT for catalog db Change-Id: Ib9c5dad03c0107778c554c54d1586e0ddd79c297 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.java111
1 files changed, 108 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 2ec75d7582..9ea1ef8bd4 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
@@ -1497,12 +1497,117 @@ public class CatalogDatabaseTest {
assertEquals(null, vfModule);
}
- @Test(expected = Exception.class)
- public void getVfModuleModelName2TestException(){
- VfModule vnf = cd.getVfModuleModelName("tetes","4kidsl");
+ @Test
+ public void getVfModuleModelNameTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ VfModule vfModule = new VfModule();
+ vfModule.setModelUUID("123-uuid");
+ return vfModule;
+ }
+ };
+
+ 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();
+ }
+ };
+
+ VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
+ assertEquals("123-uuid", vfModule.getModelUUID());
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getVfModuleModelNameNURExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ 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();
+ }
+ };
+
+ VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getVfModuleModelNameHibernateExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ 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();
+ }
+ };
+
+ VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
}
@Test(expected = Exception.class)
+ public void getVfModuleModelNameGenericExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ 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();
+ }
+ };
+
+ VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
+ }
+ @Test(expected = Exception.class)
public void ggetVfModuleCustomizationByModelNameTestException(){
VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
}