aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test/java
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-17 11:52:39 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-17 11:52:39 +0000
commit487482d147a46e237b6f4f8c1ae07762e3f49b05 (patch)
tree43738a1539033622407f57ef2108c712ea1eca30 /mso-catalog-db/src/test/java
parent5621e24fe7336f978666e1a5bdae0adf75f4d144 (diff)
UT improvement for catalog DB
Improve UT for catalog DB. Change-Id: I703e86d0bcde663b81cf46260a6f5656dae6dab3 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.java55
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 445ca12892..cad4093936 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
@@ -1026,9 +1026,58 @@ public class CatalogDatabaseTest {
VnfComponent ht = cd.getVnfComponent(123,"vnf");
}
- @Test(expected = Exception.class)
- public void getVnfResourceTestException() throws Exception{
- VnfResource ht = cd.getVnfResource("vnf");
+ @Test
+ public void getVnfResourceTest() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResource> list() {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("123-uuid");
+ return Arrays.asList(vnfResource);
+ }
+ };
+
+ 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();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf");
+ assertEquals("123-uuid", vnfResource.getModelUuid());
+ }
+
+ @Test
+ public void getVnfResourceEmptyTest() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResource> list() {
+ 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();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf");
+ assertEquals(null, vnfResource);
}
@Test(expected = Exception.class)