aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-19 09:16:22 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-19 09:16:22 +0000
commit9a739d06b6a1821230090812b20d559f082051cc (patch)
tree962a2a62845f1caa962ac336cf0765ddc9dbad99 /mso-catalog-db/src/test
parentc3894b6acd5feb6bc0d6a99a48700e98b76bed3a (diff)
Improve UT for catalog db
Improve UT for catalog db. Change-Id: I1fbe5516b29763fdaf2a2734f1aa7432a1261eae Issue-ID: SO-360 Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/test')
-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 b32e705252..c08cb3d222 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
@@ -1662,9 +1662,58 @@ public class CatalogDatabaseTest {
assertEquals(null, vfModuleCustomization);
}
- @Test(expected = Exception.class)
- public void getNetworkResourceTestException(){
- NetworkResource vnf = cd.getNetworkResource("tetes");
+ @Test
+ public void getNetworkResourceTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<NetworkResource> list() throws Exception {
+ NetworkResource networkResource = new NetworkResource();
+ networkResource.setModelUUID("123-uuid");
+ return Arrays.asList(networkResource);
+ }
+ };
+
+ 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();
+ }
+ };
+ NetworkResource networkResource = cd.getNetworkResource("tetes");
+ assertEquals("123-uuid", networkResource.getModelUUID());
+ }
+
+ @Test
+ public void getNetworkResourceTestEmptyException(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<NetworkResource> 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();
+ }
+ };
+ NetworkResource networkResource = cd.getNetworkResource("tetes");
+ assertEquals(null, networkResource);
}
@Test(expected = Exception.class)