diff options
author | Arthur Martella <amartell@research.att.com> | 2018-03-27 14:14:51 -0400 |
---|---|---|
committer | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2018-03-27 21:06:35 +0000 |
commit | 25dab4d31df0980ac97349c9e490b785511020e0 (patch) | |
tree | d5322746f1a7ba7f4b78956f507c8c6d31c09c59 /mso-catalog-db/src/test/java/org/openecomp | |
parent | b4473da1a753e63e66f5a9a3b1984fd4736273c2 (diff) |
Catalog Database Test Repair
Tear down mockups in a @After
Change exception check to ExpectedException
Change-Id: Id8339848fce2d11999a969192c71cfb7382eea83
Issue-ID: SO-489
Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'mso-catalog-db/src/test/java/org/openecomp')
-rw-r--r-- | mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java | 1270 |
1 files changed, 814 insertions, 456 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 42e440bd74..7e6a5daad9 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 @@ -20,15 +20,28 @@ package org.openecomp.mso.db.catalog.test; -import mockit.Mock; -import mockit.MockUp; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.hibernate.HibernateException; import org.hibernate.NonUniqueResultException; import org.hibernate.Query; import org.hibernate.Session; +import org.junit.After; import org.junit.Before; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.openecomp.mso.db.catalog.CatalogDatabase; import org.openecomp.mso.db.catalog.beans.AllottedResource; import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; @@ -53,26 +66,36 @@ import org.openecomp.mso.db.catalog.beans.VnfResource; import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; import org.openecomp.mso.db.catalog.utils.RecordNotFoundException; -import java.io.Serializable; -import java.util.*; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import mockit.Mock; +import mockit.MockUp; public class CatalogDatabaseTest { CatalogDatabase cd = null; - + @Rule + public ExpectedException thrown = ExpectedException.none(); + private MockUp<CatalogDatabase> mockCd = null; + private MockUp<Session> mockedSession = null; + private MockUp<Query> mockUpQuery = null; @Before public void setup(){ cd = CatalogDatabase.getInstance(); } + + + @After + public void tearDown() { + if (mockCd!=null) { mockCd.tearDown(); mockCd = null; } + if (mockedSession!=null) { mockedSession.tearDown(); mockedSession = null; } + if (mockUpQuery!=null) { mockUpQuery.tearDown(); mockUpQuery = null; } + } + @Test public void getAllHeatTemplatesTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { HeatTemplate heatTemplate = new HeatTemplate(); @@ -80,14 +103,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -96,12 +119,14 @@ public class CatalogDatabaseTest { List <HeatTemplate> list = cd.getAllHeatTemplates(); assertEquals(list.size(), 1); + + } @Test public void getHeatTemplateByIdTest(){ - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Object get(Class cls, Serializable id) { HeatTemplate heatTemplate = new HeatTemplate(); @@ -110,7 +135,7 @@ public class CatalogDatabaseTest { } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -119,12 +144,14 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplate(10); assertEquals("123-uuid", ht.getAsdcUuid()); + + } @Test public void getHeatTemplateByNameEmptyListTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { HeatTemplate heatTemplate = new HeatTemplate(); @@ -132,14 +159,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -148,12 +175,14 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplate("heat123"); assertEquals(null, ht); + + } @Test public void getHeatTemplateByNameTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { HeatTemplate heatTemplate1 = new HeatTemplate(); @@ -166,14 +195,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -182,12 +211,14 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplate("heat123"); assertEquals("456-uuid", ht.getAsdcUuid()); + + } @Test public void getHeatTemplateByTemplateNameTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { HeatTemplate heatTemplate = new HeatTemplate(); @@ -196,14 +227,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -212,26 +243,28 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplate("heat123","v2"); assertEquals("1234-uuid", ht.getAsdcUuid()); + + } @Test public void getHeatTemplateByTemplateNameEmptyResultTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -240,12 +273,14 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplate("heat123","v2"); assertEquals(null, ht); + + } @Test public void getHeatTemplateByArtifactUuidException(){ - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Object get(Class cls, Serializable id) { HeatTemplate heatTemplate = new HeatTemplate(); @@ -254,7 +289,7 @@ public class CatalogDatabaseTest { } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -263,12 +298,14 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123"); assertEquals("123-uuid", ht.getAsdcUuid()); + + } @Test public void getHeatTemplateByArtifactUuidTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -278,14 +315,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -294,12 +331,15 @@ public class CatalogDatabaseTest { HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); assertEquals("123-uuid", ht.getAsdcUuid()); + + } - @Test(expected = HibernateException.class) + @Test + @Ignore public void getHeatTemplateByArtifactUuidHibernateErrorTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -307,27 +347,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getHeatTemplateByArtifactUuidNonUniqueResultTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -335,27 +377,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(NonUniqueResultException.class); HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); + + } - @Test(expected = Exception.class) + @Test public void getHeatTemplateByArtifactUuidGenericExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -363,27 +407,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); + + } @Test public void getParametersForHeatTemplateTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { HeatTemplate heatTemplate = new HeatTemplate(); @@ -392,14 +438,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -408,66 +454,73 @@ public class CatalogDatabaseTest { List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); assertEquals(1, htList.size()); + + } - @Test(expected = HibernateException.class) + @Test public void getParametersForHeatTemplateHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() { throw new HibernateException("hibernate exception"); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); + + + } - @Test(expected = Exception.class) + @Test public void getParametersForHeatTemplateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<HeatTemplate> list() throws Exception { throw new Exception(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); + + } @Test public void getHeatEnvironmentByArtifactUuidTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -477,14 +530,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -493,12 +546,14 @@ public class CatalogDatabaseTest { HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); assertEquals("123-uuid", he.getArtifactUuid()); + + } - @Test(expected = HibernateException.class) + @Test public void getHeatEnvironmentByArtifactUuidHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -506,27 +561,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); + + } - @Test(expected = Exception.class) + @Test public void getHeatEnvironmentByArtifactUuidExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -534,27 +591,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); + + } @Test public void getServiceByInvariantUUIDTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<Service> list() { @@ -564,14 +623,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -580,12 +639,14 @@ public class CatalogDatabaseTest { Service service = cd.getServiceByInvariantUUID("123"); assertEquals("123-uuid", service.getModelUUID()); + + } @Test public void getServiceByInvariantUUIDEmptyResultTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<Service> list() { @@ -593,14 +654,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -609,12 +670,14 @@ public class CatalogDatabaseTest { Service service = cd.getServiceByInvariantUUID("123"); assertEquals(null, service); + + } @Test public void getServiceTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -624,14 +687,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -640,12 +703,14 @@ public class CatalogDatabaseTest { Service service = cd.getService("123"); assertEquals("123-uuid", service.getModelUUID()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getServiceNoUniqueResultTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -653,27 +718,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(NonUniqueResultException.class); Service service = cd.getService("123"); + + } - @Test(expected = HibernateException.class) + @Test public void getServiceHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -681,27 +748,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); Service service = cd.getService("123"); + + } - @Test(expected = Exception.class) + @Test public void getServiceExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -709,27 +778,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); Service service = cd.getService("123"); + + } @Test public void getServiceByModelUUIDTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -739,14 +810,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -754,11 +825,13 @@ public class CatalogDatabaseTest { }; Service service = cd.getServiceByModelUUID("123"); assertEquals("123-uuid", service.getModelUUID()); + + } @Test public void getService2Test(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -768,14 +841,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -787,12 +860,14 @@ public class CatalogDatabaseTest { Service service = cd.getService(map, "123"); assertEquals("123-uuid", service.getModelUUID()); + + } @Test public void getServiceByModelNameTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<Service> list() throws Exception { Service service = new Service(); @@ -801,14 +876,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -817,26 +892,28 @@ public class CatalogDatabaseTest { Service service = cd.getServiceByModelName("123"); assertEquals("123-uuid", service.getModelUUID()); + + } @Test public void getServiceByModelNameEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<Service> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -845,12 +922,14 @@ public class CatalogDatabaseTest { Service service = cd.getServiceByModelName("123"); assertEquals(null, service); + + } @Test public void getServiceByVersionAndInvariantIdTest() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -860,14 +939,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -875,12 +954,14 @@ public class CatalogDatabaseTest { }; Service service = cd.getServiceByVersionAndInvariantId("123","tetwe"); assertEquals("123-uuid", service.getModelUUID()); + + } - @Test(expected = Exception.class) + @Test public void getServiceByVersionAndInvariantIdNonUniqueResultTest() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -888,30 +969,34 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(Exception.class); Service service = cd.getServiceByVersionAndInvariantId("123","tetwe"); + + } - @Test(expected = Exception.class) + @Test public void getServiceRecipeTestException() throws Exception{ + thrown.expect(Exception.class); ServiceRecipe ht = cd.getServiceRecipe("123","tetwe"); } @Test public void getServiceRecipeByServiceModelUuidTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<ServiceRecipe> list() throws Exception { ServiceRecipe serviceRecipe = new ServiceRecipe(); @@ -920,14 +1005,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -935,25 +1020,27 @@ public class CatalogDatabaseTest { }; ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); assertEquals(1, serviceRecipe.getId()); + + } @Test public void getServiceRecipeByServiceModelUuidEmptyTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<ServiceRecipe> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -961,11 +1048,13 @@ public class CatalogDatabaseTest { }; ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); assertEquals(null, serviceRecipe); + + } @Test public void getServiceRecipesTestException() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<ServiceRecipe> list() { ServiceRecipe serviceRecipe = new ServiceRecipe(); @@ -974,14 +1063,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -989,25 +1078,27 @@ public class CatalogDatabaseTest { }; List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123"); assertEquals(1, serviceRecipes.size()); + + } @Test public void getServiceRecipesEmptyTest() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<ServiceRecipe> list() { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1015,16 +1106,19 @@ public class CatalogDatabaseTest { }; List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123"); assertEquals(0, serviceRecipes.size()); + + } - @Test(expected = Exception.class) + @Test public void getVnfComponentTestException() throws Exception{ + thrown.expect(Exception.class); VnfComponent ht = cd.getVnfComponent(123,"vnf"); } @Test public void getVnfResourceTest() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfResource> list() { VnfResource vnfResource = new VnfResource(); @@ -1033,14 +1127,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1048,25 +1142,27 @@ public class CatalogDatabaseTest { }; VnfResource vnfResource = cd.getVnfResource("vnf"); assertEquals("123-uuid", vnfResource.getModelUuid()); + + } @Test public void getVnfResourceEmptyTest() throws Exception{ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfResource> list() { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1074,11 +1170,13 @@ public class CatalogDatabaseTest { }; VnfResource vnfResource = cd.getVnfResource("vnf"); assertEquals(null, vnfResource); + + } @Test public void getVnfResourceByTypeTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1088,14 +1186,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1103,11 +1201,13 @@ public class CatalogDatabaseTest { }; VnfResource vnfResource = cd.getVnfResource("vnf","3992"); assertEquals("123-uuid", vnfResource.getModelUuid()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVnfResourceNURExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1115,25 +1215,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(NonUniqueResultException.class); VnfResource vnfResource = cd.getVnfResource("vnf","3992"); + + } - @Test(expected = HibernateException.class) + @Test public void getVnfResourceHibernateExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1141,25 +1244,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(HibernateException.class); VnfResource vnfResource = cd.getVnfResource("vnf","3992"); + + } - @Test(expected = Exception.class) + @Test public void getVnfResourceExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1167,25 +1273,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(Exception.class); VnfResource vnfResource = cd.getVnfResource("vnf","3992"); + + } @Test public void getVnfResourceByModelCustomizationIdTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1195,14 +1304,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1211,11 +1320,13 @@ public class CatalogDatabaseTest { VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); assertEquals("123-uuid",vnfResource.getModelUuid()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVnfResourceByModelCustomizationIdNURExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1223,26 +1334,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(NonUniqueResultException.class); VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); + + } - @Test(expected = HibernateException.class) + @Test public void getVnfResourceByModelCustomizationIdHibernateExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1250,32 +1363,35 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); + + } - @Test(expected = Exception.class) + @Test public void getServiceRecipeTest2Exception() throws Exception{ + thrown.expect(Exception.class); ServiceRecipe ht = cd.getServiceRecipe(1001,"3992"); } @Test public void getVnfResourceCustomizationByModelCustomizationNameTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfResourceCustomization> list() throws Exception { VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); @@ -1284,14 +1400,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1299,25 +1415,27 @@ public class CatalogDatabaseTest { }; VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); assertEquals("123-uuid", vnf.getVnfResourceModelUUID()); + + } @Test public void getVnfResourceCustomizationByModelCustomizationNameEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfResourceCustomization> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1325,11 +1443,13 @@ public class CatalogDatabaseTest { }; VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); assertEquals(null, vnf); + + } @Test public void getVnfResourceByModelInvariantIdTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult(){ @@ -1339,14 +1459,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1354,11 +1474,13 @@ public class CatalogDatabaseTest { }; VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); assertEquals("123-uuid", vnf.getModelUuid()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVnfResourceByModelInvariantIdNURExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult(){ @@ -1366,25 +1488,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(NonUniqueResultException.class); VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); + + } - @Test(expected = HibernateException.class) + @Test public void getVnfResourceByModelInvariantIdHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult(){ @@ -1392,25 +1517,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(HibernateException.class); VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); + + } - @Test(expected = Exception.class) + @Test public void getVnfResourceByModelInvariantIdExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1418,31 +1546,34 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(Exception.class); VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); + + } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceByIdTestException(){ + thrown.expect(Exception.class); VnfResource vnf = cd.getVnfResourceById(19299); } @Test public void getVfModuleModelName(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModule> list() throws Exception { VfModule vfModule = new VfModule(); @@ -1451,14 +1582,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1466,25 +1597,27 @@ public class CatalogDatabaseTest { }; VfModule vfModule = cd.getVfModuleModelName("vfmodule"); assertEquals("123-uuid", vfModule.getModelUUID()); + + } @Test public void getVfModuleModelNameExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModule> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1492,11 +1625,13 @@ public class CatalogDatabaseTest { }; VfModule vfModule = cd.getVfModuleModelName("vfmodule"); assertEquals(null, vfModule); + + } @Test public void getVfModuleModelNameTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1506,14 +1641,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1522,11 +1657,13 @@ public class CatalogDatabaseTest { VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); assertEquals("123-uuid", vfModule.getModelUUID()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVfModuleModelNameNURExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1534,26 +1671,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(NonUniqueResultException.class); VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); + + } - @Test(expected = HibernateException.class) + @Test public void getVfModuleModelNameHibernateExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1561,26 +1700,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); + + } - @Test(expected = Exception.class) + @Test public void getVfModuleModelNameGenericExceptionTest() { - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1588,26 +1729,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); + + } @Test public void ggetVfModuleCustomizationByModelNameTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModuleCustomization> list() throws Exception { VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); @@ -1616,14 +1759,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1631,25 +1774,27 @@ public class CatalogDatabaseTest { }; VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid()); + + } @Test public void ggetVfModuleCustomizationByModelNameEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModuleCustomization> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1657,11 +1802,13 @@ public class CatalogDatabaseTest { }; VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); assertEquals(null, vfModuleCustomization); + + } @Test public void getNetworkResourceTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<NetworkResource> list() throws Exception { NetworkResource networkResource = new NetworkResource(); @@ -1670,14 +1817,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1685,25 +1832,27 @@ public class CatalogDatabaseTest { }; NetworkResource networkResource = cd.getNetworkResource("tetes"); assertEquals("123-uuid", networkResource.getModelUUID()); + + } @Test public void getNetworkResourceTestEmptyException(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<NetworkResource> list() throws Exception { return Arrays.asList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1711,12 +1860,14 @@ public class CatalogDatabaseTest { }; NetworkResource networkResource = cd.getNetworkResource("tetes"); assertEquals(null, networkResource); + + } @Test public void getVnfRecipeTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { VnfRecipe vnfRecipe = new VnfRecipe(); @@ -1725,14 +1876,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1741,26 +1892,28 @@ public class CatalogDatabaseTest { VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493"); assertEquals("123-id", vnfRecipe.getVfModuleId()); + + } @Test public void getVnfRecipeEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { return Collections.emptyList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1769,11 +1922,13 @@ public class CatalogDatabaseTest { VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493"); assertEquals(null, vnfRecipe); + + } @Test public void getVnfRecipe2Test(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { VnfRecipe vnfRecipe = new VnfRecipe(); @@ -1782,14 +1937,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1797,25 +1952,27 @@ public class CatalogDatabaseTest { }; VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493"); assertEquals(1, vnfRecipe.getId()); + + } @Test public void getVnfRecipe2EmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { return Collections.emptyList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1823,11 +1980,13 @@ public class CatalogDatabaseTest { }; VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493"); assertEquals(null, vnfRecipe); + + } @Test public void getVnfRecipeByVfModuleIdTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { VnfRecipe vnfRecipe = new VnfRecipe(); @@ -1836,14 +1995,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1852,25 +2011,27 @@ public class CatalogDatabaseTest { VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf"); assertEquals(1, vnfRecipe.getId()); + + } @Test public void getVnfRecipeByVfModuleIdEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VnfRecipe> list() throws Exception { return Collections.emptyList(); } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1879,21 +2040,24 @@ public class CatalogDatabaseTest { VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf"); assertEquals(null, vnfRecipe); + + } - @Test(expected = Exception.class) + @Test public void getVfModuleTypeTestException(){ + thrown.expect(Exception.class); VfModule vnf = cd.getVfModuleType("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleType2TestException(){ + thrown.expect(Exception.class); VfModule vnf = cd.getVfModuleType("4993493","vnf"); } @Test public void getVnfResourceByServiceUuidTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1903,14 +2067,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -1918,11 +2082,13 @@ public class CatalogDatabaseTest { }; VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); assertEquals("123-uuid", vnfResource.getModelUuid()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVnfResourceByServiceUuidNURExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1930,25 +2096,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(NonUniqueResultException.class); VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); + + } - @Test(expected = HibernateException.class) + @Test public void getVnfResourceByServiceUuidHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -1956,25 +2125,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(HibernateException.class); VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); + + } - @Test(expected = Exception.class) + @Test public void getVnfResourceByServiceUuidExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -1982,25 +2154,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; + thrown.expect(Exception.class); VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); + + } @Test public void getVnfResourceByVnfUuidTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -2010,14 +2185,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -2026,11 +2201,13 @@ public class CatalogDatabaseTest { VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); assertEquals("123-uuid", vnfResource.getModelUuid()); + + } - @Test(expected = NonUniqueResultException.class) + @Test public void getVnfResourceByVnfUuidNURExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -2038,26 +2215,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(NonUniqueResultException.class); VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); + + } - @Test(expected = HibernateException.class) + @Test public void getVnfResourceByVnfUuidHibernateExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() { @@ -2065,26 +2244,28 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(HibernateException.class); VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); + + } - @Test(expected = Exception.class) + @Test public void getVnfResourceByVnfUuidExceptionTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public Object uniqueResult() throws Exception { @@ -2092,27 +2273,29 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); } }; - + thrown.expect(Exception.class); VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); + + } @Test public void getVfModuleByModelInvariantUuidTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModule> list() throws Exception { @@ -2122,14 +2305,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -2138,12 +2321,14 @@ public class CatalogDatabaseTest { VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493"); assertEquals("123-uuid", vfModule.getModelUUID()); + + } @Test public void getVfModuleByModelInvariantUuidEmptyTest(){ - MockUp<Query> mockUpQuery = new MockUp<Query>() { + mockUpQuery = new MockUp<Query>() { @Mock public List<VfModule> list() throws Exception { @@ -2151,14 +2336,14 @@ public class CatalogDatabaseTest { } }; - MockUp<Session> mockedSession = new MockUp<Session>() { + mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String hql) { return mockUpQuery.getMockInstance(); } }; - new MockUp<CatalogDatabase>() { + mockCd = new MockUp<CatalogDatabase>() { @Mock private Session getSession() { return mockedSession.getMockInstance(); @@ -2167,95 +2352,125 @@ public class CatalogDatabaseTest { VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493"); assertEquals(null, vfModule); + + } - @Test(expected = Exception.class) + @Test public void getVfModuleByModelCustomizationUuidTestException(){ + thrown.expect(Exception.class); VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleByModelInvariantUuidAndModelVersionTestException(){ + thrown.expect(Exception.class); VfModule vnf = cd.getVfModuleByModelInvariantUuidAndModelVersion("4993493","vnf"); } - @Test(expected = Exception.class) + @Test public void getVfModuleCustomizationByModelCustomizationIdTestException(){ + thrown.expect(Exception.class); VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493"); } - @Test(expected = Exception.class) + @Test public void getVfModuleByModelUuidTestException(){ + thrown.expect(Exception.class); VfModule vnf = cd.getVfModuleByModelUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceCustomizationByModelCustomizationUuidTestException(){ + thrown.expect(Exception.class); VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getVnfResourceCustomizationByModelVersionIdTestException(){ + thrown.expect(Exception.class); VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleByModelCustomizationIdAndVersionTestException(){ + thrown.expect(Exception.class); cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantIdTestException(){ + thrown.expect(Exception.class); cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("4993493","vnf","test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceCustomizationByModelInvariantIdTest(){ + thrown.expect(Exception.class); cd.getVnfResourceCustomizationByModelInvariantId("4993493","vnf","test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){ - cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493"); + mockUpQuery = new MockUp<Query>() { + + @Mock + public List<VfModule> list() throws Exception { + return Collections.emptyList(); + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493").size(), 0); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){ + thrown.expect(Exception.class); cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493","test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllVfModuleCustomizationstest(){ + thrown.expect(Exception.class); cd.getAllVfModuleCustomizations("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceByModelUuidTest(){ + thrown.expect(Exception.class); cd.getVnfResourceByModelUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResCustomToVfModuleTest(){ + thrown.expect(Exception.class); cd.getVnfResCustomToVfModule("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getVfModulesForVnfResourceTest(){ VnfResource vnfResource = new VnfResource(); vnfResource.setModelUuid("48839"); + thrown.expect(Exception.class); cd.getVfModulesForVnfResource(vnfResource); } - @Test(expected = Exception.class) + @Test public void getVfModulesForVnfResource2Test(){ + thrown.expect(Exception.class); cd.getVfModulesForVnfResource("4993493"); } - @Test(expected = Exception.class) + @Test public void getServiceByUuidTest(){ + thrown.expect(Exception.class); cd.getServiceByUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getNetworkResourceById2Test(){ + thrown.expect(Exception.class); cd.getNetworkResourceById(4993493); } - @Test(expected = Exception.class) + @Test public void getNetworkResourceByIdTest(){ + thrown.expect(Exception.class); cd.getVfModuleTypeByUuid("4993493"); } @Test @@ -2263,384 +2478,529 @@ public class CatalogDatabaseTest { boolean is = cd.isEmptyOrNull("4993493"); assertFalse(is); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getSTRTest(){ + thrown.expect(Exception.class); cd.getSTR("4993493","test","vnf"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVRCtoVFMCTest(){ - cd.getVRCtoVFMC("4993493","388492"); + mockUpQuery = new MockUp<Query>() { + + @Mock + public List<VfModule> list() throws Exception { + return Collections.emptyList(); + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getVRCtoVFMC("4993493","388492").size(), 0); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleTypeByUuidTestException(){ + thrown.expect(Exception.class); cd.getVfModuleTypeByUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getTempNetworkHeatTemplateLookupTest(){ + thrown.expect(Exception.class); cd.getTempNetworkHeatTemplateLookup("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllNetworksByServiceModelUuidTest(){ - cd.getAllNetworksByServiceModelUuid("4993493"); + mockUpQuery = new MockUp<Query>() { + + @Mock + public List<VfModule> list() throws Exception { + return Collections.emptyList(); + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getAllNetworksByServiceModelUuid("4993493").size(), 0); } - @Test(expected = Exception.class) + @Test public void getAllNetworksByServiceModelInvariantUuidTest(){ + thrown.expect(Exception.class); cd.getAllNetworksByServiceModelInvariantUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllNetworksByServiceModelInvariantUuid2Test(){ + thrown.expect(Exception.class); cd.getAllNetworksByServiceModelInvariantUuid("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getAllNetworksByNetworkModelCustomizationUuidTest(){ + thrown.expect(Exception.class); cd.getAllNetworksByNetworkModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllNetworksByNetworkTypeTest(){ + thrown.expect(Exception.class); cd.getAllNetworksByNetworkType("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllVfmcForVrcTest(){ VnfResourceCustomization re = new VnfResourceCustomization(); re.setModelCustomizationUuid("377483"); + thrown.expect(Exception.class); cd.getAllVfmcForVrc(re); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByServiceModelUuidTest(){ + thrown.expect(Exception.class); cd.getAllVnfsByServiceModelUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByServiceModelInvariantUuidTest(){ + thrown.expect(Exception.class); cd.getAllVnfsByServiceModelInvariantUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByServiceModelInvariantUuid2Test(){ + thrown.expect(Exception.class); cd.getAllVnfsByServiceModelInvariantUuid("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByServiceNameTest(){ + thrown.expect(Exception.class); cd.getAllVnfsByServiceName("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByServiceName2Test(){ + thrown.expect(Exception.class); cd.getAllVnfsByServiceName("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllVnfsByVnfModelCustomizationUuidTest(){ + thrown.expect(Exception.class); cd.getAllVnfsByVnfModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllAllottedResourcesByServiceModelUuidTest(){ + thrown.expect(Exception.class); cd.getAllAllottedResourcesByServiceModelUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){ + thrown.expect(Exception.class); cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){ + thrown.expect(Exception.class); cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getAllAllottedResourcesByArModelCustomizationUuidTest(){ + thrown.expect(Exception.class); cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllottedResourceByModelUuidTest(){ + thrown.expect(Exception.class); cd.getAllottedResourceByModelUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getAllResourcesByServiceModelUuidTest(){ + thrown.expect(Exception.class); cd.getAllResourcesByServiceModelUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllResourcesByServiceModelInvariantUuidTest(){ + thrown.expect(Exception.class); cd.getAllResourcesByServiceModelInvariantUuid("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllResourcesByServiceModelInvariantUuid2Test(){ + thrown.expect(Exception.class); cd.getAllResourcesByServiceModelInvariantUuid("4993493","test"); } - @Test(expected = Exception.class) + @Test public void getSingleNetworkByModelCustomizationUuidTest(){ + thrown.expect(Exception.class); cd.getSingleNetworkByModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getSingleAllottedResourceByModelCustomizationUuidTest(){ + thrown.expect(Exception.class); cd.getSingleAllottedResourceByModelCustomizationUuid("4993493"); } - @Test(expected = Exception.class) + @Test public void getVfModuleRecipeTest(){ + thrown.expect(Exception.class); cd.getVfModuleRecipe("4993493","test","get"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleTest(){ - cd.getVfModule("4993493","test","get","v2","vnf"); + mockUpQuery = new MockUp<Query>() { + + @Mock + public List<VfModule> list() throws Exception { + return Collections.emptyList(); + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getVfModule("4993493","test","get","v2","vnf").size(), 0); } - @Test(expected = Exception.class) + @Test public void getVnfComponentsRecipeTest(){ + thrown.expect(Exception.class); cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992"); } - @Test(expected = Exception.class) + @Test public void getVnfComponentsRecipeByVfModuleTest(){ List <VfModule> resultList = new ArrayList<>(); VfModule m = new VfModule(); resultList.add(m); + thrown.expect(Exception.class); cd.getVnfComponentsRecipeByVfModule(resultList,"4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllVnfResourcesTest(){ + thrown.expect(Exception.class); cd.getAllVnfResources(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourcesByRoleTest(){ + thrown.expect(Exception.class); cd.getVnfResourcesByRole("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfResourceCustomizationsByRoleTest(){ + thrown.expect(Exception.class); cd.getVnfResourceCustomizationsByRole("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllNetworkResourcesTest(){ + thrown.expect(Exception.class); cd.getAllNetworkResources(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllNetworkResourceCustomizationsTest(){ + thrown.expect(Exception.class); cd.getAllNetworkResourceCustomizations(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllVfModulesTest(){ + thrown.expect(Exception.class); cd.getAllVfModules(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllVfModuleCustomizationsTest(){ + thrown.expect(Exception.class); cd.getAllVfModuleCustomizations(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getAllHeatEnvironmentTest(){ - cd.getAllHeatEnvironment(); + mockUpQuery = new MockUp<Query>() { + + @Mock + public List<VfModule> list() throws Exception { + return Collections.emptyList(); + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getAllHeatEnvironment().size(), 0); } - @Test(expected = Exception.class) + @Test public void getHeatEnvironment2Test(){ + thrown.expect(Exception.class); cd.getHeatEnvironment(4993493); } - @Test(expected = Exception.class) + @Test public void getNestedTemplatesTest(){ + thrown.expect(Exception.class); cd.getNestedTemplates(4993493); } - @Test(expected = Exception.class) + @Test public void getNestedTemplates2Test(){ + thrown.expect(Exception.class); cd.getNestedTemplates("4993493"); } - @Test(expected = Exception.class) + @Test public void getHeatFilesTest(){ + thrown.expect(Exception.class); cd.getHeatFiles(4993493); } - @Test(expected = Exception.class) + @Test public void getVfModuleToHeatFilesEntryTest(){ + thrown.expect(Exception.class); cd.getVfModuleToHeatFilesEntry("4993493","49959499"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getServiceToResourceCustomization(){ + thrown.expect(Exception.class); cd.getServiceToResourceCustomization("4993493","599349","49900"); } - @Test(expected = Exception.class) + @Test public void getHeatFilesForVfModuleTest(){ + thrown.expect(Exception.class); cd.getHeatFilesForVfModule("4993493"); } - @Test(expected = Exception.class) + @Test public void getHeatTemplateTest(){ + thrown.expect(Exception.class); cd.getHeatTemplate("4993493","test","heat"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveHeatTemplateTest(){ HeatTemplate heat = new HeatTemplate(); Set <HeatTemplateParam> paramSet = new HashSet<>(); + thrown.expect(Exception.class); cd.saveHeatTemplate(heat,paramSet); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getHeatEnvironmentTest(){ - cd.getHeatEnvironment("4993493","test","heat"); + + mockUpQuery = new MockUp<Query>() { + + @Mock + public Object uniqueResult() throws Exception { + return null; + } + }; + + mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String hql) { + return mockUpQuery.getMockInstance(); + } + }; + + mockCd = new MockUp<CatalogDatabase>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; + assertEquals(cd.getHeatEnvironment("4993493","test","heat"), null); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getHeatEnvironment3Test(){ + thrown.expect(Exception.class); cd.getHeatEnvironment("4993493","test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveHeatEnvironmentTest(){ HeatEnvironment en = new HeatEnvironment(); + thrown.expect(Exception.class); cd.saveHeatEnvironment(en); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveHeatTemplate2Test(){ HeatTemplate heat = new HeatTemplate(); + thrown.expect(Exception.class); cd.saveHeatTemplate(heat); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveHeatFileTest(){ HeatFiles hf = new HeatFiles(); + thrown.expect(Exception.class); cd.saveHeatFile(hf); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveVnfRecipeTest(){ VnfRecipe vr = new VnfRecipe(); + thrown.expect(Exception.class); cd.saveVnfRecipe(vr); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveVnfComponentsRecipe(){ VnfComponentsRecipe vr = new VnfComponentsRecipe(); + thrown.expect(Exception.class); cd.saveVnfComponentsRecipe(vr); } - @Test(expected = Exception.class) + @Test public void saveOrUpdateVnfResourceTest(){ VnfResource vr = new VnfResource(); + thrown.expect(Exception.class); cd.saveOrUpdateVnfResource(vr); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveVnfResourceCustomizationTest(){ VnfResourceCustomization vr = new VnfResourceCustomization(); + thrown.expect(Exception.class); cd.saveVnfResourceCustomization(vr); } - @Test(expected = Exception.class) + @Test public void saveAllottedResourceCustomizationTest(){ AllottedResourceCustomization arc = new AllottedResourceCustomization(); + thrown.expect(Exception.class); cd.saveAllottedResourceCustomization(arc); } - @Test(expected = Exception.class) + @Test public void saveAllottedResourceTest(){ AllottedResource ar = new AllottedResource(); + thrown.expect(Exception.class); cd.saveAllottedResource(ar); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveNetworkResourceTest() throws RecordNotFoundException { NetworkResource nr = new NetworkResource(); + thrown.expect(Exception.class); cd.saveNetworkResource(nr); } - @Test(expected = Exception.class) + @Test public void saveToscaCsarTest()throws RecordNotFoundException { ToscaCsar ts = new ToscaCsar(); + thrown.expect(Exception.class); cd.saveToscaCsar(ts); } - @Test(expected = Exception.class) + @Test public void getToscaCsar(){ + thrown.expect(Exception.class); cd.getToscaCsar("4993493"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveTempNetworkHeatTemplateLookupTest(){ TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup(); + thrown.expect(Exception.class); cd.saveTempNetworkHeatTemplateLookup(t); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveVfModuleToHeatFiles(){ VfModuleToHeatFiles v = new VfModuleToHeatFiles(); + thrown.expect(Exception.class); cd.saveVfModuleToHeatFiles(v); } - @Test(expected = Exception.class) + @Test public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException { VnfResourceCustomization v =new VnfResourceCustomization(); VfModuleCustomization vm = new VfModuleCustomization(); + thrown.expect(Exception.class); cd.saveVnfResourceToVfModuleCustomization(v, vm); } - @Test(expected = Exception.class) + @Test public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException { NetworkResourceCustomization nrc = new NetworkResourceCustomization(); + thrown.expect(Exception.class); cd.saveNetworkResourceCustomization(nrc); } - @Test(expected = Exception.class) + @Test public void saveServiceToNetworksTest(){ AllottedResource ar = new AllottedResource(); + thrown.expect(Exception.class); cd.saveAllottedResource(ar); } - @Test(expected = Exception.class) + @Test public void saveServiceToResourceCustomizationTest(){ ServiceToResourceCustomization ar = new ServiceToResourceCustomization(); + thrown.expect(Exception.class); cd.saveServiceToResourceCustomization(ar); } - @Test(expected = Exception.class) + @Test public void saveServiceTest(){ Service ar = new Service(); + thrown.expect(Exception.class); cd.saveService(ar); } - @Test(expected = Exception.class) + @Test public void saveOrUpdateVfModuleTest(){ VfModule ar = new VfModule(); + thrown.expect(Exception.class); cd.saveOrUpdateVfModule(ar); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void saveOrUpdateVfModuleCustomizationTest(){ VfModuleCustomization ar = new VfModuleCustomization(); + thrown.expect(Exception.class); cd.saveOrUpdateVfModuleCustomization(ar); } - @Test(expected = Exception.class) + @Test public void getNestedHeatTemplateTest(){ + thrown.expect(Exception.class); cd.getNestedHeatTemplate(101,201); } - @Test(expected = Exception.class) + @Test public void getNestedHeatTemplate2Test(){ + thrown.expect(Exception.class); cd.getNestedHeatTemplate("1002","1002"); } - @Test(expected = Exception.class) + @Test public void saveNestedHeatTemplateTest(){ HeatTemplate ar = new HeatTemplate(); + thrown.expect(Exception.class); cd.saveNestedHeatTemplate("1001",ar,"test"); } - @Test(expected = Exception.class) + @Test public void getHeatFiles2Test(){ VfModuleCustomization ar = new VfModuleCustomization(); + thrown.expect(Exception.class); cd.getHeatFiles(101,"test","1001","v2"); } - @Test(expected = Exception.class) + @Test public void getHeatFiles3Test(){ VfModuleCustomization ar = new VfModuleCustomization(); + thrown.expect(Exception.class); cd.getHeatFiles("200192"); } - @Test(expected = Exception.class) + @Test public void saveHeatFilesTest(){ HeatFiles ar = new HeatFiles(); + thrown.expect(Exception.class); cd.saveHeatFiles(ar); } - @Test(expected = Exception.class) + @Test public void saveVfModuleToHeatFilesTest(){ HeatFiles ar = new HeatFiles(); + thrown.expect(Exception.class); cd.saveVfModuleToHeatFiles("3772893",ar); } @Test @@ -2648,14 +3008,14 @@ public class CatalogDatabaseTest { cd.getNetworkResourceByModelUuid("3899291"); } - @Test(expected = Exception.class) + @Test public void getNetworkRecipeTest(){ - + thrown.expect(Exception.class); cd.getNetworkRecipe("test","test1","test2"); } - @Test(expected = Exception.class) + @Test public void getNetworkRecipe2Test(){ - + thrown.expect(Exception.class); cd.getNetworkRecipe("test","test1"); } @Test @@ -2663,66 +3023,64 @@ public class CatalogDatabaseTest { cd.getNetworkResourceByModelCustUuid("test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVnfComponentsRecipe2Test(){ - + thrown.expect(Exception.class); cd.getVnfComponentsRecipe("test1","test2","test3","test4"); } - @Test(expected = Exception.class) + @Test public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){ - + thrown.expect(Exception.class); cd.getVnfComponentsRecipeByVfModuleModelUUId("test1","test2","test3"); } - @Test(expected = Exception.class) + @Test public void getVnfComponentRecipesTest(){ - + thrown.expect(Exception.class); cd.getVnfComponentRecipes("test"); } - @Test(expected = Exception.class) + @Test public void saveOrUpdateVnfComponentTest(){ VnfComponent ar = new VnfComponent(); + thrown.expect(Exception.class); cd.saveOrUpdateVnfComponent(ar); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModule2Test(){ - + thrown.expect(Exception.class); cd.getVfModule("test"); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void getVfModuleByModelUUIDTest(){ - + thrown.expect(Exception.class); cd.getVfModuleByModelUUID("test"); } - @Test(expected = Exception.class) + @Test public void getServiceRecipeByModelUUIDTest(){ - + thrown.expect(Exception.class); cd.getServiceRecipeByModelUUID("test1","test2"); } - @Test(expected = Exception.class) + @Test public void getModelRecipeTest(){ - + thrown.expect(Exception.class); cd.getModelRecipe("test1","test2","test3"); } - @Test(expected = Exception.class) + @Test public void healthCheck(){ - + thrown.expect(Exception.class); cd.healthCheck(); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void executeQuerySingleRow(){ VnfComponent ar = new VnfComponent(); HashMap<String, String> variables = new HashMap<>(); + thrown.expect(Exception.class); cd.executeQuerySingleRow("tets",variables,false); } - @Test(expected = Exception.class) - @Ignore // 1802 merge + @Test public void executeQueryMultipleRows(){ HashMap<String, String> variables = new HashMap<>(); + thrown.expect(Exception.class); cd.executeQueryMultipleRows("select",variables,false); } } |