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 10:36:15 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-01-17 10:36:15 +0000
commit806569f572bf2af202c7f9970fdb85ae1f7da9cd (patch)
tree4692627728c9e7fc53dd3834032949a8abffac16 /mso-catalog-db/src/test/java
parentec3394aa110893362424cc3b4518da0b5f6415c9 (diff)
UT improvement for catalog db
UT improvement for catalog db. Change-Id: I711e84a4a80877f49552ddfef1ec5893daef7b0b 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.java56
1 files changed, 54 insertions, 2 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 46c175c9fb..d65928f508 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
@@ -851,9 +851,61 @@ public class CatalogDatabaseTest {
assertEquals(null, service);
}
+ @Test
+ public void getServiceByVersionAndInvariantIdTest() throws Exception{
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return 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.getServiceByVersionAndInvariantId("123","tetwe");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
@Test(expected = Exception.class)
- public void getServiceByVersionAndInvariantIdTestException() throws Exception{
- Service ht = cd.getServiceByVersionAndInvariantId("123","tetwe");
+ public void getServiceByVersionAndInvariantIdNonUniqueResultTest() throws Exception{
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ 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();
+ }
+ };
+ Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
}
@Test(expected = Exception.class)