aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test/java
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-15 13:00:05 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-15 13:00:05 +0000
commitad502b1340dc62c18ed7eb225d8d392a86cc89b6 (patch)
tree4d359c7a01f385d5f27dff7f4ba1ba1c559c554c /mso-catalog-db/src/test/java
parentbecadde04b85e4d4c7df4a7e957fcff8aa8448a8 (diff)
Improve TC for catalog database
Improve TC for catalog database. Change-Id: I698a6e6b929586c84e43266480a4a459265951ae 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.java61
1 files changed, 58 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 705f64c8cb..7d39dd6409 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
@@ -555,9 +555,64 @@ public class CatalogDatabaseTest {
HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
}
- @Test(expected = Exception.class)
- public void getServiceByInvariantUUIDTestException(){
- Service ht = cd.getServiceByInvariantUUID("123");
+ @Test
+ public void getServiceByInvariantUUIDTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public List<Service> list() {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return Arrays.asList(service);
+ }
+ };
+
+ 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();
+ }
+ };
+
+ Service service = cd.getServiceByInvariantUUID("123");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test
+ public void getServiceByInvariantUUIDEmptyResultTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public List<Service> 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();
+ }
+ };
+
+ Service service = cd.getServiceByInvariantUUID("123");
+ assertEquals(null, service);
}
@Test(expected = Exception.class)